Repository navigation
SPECULA science camera: one writer for strehl/tiptilt - #179
Merged
Merged
Conversation
…ame in tests SPECULAScienceCamera.expose() also wrote SPECULA's Strehl and a constant 0 tip-tilt, so the streams alternated with integrate()'s long-exposure estimate. SPECULA's out_sr is the on-axis Strehl and pyrtc's estimate is peak-based (aocore CONVENTIONS 4.2), so they diverge with residual tip-tilt, and the optimizers use `strehl` as their objective. Write them only from integrate(), as the OOPAO and HCIPy cameras do. While testing: compute_im leaves its last poke frame unconsumed on the signal stream, and the convergence tests' first "calibrated" sample was that frame. Since #178 it made the SPECULA PYWFS test fail about 3 runs in 4. Drain the in-flight frames first (testsupport.drain_in_flight_signal). 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.
The oddity
SPECULAScienceCamera.expose()wrote SPECULA's Strehl and a constant0.0tip-tilt to thestrehl/tiptiltstreams. Thenintegrate()overwrote them with pyRTC's long-exposure estimate (ScienceCamera.compute_strehl), so the streams alternated between the two.These are different quantities. SPECULA's
out_sris the on-axis Strehl, while pyRTC's estimate is peak-based, the stack convention (aocore CONVENTIONS 4.2). They agree only when the PSF peak sits on axis. In one run with residual tip-tilt they read 0.24 (on-axis) vs 0.40 (peak).pid_optimizerandloop_hyperparams_optimizerusestrehlas their objective.Fix:
expose()no longer writes them. Onlyintegrate()publishesstrehl/tiptilt, as the OOPAO and HCIPy cameras do. The camera still takes its model PSF from SPECULA's diffraction-limited reference.On the SHWFS example with turbulence and the loop closed, the stream now reads 0.59–0.70 (std 0.024), against 0.51–0.69 when the two writers were mixed.
Also fixed: a flaky convergence test (regression from #178)
test_specula_loop_converges_after_calibration[pywfs]failed about 3 runs in 4 on dev, always with the same value.Loop.compute_imreturns with its last poke frame unconsumed, so the test's first "calibrated" sample was that poke frame (signal RMS 0.31; every later frame reads 0.000). #178 changed the mode shapes, which made that poke frame large enough to push the mean over the bar.The new
testsupport.drain_in_flight_signal(loop)drops one round trip of frames before the measurement; the SPECULA and OOPAO convergence tests now use it. Afterwards the test passed 4 runs out of 4.Tests
test_specula_science_camera_writes_strehl_only_from_integrate(fake SDK):expose()leaves the stream counts unchanged andintegrate()advances them. It fails on the old code.🤖 Generated with Claude Code