physicaloptix 0.0.1__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.
@@ -0,0 +1,221 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
219
+
220
+ # hatch-vcs generated version file
221
+ *_version.py
@@ -0,0 +1,20 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: "v6.0.0"
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: name-tests-test
7
+ args: [--pytest-test-first]
8
+ - id: end-of-file-fixer
9
+ - repo: https://github.com/astral-sh/ruff-pre-commit
10
+ rev: v0.15.2
11
+ hooks:
12
+ - id: ruff-check
13
+ args: [--fix]
14
+ - id: ruff-format
15
+ - repo: https://github.com/compilerla/conventional-pre-commit
16
+ rev: v4.3.0
17
+ hooks:
18
+ - id: conventional-pre-commit
19
+ stages: [commit-msg]
20
+ args: []
@@ -0,0 +1,20 @@
1
+ # Required
2
+ version: 2
3
+
4
+ # Set the OS, Python version and other tools you might need
5
+ build:
6
+ os: ubuntu-22.04
7
+ tools:
8
+ python: "3.12"
9
+
10
+ python:
11
+ install:
12
+ - method: pip
13
+ path: .
14
+ extra_requirements:
15
+ # Install with the [docs] flag for sphinx docs specific extensions
16
+ - docs
17
+
18
+ # Build documentation in the "docs/" directory with Sphinx
19
+ sphinx:
20
+ configuration: docs/conf.py
@@ -0,0 +1,28 @@
1
+ {
2
+ "upload_type": "software",
3
+ "creators": [
4
+ {
5
+ "orcid": "0000-0002-3138-0240",
6
+ "affiliation": "NASA Goddard Space Flight Center, Greenbelt, MD",
7
+ "name": "Spohn, Corey"
8
+ }
9
+ ],
10
+ "license": "MIT",
11
+ "title": "physicaloptix",
12
+ "description": "physicaloptix is an open-source JAX library providing physical-optics PSF and diffraction modeling, built on dLux, for the Habitable Worlds Observatory direct imaging simulation suite.",
13
+ "keywords": [
14
+ "physical optics",
15
+ "point spread function",
16
+ "diffraction",
17
+ "Habitable Worlds Observatory",
18
+ "direct imaging",
19
+ "JAX"
20
+ ],
21
+ "related_identifiers": [
22
+ {
23
+ "identifier": "https://github.com/CoreySpohn/physicaloptix",
24
+ "relation": "isSupplementTo",
25
+ "scheme": "url"
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1 (2026-06-27)
4
+
5
+
6
+ ### Features
7
+
8
+ * Initial commit ([8ce773d](https://github.com/CoreySpohn/physicaloptix/commit/8ce773d3a96b000e1bbaf0525030c1a8801333c6))
9
+
10
+
11
+ ### Miscellaneous Chores
12
+
13
+ * release 0.0.1 ([155d963](https://github.com/CoreySpohn/physicaloptix/commit/155d96329592b79d33db01981350de5023da7c07))
14
+
15
+ ## Changelog
@@ -0,0 +1,12 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ type: software
4
+ title: physicaloptix
5
+ abstract: "physicaloptix is an open-source JAX library providing physical-optics PSF and diffraction modeling, built on dLux, for the Habitable Worlds Observatory direct imaging simulation suite."
6
+ authors:
7
+ - family-names: Spohn
8
+ given-names: Corey
9
+ orcid: "https://orcid.org/0000-0002-3138-0240"
10
+ affiliation: "NASA Goddard Space Flight Center"
11
+ repository-code: "https://github.com/CoreySpohn/physicaloptix"
12
+ license: MIT
@@ -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.
@@ -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,81 @@
1
+ # physicaloptix
2
+
3
+ Physical optics — PSFs and diffraction — for the HWO direct-imaging
4
+ simulation suite.
5
+
6
+ ## What physicaloptix is
7
+
8
+ `physicaloptix` turns an [optixstuff](https://github.com/CoreySpohn/optixstuff)
9
+ hardware description into point-spread functions by wave-optics propagation,
10
+ using [dLux](https://github.com/LouisDesdoigts/dLux) as the (hidden, swappable)
11
+ backend. It is a downstream consumer of optixstuff — parallel to
12
+ [coronagraphoto](https://github.com/CoreySpohn/coronagraphoto) (2D image
13
+ simulation) and [jaxEDITH](https://github.com/CoreySpohn/jaxedith)
14
+ (exposure-time and yield calculations) — so optixstuff itself stays free of
15
+ diffraction code.
16
+
17
+ The key piece is `DLuxCoronagraph`, which implements optixstuff's
18
+ `AbstractCoronagraph`. Build one from an optixstuff primary and hand it to any
19
+ downstream tool: it is consumed as an `AbstractCoronagraph`, so coronagraphoto
20
+ and jaxEDITH get dLux-propagated PSFs by dependency injection, without depending
21
+ on physicaloptix or dLux themselves.
22
+
23
+ ```python
24
+ import physicaloptix as po
25
+
26
+ coro = po.DLuxCoronagraph.from_primary(primary) # optixstuff in, dLux hidden
27
+ psf = coro.on_axis_psf(600.0, pixel_scale_rad, npix) # PSF out
28
+ ```
29
+
30
+ ## What physicaloptix is *not*
31
+
32
+ - **Not a hardware model.** The telescope / coronagraph / detector description
33
+ lives in [optixstuff](https://github.com/CoreySpohn/optixstuff); physicaloptix
34
+ consumes it.
35
+ - **Not a PSF interpolator.** That's [yippy](https://github.com/CoreySpohn/yippy)'s
36
+ job (a sampled YIP table). physicaloptix is its functional sibling — live
37
+ propagation — and both back the same `AbstractCoronagraph` slot.
38
+ - **Not a scene model.** Stars, planets, disks, and zodi live in
39
+ [skyscapes](https://github.com/CoreySpohn/skyscapes).
40
+
41
+ ## Architecture
42
+
43
+ Built on [JAX](https://github.com/google/jax),
44
+ [Equinox](https://github.com/patrick-kidger/equinox), and
45
+ [dLux](https://github.com/LouisDesdoigts/dLux), `physicaloptix` provides:
46
+
47
+ - **The optixstuff -> dLux adapter** — `to_dlux_aperture`, a `singledispatch`
48
+ that renders each optixstuff primary type into a dLux aperture (segmented hex
49
+ -> `MultiAperture`, simple circular -> `CircularAperture`).
50
+ - **A dLux-backed coronagraph** — `DLuxCoronagraph`, an optixstuff
51
+ `AbstractCoronagraph` producing `on_axis_psf` / `off_axis_psf` by propagation.
52
+ - **A facade** — `psf(primary, ...)`, a one-liner from primary to PSF.
53
+
54
+ ### Ecosystem position
55
+
56
+ ```mermaid
57
+ flowchart TB
58
+ optix["<b>optixstuff</b><br/>Telescope · Coronagraph · Detector · OpticalPath"]
59
+ physopt["<b>physicaloptix</b><br/>dLux-backed PSFs / diffraction<br/>DLuxCoronagraph"]
60
+ yippy["<b>yippy</b><br/>Sampled-YIP PSF interpolation"]
61
+ corono["<b>coronagraphoto</b><br/>2D image simulation"]
62
+ jaxedith["<b>jaxEDITH</b><br/>Exposure-time / yield"]
63
+
64
+ optix --> physopt
65
+ optix --> yippy
66
+ physopt -- AbstractCoronagraph --> corono
67
+ physopt -- AbstractCoronagraph --> jaxedith
68
+ yippy -- AbstractCoronagraph --> corono
69
+ ```
70
+
71
+ ## Installation
72
+
73
+ ```bash
74
+ pip install physicaloptix
75
+ ```
76
+
77
+ ## Status
78
+
79
+ This package is in early development (pre-v0.1.0). No coronagraph mask
80
+ (focal-plane / Lyot) is modelled yet, so `on_axis_psf` is currently the
81
+ telescope PSF.
@@ -0,0 +1,73 @@
1
+ [build-system]
2
+ requires = ['hatchling', "hatch-fancy-pypi-readme", "hatch-vcs"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "physicaloptix"
7
+ description = "Physical optics (PSFs and diffraction) for the HWO direct imaging simulation suite"
8
+ authors = [{ name = "Corey Spohn", email = "corey.a.spohn@nasa.gov" }]
9
+ dynamic = ['readme', 'version']
10
+ requires-python = ">=3.11"
11
+ license = { file = "LICENSE" }
12
+ classifiers = [
13
+ "Development Status :: 2 - Pre-Alpha",
14
+ "Intended Audience :: Science/Research",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Topic :: Scientific/Engineering :: Astronomy",
18
+ ]
19
+ # NOTE: requires the optixstuff release that adds SegmentedPrimary + spectral
20
+ # detector QE (the local workspace optixstuff already has them).
21
+ dependencies = [
22
+ "dLux",
23
+ "equinox>=0.12.0",
24
+ "jax>=0.4.1",
25
+ "jaxlib>=0.4.1",
26
+ "numpy",
27
+ "optixstuff",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ dev = ["pre-commit"]
32
+ docs = [
33
+ "sphinx",
34
+ "myst-nb",
35
+ "sphinx-book-theme",
36
+ "sphinx-autoapi",
37
+ "sphinx_autodoc_typehints",
38
+ "sphinxcontrib-mermaid",
39
+ "ipython",
40
+ "matplotlib",
41
+ ]
42
+ test = ["nox", "pytest", "hypothesis", "pytest-cov"]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/CoreySpohn/physicaloptix"
46
+ Issues = "https://github.com/CoreySpohn/physicaloptix/issues"
47
+
48
+ [tool.hatch.version]
49
+ source = "vcs"
50
+
51
+ [tool.hatch.build.hooks.vcs]
52
+ version-file = "src/physicaloptix/_version.py"
53
+
54
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
55
+ content-type = "text/markdown"
56
+
57
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
58
+ path = "README.md"
59
+
60
+ [tool.ruff.lint]
61
+ select = ["B", "D", "E", "F", "I", "UP", "RUF"]
62
+
63
+ [tool.ruff.lint.pydocstyle]
64
+ convention = "google"
65
+
66
+ [tool.ruff.lint.per-file-ignores]
67
+ "tests/**" = ["D"]
68
+
69
+ [tool.hatch.build.targets.wheel]
70
+ packages = ["src/physicaloptix"]
71
+
72
+ [tool.hatch.build.targets.sdist]
73
+ exclude = ["/scripts", "/docs", "/tests", "/.github"]
@@ -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)