physicaloptix 2.0.0__tar.gz → 2.2.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.
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/CHANGELOG.md +29 -0
- physicaloptix-2.2.0/NOTICE +90 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/PKG-INFO +3 -2
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/pyproject.toml +3 -1
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/_version.py +2 -2
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/instruments/__init__.py +3 -0
- physicaloptix-2.2.0/src/physicaloptix/instruments/_proper_beam.py +304 -0
- physicaloptix-2.2.0/src/physicaloptix/instruments/_proper_ops.py +194 -0
- physicaloptix-2.2.0/src/physicaloptix/instruments/roman.py +551 -0
- physicaloptix-2.2.0/src/physicaloptix/instruments/roman_full.py +363 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/columns.py +219 -31
- physicaloptix-2.0.0/src/physicaloptix/instruments/roman.py +0 -285
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/.gitignore +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/.pre-commit-config.yaml +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/.readthedocs.yaml +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/.zenodo.json +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/CITATION.cff +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/LICENSE +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/README.md +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/__init__.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/apertures.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/coatings.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/core/__init__.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/core/field.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/core/grid.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/data/eac1_ci_train.yaml +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/data/eac1_primary.yaml +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/detector.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/diagnostics.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/diff.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/__init__.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/base.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/basis.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/dispersive.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/modes.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/phase_screen.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/vortex.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/elements/zernike_wfs.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/ifs.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/instruments/nircam.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/interop.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/linearize.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/multichannel.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/path.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/robustness.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/sources.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/speckle.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/stats.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/system.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/trains.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/transforms/__init__.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/transforms/cmft.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/transforms/fraunhofer.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/transforms/fresnel.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/__init__.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/_legacy.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/_prepare.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/_require.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/boiling.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/fields.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/modes.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/profiles.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/speckle.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/viz/train.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/src/physicaloptix/yip.py +0 -0
- {physicaloptix-2.0.0 → physicaloptix-2.2.0}/tools/check_internal_refs.py +0 -0
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.0](https://github.com/CoreySpohn/physicaloptix/compare/v2.1.0...v2.2.0) (2026-09-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **roman:** add flight DM wavefront terms to the compact model and document the full train ([d5eb0bc](https://github.com/CoreySpohn/physicaloptix/commit/d5eb0bcd41f8482afd7a4d1a3780153787ba4edc))
|
|
9
|
+
* **roman:** add PROPER-convention transforms, masks and resampling weights ([df3fb93](https://github.com/CoreySpohn/physicaloptix/commit/df3fb93800cf199d7e0d6845cfec58141fa4d52f))
|
|
10
|
+
* **roman:** compile and run the full Roman train on pilot-beam grids ([c3d1b44](https://github.com/CoreySpohn/physicaloptix/commit/c3d1b449d9143c9e9d07e977af3dbc699e2d9815))
|
|
11
|
+
* **roman:** plan PROPER-style pilot-beam propagation and run it in JAX ([4a72f9b](https://github.com/CoreySpohn/physicaloptix/commit/4a72f9b5eb1e700aeb92ed710129bcc7f4ef99ec))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **roman:** normalize batched transforms by the grid, expose the full-train build helpers, and state the full-train agreement ([87c4bb3](https://github.com/CoreySpohn/physicaloptix/commit/87c4bb3009c0477094adca788f57de2df3829dec))
|
|
17
|
+
|
|
18
|
+
## [2.1.0](https://github.com/CoreySpohn/physicaloptix/compare/v2.0.0...v2.1.0) (2026-09-29)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **instruments:** add the Roman DM model: influence-function surface maps and voltage-to-height conversion ([7d26d54](https://github.com/CoreySpohn/physicaloptix/commit/7d26d54bfd62be3c62b0befcf19aef5380dbc545))
|
|
24
|
+
* **viz:** give the field_columns no-light hatch its own hatch_color, keeping blank_color the flat fill ([c2b6a9a](https://github.com/CoreySpohn/physicaloptix/commit/c2b6a9a7d579c324f2ca2de3d77160180b84b69e))
|
|
25
|
+
* **viz:** let field_columns take caller-placed keys, hang gap labels on the figure, and hatch the no-light phase pixels ([5ffd710](https://github.com/CoreySpohn/physicaloptix/commit/5ffd710afc2e7d835ca6081a7dd0742d7a0724b5))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **deps:** require eyepiece 0.5.0 in the viz extra, the first release with eyepiece.prepared ([9a9119f](https://github.com/CoreySpohn/physicaloptix/commit/9a9119f5de691ce5a7a3d010a7f2ebbf0fadeac0))
|
|
31
|
+
|
|
3
32
|
## [2.0.0](https://github.com/CoreySpohn/physicaloptix/compare/v1.2.0...v2.0.0) (2026-09-29)
|
|
4
33
|
|
|
5
34
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
physicaloptix
|
|
2
|
+
Copyright (c) 2026 Corey Spohn, released under the MIT License (see LICENSE).
|
|
3
|
+
|
|
4
|
+
Third-party notices
|
|
5
|
+
===================
|
|
6
|
+
|
|
7
|
+
PROPER
|
|
8
|
+
------
|
|
9
|
+
Parts of physicaloptix are ports of routines from the PROPER optical propagation
|
|
10
|
+
library (John Krist, Jet Propulsion Laboratory; Python translation by Navtej Saini,
|
|
11
|
+
with Luis Marchen and Nikta Amiri):
|
|
12
|
+
|
|
13
|
+
- physicaloptix/instruments/_proper_ops.py: ellipse_mask (from prop_ellipse),
|
|
14
|
+
cubic_conv_weights and resample_map (the prop_cubic_conv edge rule),
|
|
15
|
+
szoom_weights (from prop_szoom_c).
|
|
16
|
+
- physicaloptix/instruments/_proper_beam.py: the pilot-beam schedule and its
|
|
17
|
+
operations (from prop_propagate, prop_lens, prop_ptp, prop_stw and prop_wts).
|
|
18
|
+
|
|
19
|
+
PROPER carries the following notice, reproduced as its terms require:
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
© 2006-2019. California Institute of Technology ("Caltech"). This
|
|
23
|
+
software, including source and object code, and any accompanying documentation
|
|
24
|
+
("Software") is owned by Caltech. Caltech has designated this Software as
|
|
25
|
+
Technology and Software Publicly Available ("TSPA"), which means that this
|
|
26
|
+
Software is publicly available under U.S. Export Laws. With the TSPA
|
|
27
|
+
designation, a user may use and distribute the Software on a royalty-free basis
|
|
28
|
+
with the understanding that:
|
|
29
|
+
|
|
30
|
+
(1) THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE CALIFORNIA
|
|
31
|
+
INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. GOVERNMENT CONTRACT WITH THE
|
|
32
|
+
NATIONAL AERONAUTICS AND SPACE ADMINISTRATION (NASA). THE SOFTWARE IS
|
|
33
|
+
TECHNOLOGY AND SOFTWARE PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS
|
|
34
|
+
PROVIDED "AS-IS" TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
|
|
35
|
+
WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR
|
|
36
|
+
PURPOSE (AS SET FORTH IN UNITED STATES UCC §2312-§2313) OR FOR ANY PURPOSE
|
|
37
|
+
WHATSOEVER, FOR THE SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
|
|
38
|
+
|
|
39
|
+
IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA BE LIABLE FOR
|
|
40
|
+
ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT LIMITED TO, INCIDENTAL OR
|
|
41
|
+
CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC DAMAGE OR INJURY TO
|
|
42
|
+
PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE
|
|
43
|
+
ADVISED, HAVE REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
|
|
44
|
+
|
|
45
|
+
RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE
|
|
46
|
+
AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY CALTECH AND NASA FOR ALL
|
|
47
|
+
THIRD-PARTY CLAIMS RESULTING FROM THE ACTIONS OF RECIPIENT IN THE USE OF THE
|
|
48
|
+
SOFTWARE; and
|
|
49
|
+
|
|
50
|
+
(2) Caltech is under no obligation to provide technical support for the
|
|
51
|
+
Software; and
|
|
52
|
+
|
|
53
|
+
(3) all copies of the Software released by user must be marked with this
|
|
54
|
+
marking language, inclusive of the copyright statement, TSPA designation and
|
|
55
|
+
user understandings.
|
|
56
|
+
|
|
57
|
+
(4) License for the Python wrapper for Intel MKL FFT routines (https://github.com/LCAV/mkl_fft)
|
|
58
|
+
|
|
59
|
+
Copyright (c) 2016 Ivan Dokmanić, Robin Scheibler
|
|
60
|
+
|
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
62
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
63
|
+
the Software without restriction, including without limitation the rights to
|
|
64
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
65
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
66
|
+
so, subject to the following conditions:
|
|
67
|
+
|
|
68
|
+
The above copyright notice and this permission notice shall be included in all
|
|
69
|
+
copies or substantial portions of the Software.
|
|
70
|
+
|
|
71
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
72
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
73
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
74
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
75
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
76
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
77
|
+
SOFTWARE.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Roman Preflight PROPER prescription
|
|
82
|
+
-----------------------------------
|
|
83
|
+
The Roman Coronagraph models in physicaloptix/instruments/roman.py and
|
|
84
|
+
roman_full.py, and the prescription helpers in _proper_ops.py (ffts, mft2,
|
|
85
|
+
noll_z6), follow the public version of the Roman Preflight PROPER prescription
|
|
86
|
+
(roman_preflight_proper, John Krist; Copyright 2019-2026 California Institute of
|
|
87
|
+
Technology). That prescription is distributed publicly by the Roman Coronagraph
|
|
88
|
+
team. No prescription source files or data files are included in physicaloptix;
|
|
89
|
+
the models take the prescription's masks, maps and DM data as inputs supplied by
|
|
90
|
+
the user.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: physicaloptix
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Physical optics (PSFs and diffraction) for the HWO direct imaging simulation suite
|
|
5
5
|
Project-URL: Homepage, https://github.com/CoreySpohn/physicaloptix
|
|
6
6
|
Project-URL: Issues, https://github.com/CoreySpohn/physicaloptix/issues
|
|
@@ -27,6 +27,7 @@ License: MIT License
|
|
|
27
27
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
28
|
SOFTWARE.
|
|
29
29
|
License-File: LICENSE
|
|
30
|
+
License-File: NOTICE
|
|
30
31
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
31
32
|
Classifier: Intended Audience :: Science/Research
|
|
32
33
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -64,7 +65,7 @@ Requires-Dist: pytest; extra == 'test'
|
|
|
64
65
|
Requires-Dist: pytest-cov; extra == 'test'
|
|
65
66
|
Requires-Dist: scipy; extra == 'test'
|
|
66
67
|
Provides-Extra: viz
|
|
67
|
-
Requires-Dist: eyepiece>=0.
|
|
68
|
+
Requires-Dist: eyepiece>=0.5.0; extra == 'viz'
|
|
68
69
|
Requires-Dist: hwostyle>=1.4.0; extra == 'viz'
|
|
69
70
|
Description-Content-Type: text/markdown
|
|
70
71
|
|
|
@@ -52,7 +52,9 @@ test = ["matplotlib", "nox", "pytest", "hypothesis", "pytest-cov", "scipy"]
|
|
|
52
52
|
# through eyepiece -- whose own pin (hwostyle>=1.3.0) would legally resolve a
|
|
53
53
|
# version with no cmaps.opd, turning plot_mode_gallery into a call-time
|
|
54
54
|
# AttributeError with no install-time error.
|
|
55
|
-
|
|
55
|
+
# eyepiece 0.5.0 is the first release with eyepiece.prepared, which
|
|
56
|
+
# viz/_prepare.py and viz/boiling.py import.
|
|
57
|
+
viz = ["eyepiece>=0.5.0", "hwostyle>=1.4.0"]
|
|
56
58
|
|
|
57
59
|
[project.urls]
|
|
58
60
|
Homepage = "https://github.com/CoreySpohn/physicaloptix"
|
|
@@ -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 = '2.
|
|
22
|
-
__version_tuple__ = version_tuple = (2,
|
|
21
|
+
__version__ = version = '2.2.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 2, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -11,6 +11,7 @@ from physicaloptix.instruments.nircam import (
|
|
|
11
11
|
nircam_band_image,
|
|
12
12
|
)
|
|
13
13
|
from physicaloptix.instruments.roman import RomanCompact
|
|
14
|
+
from physicaloptix.instruments.roman_full import RomanFull, compile_train
|
|
14
15
|
|
|
15
16
|
__all__ = [
|
|
16
17
|
"BandLimitedRoundMask",
|
|
@@ -18,7 +19,9 @@ __all__ = [
|
|
|
18
19
|
"NIRCamConfig",
|
|
19
20
|
"NIRCamInputs",
|
|
20
21
|
"RomanCompact",
|
|
22
|
+
"RomanFull",
|
|
21
23
|
"build_nircam",
|
|
24
|
+
"compile_train",
|
|
22
25
|
"integrate_detector_pixels",
|
|
23
26
|
"mask_plane_field",
|
|
24
27
|
"nircam_band_image",
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"""Pilot-beam propagation in the convention of the PROPER library (internal module).
|
|
2
|
+
|
|
3
|
+
PROPER (Krist 2007) carries a Gaussian pilot beam beside the field. A propagation
|
|
4
|
+
whose ends both lie within a Rayleigh distance of the pilot waist uses the
|
|
5
|
+
paraxial Fresnel transfer function on a fixed grid. Any other is split at the
|
|
6
|
+
waist: a leg inside the Rayleigh distance uses the transfer function, and a leg
|
|
7
|
+
outside it is carried relative to a spherical reference surface and moved to or
|
|
8
|
+
from the waist by a single-FFT Fresnel transform, which sets the sample spacing to
|
|
9
|
+
``lambda |dz| / (n dx)`` with ``dz`` the leg length. A lens
|
|
10
|
+
updates the pilot waist and applies only the part of its phase that the change of
|
|
11
|
+
reference surface does not absorb.
|
|
12
|
+
|
|
13
|
+
The beam state never reads the field, so :func:`plan_propagate` and
|
|
14
|
+
:func:`plan_lens` resolve the schedule in NumPy when a model is built and
|
|
15
|
+
:func:`run_ops` executes the fixed operation list in JAX. Arrays are held in
|
|
16
|
+
PROPER's layout, with the grid center ``n // 2`` rolled to the ``[0, 0]`` corner.
|
|
17
|
+
Expressions follow PROPER's operation order so the schedule reproduces its beam
|
|
18
|
+
state to rounding.
|
|
19
|
+
|
|
20
|
+
The schedule is ported from PROPER's prop_propagate, prop_lens, prop_ptp,
|
|
21
|
+
prop_stw and prop_wts (Copyright California Institute of Technology, designated
|
|
22
|
+
Technology and Software Publicly Available); see the NOTICE file for its terms.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
import dataclasses
|
|
26
|
+
from typing import NamedTuple
|
|
27
|
+
|
|
28
|
+
import jax.numpy as jnp
|
|
29
|
+
import numpy as np
|
|
30
|
+
|
|
31
|
+
RAYLEIGH_FACTOR = 1.0
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclasses.dataclass(frozen=True)
|
|
35
|
+
class PilotBeam:
|
|
36
|
+
"""Gaussian pilot-beam state; lengths in meters, ``n`` samples across the grid.
|
|
37
|
+
|
|
38
|
+
Attributes:
|
|
39
|
+
lam_m: Wavelength.
|
|
40
|
+
n: Grid size (even).
|
|
41
|
+
dx: Sample spacing of the field at ``z``.
|
|
42
|
+
z: Position along the beam.
|
|
43
|
+
z_w0: Position of the pilot waist.
|
|
44
|
+
w0: Pilot waist radius.
|
|
45
|
+
z_rayleigh: Rayleigh distance of the pilot beam.
|
|
46
|
+
reference: Reference surface the field is stored against, ``"PLANAR"``
|
|
47
|
+
or ``"SPHERI"`` (spherical, centered on the waist).
|
|
48
|
+
beam_type_old: Whether ``z`` was last classified ``"INSIDE_"`` or
|
|
49
|
+
``"OUTSIDE"`` the Rayleigh range.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
lam_m: float
|
|
53
|
+
n: int
|
|
54
|
+
dx: float
|
|
55
|
+
z: float
|
|
56
|
+
z_w0: float
|
|
57
|
+
w0: float
|
|
58
|
+
z_rayleigh: float
|
|
59
|
+
reference: str
|
|
60
|
+
beam_type_old: str
|
|
61
|
+
|
|
62
|
+
def __post_init__(self):
|
|
63
|
+
"""Hold plain Python floats (static data under jit, never NumPy scalars)."""
|
|
64
|
+
for name in ("lam_m", "dx", "z", "z_w0", "w0", "z_rayleigh"):
|
|
65
|
+
object.__setattr__(self, name, float(getattr(self, name)))
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def begin(cls, beam_diameter_m, lam_m, n, beam_diam_fraction):
|
|
69
|
+
"""Entrance state: a collimated beam of ``beam_diameter_m`` at its waist.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
beam_diameter_m: Entrance beam diameter.
|
|
73
|
+
lam_m: Wavelength.
|
|
74
|
+
n: Grid size; must be even.
|
|
75
|
+
beam_diam_fraction: Fraction of the grid the beam diameter spans.
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
ValueError: If ``n`` is not an even integer.
|
|
79
|
+
"""
|
|
80
|
+
if int(n) != n or int(n) % 2:
|
|
81
|
+
raise ValueError(f"grid size n={n} must be an even integer")
|
|
82
|
+
n = int(n)
|
|
83
|
+
diam = float(beam_diameter_m)
|
|
84
|
+
lam = float(lam_m)
|
|
85
|
+
w0 = diam / 2.0
|
|
86
|
+
return cls(
|
|
87
|
+
lam_m=lam,
|
|
88
|
+
n=n,
|
|
89
|
+
dx=diam / (n * beam_diam_fraction),
|
|
90
|
+
z=0.0,
|
|
91
|
+
z_w0=0.0,
|
|
92
|
+
w0=w0,
|
|
93
|
+
z_rayleigh=np.pi * w0**2 / lam,
|
|
94
|
+
reference="PLANAR",
|
|
95
|
+
beam_type_old="INSIDE_",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def radius(self):
|
|
100
|
+
"""Pilot-beam radius at ``z``."""
|
|
101
|
+
return self.w0 * np.sqrt(
|
|
102
|
+
1.0 + (self.lam_m * (self.z - self.z_w0) / (np.pi * self.w0**2)) ** 2
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class Op(NamedTuple):
|
|
107
|
+
"""One scheduled array operation.
|
|
108
|
+
|
|
109
|
+
``kind`` is ``"ptp"``, ``"stw"``, ``"wts"`` or ``"lens"``; ``value`` is the
|
|
110
|
+
distance in meters (for a lens, the applied curvature in 1/m); ``dx`` is the
|
|
111
|
+
sample spacing the operation's phase uses; ``forward`` selects the FFT
|
|
112
|
+
direction of ``stw`` and ``wts``.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
kind: str
|
|
116
|
+
value: float
|
|
117
|
+
dx: float
|
|
118
|
+
forward: bool
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _op(kind, value, dx, forward):
|
|
122
|
+
return Op(kind, float(value), float(dx), bool(forward))
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _ptp(beam, dz):
|
|
126
|
+
if np.abs(dz) < 1e-12:
|
|
127
|
+
return beam, ()
|
|
128
|
+
if beam.reference != "PLANAR":
|
|
129
|
+
raise ValueError("ptp: input reference surface is not planar")
|
|
130
|
+
return dataclasses.replace(beam, z=beam.z + dz), (_op("ptp", dz, beam.dx, True),)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _stw(beam, dz=0.0):
|
|
134
|
+
if beam.reference != "SPHERI":
|
|
135
|
+
return _ptp(beam, dz)
|
|
136
|
+
if dz == 0.0:
|
|
137
|
+
dz = beam.z_w0 - beam.z
|
|
138
|
+
dx = beam.lam_m * np.abs(dz) / (beam.n * beam.dx)
|
|
139
|
+
beam = dataclasses.replace(beam, z=beam.z + dz, dx=dx, reference="PLANAR")
|
|
140
|
+
return beam, (_op("stw", dz, dx, dz >= 0.0),)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _wts(beam, dz):
|
|
144
|
+
beam = dataclasses.replace(beam, reference="SPHERI")
|
|
145
|
+
if dz == 0.0:
|
|
146
|
+
return beam, ()
|
|
147
|
+
op = _op("wts", dz, beam.dx, dz >= 0.0)
|
|
148
|
+
dx = beam.lam_m * np.abs(dz) / (beam.n * beam.dx)
|
|
149
|
+
return dataclasses.replace(beam, z=beam.z + dz, dx=dx), (op,)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def plan_propagate(beam, dz, *, to_plane=False):
|
|
153
|
+
"""Schedule a propagation by ``dz`` meters (PROPER's prop_propagate).
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
beam: Pilot beam before the propagation.
|
|
157
|
+
dz: Signed distance.
|
|
158
|
+
to_plane: End on a planar reference regardless of the beam (PROPER's
|
|
159
|
+
``TO_PLANE``); the recorded beam type keeps its selected value.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
The new beam, the scheduled operations, and the propagator type
|
|
163
|
+
(``"INSIDE__to_OUTSIDE"`` and so on).
|
|
164
|
+
"""
|
|
165
|
+
newz = beam.z + dz
|
|
166
|
+
if np.abs(beam.z_w0 - newz) < RAYLEIGH_FACTOR * beam.z_rayleigh:
|
|
167
|
+
new = "INSIDE_"
|
|
168
|
+
else:
|
|
169
|
+
new = "OUTSIDE"
|
|
170
|
+
ptype = beam.beam_type_old + "_to_" + new
|
|
171
|
+
beam = dataclasses.replace(beam, beam_type_old=new)
|
|
172
|
+
z1 = beam.z
|
|
173
|
+
z2 = z1 + dz
|
|
174
|
+
if to_plane:
|
|
175
|
+
ptype = ptype[:11] + "INSIDE_"
|
|
176
|
+
if ptype == "INSIDE__to_INSIDE_":
|
|
177
|
+
plan = ((_ptp, dz),)
|
|
178
|
+
elif ptype == "INSIDE__to_OUTSIDE":
|
|
179
|
+
plan = ((_ptp, beam.z_w0 - z1), (_wts, z2 - beam.z_w0))
|
|
180
|
+
elif ptype == "OUTSIDE_to_INSIDE_":
|
|
181
|
+
plan = ((_stw, beam.z_w0 - z1), (_ptp, z2 - beam.z_w0))
|
|
182
|
+
else:
|
|
183
|
+
plan = ((_stw, beam.z_w0 - z1), (_wts, z2 - beam.z_w0))
|
|
184
|
+
ops = ()
|
|
185
|
+
for step, d in plan:
|
|
186
|
+
beam, new_ops = step(beam, d)
|
|
187
|
+
ops = ops + new_ops
|
|
188
|
+
return beam, ops, ptype
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def plan_lens(beam, lens_fl):
|
|
192
|
+
"""Schedule a thin lens of focal length ``lens_fl`` meters (PROPER's prop_lens).
|
|
193
|
+
|
|
194
|
+
Positive focal lengths converge. Returns the new beam and the lens operation.
|
|
195
|
+
"""
|
|
196
|
+
lam = beam.lam_m
|
|
197
|
+
z_rayleigh = np.pi * beam.w0**2 / lam
|
|
198
|
+
w_at_surface = beam.w0 * np.sqrt(1.0 + ((beam.z - beam.z_w0) / z_rayleigh) ** 2)
|
|
199
|
+
g_inf = False
|
|
200
|
+
g_new = 0.0
|
|
201
|
+
if (beam.z - beam.z_w0) != 0.0:
|
|
202
|
+
g_old = (beam.z - beam.z_w0) + z_rayleigh**2 / (beam.z - beam.z_w0)
|
|
203
|
+
if g_old != lens_fl:
|
|
204
|
+
g_new = 1.0 / (1.0 / g_old - 1.0 / lens_fl)
|
|
205
|
+
else:
|
|
206
|
+
g_inf = True
|
|
207
|
+
else:
|
|
208
|
+
g_new = -lens_fl
|
|
209
|
+
if beam.beam_type_old == "INSIDE_" or beam.reference == "PLANAR":
|
|
210
|
+
r_old = 0.0
|
|
211
|
+
else:
|
|
212
|
+
r_old = beam.z - beam.z_w0
|
|
213
|
+
if not g_inf:
|
|
214
|
+
z_w0 = -g_new / (1.0 + (lam * g_new / (np.pi * w_at_surface**2)) ** 2) + beam.z
|
|
215
|
+
w0 = w_at_surface / np.sqrt(
|
|
216
|
+
1.0 + (np.pi * w_at_surface**2 / (lam * g_new)) ** 2
|
|
217
|
+
)
|
|
218
|
+
else:
|
|
219
|
+
z_w0, w0 = beam.z, w_at_surface
|
|
220
|
+
z_rayleigh = np.pi * w0**2 / lam
|
|
221
|
+
if np.abs(z_w0 - beam.z) < RAYLEIGH_FACTOR * z_rayleigh:
|
|
222
|
+
new, r_new = "INSIDE_", 0.0
|
|
223
|
+
else:
|
|
224
|
+
new, r_new = "OUTSIDE", beam.z - z_w0
|
|
225
|
+
ptype = beam.beam_type_old + "_to_" + new
|
|
226
|
+
if ptype == "INSIDE__to_INSIDE_":
|
|
227
|
+
phase = 1.0 / lens_fl
|
|
228
|
+
elif ptype == "INSIDE__to_OUTSIDE":
|
|
229
|
+
phase = 1.0 / lens_fl + 1.0 / r_new
|
|
230
|
+
elif ptype == "OUTSIDE_to_INSIDE_":
|
|
231
|
+
phase = 1.0 / lens_fl - 1.0 / r_old
|
|
232
|
+
elif r_old == 0.0:
|
|
233
|
+
phase = 1.0 / lens_fl + 1.0 / r_new
|
|
234
|
+
elif r_new == 0.0:
|
|
235
|
+
phase = 1.0 / lens_fl - 1.0 / r_old
|
|
236
|
+
else:
|
|
237
|
+
phase = 1.0 / lens_fl - 1.0 / r_old + 1.0 / r_new
|
|
238
|
+
beam = dataclasses.replace(
|
|
239
|
+
beam,
|
|
240
|
+
z_w0=z_w0,
|
|
241
|
+
w0=w0,
|
|
242
|
+
z_rayleigh=z_rayleigh,
|
|
243
|
+
reference="PLANAR" if new == "INSIDE_" else "SPHERI",
|
|
244
|
+
beam_type_old=new,
|
|
245
|
+
)
|
|
246
|
+
return beam, _op("lens", phase, beam.dx, True)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _to_corner(a):
|
|
250
|
+
n = a.shape[-1]
|
|
251
|
+
return jnp.roll(a, (n // 2, n // 2), axis=(-2, -1))
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _fft_forward(a, n):
|
|
255
|
+
size = a.shape[-2] * a.shape[-1]
|
|
256
|
+
return jnp.fft.fft2(a) / size * n
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _fft_backward(a, n):
|
|
260
|
+
size = a.shape[-2] * a.shape[-1]
|
|
261
|
+
return jnp.fft.ifft2(a) * size / n
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _ptp_array(a, lam, dz, dx, n):
|
|
265
|
+
x = ((jnp.arange(n, dtype=float) - n // 2) / (n * dx)) ** 2
|
|
266
|
+
rhosqr = _to_corner(x[None, :] + x[:, None])
|
|
267
|
+
a = _fft_forward(a, n)
|
|
268
|
+
a = a * jnp.exp((-1j * jnp.pi * lam * dz) * rhosqr)
|
|
269
|
+
return _fft_backward(a, n)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def _qphase_array(a, lam, c, dx, n):
|
|
273
|
+
xsqr = ((jnp.arange(n, dtype=float) - n / 2.0) * dx) ** 2
|
|
274
|
+
rsqr = _to_corner(xsqr[None, :] + xsqr[:, None])
|
|
275
|
+
return a * jnp.exp(1j * jnp.pi / (lam * c) * rsqr)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def _lens_array(a, lam, lens_phase, dx, n):
|
|
279
|
+
x2 = (jnp.arange(n, dtype=float) - n // 2) ** 2
|
|
280
|
+
rho = jnp.sqrt(x2[None, :] + x2[:, None]) * dx
|
|
281
|
+
phase = -(rho**2) * (lens_phase / 2.0)
|
|
282
|
+
return a * jnp.exp(2 * jnp.pi * 1j / lam * _to_corner(phase))
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def apply_op(a, op, lam_m):
|
|
286
|
+
"""Execute one scheduled operation on a corner-layout field."""
|
|
287
|
+
n = a.shape[-1]
|
|
288
|
+
if op.kind == "ptp":
|
|
289
|
+
return _ptp_array(a, lam_m, op.value, op.dx, n)
|
|
290
|
+
if op.kind == "lens":
|
|
291
|
+
return _lens_array(a, lam_m, op.value, op.dx, n)
|
|
292
|
+
fft = _fft_forward if op.forward else _fft_backward
|
|
293
|
+
if op.kind == "stw":
|
|
294
|
+
return _qphase_array(fft(a, n), lam_m, op.value, op.dx, n)
|
|
295
|
+
if op.kind == "wts":
|
|
296
|
+
return fft(_qphase_array(a, lam_m, op.value, op.dx, n), n)
|
|
297
|
+
raise ValueError(f"unknown operation {op.kind!r}")
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def run_ops(a, ops, lam_m):
|
|
301
|
+
"""Execute a fixed operation list; ``ops`` and ``lam_m`` are static under jit."""
|
|
302
|
+
for op in ops:
|
|
303
|
+
a = apply_op(a, op, lam_m)
|
|
304
|
+
return a
|