CODEBASE MAP#
Developer-facing map of the library layout, runtime flow, and edit boundaries. Use this for orientation. Use tests and the source for exact behavior.
Top-Level Layout#
src/fouriax/__init__.py: top-level re-exports for the public APIsrc/fouriax/optics/: core optics runtimesrc/fouriax/analysis.py: Fisher information and sensitivity helperssrc/fouriax/optim.py: batching, loss helpers, and Optax training loops used by examplessrc/fouriax/fft.py: FFT-based convolution helperssrc/fouriax/linop.py: lightweight linear-operator wrapperexamples/scripts/: source-of-truth examplesexamples/notebooks/: synced notebookstests/: pytest suite
Optics Package#
src/fouriax/optics/grid.pyDefinesGrid,AngularGrid, andSpectrum.src/fouriax/optics/field.pyDefinesFieldandIntensity. Also holds field-shape, domain, and broadcasting helpers shared by layers.src/fouriax/optics/interfaces.pyDefines the abstract surfaces:OpticalLayer,IncoherentLayer,Sensor,Monitor.src/fouriax/optics/layers.pyContains scalar-domain layers and coherent composition:OpticalModule, masks,ThinLens,FourierTransform,InverseFourierTransform.src/fouriax/optics/polarization.pyJones-specific layers:JonesMatrixLayer,KJonesMatrixLayer.src/fouriax/optics/imaging.pyIncoherent imaging runtime:IncoherentImager, PSF/OTF convolution, cached linear operators.src/fouriax/optics/propagation.pyConcrete propagators and propagation planning:RSPropagator,ASMPropagator,KSpacePropagator,plan_propagation,build_na_mask, regime helpers.src/fouriax/optics/sensors.pyReadout layers:Detector,DetectorArray, detector linear operators.src/fouriax/optics/noise.pyAnalytic sensor-noise models.src/fouriax/optics/meta_atoms.pyLUT-backed meta-atom interpolation layers.src/fouriax/optics/monitors.pyNon-mutating observation helpers for traces and debugging.
Main Runtime Flows#
Coherent Path#
Field -> OpticalModule -> layers/polarization/propagation -> Field
Spatial and k-space are explicit.
Domain conversion only happens through
FourierTransform,InverseFourierTransform,Field.to_kspace(), orField.to_spatial().
Incoherent Path#
Field.to_intensity() -> IncoherentImager -> Intensity -> DetectorArray
IncoherentImageris shift-invariant and scalar-only.Detector-grid resampling belongs in
DetectorArray, not in the imager.
Planning Path#
plan_propagation(...) -> concrete propagator instance
plan_propagationresolves method selection and precomputed transfer data.NA masking belongs in
propagation.py.
Ownership Rules#
Put sampling primitives in
grid.py.Put field containers and field-shape helpers in
field.py.Put scalar modulation and module composition in
layers.py.Put Jones-only logic in
polarization.py.Put incoherent imaging logic in
imaging.py.Put propagators and propagation selection in
propagation.py.Put detector readout and detector-grid resampling in
sensors.py.Keep
analysis.pyandoptim.pyoutsideoptics/; they are helpers built on top of the runtime.
Invariants#
Domains are explicit: no hidden spatial/k-space inference.
Shape order is:
*batch, wavelength, [jones], y, xScalar fields use trailing shape
(wavelength, y, x).Jones fields use trailing shape
(wavelength, 2, y, x).Layers validate domain explicitly and fail on the wrong domain.
Propagation method selection is explicit at construction time, not hidden inside unrelated layers.
Public API Mapping#
fouriaxre-exports the main user-facing surface fromfouriax.optics, plusanalysis,optim,fftconvolve, andLinearOperator.fouriax.opticsis the internal package boundary for the runtime.Internal file layout may move; preserve the public
fouriax.*surface unless the change is intentionally breaking.
Edit Guide#
If changing field shape, domain, or metadata: read
src/fouriax/optics/field.py,tests/test_field_domain.py,tests/test_jones_polarization.pyIf changing coherent layer composition or domain transitions: read
src/fouriax/optics/layers.py,tests/test_optical_module.py,tests/test_k_layers.pyIf changing Jones behavior: read
src/fouriax/optics/polarization.py,tests/test_jones_polarization.pyIf changing propagation or NA behavior: read
src/fouriax/optics/propagation.py,tests/test_propagation_selection.pyIf changing incoherent imaging: read
src/fouriax/optics/imaging.py,tests/test_incoherent_propagation.pyIf changing detector behavior: read
src/fouriax/optics/sensors.py,tests/test_camera_sensor.pyIf changing meta-atom interpolation: read
src/fouriax/optics/meta_atoms.py,tests/test_meta_atoms.py
Example Workflow Boundary#
Treat
examples/scripts/*.pyas source of truth.If an example has a synced notebook, update the script first and sync the notebook.
Example-facing training helpers belong in
src/fouriax/optim.py, not inoptics/.