Repository navigation
Import generic optics helpers from aocore - #9
Merged
Merged
Conversation
aocore owns the stack's coordinates, angle constants, OPD/phase conversion and pixel binning (CONVENTIONS.md section 9). makewfs now imports them: centered_coordinates for the pupil, field-stop and DFT detector grids, ARCSEC_TO_RAD/RAD_TO_ARCSEC for source angles and the plate scale, opd_to_phase/phase_to_opd for phase input and the sensor phasors, and block_sum behind makewfs.sampling.block_sum, which keeps its signature, messages and factor-two fast path. aocore>=0.1.2,<0.2 becomes a core dependency. The pupil masks, ArrayBackend and its fftshift-convention centred FFTs stay local because aocore has no equivalent; their docstrings say why. Float32 example renders are bit-identical and float64 renders differ only by rounding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
aocore owns the AO stack's conventions and its generic optics primitives. CONVENTIONS.md §9 says consumers import them rather than re-implement them. This PR moves makewfs onto them and makes
aocore>=0.1.2,<0.2a core dependency. It was previously in thedevextra. makewfs already requires Python >= 3.10, which matches aocore.Replaced
api._ARCSEC_PER_RADIAN = 206264.806…(plate scale)aocore.RAD_TO_ARCSEC(same value)math.radians(x / 3600)insource.py(field angle, angular kernel, FWHM)x * aocore.ARCSEC_TO_RAD(arange(n) - (n-1)/2)inwavefront._coordinates, the SH field-stop mask and the DFT detector gridaocore.centered_coordinates(scaled on the backend in the working dtype)phase * λ / 2πfor phase inputaocore.phase_to_opd2π · opd / λin the SH and pyramid phasorsaocore.opd_to_phasesampling.block_sumaocore.block_summakewfs.sampling.block_sumkeeps its public signature, error messages and factor-two fast path. aocore has no such fast path, and factor 2 is the common SH oversampling.Kept local, and why (each module docstring now says so)
pupil.make_pupil:aocore.Pupilcannot express the configured geometry. That geometry has angular-wedge spiders (width_fractionof π), square-grid segment gaps,pupil_rotation_degand rectangular grids, and it is built on the selected CuPy/NumPy backend in the working dtype.backend.ArrayBackendand its centred FFT helpers: the sensors choose a dtype per array, pass FFTworkersandoverwrite_x, and needndimagehelpers (map_coordinates,convolve,gaussian_filter).aocore.Backendhas one precision per backend and its own worker policy. The centred FFTs use thefftshiftconvention internally, and the engines convert to CONVENTIONS 1.3 centring, whichtests/test_conformance.pychecks.(i + 0.5)/s - 0.5, used for pupil supersampling and the lenslet fill factor): these are sub-pixel sample offsets, not a coordinate grid.wfs_input_opd_rms_m: this is a whole-input-grid quadratic mean with piston included, reduced on the device.aocore.rmsis pupil-weighted, removes piston and runs on the host, so it is a different quantity. It is unchanged here (see below).validation/run.pyandexamples/keck_hakakeep their batched, index-origin centroids so checked-in artifacts stay comparable.Behaviour
No CONVENTIONS violation was found, so the physics is unchanged. I rendered every
examples/configs/*.tomlonmainand on this branch with the same random OPD:Public names are unchanged.
tests/test_conformance.pynow imports aocore directly instead ofimportorskip.Docs
CHANGELOG (Unreleased), AGENTS.md (product boundary and code organisation), README and
docs/units-and-coordinates.mdare updated.Test plan
Local
3_13conda env:ruff check .andruff format --check .python -m mypypytest --cov: 208 passed, coverage 92 %. The 2 failures intests/test_oopao_validation.pyare pre-existing; they fail identically onmain(local OOPAO environment).pytest -m gpuon a Quadro P620: 17 passedpython benchmarks/run.py --representativeandcheck_regression.py: OKvalidation/run.py,mkdocs build --strictandpython -m buildall succeed🤖 Generated with Claude Code