structured-optics 0.6.2__tar.gz → 0.6.4__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 (22) hide show
  1. {structured_optics-0.6.2/structured_optics.egg-info → structured_optics-0.6.4}/PKG-INFO +13 -1
  2. {structured_optics-0.6.2 → structured_optics-0.6.4}/README.md +12 -0
  3. {structured_optics-0.6.2 → structured_optics-0.6.4}/pyproject.toml +1 -1
  4. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/diagnostics.py +4 -4
  5. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/hologram.py +2 -2
  6. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/masks.py +19 -6
  7. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/struct_opt.py +8 -3
  8. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/tools.py +0 -41
  9. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/utils.py +39 -1
  10. {structured_optics-0.6.2 → structured_optics-0.6.4/structured_optics.egg-info}/PKG-INFO +13 -1
  11. {structured_optics-0.6.2 → structured_optics-0.6.4}/LICENSE +0 -0
  12. {structured_optics-0.6.2 → structured_optics-0.6.4}/setup.cfg +0 -0
  13. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/__init__.py +0 -0
  14. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/bluestein.py +0 -0
  15. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/modes.py +0 -0
  16. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/polarization.py +0 -0
  17. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/prop_methods.py +0 -0
  18. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics/slmdisplay.py +0 -0
  19. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics.egg-info/SOURCES.txt +0 -0
  20. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics.egg-info/dependency_links.txt +0 -0
  21. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics.egg-info/requires.txt +0 -0
  22. {structured_optics-0.6.2 → structured_optics-0.6.4}/structured_optics.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: structured_optics
3
- Version: 0.6.2
3
+ Version: 0.6.4
4
4
  Summary: Package for Structured Light simulation
5
5
  Author: Altilano C. Barbosa
6
6
  License-Expression: BSD-3-Clause
@@ -95,6 +95,18 @@ Issues and pull requests are welcome at
95
95
  This project is licensed under the BSD-3-Clause License. See `LICENSE` for details.
96
96
 
97
97
  ## Citation
98
+ If you use this package in your research, please cite it:
99
+
100
+ ```bibtex
101
+ @software{barbosa_structured_optics,
102
+ author = {Barbosa, Altilano C.},
103
+ title = {structured\_optics: Package for Structured Light simulation},
104
+ year = {2026},
105
+ version = {0.6.3},
106
+ url = {https://github.com/Altilano/structured-optics}
107
+ }
108
+ ```
109
+ See also `CITATION.cff` or use GitHub's "Cite this repository" button.
98
110
 
99
111
  ## To do
100
112
 
@@ -81,6 +81,18 @@ Issues and pull requests are welcome at
81
81
  This project is licensed under the BSD-3-Clause License. See `LICENSE` for details.
82
82
 
83
83
  ## Citation
84
+ If you use this package in your research, please cite it:
85
+
86
+ ```bibtex
87
+ @software{barbosa_structured_optics,
88
+ author = {Barbosa, Altilano C.},
89
+ title = {structured\_optics: Package for Structured Light simulation},
90
+ year = {2026},
91
+ version = {0.6.3},
92
+ url = {https://github.com/Altilano/structured-optics}
93
+ }
94
+ ```
95
+ See also `CITATION.cff` or use GitHub's "Cite this repository" button.
84
96
 
85
97
  ## To do
86
98
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "structured_optics"
7
- version = "0.6.2"
7
+ version = "0.6.4"
8
8
  description = "Package for Structured Light simulation"
9
9
  readme = "README.md"
10
10
  license = "BSD-3-Clause"
@@ -62,7 +62,7 @@ class BeamDiagnostics:
62
62
  Polarization component into which the resulting intensity profile is measured. Default is sum of
63
63
  all intensity components.
64
64
 
65
- Return
65
+ Returns
66
66
  ------
67
67
  ndarray
68
68
  Array with intensity profile (x,y).
@@ -104,12 +104,12 @@ class BeamDiagnostics:
104
104
  """
105
105
  Compute the intensity-weighted center of mass of the field in physical x and y coordinates.
106
106
 
107
- Parameters
107
+ Parameters
108
108
  ----------
109
109
  pol_index : int, optional
110
110
  Polarization component to use; None uses total intensity.
111
111
 
112
- Returns
112
+ Returns
113
113
  -------
114
114
  tuple (x_cm, y_cm)
115
115
  center-of-mass coordinates in physical units. """
@@ -142,7 +142,7 @@ class BeamDiagnostics:
142
142
  Calculate the intensity-weighted spatial standard deviation
143
143
  along x and y.
144
144
 
145
- Parameters
145
+ Parameters
146
146
  ----------
147
147
  pol_index : int, optional
148
148
  Polarization component to use; None uses total intensity.
@@ -77,7 +77,7 @@ def dmd_hologram(beam, cx:float, cy:float, sign:int=1, input:object=None)-> np.n
77
77
  """
78
78
  Generate a binary-amplitude DMD hologram.
79
79
 
80
- Parameters
80
+ Parameters
81
81
  ----------
82
82
  beam : Beam
83
83
  Desired output beam. Its Ex component defines the target amplitude and phase.
@@ -89,7 +89,7 @@ def dmd_hologram(beam, cx:float, cy:float, sign:int=1, input:object=None)-> np.n
89
89
  Optional Incident beam illuminating the DMD. If None, the incident beam is assumed
90
90
  to have uniform amplitude and zero phase, reproducing the original behavior.
91
91
 
92
- Returns
92
+ Returns
93
93
  -------
94
94
  H : ndarray
95
95
  Binary DMD hologram.
@@ -127,9 +127,12 @@ class AstigmaticLens(SpatialMask):
127
127
 
128
128
 
129
129
  class TiltedLens(AstigmaticLens):
130
- """A spherical lens viewed at an angle, modeled as an equivalent
131
- AstigmaticLens with effective (fx, fy) derived from the tilt angle."""
132
- def __init__(self, f: float, phi: float, f0: tuple = (0, 0), flip_axis: bool = False):
130
+ """A thin spherical lens tilted about the y axis, modeled as an equivalent
131
+ AstigmaticLens with effective (fx, fy) derived from the tilt angle and
132
+ refractive index."""
133
+
134
+ def __init__(self, f: float, phi: float, n: float = 1.5,
135
+ f0: tuple = (0, 0), flip_axis: bool = False):
133
136
  """
134
137
  Parameters
135
138
  ----------
@@ -137,16 +140,26 @@ class TiltedLens(AstigmaticLens):
137
140
  Nominal (untilted) focal length of the lens.
138
141
  phi : float
139
142
  Tilt angle, in radians.
143
+ n : float, optional
144
+ Refractive index of the lens material. Defaults to 1.5.
140
145
  f0 : tuple, optional
141
146
  (x, y) offset of the lens center. Defaults to (0, 0).
142
147
  flip_axis : bool, optional
143
- If True, swap the roles of the tilted/untilted axes.
144
- Defaults to False.
148
+ If True, the tilt is about the x axis instead of y
149
+ (swaps fx and fy). Defaults to False.
145
150
  """
151
+ if n <= 1:
152
+ raise ValueError("n must be greater than 1")
153
+
154
+ denom = np.sqrt(n**2 - np.sin(phi)**2) - np.cos(phi)
155
+ fy = f * (n - 1) / denom
156
+ fx = fy * np.cos(phi) ** 2
146
157
 
147
- fx, fy = f * np.cos(phi) ** 3, f * np.cos(phi)
148
158
  if flip_axis:
149
159
  fx, fy = fy, fx
160
+
161
+ self.n = n
162
+ self.phi = phi
150
163
  super().__init__(fx, fy, f0)
151
164
 
152
165
 
@@ -10,7 +10,7 @@ from .prop_methods import( propagate_fresnel_conv, propagate_fresnel_fft, propa
10
10
  from .modes import (hg, hg_astigmatic, lg, nbessel, gbessel, lg_prod, frac_oam, frac_oam_qs,
11
11
  IG_even, IG_odd, HInceG, circle, square, triangle, lp, lp_hel)
12
12
 
13
- from .tools import _build_from_coefs_and_basis
13
+ from .utils import _build_from_coefs_and_basis
14
14
  from .diagnostics import BeamDiagnostics
15
15
 
16
16
  __all__ = ["Beam"]
@@ -320,7 +320,7 @@ class Beam(BeamDiagnostics):
320
320
 
321
321
  Reference
322
322
  ---------
323
- .. [1] https://en.wikipedia.org/wiki/Gaussian_beam
323
+ [1] https://en.wikipedia.org/wiki/Gaussian_beam
324
324
  """
325
325
  return self._set_mode(hg(self, n, m, z, angle=angle), polarization=polarization)
326
326
 
@@ -347,6 +347,11 @@ class Beam(BeamDiagnostics):
347
347
  -------
348
348
  Beam
349
349
  self, with field set to the requested mode.
350
+
351
+ Reference
352
+ ---------
353
+ [1] Arnaud, Jacques A., and Herwig Kogelnik. "Gaussian light beams with general astigmatism."
354
+ Applied optics 8.8 (1969): 1687-1693.
350
355
  """
351
356
  return self._set_mode(hg_astigmatic(self, n, m, wx, wy, z, angle=angle), polarization=polarization)
352
357
 
@@ -374,7 +379,7 @@ class Beam(BeamDiagnostics):
374
379
 
375
380
  Reference
376
381
  ---------
377
- .. [1] https://en.wikipedia.org/wiki/Gaussian_beam
382
+ [1] https://en.wikipedia.org/wiki/Gaussian_beam
378
383
  """
379
384
  return self._set_mode(lg(self, l, p, z, angle=angle), polarization=polarization)
380
385
 
@@ -257,45 +257,4 @@ def bessel_basis(Beam, Nmax, waist=None, norm1=False):
257
257
  basis = basis / np.max(np.abs(basis))
258
258
  return basis
259
259
 
260
- def _build_from_coefs_and_basis(Beam, coefs, basis, pol_index = 0):
261
- """
262
- Reconstruct a field as a weighted sum of basis modes and store it
263
- into `Beam.field`.
264
-
265
- Internal helper (not in `__all__`); used to turn a modal
266
- decomposition (e.g. from `hg_proj`/`lg_proj`) plus its basis
267
- (e.g. from `hg_basis`/`lg_basis`/`bessel_basis`) back into an
268
- actual field.
269
-
270
- Parameters
271
- ----------
272
- Beam : object
273
- Beam instance whose `.field` will be overwritten with the
274
- reconstructed field.
275
- coefs : np.ndarray
276
- 2D array of complex coefficients, shape (N, N), one per basis
277
- mode.
278
- basis : np.ndarray
279
- Array of basis mode fields, shape (N, N, Dy, Dx), matching
280
- `coefs` in its first two dimensions (e.g. as returned by
281
- `hg_basis` or `lg_basis`).
282
- pol_index : int, optional
283
- Polarization/field-component index of `Beam.field` (and of the
284
- internal auxiliary field) that the reconstructed sum is
285
- written into. Defaults to 0.
286
-
287
- Returns
288
- -------
289
- Beam : object
290
- `Beam`, with `Beam.field` set to the auxiliary field after
291
- accumulating `sum(coefs[i, j] * basis[i, j])` into component
292
- `pol_index`.
293
- """
294
- N = len(coefs)
295
- aux = Beam.copy_clean()
296
- for i in range(N):
297
- for j in range(N):
298
- aux.field[pol_index] = aux.field[pol_index] + coefs[i,j] * basis[i,j]
299
- Beam.field = aux.field
300
- return Beam
301
260
 
@@ -880,4 +880,42 @@ def zernikes_phase(beam, coefs, strengths,):
880
880
 
881
881
  for (n, m), strength in zip(coefs, strengths):
882
882
  phase += strength * zernike(n, m, r, phi)
883
- return np.exp(1j * phase)
883
+ return np.exp(1j * phase)
884
+
885
+
886
+ #builder util
887
+ def _build_from_coefs_and_basis(Beam, coefs, basis, pol_index=0):
888
+ """
889
+ Reconstruct a field as a weighted sum of basis modes.
890
+
891
+ Parameters
892
+ ----------
893
+ Beam : object
894
+ Beam instance whose `.field` will be overwritten.
895
+ coefs : np.ndarray
896
+ Complex coefficient array, shape (N, N).
897
+ basis : np.ndarray
898
+ Basis modes, shape (N, N, Dy, Dx).
899
+ pol_index : int or None, optional
900
+ Polarization/field-component index to reconstruct. If None,
901
+ the reconstructed field is assigned to all polarization
902
+ components.
903
+
904
+ Returns
905
+ -------
906
+ Beam
907
+ Beam with the reconstructed field.
908
+ """
909
+ field = np.einsum(
910
+ "ij,ijyx->yx",
911
+ coefs,
912
+ basis,
913
+ optimize=True,
914
+ )
915
+
916
+ if pol_index is None:
917
+ Beam.field[...] = field
918
+ else:
919
+ Beam.field[pol_index] = field
920
+
921
+ return Beam
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: structured_optics
3
- Version: 0.6.2
3
+ Version: 0.6.4
4
4
  Summary: Package for Structured Light simulation
5
5
  Author: Altilano C. Barbosa
6
6
  License-Expression: BSD-3-Clause
@@ -95,6 +95,18 @@ Issues and pull requests are welcome at
95
95
  This project is licensed under the BSD-3-Clause License. See `LICENSE` for details.
96
96
 
97
97
  ## Citation
98
+ If you use this package in your research, please cite it:
99
+
100
+ ```bibtex
101
+ @software{barbosa_structured_optics,
102
+ author = {Barbosa, Altilano C.},
103
+ title = {structured\_optics: Package for Structured Light simulation},
104
+ year = {2026},
105
+ version = {0.6.3},
106
+ url = {https://github.com/Altilano/structured-optics}
107
+ }
108
+ ```
109
+ See also `CITATION.cff` or use GitHub's "Cite this repository" button.
98
110
 
99
111
  ## To do
100
112