geometric op• Data kinds: table → matrix
• Call: import optics; optics.abcd_matrix(elements) (or opsoptics.get("abcd_matrix"))
Compose a paraxial system into one 2x2 ray-transfer (ABCD) matrix.
*elements* is a sequence of `(kind, *params)` **in the order light meets
them** (the matrix product is formed right-to-left accordingly, so the list
reads like the optical layout, not like the algebra):
`("free", d_mm) free-space / homogeneous medium of length d >= 0` ·
`("lens", f_mm) thin lens of focal length f != 0` (negative =
diverging) · `("mirror", r_mm) curved mirror of radius r` in the
unfolded system (power `-2/r) · ("interface", n1, n2)` flat refracting
surface · `("curved", n1, n2, r_mm)` curved refracting surface.
Returns a `(2, 2)` float64 matrix acting on the ray state
`[y_mm, theta_rad] — feed it to :func:abcd_trace`, which handles the
milliradian conversion at the API boundary.
Ground truth it reproduces exactly: a single free-space section is
`[[1, d], [0, 1]]; det(M) = n_in / n_out`, hence exactly 1 for any
system that starts and ends in the same medium (checked to ~1e-16 in the
tests, and the cheapest correctness self-check you have); two thin lenses
separated by `d` compose to the classical combined power
`1/f = 1/f1 + 1/f2 - d/(f1*f2)`; a lens sandwiched between two
free-space sections of length `f gives the [[0, f], [-1/f, 0]]`
Fourier-transform geometry.
Raises `ValueError`: an empty system, more than
:data:MAX_SYSTEM_ELEMENTS elements, an element that is not a sequence, an
unknown kind, the wrong parameter count for a kind, a negative free-space
distance (reverse the list instead of running light backwards), a zero
focal length or radius, a non-positive refractive index, or any non-finite
parameter.
HALCON: no equivalent (its optics stop at the pinhole camera model).
Every optics op validates its input before computing (nothing slips through silently):
• Units are baked into the argument name — _mm / _um / _deg / _mrad. Confusing mm with µm does not crash; it yields a plausible-looking wrong answer, so the name prevents it. Nothing here guesses the unit from the magnitude.
• **Strings raise ValueError** — float('50') succeeds, so an unparsed configuration value would slip through as a length (measured: thin_lens('50', '200') returned a plausible 66.667 mm). bool is refused too, as the implicit promotion True == 1.
• **complex / masked arrays raise ValueError (real-valued slots only; silently dropping the imaginary part or peeling off the mask is refused). NaN/Inf raises ValueError on every input.**
• Division by zero and its relatives are refused by name: focal length 0, radius of curvature 0, refractive index <= 0, a fully opaque aperture (all zeros, so the normalisation is 0/0), a PSF whose sum is <= 0, a Stokes vector with S0 = 0, and an object sitting at the front focal point (the image is at infinity).
• Only two ops return a non-finite value, and both state it as a contract: depth_of_field returns far_mm = inf beyond the hyperfocal distance (that is what the hyperfocal distance means), and gaussian_beam returns wavefront_radius_mm = inf at the waist (the radius of curvature of a plane wavefront). Both also return a finite companion (far_is_infinite / curvature_per_mm). **Any other silent NaN/Inf is detected internally and raises ValueError** — "float64 overflowed" and "the answer is infinite" are different claims, so the first is never returned wearing the face of the second.
• Size caps: generated grids are capped by optics.MAX_GRID (4096); supplied fields/PSFs/apertures by optics.MAX_FIELD_ELEMENTS (2^24); ABCD element chains by optics.MAX_SYSTEM_ELEMENTS (1024); Zernike by MAX_ZERNIKE_TERMS (512) / MAX_ZERNIKE_ORDER (40) / MAX_ZERNIKE_BASIS (2^25). This closes, fail-closed, the paths where a small argument triggers a huge internal allocation (measured: n_max=40 × 4096² needs 108 GB).
• Physically impossible states are refused too: a Stokes vector with degree of polarisation > 1, negative transmittance, negative intensity, and invalid Zernike indices such as n-|m| odd.
• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).
• Operator provenance and references — the sources of the research/methods this op family came from.
• The canonical algorithm (author, year) and its uses are named in the family usage guide above.
• optics_imaging — py -3.11 examples/optics_imaging.py
matrix as input)geometric)thin_lens · abcd_trace · depth_of_field · relative_illumination
*Provenance: optics.py — OPTICS operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.