physicaloptix 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ """physicaloptix -- physical optics (PSFs and diffraction) for the HWO suite.
2
+
3
+ A downstream consumer of optixstuff that produces PSFs via dLux, parallel to
4
+ coronagraphoto (image sim) and jaxedith (ETC). optixstuff stays free of dLux and
5
+ physical optics; diffraction lives here, with dLux as the (hidden, swappable)
6
+ backend.
7
+
8
+ ``DLuxCoronagraph`` implements optixstuff's ``AbstractCoronagraph``, so
9
+ coronagraphoto / jaxedith get dLux-propagated PSFs by dependency injection: build
10
+ one from an optixstuff primary and hand it over, no dLux in sight.
11
+ """
12
+
13
+ from physicaloptix._version import __version__
14
+ from physicaloptix.apertures import to_dlux_aperture
15
+ from physicaloptix.coronagraph import DLuxCoronagraph, psf
16
+
17
+ __all__ = [
18
+ "DLuxCoronagraph",
19
+ "__version__",
20
+ "psf",
21
+ "to_dlux_aperture",
22
+ ]
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.0.1'
22
+ __version_tuple__ = version_tuple = (0, 0, 1)
23
+
24
+ __commit_id__ = commit_id = None
@@ -0,0 +1,51 @@
1
+ """Render optixstuff primaries into dLux apertures (the optixstuff -> dLux seam).
2
+
3
+ This is where the (unavoidable) translation from an optixstuff hardware
4
+ description to a dLux object lives -- once, dispatched by primary type, so callers
5
+ work with optixstuff objects and never construct dLux apertures by hand.
6
+ """
7
+
8
+ import functools
9
+
10
+ import dLux as dl
11
+ import numpy as np
12
+ from optixstuff import SegmentedPrimary, SimplePrimary
13
+
14
+
15
+ @functools.singledispatch
16
+ def to_dlux_aperture(primary):
17
+ """Render an optixstuff primary into a dLux aperture layer.
18
+
19
+ Register a new primary type with ``@to_dlux_aperture.register`` rather than
20
+ branching here -- O(primary types), not a growing if/elif.
21
+
22
+ Args:
23
+ primary: An :class:`optixstuff.AbstractPrimary` concrete instance.
24
+
25
+ Returns:
26
+ A dLux aperture layer (e.g. ``MultiAperture`` or ``CircularAperture``).
27
+ """
28
+ raise NotImplementedError(f"no dLux adapter for {type(primary).__name__}")
29
+
30
+
31
+ @to_dlux_aperture.register
32
+ def _(primary: SegmentedPrimary):
33
+ centres = np.asarray(primary.segment_centres_m)
34
+ seg_rmax = float(primary.segment_flat_to_flat_m) / np.sqrt(3.0)
35
+ segments = []
36
+ for x, y in centres:
37
+ transform = dl.CoordTransform(
38
+ translation=[float(x), float(y)], rotation=float(np.pi / 6)
39
+ ) # flat-top hexagons
40
+ segments.append(
41
+ dl.RegPolyAperture(
42
+ nsides=6, rmax=seg_rmax, transformation=transform, softening=1.0
43
+ )
44
+ )
45
+ return dl.MultiAperture(segments, normalise=True)
46
+
47
+
48
+ @to_dlux_aperture.register
49
+ def _(primary: SimplePrimary):
50
+ # no segment geometry -> model the circumscribing circle
51
+ return dl.CircularAperture(radius=float(primary.diameter_m) / 2.0, normalise=True)
@@ -0,0 +1,120 @@
1
+ """A dLux-backed optixstuff coronagraph.
2
+
3
+ ``DLuxCoronagraph`` satisfies optixstuff's ``AbstractCoronagraph`` interface, so
4
+ coronagraphoto / jaxedith consume it as any other coronagraph -- the dLux optical
5
+ system is hidden inside. This is the sibling of yippy's sampled-YIP coronagraph:
6
+ yippy interpolates a precomputed PSF table, this propagates live (freeze-to-table
7
+ is a planned bridge).
8
+ """
9
+
10
+ import dLux as dl
11
+ import equinox as eqx
12
+ import jax.numpy as jnp
13
+ import numpy as np
14
+ from optixstuff.coronagraph import AbstractCoronagraph
15
+
16
+ from physicaloptix.apertures import to_dlux_aperture
17
+
18
+ ARCSEC = 180.0 / np.pi * 3600.0 # arcsec per radian
19
+
20
+
21
+ class DLuxCoronagraph(AbstractCoronagraph):
22
+ """An optixstuff coronagraph whose PSFs come from live dLux propagation.
23
+
24
+ Build it from an optixstuff primary with :meth:`from_primary`; it then
25
+ satisfies the ``AbstractCoronagraph`` interface (``on_axis_psf`` /
26
+ ``off_axis_psf`` plus the scalar ETC methods).
27
+
28
+ No coronagraph mask is modelled yet, so ``on_axis_psf`` is presently the
29
+ telescope PSF -- a suppression-free degenerate coronagraph. Adding an
30
+ occulter / Lyot-stop layer is the next step.
31
+ """
32
+
33
+ _aperture: eqx.Module
34
+ _diameter_m: float
35
+ _wf_npixels: int = eqx.field(static=True)
36
+ pixel_scale_lod: float
37
+ IWA: float
38
+ OWA: float
39
+ _raw_contrast: float
40
+ _core_throughput: float
41
+
42
+ def __init__(
43
+ self,
44
+ aperture: eqx.Module,
45
+ diameter_m: float,
46
+ *,
47
+ wf_npixels: int = 256,
48
+ pixel_scale_lod: float = 0.25,
49
+ IWA: float = 3.0,
50
+ OWA: float = 30.0,
51
+ raw_contrast: float = 1e-10,
52
+ core_throughput: float = 0.2,
53
+ ) -> None:
54
+ """Wrap a dLux aperture as an optixstuff coronagraph."""
55
+ self._aperture = aperture
56
+ self._diameter_m = diameter_m
57
+ self._wf_npixels = wf_npixels
58
+ self.pixel_scale_lod = pixel_scale_lod
59
+ self.IWA = IWA
60
+ self.OWA = OWA
61
+ self._raw_contrast = raw_contrast
62
+ self._core_throughput = core_throughput
63
+
64
+ @classmethod
65
+ def from_primary(cls, primary, **kwargs) -> "DLuxCoronagraph":
66
+ """Build from an optixstuff primary (the optixstuff -> dLux seam)."""
67
+ return cls(to_dlux_aperture(primary), float(primary.diameter_m), **kwargs)
68
+
69
+ def _optics(self, pixel_scale_rad, npixels):
70
+ return dl.AngularOpticalSystem(
71
+ wf_npixels=self._wf_npixels,
72
+ diameter=self._diameter_m,
73
+ layers=[("pupil", self._aperture)],
74
+ psf_npixels=int(npixels),
75
+ psf_pixel_scale=float(pixel_scale_rad) * ARCSEC,
76
+ oversample=1,
77
+ )
78
+
79
+ # -- image interface (consumed by coronagraphoto) ---------------------
80
+ def on_axis_psf(self, wavelength_nm, pixel_scale_rad, npixels):
81
+ """On-axis PSF via dLux (telescope PSF until a mask is added)."""
82
+ optics = self._optics(pixel_scale_rad, npixels)
83
+ return optics.propagate(jnp.array([wavelength_nm * 1e-9]))
84
+
85
+ def off_axis_psf(self, wavelength_nm, separation_lod, pixel_scale_rad, npixels):
86
+ """Off-axis (planet) PSF, placed along +x by convention."""
87
+ optics = self._optics(pixel_scale_rad, npixels)
88
+ wl_m = wavelength_nm * 1e-9
89
+ offset = jnp.array([separation_lod * wl_m / self._diameter_m, 0.0])
90
+ return optics.propagate(jnp.array([wl_m]), offset)
91
+
92
+ # -- scalar interface (consumed by jaxedith) -- placeholders ----------
93
+ def throughput(self, separation_lod, wavelength_nm, *, time_s=0.0):
94
+ """Core throughput (constant eta_p placeholder)."""
95
+ return self._core_throughput
96
+
97
+ def core_area(self, separation_lod, wavelength_nm, *, time_s=0.0):
98
+ """Photometric core area in (lambda/D)^2 (placeholder)."""
99
+ return 1.0
100
+
101
+ def core_mean_intensity(self, separation_lod, wavelength_nm, *, time_s=0.0):
102
+ """Mean stellar leakage (constant raw_contrast placeholder)."""
103
+ return self._raw_contrast
104
+
105
+ def occulter_transmission(self, separation_lod, wavelength_nm, *, time_s=0.0):
106
+ """Off-axis sky transmission (no occulter modelled -> 1)."""
107
+ return 1.0
108
+
109
+ def __repr__(self):
110
+ """One-line summary."""
111
+ return (
112
+ f"DLuxCoronagraph(D={self._diameter_m:.3g} m, "
113
+ f"wf_npix={self._wf_npixels}, no mask [telescope PSF])"
114
+ )
115
+
116
+
117
+ def psf(primary, wavelength_nm, pixel_scale_rad, npixels, **kwargs):
118
+ """One-liner facade: optixstuff primary -> on-axis PSF, no visible dLux."""
119
+ coro = DLuxCoronagraph.from_primary(primary, **kwargs)
120
+ return coro.on_axis_psf(wavelength_nm, pixel_scale_rad, npixels)
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.4
2
+ Name: physicaloptix
3
+ Version: 0.0.1
4
+ Summary: Physical optics (PSFs and diffraction) for the HWO direct imaging simulation suite
5
+ Project-URL: Homepage, https://github.com/CoreySpohn/physicaloptix
6
+ Project-URL: Issues, https://github.com/CoreySpohn/physicaloptix/issues
7
+ Author-email: Corey Spohn <corey.a.spohn@nasa.gov>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2026 Corey Spohn
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Classifier: Development Status :: 2 - Pre-Alpha
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
35
+ Requires-Python: >=3.11
36
+ Requires-Dist: dlux
37
+ Requires-Dist: equinox>=0.12.0
38
+ Requires-Dist: jax>=0.4.1
39
+ Requires-Dist: jaxlib>=0.4.1
40
+ Requires-Dist: numpy
41
+ Requires-Dist: optixstuff
42
+ Provides-Extra: dev
43
+ Requires-Dist: pre-commit; extra == 'dev'
44
+ Provides-Extra: docs
45
+ Requires-Dist: ipython; extra == 'docs'
46
+ Requires-Dist: matplotlib; extra == 'docs'
47
+ Requires-Dist: myst-nb; extra == 'docs'
48
+ Requires-Dist: sphinx; extra == 'docs'
49
+ Requires-Dist: sphinx-autoapi; extra == 'docs'
50
+ Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
51
+ Requires-Dist: sphinx-book-theme; extra == 'docs'
52
+ Requires-Dist: sphinxcontrib-mermaid; extra == 'docs'
53
+ Provides-Extra: test
54
+ Requires-Dist: hypothesis; extra == 'test'
55
+ Requires-Dist: nox; extra == 'test'
56
+ Requires-Dist: pytest; extra == 'test'
57
+ Requires-Dist: pytest-cov; extra == 'test'
58
+ Description-Content-Type: text/markdown
59
+
60
+ # physicaloptix
61
+
62
+ Physical optics — PSFs and diffraction — for the HWO direct-imaging
63
+ simulation suite.
64
+
65
+ ## What physicaloptix is
66
+
67
+ `physicaloptix` turns an [optixstuff](https://github.com/CoreySpohn/optixstuff)
68
+ hardware description into point-spread functions by wave-optics propagation,
69
+ using [dLux](https://github.com/LouisDesdoigts/dLux) as the (hidden, swappable)
70
+ backend. It is a downstream consumer of optixstuff — parallel to
71
+ [coronagraphoto](https://github.com/CoreySpohn/coronagraphoto) (2D image
72
+ simulation) and [jaxEDITH](https://github.com/CoreySpohn/jaxedith)
73
+ (exposure-time and yield calculations) — so optixstuff itself stays free of
74
+ diffraction code.
75
+
76
+ The key piece is `DLuxCoronagraph`, which implements optixstuff's
77
+ `AbstractCoronagraph`. Build one from an optixstuff primary and hand it to any
78
+ downstream tool: it is consumed as an `AbstractCoronagraph`, so coronagraphoto
79
+ and jaxEDITH get dLux-propagated PSFs by dependency injection, without depending
80
+ on physicaloptix or dLux themselves.
81
+
82
+ ```python
83
+ import physicaloptix as po
84
+
85
+ coro = po.DLuxCoronagraph.from_primary(primary) # optixstuff in, dLux hidden
86
+ psf = coro.on_axis_psf(600.0, pixel_scale_rad, npix) # PSF out
87
+ ```
88
+
89
+ ## What physicaloptix is *not*
90
+
91
+ - **Not a hardware model.** The telescope / coronagraph / detector description
92
+ lives in [optixstuff](https://github.com/CoreySpohn/optixstuff); physicaloptix
93
+ consumes it.
94
+ - **Not a PSF interpolator.** That's [yippy](https://github.com/CoreySpohn/yippy)'s
95
+ job (a sampled YIP table). physicaloptix is its functional sibling — live
96
+ propagation — and both back the same `AbstractCoronagraph` slot.
97
+ - **Not a scene model.** Stars, planets, disks, and zodi live in
98
+ [skyscapes](https://github.com/CoreySpohn/skyscapes).
99
+
100
+ ## Architecture
101
+
102
+ Built on [JAX](https://github.com/google/jax),
103
+ [Equinox](https://github.com/patrick-kidger/equinox), and
104
+ [dLux](https://github.com/LouisDesdoigts/dLux), `physicaloptix` provides:
105
+
106
+ - **The optixstuff -> dLux adapter** — `to_dlux_aperture`, a `singledispatch`
107
+ that renders each optixstuff primary type into a dLux aperture (segmented hex
108
+ -> `MultiAperture`, simple circular -> `CircularAperture`).
109
+ - **A dLux-backed coronagraph** — `DLuxCoronagraph`, an optixstuff
110
+ `AbstractCoronagraph` producing `on_axis_psf` / `off_axis_psf` by propagation.
111
+ - **A facade** — `psf(primary, ...)`, a one-liner from primary to PSF.
112
+
113
+ ### Ecosystem position
114
+
115
+ ```mermaid
116
+ flowchart TB
117
+ optix["<b>optixstuff</b><br/>Telescope · Coronagraph · Detector · OpticalPath"]
118
+ physopt["<b>physicaloptix</b><br/>dLux-backed PSFs / diffraction<br/>DLuxCoronagraph"]
119
+ yippy["<b>yippy</b><br/>Sampled-YIP PSF interpolation"]
120
+ corono["<b>coronagraphoto</b><br/>2D image simulation"]
121
+ jaxedith["<b>jaxEDITH</b><br/>Exposure-time / yield"]
122
+
123
+ optix --> physopt
124
+ optix --> yippy
125
+ physopt -- AbstractCoronagraph --> corono
126
+ physopt -- AbstractCoronagraph --> jaxedith
127
+ yippy -- AbstractCoronagraph --> corono
128
+ ```
129
+
130
+ ## Installation
131
+
132
+ ```bash
133
+ pip install physicaloptix
134
+ ```
135
+
136
+ ## Status
137
+
138
+ This package is in early development (pre-v0.1.0). No coronagraph mask
139
+ (focal-plane / Lyot) is modelled yet, so `on_axis_psf` is currently the
140
+ telescope PSF.
@@ -0,0 +1,8 @@
1
+ physicaloptix/__init__.py,sha256=CFZNG7wy-mOo87TP16QT2Mt-SA_-KlgV33mo_j1dcP4,802
2
+ physicaloptix/_version.py,sha256=8OsTLsIVB9D0HdPTmt5rVwyVUBe9xTVGkRslXicxzkM,520
3
+ physicaloptix/apertures.py,sha256=pwbTyD1iinoEDQftkp5q-F6hN5f7JT_l8uOY2TQ3I-o,1752
4
+ physicaloptix/coronagraph.py,sha256=hxUNB4TTWYM040TL7BVBsAOYbVhrrS3qKoXQqKUVGgE,4626
5
+ physicaloptix-0.0.1.dist-info/METADATA,sha256=H8_ClrZvm15mFGf4XmpGr3Mg-_65plW0XYRLjuB-8ig,5930
6
+ physicaloptix-0.0.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
7
+ physicaloptix-0.0.1.dist-info/licenses/LICENSE,sha256=66ed08OMdjt-G3WoW0mfxmaAt-zqSwZ2A0kvPklkwwQ,1068
8
+ physicaloptix-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Corey Spohn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.