A Python and JAX wrapper to create a coronagraph object from a yield input package
Project description
yippy
A Python and JAX library for loading coronagraph yield input packages (YIPs) and computing coronagraph performance metrics. yippy provides Fourier-based off-axis PSF interpolation, throughput/contrast/core-area curves, 2D performance maps, and export to EXOSIMS and AYO formats.
Installation
pip install yippy
Quick Start
from yippy import Coronagraph, fetch_yip
# Download an example YIP (cached after first call)
yip_path = fetch_yip("eac1_aavc")
# 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)
# 2D performance maps (pixel grids)
throughput_map = coro.throughput_map()
core_area_map = coro.core_area_map()
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")
# 1D performance curves (scalar or array separations in lam/D)
coro.throughput(5.0)
coro.raw_contrast(5.0)
coro.occulter_transmission(5.0)
coro.core_area(5.0)
coro.core_mean_intensity(5.0)
# Noise floors
coro.noise_floor_exosims(5.0) # |raw_contrast| / ppf
coro.noise_floor_ayo(5.0, ppf=30.0) # core_mean_intensity / ppf
# 2D maps (full pixel grids)
coro.separation_map()
coro.throughput_map()
coro.core_area_map()
coro.core_mean_intensity_map()
coro.noise_floor_ayo_map(ppf=30.0)
# Export
coro.to_exosims()
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_truncation_throughput_curve, # PSF truncation-ratio aperture
compute_truncation_core_area_curve,
)
# Compute individual curves
separations, throughputs = compute_throughput_curve(coro)
separations, contrasts = compute_raw_contrast_curve(coro)
PSF Truncation Ratio
When psf_trunc_ratio is set (e.g. Coronagraph(path, psf_trunc_ratio=0.3)),
throughput and core area are computed using an adaptive aperture that includes
all oversampled pixels exceeding ratio * peak. This matches AYO's
photap_frac / omega_lod calculation and is recommended for ETC integration.
Example Data
yippy ships with pooch-managed example data for testing and notebooks:
from yippy import fetch_yip
# Downloads and caches an example apodized vortex coronagraph
yip_path = fetch_yip("eac1_aavc")
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
yippy uses JAX for JIT compilation and GPU/TPU-accelerated PSF generation. JAX defaults to 32-bit precision; if you need 64-bit precision, configure it before importing yippy or any other JAX-based library:
# At the very top of your script
from hwoutils import enable_x64, set_platform
enable_x64() # switch to float64
set_platform("cpu") # or "gpu", "gpu,cpu" for fallback
# Now it's safe to import yippy
from yippy import Coronagraph
Or via environment variables (safest):
JAX_ENABLE_X64=True JAX_PLATFORMS=cpu python my_script.py
See the JAX Configuration Guide in hwoutils for details and common gotchas.
Constructor options
use_jax: Use JAX for PSF computation. Default isTrue.x_symmetric: Off-axis PSFs are symmetric about the x-axis. Default isTrue.y_symmetric: Off-axis PSFs are symmetric about the y-axis. Default isTrue.
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 CPU devices.
To use multiple CPU devices, call hwoutils.set_host_device_count(N) or set
XLA_FLAGS=--xla_force_host_platform_device_count=N before importing JAX.
On GPU/TPU backends, yippy automatically uses vmap+jit instead of shard_map.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yippy-2.6.0.tar.gz.
File metadata
- Download URL: yippy-2.6.0.tar.gz
- Upload date:
- Size: 4.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78829a31c6c95f1bca0329a4709e0ae46c963f5af24fabd18b8bf061b0766945
|
|
| MD5 |
02ce70d4c4a0de5c04807944e7e19b1e
|
|
| BLAKE2b-256 |
92656ead4581bd71ce6a02192672dac6d5b0b42dd28ef28dcdae0ed1fe91e050
|
Provenance
The following attestation bundles were made for yippy-2.6.0.tar.gz:
Publisher:
publish-to-pypi.yml on CoreySpohn/yippy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yippy-2.6.0.tar.gz -
Subject digest:
78829a31c6c95f1bca0329a4709e0ae46c963f5af24fabd18b8bf061b0766945 - Sigstore transparency entry: 1524643127
- Sigstore integration time:
-
Permalink:
CoreySpohn/yippy@cb18d1180f1b88b552e8bf27f49d99ffd7c3b00e -
Branch / Tag:
refs/tags/v2.6.0 - Owner: https://github.com/CoreySpohn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@cb18d1180f1b88b552e8bf27f49d99ffd7c3b00e -
Trigger Event:
push
-
Statement type:
File details
Details for the file yippy-2.6.0-py3-none-any.whl.
File metadata
- Download URL: yippy-2.6.0-py3-none-any.whl
- Upload date:
- Size: 57.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e02170091d5a5fc6c75f51795314a71422a71835421a4f7b9a6f48039be0f91c
|
|
| MD5 |
755f51ecc54e43371d7af15d14a581ff
|
|
| BLAKE2b-256 |
7acc625757a18799c3d141c799ca9ac3cee2ccdb9c10641d36ce44bedab2ac5e
|
Provenance
The following attestation bundles were made for yippy-2.6.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on CoreySpohn/yippy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yippy-2.6.0-py3-none-any.whl -
Subject digest:
e02170091d5a5fc6c75f51795314a71422a71835421a4f7b9a6f48039be0f91c - Sigstore transparency entry: 1524643167
- Sigstore integration time:
-
Permalink:
CoreySpohn/yippy@cb18d1180f1b88b552e8bf27f49d99ffd7c3b00e -
Branch / Tag:
refs/tags/v2.6.0 - Owner: https://github.com/CoreySpohn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@cb18d1180f1b88b552e8bf27f49d99ffd7c3b00e -
Trigger Event:
push
-
Statement type: