Metadata-Version: 2.5
Name: physicaloptix
Version: 1.2.0
Summary: Physical optics (PSFs and diffraction) for the HWO direct imaging simulation suite
Project-URL: Homepage, https://github.com/CoreySpohn/physicaloptix
Project-URL: Issues, https://github.com/CoreySpohn/physicaloptix/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 :: 2 - Pre-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.11
Requires-Dist: equinox>=0.12.0
Requires-Dist: hwoutils
Requires-Dist: jax>=0.4.1
Requires-Dist: jaxlib>=0.4.1
Requires-Dist: jaxtyping
Requires-Dist: numpy
Requires-Dist: optixstuff>=3.0.0
Requires-Dist: pyyaml
Provides-Extra: dev
Requires-Dist: pre-commit; extra == 'dev'
Provides-Extra: docs
Requires-Dist: eyepiece; extra == 'docs'
Requires-Dist: imageio-ffmpeg; extra == 'docs'
Requires-Dist: ipython; extra == 'docs'
Requires-Dist: matplotlib; extra == 'docs'
Requires-Dist: myst-nb; extra == 'docs'
Requires-Dist: sphinx; extra == 'docs'
Requires-Dist: sphinx-autoapi; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
Requires-Dist: sphinx-book-theme; extra == 'docs'
Requires-Dist: sphinxcontrib-mermaid; extra == 'docs'
Provides-Extra: test
Requires-Dist: hypothesis; extra == 'test'
Requires-Dist: matplotlib; extra == 'test'
Requires-Dist: nox; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: scipy; extra == 'test'
Provides-Extra: viz
Requires-Dist: eyepiece>=0.1.0; extra == 'viz'
Description-Content-Type: text/markdown

# physicaloptix

Physical optics -- PSFs and diffraction -- for the HWO direct-imaging
simulation suite.

## What physicaloptix is

`physicaloptix` turns an [optixstuff](https://github.com/CoreySpohn/optixstuff)
hardware description into point-spread functions by wave-optics propagation.
It is a downstream consumer of optixstuff -- parallel to
[coronagraphoto](https://github.com/CoreySpohn/coronagraphoto) (2D image
simulation) and [jaxEDITH](https://github.com/CoreySpohn/jaxedith)
(exposure-time and yield calculations) -- so optixstuff itself stays free of
diffraction code.

The propagation core is owned: a
plane-aware `Field`/`Grid` data model, the continuous-FT MFT pair, the
multi-scale vortex, and the `OpticalPath` fold with construction-time
sampling gates, validated against the HWO Coronagraph Design Survey
(cds_pipeline) EAC-1 AAVC to an on-axis null of 3.05e-11 (0.2 percent of the
reference; the acceptance gates live in `tests/validation/`).

The key piece is `PathCoronagraph`, which implements optixstuff's
`AbstractCoronagraph`: build an `OpticalPath` (entrance pupil to Lyot plane),
wrap it, and hand it to any downstream tool. Its IWA and scalar performance
curves are derived from the propagated PSFs at construction, never declared.

```python
import physicaloptix as po

coro = po.PathCoronagraph.from_path(
    core_path, pupil_field, diameter_m=6.0, owa_lod=32.0
)
psf = coro.on_axis_psf(600.0, pixel_scale_rad, npix)   # unit-flux PSF out
eta = coro.throughput(6.0, 600.0)                      # derived, not declared
```

## What physicaloptix is *not*

- **Not a hardware model.** The telescope / coronagraph / detector description
  lives in [optixstuff](https://github.com/CoreySpohn/optixstuff); physicaloptix
  consumes it.
- **Not a PSF interpolator.** That is [yippy](https://github.com/CoreySpohn/yippy)'s
  job (a sampled YIP table). physicaloptix is its functional sibling -- live
  propagation -- and both back the same `AbstractCoronagraph` slot.
- **Not a scene model.** Stars, planets, disks, and zodi live in
  [skyscapes](https://github.com/CoreySpohn/skyscapes).

## Architecture

Built on [JAX](https://github.com/google/jax) and
[Equinox](https://github.com/patrick-kidger/equinox), `physicaloptix` provides:

- **The owned core** (`physicaloptix.core`) -- `Grid` (all-static, half-pixel
  offset, continuous-FT weights), `PlaneKind`-tagged `Field` pytrees, and
  `Spectrum` for chromatic fields.
- **Propagators** (`physicaloptix.transforms`) -- the validated `cmft_fwd` /
  `cmft_bwd` continuous-FT MFT pair and the plane-aware `Fraunhofer` wrapper,
  with sampling diagnostics evaluated at construction time.
- **Elements** (`physicaloptix.elements`) -- grid-stamped `SampledOptic` for
  ingested masks and the `MultiScaleVortex` ladder (hcipy port; reaches the
  cds EAC-1 on-axis null).
- **The optical path** (`physicaloptix.path`) -- `OpticalPath`, named plane-checked
  stages folded once, with static taps for free instrumented propagation.
- **The speckle layer** -- `SpeckleProcess` / `AnalyticSpeckleField`, the
  linear speckle generator (E_nom, G) behind optixstuff's `AbstractSpeckleField`.
- **Interop** (`physicaloptix.interop`) -- `PathCoronagraph`, the
  optixstuff `AbstractCoronagraph` adapter: cached-Lyot image interface and
  scalar curves (throughput, core area/intensity, occulter transmission)
  derived from a build-time separation sweep.

### Ecosystem position

```mermaid
flowchart TB
    optix["<b>optixstuff</b><br/>Telescope · Coronagraph · Detector · OpticalPath"]
    physopt["<b>physicaloptix</b><br/>Owned propagation core / diffraction<br/>OpticalPath · PathCoronagraph"]
    yippy["<b>yippy</b><br/>Sampled-YIP PSF interpolation"]
    corono["<b>coronagraphoto</b><br/>2D image simulation"]
    jaxedith["<b>jaxEDITH</b><br/>Exposure-time / yield"]

    optix --> physopt
    optix --> yippy
    physopt -- AbstractCoronagraph --> corono
    physopt -- AbstractCoronagraph --> jaxedith
    yippy -- AbstractCoronagraph --> corono
```

## Installation

```bash
pip install physicaloptix
```

## Status

Early development. The owned core propagates a full apodized vortex
coronagraph chain (see `tests/validation/`), and `PathCoronagraph` serves it
through the optixstuff interface with derived performance curves. The optical
model is scalar; the chain propagates broadband on a fixed angular grid, and
the yield-input-package emitter freezes it to tables.

## Verification and validation

The propagation core is verified against closed-form physics in tests that
run everywhere (the Airy pattern absolutely, the Mawet ideal-null theorem at
the 1e-11 contrast regime, Talbot and Gaussian-beam laws, gradient
correctness against finite differences) and validated against the HWO
Coronagraph Design Survey EAC-1 reference to a 0.2 percent on-axis null
agreement at 3e-11 contrast. The evidence, tolerances, and how to reproduce
them are documented on the
[validation page](https://physicaloptix.readthedocs.io/en/latest/validation.html).
The deep-contrast path requires float64 (`jax_enable_x64`).
