optixstuff 4.0.0__tar.gz → 4.1.0__tar.gz

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.
Files changed (27) hide show
  1. {optixstuff-4.0.0 → optixstuff-4.1.0}/.pre-commit-config.yaml +1 -1
  2. {optixstuff-4.0.0 → optixstuff-4.1.0}/CHANGELOG.md +19 -0
  3. {optixstuff-4.0.0 → optixstuff-4.1.0}/PKG-INFO +11 -2
  4. {optixstuff-4.0.0 → optixstuff-4.1.0}/README.md +9 -0
  5. {optixstuff-4.0.0 → optixstuff-4.1.0}/pyproject.toml +2 -1
  6. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/_version.py +2 -2
  7. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/detector.py +8 -2
  8. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/primary.py +68 -0
  9. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/yippy_coronagraph.py +78 -4
  10. {optixstuff-4.0.0 → optixstuff-4.1.0}/.codespellrc +0 -0
  11. {optixstuff-4.0.0 → optixstuff-4.1.0}/.editorconfig +0 -0
  12. {optixstuff-4.0.0 → optixstuff-4.1.0}/.gitattributes +0 -0
  13. {optixstuff-4.0.0 → optixstuff-4.1.0}/.gitignore +0 -0
  14. {optixstuff-4.0.0 → optixstuff-4.1.0}/.readthedocs.yaml +0 -0
  15. {optixstuff-4.0.0 → optixstuff-4.1.0}/.zenodo.json +0 -0
  16. {optixstuff-4.0.0 → optixstuff-4.1.0}/CITATION.cff +0 -0
  17. {optixstuff-4.0.0 → optixstuff-4.1.0}/LICENSE +0 -0
  18. {optixstuff-4.0.0 → optixstuff-4.1.0}/SECURITY.md +0 -0
  19. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/__init__.py +0 -0
  20. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/_repr.py +0 -0
  21. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/coronagraph.py +0 -0
  22. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/disperser.py +0 -0
  23. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/exposure.py +0 -0
  24. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/optical_elements.py +0 -0
  25. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/optical_path.py +0 -0
  26. {optixstuff-4.0.0 → optixstuff-4.1.0}/src/optixstuff/speckle.py +0 -0
  27. {optixstuff-4.0.0 → optixstuff-4.1.0}/tools/check_internal_refs.py +0 -0
@@ -21,7 +21,7 @@ repos:
21
21
  args: [--fix]
22
22
  - id: ruff-format
23
23
  - repo: https://github.com/codespell-project/codespell
24
- rev: v2.4.1
24
+ rev: v2.4.3
25
25
  hooks:
26
26
  - id: codespell
27
27
  - repo: https://github.com/compilerla/conventional-pre-commit
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.1.0](https://github.com/CoreySpohn/optixstuff/compare/v4.0.1...v4.1.0) (2026-11-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * **primary:** add SimplePrimary.from_yip ([f8f563e](https://github.com/CoreySpohn/optixstuff/commit/f8f563e94eeb326eebb5a4600236ad20b79068b3))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **detector:** default dqe to 1.0 so the default means no QE degradation ([735a651](https://github.com/CoreySpohn/optixstuff/commit/735a651607741091a494b8a0f710821d71da0bb5))
14
+
15
+ ## [4.0.1](https://github.com/CoreySpohn/optixstuff/compare/v4.0.0...v4.0.1) (2026-11-06)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * route yippy stellar and sky products through their own frame ([b9a029b](https://github.com/CoreySpohn/optixstuff/commit/b9a029b2b03a96564b443ad14aacfe3fdbb9b62b))
21
+
3
22
  ## [4.0.0](https://github.com/CoreySpohn/optixstuff/compare/v3.0.0...v4.0.0) (2026-11-05)
4
23
 
5
24
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: optixstuff
3
- Version: 4.0.0
3
+ Version: 4.1.0
4
4
  Summary: Hardware abstractions for the HWO direct imaging simulation suite
5
5
  Project-URL: Homepage, https://github.com/CoreySpohn/optixstuff
6
6
  Project-URL: Issues, https://github.com/CoreySpohn/optixstuff/issues
@@ -33,6 +33,7 @@ Classifier: License :: OSI Approved :: MIT License
33
33
  Classifier: Programming Language :: Python :: 3
34
34
  Classifier: Topic :: Scientific/Engineering :: Astronomy
35
35
  Requires-Python: >=3.12
36
+ Requires-Dist: astropy>=6.1
36
37
  Requires-Dist: equinox>=0.13.2
37
38
  Requires-Dist: hwoutils>=1.10.0
38
39
  Requires-Dist: interpax>=0.3.12
@@ -54,7 +55,6 @@ Provides-Extra: test
54
55
  Requires-Dist: hypothesis>=6.79.1; extra == 'test'
55
56
  Requires-Dist: numpy>=2.0; extra == 'test'
56
57
  Requires-Dist: psutil>=5.9.4; extra == 'test'
57
- Requires-Dist: pytest-cov>=1.0; extra == 'test'
58
58
  Requires-Dist: pytest-fail-slow>=0.1.0; extra == 'test'
59
59
  Requires-Dist: pytest-markdown-docs>=0.5.0; extra == 'test'
60
60
  Requires-Dist: pytest-testmon>=2.0.7; extra == 'test'
@@ -65,6 +65,15 @@ Description-Content-Type: text/markdown
65
65
 
66
66
  # optixstuff
67
67
 
68
+ <p align="center">
69
+ <a href="https://pypi.org/project/optixstuff/"><img src="https://img.shields.io/pypi/v/optixstuff.svg?style=flat-square&logo=pypi" alt="PyPI"/></a>
70
+ <a href="https://optixstuff.readthedocs.io"><img src="https://readthedocs.org/projects/optixstuff/badge/?version=latest&style=flat-square" alt="Documentation Status"/></a>
71
+ <a href="https://github.com/CoreySpohn/optixstuff/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/CoreySpohn/optixstuff/ci.yml?branch=main&style=flat-square&logo=github&label=tests" alt="Tests"/></a>
72
+ <a href="https://github.com/CoreySpohn/optixstuff/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License"/></a>
73
+ <a href="https://github.com/CoreySpohn/optixstuff/blob/main/pyproject.toml"><img src="https://img.shields.io/badge/python-3.12%2B-blue.svg?style=flat-square&logo=python" alt="Python 3.12+"/></a>
74
+ <a href="https://doi.org/10.5281/zenodo.20819379"><img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.20819379-blue?style=flat-square" alt="DOI"/></a>
75
+ </p>
76
+
68
77
  Shared hardware objects — with standard values — for the HWO direct-imaging
69
78
  simulation suite.
70
79
 
@@ -1,5 +1,14 @@
1
1
  # optixstuff
2
2
 
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/optixstuff/"><img src="https://img.shields.io/pypi/v/optixstuff.svg?style=flat-square&logo=pypi" alt="PyPI"/></a>
5
+ <a href="https://optixstuff.readthedocs.io"><img src="https://readthedocs.org/projects/optixstuff/badge/?version=latest&style=flat-square" alt="Documentation Status"/></a>
6
+ <a href="https://github.com/CoreySpohn/optixstuff/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/CoreySpohn/optixstuff/ci.yml?branch=main&style=flat-square&logo=github&label=tests" alt="Tests"/></a>
7
+ <a href="https://github.com/CoreySpohn/optixstuff/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License"/></a>
8
+ <a href="https://github.com/CoreySpohn/optixstuff/blob/main/pyproject.toml"><img src="https://img.shields.io/badge/python-3.12%2B-blue.svg?style=flat-square&logo=python" alt="Python 3.12+"/></a>
9
+ <a href="https://doi.org/10.5281/zenodo.20819379"><img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.20819379-blue?style=flat-square" alt="DOI"/></a>
10
+ </p>
11
+
3
12
  Shared hardware objects — with standard values — for the HWO direct-imaging
4
13
  simulation suite.
5
14
 
@@ -17,6 +17,8 @@ classifiers = [
17
17
  "Topic :: Scientific/Engineering :: Astronomy",
18
18
  ]
19
19
  dependencies = [
20
+ # SimplePrimary.from_yip reads the response header; yippy's own floor.
21
+ "astropy>=6.1",
20
22
  "equinox>=0.13.2",
21
23
  "hwoutils>=1.10.0",
22
24
  "interpax>=0.3.12",
@@ -40,7 +42,6 @@ docs = [
40
42
  test = [
41
43
  "pytest>=7.3.2",
42
44
  "hypothesis>=6.79.1",
43
- "pytest-cov>=1.0",
44
45
  "pytest-xdist>=2.5",
45
46
  "pytest-testmon>=2.0.7",
46
47
  "pytest-markdown-docs>=0.5.0",
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '4.0.0'
22
- __version_tuple__ = version_tuple = (4, 0, 0)
21
+ __version__ = version = '4.1.0'
22
+ __version_tuple__ = version_tuple = (4, 1, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -286,6 +286,9 @@ class IdealDetector(AbstractDetector):
286
286
 
287
287
  Suitable for broadband imager studies where wavelength-dependent
288
288
  QE variation is not important and CIC/read noise are negligible.
289
+
290
+ ``dqe`` is the multiplicative QE degradation factor; the default 1.0
291
+ means no degradation, so the effective QE is ``quantum_efficiency * dqe``.
289
292
  """
290
293
 
291
294
  pixel_scale_arcsec: float
@@ -308,7 +311,7 @@ class IdealDetector(AbstractDetector):
308
311
  clock_induced_charge_rate_e_per_frame: float = 0.0,
309
312
  frame_time_s: float = 1.0,
310
313
  read_time_s: float = 0.05,
311
- dqe: float = 0.0,
314
+ dqe: float = 1.0,
312
315
  ) -> None:
313
316
  """Create a simple constant-QE detector."""
314
317
  self.pixel_scale_arcsec = pixel_scale_arcsec
@@ -379,6 +382,9 @@ class Detector(AbstractDetector):
379
382
  sources matter. Uses Poisson statistics for dark/CIC and Gaussian
380
383
  for read noise, matching the coronagraphoto convention.
381
384
 
385
+ ``dqe`` is the multiplicative QE degradation factor; the default 1.0
386
+ means no degradation.
387
+
382
388
  Warning: ``num_frames = jnp.ceil(exposure_time_s / frame_time_s)`` is
383
389
  kept as a float. Never cast it to int inside JIT -- that triggers a
384
390
  ConcretizationTypeError when exposure_time_s is traced.
@@ -405,7 +411,7 @@ class Detector(AbstractDetector):
405
411
  clock_induced_charge_rate_e_per_frame: float = 0.0,
406
412
  frame_time_s: float = 1.0,
407
413
  read_time_s: float = 0.05,
408
- dqe: float = 0.0,
414
+ dqe: float = 1.0,
409
415
  qe_curve: tuple[ArrayLike, ArrayLike] | None = None,
410
416
  ) -> None:
411
417
  """Create a full detector with all noise sources.
@@ -1,5 +1,8 @@
1
1
  """Primary mirror abstractions."""
2
2
 
3
+ from math import sqrt
4
+ from pathlib import Path
5
+
3
6
  import equinox as eqx
4
7
  import jax.numpy as jnp
5
8
  from equinox import AbstractVar
@@ -23,6 +26,11 @@ class AbstractPrimary(eqx.Module):
23
26
  class SimplePrimary(AbstractPrimary):
24
27
  """A simple circular primary mirror with a central obscuration.
25
28
 
29
+ The obscuration is the inner-to-outer diameter ratio, so the annular
30
+ collecting area is ``pi * (diameter_m / 2)**2 * (1 - obscuration**2)``
31
+ times ``shape_factor``. :meth:`from_yip` converts the YIP ``OBSCURED``
32
+ area fraction to this linear ratio by taking its square root.
33
+
26
34
  Args:
27
35
  diameter_m: Primary mirror diameter in meters.
28
36
  obscuration: Linear obscuration fraction (0 = no obscuration).
@@ -45,6 +53,66 @@ class SimplePrimary(AbstractPrimary):
45
53
  self.obscuration = obscuration
46
54
  self.shape_factor = shape_factor
47
55
 
56
+ @classmethod
57
+ def from_yip(cls, yip, shape_factor: float = 1.0) -> "SimplePrimary":
58
+ """Build an aperture from YIP diameter and obscured area metadata.
59
+
60
+ Args:
61
+ yip: YIP directory or stellar-intensity FITS path, a
62
+ YippyCoronagraph, or a yippy Coronagraph/EqxCoronagraph.
63
+ Objects must retain the header or diameter metadata.
64
+ Paths read only the header, without loading PSF arrays.
65
+ shape_factor: Fraction of remaining area that collects light.
66
+
67
+ Returns:
68
+ An aperture with diameter in meters and linear obscuration.
69
+
70
+ Raises:
71
+ ValueError: If D or OBSCURED is missing or None. Some yippy
72
+ EqxCoronagraph versions discard D; use the original YIP
73
+ path or yippy Coronagraph in that case.
74
+ """
75
+ from astropy.io import fits
76
+ from yippy.header import HeaderData
77
+
78
+ from optixstuff.yippy_coronagraph import YippyCoronagraph
79
+
80
+ if isinstance(yip, YippyCoronagraph):
81
+ yip = yip._backend
82
+ if isinstance(yip, (str, Path)):
83
+ path = Path(yip)
84
+ if path.is_dir():
85
+ path = path / "stellar_intens.fits"
86
+ raw_header = fits.getheader(path, 0)
87
+ for key in ("D", "OBSCURED"):
88
+ if raw_header.get(key) is None:
89
+ raise ValueError(f"YIP header is missing {key}")
90
+ header = HeaderData.from_fits_header(raw_header)
91
+ else:
92
+ header = getattr(yip, "header", None)
93
+
94
+ if header is not None:
95
+ diameter = getattr(header, "diameter", None)
96
+ obscured = getattr(header, "obscured", None)
97
+ else:
98
+ diameter = getattr(yip, "diameter_m", None)
99
+ obscured = getattr(yip, "frac_obscured", None)
100
+ if diameter is None:
101
+ raise ValueError(
102
+ "YIP metadata is missing D (diameter); use the original YIP "
103
+ "path or yippy Coronagraph if the backend discarded it"
104
+ )
105
+ if obscured is None:
106
+ raise ValueError(
107
+ "YIP metadata is missing OBSCURED (obscured area fraction)"
108
+ )
109
+ diameter_m = (
110
+ float(diameter.to_value("m"))
111
+ if hasattr(diameter, "to_value")
112
+ else float(diameter)
113
+ )
114
+ return cls(diameter_m, obscuration=sqrt(obscured), shape_factor=shape_factor)
115
+
48
116
  @property
49
117
  def diameter_m(self) -> float:
50
118
  """Primary mirror diameter in meters."""
@@ -103,7 +103,7 @@ class YippyCoronagraph(AbstractTableCoronagraph):
103
103
  """Mean stellar leakage per (lambda/D)^2 from the YIP interpolation table.
104
104
 
105
105
  yippy tabulates the fraction of the star's light per pixel, so the
106
- value is divided by the pixel's solid angle, ``pixel_scale_lod**2``,
106
+ value is divided by the stellar pixel's solid angle,
107
107
  to meet the contract of :meth:`AbstractCoronagraph.core_mean_intensity`.
108
108
  The backend interpolates over the stellar diameter axis when present;
109
109
  otherwise it accepts and ignores the diameter.
@@ -116,7 +116,13 @@ class YippyCoronagraph(AbstractTableCoronagraph):
116
116
  queried wavelength; 0 means a point star.
117
117
  """
118
118
  per_pixel = self._backend.core_mean_intensity(separation_lod, stellar_diam_lod)
119
- return per_pixel / self._backend.pixel_scale_lod**2
119
+ return (
120
+ per_pixel
121
+ / getattr(
122
+ self._backend, "stellar_pixel_scale_lod", self._backend.pixel_scale_lod
123
+ )
124
+ ** 2
125
+ )
120
126
 
121
127
  def occulter_transmission(
122
128
  self,
@@ -139,6 +145,68 @@ class YippyCoronagraph(AbstractTableCoronagraph):
139
145
  """Stellar leakage PSF from the YIP stellar intensity model."""
140
146
  return self._backend.stellar_intens(0.0)
141
147
 
148
+ def stellar_map(
149
+ self,
150
+ wavelength_nm: ArrayLike,
151
+ stellar_diam_lod: ArrayLike,
152
+ *,
153
+ pixel_scale_lod: ArrayLike,
154
+ shape: tuple[int, int],
155
+ ) -> Array:
156
+ """Resample stellar flux in the backend's stellar reference frame."""
157
+ method = getattr(self._backend, "stellar_map", None)
158
+ if method is None:
159
+ return super().stellar_map(
160
+ wavelength_nm,
161
+ stellar_diam_lod,
162
+ pixel_scale_lod=pixel_scale_lod,
163
+ shape=shape,
164
+ )
165
+ return method(
166
+ wavelength_nm,
167
+ stellar_diam_lod,
168
+ pixel_scale_lod=pixel_scale_lod,
169
+ shape=shape,
170
+ )
171
+
172
+ def source_psfs(
173
+ self,
174
+ wavelength_nm: ArrayLike,
175
+ x_lod: ArrayLike,
176
+ y_lod: ArrayLike,
177
+ *,
178
+ pixel_scale_lod: ArrayLike,
179
+ shape: tuple[int, int],
180
+ ) -> Array:
181
+ """Resample source flux in the backend's off-axis reference frame."""
182
+ method = getattr(self._backend, "source_psfs", None)
183
+ if method is None:
184
+ return super().source_psfs(
185
+ wavelength_nm,
186
+ x_lod,
187
+ y_lod,
188
+ pixel_scale_lod=pixel_scale_lod,
189
+ shape=shape,
190
+ )
191
+ return method(
192
+ wavelength_nm, x_lod, y_lod, pixel_scale_lod=pixel_scale_lod, shape=shape
193
+ )
194
+
195
+ def background_transmission(
196
+ self,
197
+ wavelength_nm: ArrayLike,
198
+ *,
199
+ pixel_scale_lod: ArrayLike,
200
+ shape: tuple[int, int],
201
+ ) -> Array:
202
+ """Resample sky values in the backend's sky reference frame."""
203
+ method = getattr(self._backend, "background_transmission", None)
204
+ if method is None:
205
+ return super().background_transmission(
206
+ wavelength_nm, pixel_scale_lod=pixel_scale_lod, shape=shape
207
+ )
208
+ return method(wavelength_nm, pixel_scale_lod=pixel_scale_lod, shape=shape)
209
+
142
210
  def off_axis_psf(
143
211
  self,
144
212
  wavelength_nm: ArrayLike,
@@ -166,7 +234,7 @@ class YippyCoronagraph(AbstractTableCoronagraph):
166
234
  Same units as :meth:`core_mean_intensity`, so multiplying by
167
235
  :meth:`core_area` gives the floor as a fraction of the star's light.
168
236
  yippy's own ``noise_floor_ayo`` is per pixel and is divided by the
169
- pixel's solid angle, ``pixel_scale_lod**2``. Not part of the
237
+ stellar pixel's solid angle. Not part of the
170
238
  AbstractCoronagraph contract -- downstream ETCs should compute
171
239
  noise floors as pure functions.
172
240
 
@@ -183,7 +251,13 @@ class YippyCoronagraph(AbstractTableCoronagraph):
183
251
  per_pixel = (
184
252
  self._backend.core_mean_intensity(separation_lod, stellar_diam_lod) / ppf
185
253
  )
186
- return per_pixel / self._backend.pixel_scale_lod**2
254
+ return (
255
+ per_pixel
256
+ / getattr(
257
+ self._backend, "stellar_pixel_scale_lod", self._backend.pixel_scale_lod
258
+ )
259
+ ** 2
260
+ )
187
261
 
188
262
  def raw_contrast(self, separation_lod: ArrayLike) -> ArrayLike:
189
263
  """Raw contrast from the YIP interpolation table."""
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes