Repository navigation
feat(tuning_tools): first-turn trajectory correction tool - #1
Merged
Merged
Conversation
pyAML had no tool for steering the beam through the first turn, when only the BPMs upstream of the loss point see a trajectory and an orbit correction cannot be applied. Trajectory is a tuning tool built from a trajectory response matrix (OrbitResponseMatrixData file, mapping or instance) plus default alpha, n_discard and gain. It validates the matrix once on load and publishes its facts as a read-only layout. pseudo_inverse() returns the Tikhonov- and truncation-regularised pseudo-inverse, and correct() returns one frozen corrector step that zeroes the correctors downstream of the last BPM with beam, plane by plane, together with a Reason saying why it did so. It reads no hardware. The test module checks the tool against goldens frozen from the ALS MATLAB sources (SCgetPinv.m and SCexp_ALS_calcCMstep.m) run in MATLAB 26.1.0.3276743 (R2026a) Update 3 on appsdev2.als.lbl.gov, over the 19 cases in trajectory_cases.json: trajectory_goldens.npz a00777fa45100b887c515ffee265dc641d128b7d1f01972cda42733aece62fef trajectory_cases.json 5c98dfb1e64e6d303aa38069d0b56fde2fd364573117813831e9cff72e0243be SCgetPinv.m e35239d6c5cafae8477adfdbccfba6d7c3d65d48d11c3a581de7fbc768575d1f calcCMstep.m 592b1a6cf05f7f5889f7b20aac26945ce80c3673e2d581563ac5a9e65a167f78 MATLAB driver df9cc13c5986a1922616619f6aefc4488fea4865da0567b6dd3f0d65c908341f Set PYAML_TRAJECTORY_GOLDENS to test against another goldens file; tests that need the goldens carry "golden" in their name.
A checkout without tests/tuning_tools/trajectory_goldens.npz now skips the 156 golden tests with a reason instead of erroring, so the module runs on a tree that does not ship the binary. A file named through PYAML_TRAJECTORY_GOLDENS stays required: a wrong path still errors.
This branch was successfully deployed
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.
What
Adds
pyaml.tuning_tools.trajectory.Trajectory, a first-turn trajectory correction tool ported from the ALS MATLAB threading code (SCgetPinv/calcCMsteporder).Reasonverdict on every step (NO_BEAM…OK).Proof
tests/tuning_tools/test_trajectory.pyruns 494 tests. 156 of them compare against goldens frozen from MATLAB R2026a over the 19-case table intrajectory_cases.json. The golden tests skip with a reason whentrajectory_goldens.npzis absent; a file named throughPYAML_TRAJECTORY_GOLDENSis required.Scope
This lands on
apgonly. The tool stays on the fork until it has threaded beam on the ALS-U accumulator ring; the upstream pyAML PR follows after that. No PyPI release is cut for it yet; consumers pin the merged commit by git ref.Relation to the existing
Orbittool: the RM data type, loader pattern, registration and per-call overrides followOrbit. The inverse is its own (pySC'sbuild_pseudoinversedoes not expose Tikhonov with tail discard, which MATLAB parity needs). The RM validation duplicates what an upstream RM primitive should own and is a candidate to drop when one lands.