Skip to main content

A Python and JAX wrapper to create a coronagraph object from a yield input package

Project description

yippy logo

PyPI Documentation Status


yippy

A wrapper to create a coronagraph object from a yield input package (a "YIP"). A core feature is its ability to use Fourier interpolation to generate off axis PSFs at arbitrary locations in the (x,y) plane efficiently. yippy uses JAX to speed up computation by default, with an optional Python backend.

Installation

pip install yippy

Quick Start

from yippy import Coronagraph
from yippy.datasets import fetch_coronagraph

# Download an example YIP (cached after first call)
yip_path = fetch_coronagraph()

# Create a coronagraph object
coro = Coronagraph(yip_path)

# Off-axis PSF at a given (x, y) position
from lod_unit import lod
offaxis_psf = coro.offax(2 * lod, 5 * lod)

# Performance metrics at any separation
throughput = coro.throughput(5.0)        # scalar or array
contrast   = coro.raw_contrast(5.0)
occ_trans  = coro.occulter_transmission(5.0)

Two-Class Design

yippy provides two coronagraph classes for different use cases:

Coronagraph EqxCoronagraph
Purpose Full-featured analysis & export JIT-compiled simulation
Backend NumPy/SciPy + JAX Pure JAX/Equinox
JIT-compatible No Yes (eqx.filter_jit)
GPU/TPU support PSF generation only Everything
I/O & export EXOSIMS FITS, AYO CSV None (simulation only)
Performance curves Computed on init Converted from Coronagraph

Coronagraph — Analysis & Data Management

The primary class for loading YIPs, computing performance curves, and exporting to external formats:

from yippy import Coronagraph

coro = Coronagraph("path/to/yip")

# Access pre-computed performance curves
coro.throughput(5.0)
coro.raw_contrast(5.0)
coro.noise_floor_exosims(5.0)
coro.occulter_transmission(5.0)
coro.core_area(5.0)
coro.core_mean_intensity(5.0)

# Export to EXOSIMS format
coro.to_exosims()

# Export to AYO CSV format
coro.dump_ayo_csv("output.csv")

EqxCoronagraph — JIT-Compatible Simulation

A pure JAX/Equinox module for use inside jax.jit-compiled pipelines:

from yippy import EqxCoronagraph
import equinox as eqx

# Create from a YIP path directly
coro = EqxCoronagraph("path/to/yip")

# All methods are JIT-traceable
@eqx.filter_jit
def simulate(coro, x, y):
    psf = coro.create_psf(x, y)
    stellar = coro.stellar_intens(0.01)
    throughput = coro.throughput(5.0)
    return psf, stellar, throughput

Performance Metrics

Individual metric functions are available in yippy.performance for standalone analysis:

from yippy.performance import (
    compute_throughput_curve,
    compute_raw_contrast_curve,
    compute_core_area_curve,
    compute_occ_trans_curve,
    compute_core_mean_intensity_curve,
)

# Compute individual curves
separations, throughputs = compute_throughput_curve(coro)
separations, contrasts  = compute_raw_contrast_curve(coro)

These are the same functions used internally by Coronagraph during initialization.

Example Data

yippy ships with pooch-managed example data for testing and notebooks:

from yippy.datasets import fetch_coronagraph

# Downloads and caches an example apodized vortex coronagraph
yip_path = fetch_coronagraph()  # "eac1_aavc_512"

Units

Yield input packages use $\lambda / D$ units so yippy treats them as the default and uses the lod_unit package to define the lod unit. However, it can use three different astropy units: pixels (as defined by the yield input package), angular separation (angle units), or apparent separation (length units). If no units are provided it assumes the input is in $\lambda / D$.

import astropy.units as u
# pixels
x_pos = 2 * u.pix
y_pos = 5 * u.pix
offaxis_psf = coro.offax(x_pos, y_pos)

# angular separation
telescope_diameter = 10 * u.m
wavelength = 500 * u.nm
offaxis_psf = coro.offax(x_pos, y_pos, lam=wavelength, D=telescope_diameter)

# apparent separation
star_dist = 10 * u.pc
offaxis_psf = coro.offax(x_pos, y_pos, lam=wavelength, D=telescope_diameter, dist=star_dist)

JAX

The default backend is JAX, which is a high-performance numerical computing library that we use for JIT compilation and GPU/TPU support. By default, JAX uses 32-bit floating point precision, which leads to faster computation and lower memory overhead but results in lower precision (~1e-6 precision). If you need precision at the 1e-16 level, set use_x64=True.

Off-axis PSF options

  • use_jax: Use JAX for computation. Default is True.
  • use_x64: Use 64-bit floating point precision. Default is False.
  • x_symmetric: Off-axis PSF is symmetric about the x-axis. Default is True.
  • y_symmetric: Off-axis PSF is symmetric about the y-axis. Default is False.
  • cpu_cores: Number of CPU cores to use. Default is 1.
  • platform: Computing platform to use for JAX computation. Options are cpu, gpu, tpu. Default is cpu.

Parallel processing of off-axis PSFs

The base call of coronagraph.offax(x,y) is the most user-friendly, but is not the most efficient. When generating many PSFs it is recommended to convert all required (x,y) positions into arrays of floats (in $\lambda / D$) and use the coronagraph.offax.create_psfs_parallel(x_arr, y_arr) function. This function uses JAX's shard_map to distribute the computation across multiple devices or CPU cores.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yippy-2.0.0.tar.gz (77.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

yippy-2.0.0-py3-none-any.whl (54.0 kB view details)

Uploaded Python 3

yippy-2-py3-none-any.whl (58.8 kB view details)

Uploaded Python 3

File details

Details for the file yippy-2.0.0.tar.gz.

File metadata

  • Download URL: yippy-2.0.0.tar.gz
  • Upload date:
  • Size: 77.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yippy-2.0.0.tar.gz
Algorithm Hash digest
SHA256 8f368aaa583399fcf4ea5353d079244fe7cf6a2de5b500a65bcdd320c32161c3
MD5 39d2b0845dc2a2ed79ce9879284cfc4b
BLAKE2b-256 d1d138542f8818c20c85d8618779cec4791236298a3e464b32ec674b7bacad7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for yippy-2.0.0.tar.gz:

Publisher: publish-to-pypi.yml on CoreySpohn/yippy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yippy-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: yippy-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yippy-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e96e6c5c0c06377c7fc954fd82c04cae55ce0b2872d585a0375e0ca193e0917d
MD5 772497549812beabe5877f29ea245d13
BLAKE2b-256 54f70958a83a13972ef76ecbe6a506f19722e3954d126d396dccb485366df9ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for yippy-2.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on CoreySpohn/yippy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yippy-2-py3-none-any.whl.

File metadata

  • Download URL: yippy-2-py3-none-any.whl
  • Upload date:
  • Size: 58.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yippy-2-py3-none-any.whl
Algorithm Hash digest
SHA256 22d67ba9b165136268e37353dcaa8fb681cc8d6ac5ca3807d57712696e846408
MD5 a49f71f245a72b0fa1ee6e6cf5825490
BLAKE2b-256 542be95d4e6054cab764b048df570b21bcb821829725ecf0efee31dfd4f15f5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for yippy-2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on CoreySpohn/yippy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page