Metadata-Version: 2.5
Name: jaxedith
Version: 4.0.0
Summary: JAX based HWO exposure time calculator
Project-URL: Homepage, https://github.com/CoreySpohn/jaxedith
Project-URL: Issues, https://github.com/CoreySpohn/jaxedith/issues
Author-email: Corey Spohn <corey.a.spohn@nasa.gov>
License: MIT License
        
        Copyright (c) 2026 Corey Spohn
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Astronomy
Requires-Python: >=3.12
Requires-Dist: equinox>=0.13.2
Requires-Dist: hwoutils[jax]>=3.0.0
Requires-Dist: jax>=0.8.1
Requires-Dist: jaxlib>=0.8.1
Requires-Dist: numpy>=2.1.2
Requires-Dist: optixstuff>=7.0.0
Requires-Dist: skyscapes>=6.0.0
Provides-Extra: dev
Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: ipython>=8.18.1; extra == 'docs'
Requires-Dist: matplotlib>=3.10.8; extra == 'docs'
Requires-Dist: myst-nb>=1.0.0; extra == 'docs'
Requires-Dist: sphinx-autoapi>=3.0.0; extra == 'docs'
Requires-Dist: sphinx-book-theme>=1.1.0; extra == 'docs'
Requires-Dist: sphinx>=7.2.6; extra == 'docs'
Requires-Dist: sphinxcontrib-mermaid>=0.9.2; extra == 'docs'
Provides-Extra: test
Requires-Dist: beartype>=0.20.1; extra == 'test'
Requires-Dist: equinox>=0.13.2; extra == 'test'
Requires-Dist: hypothesis>=6.112.1; extra == 'test'
Requires-Dist: ineedvalidation>=1.1.0; extra == 'test'
Requires-Dist: jaxtyping>=0.3.3; extra == 'test'
Requires-Dist: numpy>=2.1.2; extra == 'test'
Requires-Dist: optixstuff>=7.0.0; extra == 'test'
Requires-Dist: pytest-fail-slow>=0.1.0; extra == 'test'
Requires-Dist: pytest-markdown-docs>=0.5.0; extra == 'test'
Requires-Dist: pytest-testmon>=2.0.7; extra == 'test'
Requires-Dist: pytest-timeout>=1.3.1; extra == 'test'
Requires-Dist: pytest-xdist>=2.5; extra == 'test'
Requires-Dist: pytest>=7.3.2; extra == 'test'
Requires-Dist: scipy>=1.13; extra == 'test'
Requires-Dist: skyscapes>=6.0.0; extra == 'test'
Description-Content-Type: text/markdown

# jaxedith

`jaxedith` turns performance curves, a scene, an instrument and a planet
position into analytic aperture rates: the scalar AYO and pyEDITH count-rate
terms, evaluated in JAX. It returns an `optixstuff.Rates` record, which
`optixstuff.snr` and `optixstuff.exposure_time` reduce to a signal-to-noise
ratio or an exposure time. The package has five functions: `rates`, `scene_rates`,
`photon_counting_frame_time`, and the one-call `planet_exposure_time` and `planet_snr`.

## Usage

This example needs `curves` (an `optixstuff.PerformanceCurves` measured for the
telescope and star, for example from yippy's `coronagraph.curves(rule)`), a
`skyscapes.Scene`, an `optixstuff.Instrument` and the bands to read.

The curves are read at the band-centre lambda/D for every node, so the response
does not slide across a pixel and the quadrature is built with `field_lod=0`: a
wider field would add nodes and change nothing. The scene's tabulated spectra
(a PHOENIX star, a local-zodi table, a planet model with a grid) are integrated
exactly over each band by an operator built on the host, and `scene.sources` reads
them once on the nodes. A band must lie inside every source table.
Sky transmission comes with each band's curves in `PerformanceCurves.uniform_sky`.

```python notest
import jaxedith
import optixstuff as ox
from optixstuff.spectral import Quadrature, Resolution

models = [m for m in (instrument, scene.local_zodi, scene.disk) if m is not None]
quadrature = Quadrature.build(bands, *models, field_lod=0)
resolution = Resolution.build(quadrature, *scene.spectral_tables())
sources = scene.sources(quadrature, resolution, time_d)
planet_flux = sources.planets[:, :, planet, 0]  # (W, Q), photons/s/m^2/nm
contrast = 1e-10  # an optional hypothesis for the one-call contrast calculators

rates = jaxedith.rates(
    curves,
    scene,
    instrument,
    quadrature,
    east_arcsec,
    north_arcsec,
    planet=planet_flux,
    time_d=time_d,
    sources=sources,  # node rows of the one time read
)
frame_time_s = jaxedith.photon_counting_frame_time(rates, instrument.detector)
time = ox.exposure_time(
    rates,
    instrument.detector,
    7.0,
    frame_time_s=frame_time_s,
    post_processing=ox.PostProcessing(1 / 30, 0.0, background_variance_factor=2.0),
)
frames = ox.frames_for_time(time.time_s, frame_time_s)
reachable = time.valid  # Boolean mask per band
```

An unreachable target gives NaN in `time.time_s` and in the plan's frame
count and live time. A count of zero represents a request for zero seconds.

```python
import jax.numpy as jnp
import optixstuff as ox
from optixstuff.spectral import Band, Quadrature

detector = ox.Detector(pixel_scale_arcsec=0.01, shape=(1, 1), qe=0.9)
quadrature = Quadrature.build([Band(500.0, 600.0)], detector, order=1)
rates = ox.Rates(
    quadrature, "photon", planet=jnp.zeros((1, 1)), local_zodi=jnp.ones((1, 1))
)
frame_time_s = 300.0
time = ox.exposure_time(
    rates,
    detector,
    7.0,
    frame_time_s=frame_time_s,
    post_processing=ox.PostProcessing(background_variance_factor=1.0),
)
frames = ox.frames_for_time(time.time_s, frame_time_s)
assert not bool(time.valid[0])
assert jnp.isnan(frames.n_frames[0])
```

For pyEDITH and EXOSIMS users the one-call form, which answers for one planet, takes the same arguments plus
the target and the frame time. It answers for the fixed `contrast` hypothesis above, so it matches the two steps
only where that contrast implies the same planet flux at the nodes:

```python notest
time = jaxedith.planet_exposure_time(
    curves,
    scene,
    instrument,
    quadrature,
    east_arcsec,
    north_arcsec,
    contrast,
    time_d=time_d,
    sources=sources,
    target_snr=7.0,
    frame_time_s=frame_time_s,
    post_processing=ox.PostProcessing(1 / 30, 0.0, background_variance_factor=2.0),
)
snr = jaxedith.planet_snr(
    curves,
    scene,
    instrument,
    quadrature,
    east_arcsec,
    north_arcsec,
    contrast,
    time_d=time_d,
    sources=sources,
    time_s=3600.0,
    frame_time_s=frame_time_s,
    post_processing=ox.PostProcessing(1 / 30, 0.0, background_variance_factor=2.0),
)
```

`jaxedith.planet_exposure_time` is `rates` followed by `optixstuff.exposure_time` on
`instrument.detector`, and `jaxedith.planet_snr` is `rates` followed by
`optixstuff.snr`; neither adds arithmetic. They return an
`optixstuff.ExposureTime` and the S/N per band.

`rates` is a scalar read of one planet that reads no spectrum itself: the star, the local
zodi and the disk's host star are the node rows of `sources`. Pass `planet=` with
a scene's node-effective photon flux density from `sources.planets`, or `contrast=`
with a planet-to-star hypothesis; exactly one is required. Map it over positions and fluxes with
`jax.vmap`.
Fields are photons/s/nm of shape `(W, Q)`, with `n_pix` per band and a
squared-weight `variance` record. Detector yield is not applied there:
`detector.electrons(rates)` applies QE and survival once, downstream.

To read every planet of the scene at every time, `scene_rates` is a `vmap` of `rates`
over the planets and the times that reads `scene.sources` once outside the map, and takes the same layout as
`coronagraphoto.scene_aperture_rates`, so the two reads swap:

```python notest
record = jaxedith.scene_rates(
    curves,
    scene,
    instrument,
    quadrature,
    time_d,
    resolution=resolution,
)  # time_d: (T,) days; fields (W, Q, K, T), n_pix (W, K, T)
time = ox.exposure_time(
    record,
    instrument.detector,
    7.0,
    frame_time_s=frame_time_s,
    post_processing=post_processing,
)  # one time per band, planet and time
```

Planets with `scene.valid` False read zero, so their exposure time is invalid.

The reduction itself is described in optixstuff's
[how an exposure time is computed](https://optixstuff.readthedocs.io/en/latest/explanation/exposure_time.html).
The conventions of the terms, and how AYO, pyEDITH and EXOSIMS map onto
`PostProcessing`, are on the [conventions page](docs/explanation/conventions.md).
Thermal emission is read from `Instrument.warm_emission` (optixstuff's
`WarmEmission`) and is zero without it; stellar companions are zero in this
release. `coronagraphoto` fills the same field from its images and aperture
records.

## Cross-code references

Scalar pyEDITH, EXOSIMS and AYO comparison implementations live in
`tests/reference/` in the source checkout. They support cross-code benchmarks
and convention checks, and are excluded from the wheel and source distribution.
See [comparison references](docs/explanation/variants.md) for their scope.

## Installation

```bash
pip install jaxedith
```

The development tests use coordinated unreleased versions of optixstuff and
skyscapes; published dependency floors have not yet been verified for this API.
