optixstuff 4.0.1__tar.gz → 5.0.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.1 → optixstuff-5.0.0}/CHANGELOG.md +23 -0
  2. {optixstuff-4.0.1 → optixstuff-5.0.0}/PKG-INFO +2 -1
  3. {optixstuff-4.0.1 → optixstuff-5.0.0}/pyproject.toml +2 -0
  4. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/_version.py +2 -2
  5. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/detector.py +8 -2
  6. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/exposure.py +1 -1
  7. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/primary.py +68 -0
  8. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/speckle.py +9 -10
  9. {optixstuff-4.0.1 → optixstuff-5.0.0}/.codespellrc +0 -0
  10. {optixstuff-4.0.1 → optixstuff-5.0.0}/.editorconfig +0 -0
  11. {optixstuff-4.0.1 → optixstuff-5.0.0}/.gitattributes +0 -0
  12. {optixstuff-4.0.1 → optixstuff-5.0.0}/.gitignore +0 -0
  13. {optixstuff-4.0.1 → optixstuff-5.0.0}/.pre-commit-config.yaml +0 -0
  14. {optixstuff-4.0.1 → optixstuff-5.0.0}/.readthedocs.yaml +0 -0
  15. {optixstuff-4.0.1 → optixstuff-5.0.0}/.zenodo.json +0 -0
  16. {optixstuff-4.0.1 → optixstuff-5.0.0}/CITATION.cff +0 -0
  17. {optixstuff-4.0.1 → optixstuff-5.0.0}/LICENSE +0 -0
  18. {optixstuff-4.0.1 → optixstuff-5.0.0}/README.md +0 -0
  19. {optixstuff-4.0.1 → optixstuff-5.0.0}/SECURITY.md +0 -0
  20. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/__init__.py +0 -0
  21. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/_repr.py +0 -0
  22. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/coronagraph.py +0 -0
  23. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/disperser.py +0 -0
  24. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/optical_elements.py +0 -0
  25. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/optical_path.py +0 -0
  26. {optixstuff-4.0.1 → optixstuff-5.0.0}/src/optixstuff/yippy_coronagraph.py +0 -0
  27. {optixstuff-4.0.1 → optixstuff-5.0.0}/tools/check_internal_refs.py +0 -0
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.0.0](https://github.com/CoreySpohn/optixstuff/compare/v4.1.0...v5.0.0) (2026-11-16)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **exposure:** exposure start and speckle clock origin are days from the scene epoch
9
+
10
+ ### Features
11
+
12
+ * **exposure:** exposure start and speckle clock origin are days from the scene epoch ([59ce2c8](https://github.com/CoreySpohn/optixstuff/commit/59ce2c83de150c70ff1875eb0d5a3c20d41c6430))
13
+
14
+ ## [4.1.0](https://github.com/CoreySpohn/optixstuff/compare/v4.0.1...v4.1.0) (2026-11-12)
15
+
16
+
17
+ ### Features
18
+
19
+ * **primary:** add SimplePrimary.from_yip ([f8f563e](https://github.com/CoreySpohn/optixstuff/commit/f8f563e94eeb326eebb5a4600236ad20b79068b3))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **detector:** default dqe to 1.0 so the default means no QE degradation ([735a651](https://github.com/CoreySpohn/optixstuff/commit/735a651607741091a494b8a0f710821d71da0bb5))
25
+
3
26
  ## [4.0.1](https://github.com/CoreySpohn/optixstuff/compare/v4.0.0...v4.0.1) (2026-11-06)
4
27
 
5
28
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: optixstuff
3
- Version: 4.0.1
3
+ Version: 5.0.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
@@ -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",
@@ -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.1'
22
- __version_tuple__ = version_tuple = (4, 0, 1)
21
+ __version__ = version = '5.0.0'
22
+ __version_tuple__ = version_tuple = (5, 0, 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.
@@ -17,7 +17,7 @@ class ExposureConfig(eqx.Module):
17
17
  sequence), depending on how the factories are composed.
18
18
  """
19
19
 
20
- start_time_jd: jnp.ndarray # Julian Date
20
+ start_time_d: jnp.ndarray # Days from the scene epoch
21
21
  exposure_time_s: jnp.ndarray # Seconds
22
22
  central_wavelength_nm: jnp.ndarray # Nanometers
23
23
  bin_width_nm: jnp.ndarray # Nanometers
@@ -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."""
@@ -36,7 +36,7 @@ class AbstractSpeckleField(eqx.Module):
36
36
  through :meth:`realize`.
37
37
 
38
38
  All wavelength arguments are in nanometers; ``time_s`` is seconds since
39
- mission start. The returned map is on the field's native coronagraph
39
+ the speckle clock origin. The returned map is on the field's native coronagraph
40
40
  plane at :attr:`pixel_scale_lod`; the caller resamples it to the
41
41
  detector grid (as for the coronagraph ``stellar_intens`` map).
42
42
  """
@@ -44,13 +44,12 @@ class AbstractSpeckleField(eqx.Module):
44
44
  pixel_scale_lod: AbstractVar[float]
45
45
  """Native pixel scale in lambda/D per pixel."""
46
46
 
47
- epoch_jd: AbstractVar[float]
48
- """Julian Date that maps to ``time_s = 0`` -- the realization's clock
49
- origin. Consumers (e.g. ``coronagraphoto.speckle_rate``) convert an
50
- observation's absolute JD to the elapsed seconds :meth:`realize` expects
51
- via ``(start_time_jd - epoch_jd)``; anchoring the clock here keeps the
52
- physical interface in elapsed seconds and avoids feeding large absolute
53
- JDs into the temporal synthesis."""
47
+ epoch_d: AbstractVar[float]
48
+ """Days from the scene epoch at which ``time_s = 0``.
49
+
50
+ Consumers convert observation offsets via ``(start_time_d - epoch_d)``;
51
+ a nearby clock origin preserves float32 resolution in elapsed seconds.
52
+ """
54
53
 
55
54
  @abc.abstractmethod
56
55
  def realize(
@@ -81,7 +80,7 @@ class AbstractSpeckleField(eqx.Module):
81
80
 
82
81
  Args:
83
82
  wavelength_nm: Wavelength in nanometers.
84
- time_s: Time since mission start in seconds.
83
+ time_s: Time since the speckle clock origin in seconds.
85
84
 
86
85
  Returns:
87
86
  2D float contrast-delta array on the native coronagraph plane.
@@ -118,7 +117,7 @@ class AbstractSpeckleField(eqx.Module):
118
117
  Args:
119
118
  wavelength_nm: Wavelength in nanometers.
120
119
  exposure_s: Exposure length in seconds.
121
- start_time_s: Exposure start, in seconds since ``epoch_jd``.
120
+ start_time_s: Exposure start, in seconds since ``epoch_d``.
122
121
  n_sub: Number of sub-exposure samples. Must be at least 1.
123
122
 
124
123
  Returns:
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
File without changes