Repository navigation
loki: load the detector once and read it by reference - #165
Merged
Merged
Conversation
Masks and the beam centre each returned a full detector image, so that a plot could draw them. On a hosted service that image would be read for every trial of a mask, and every record held its own. CALIBRATED_DETECTOR now loads the detector once. MASKS and BEAM_CENTRE take it as Referenced[DetectorImage] and return only their small outputs. The record's request names the detector its outputs were computed from, so nothing else has to keep the two in step. These specs take no file of the run, which could differ from the detector, so the detector carries the detector numbers and the sample and source positions they need. CREATE_MASK is a new example of such a spec: it masks ranges of the angle to the beam, and adds to other masks. A configured plot is now a Plot, whose inputs name the referenced values it draws on. A plot whose input is no longer readable shows why as text; the person reruns the detector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
esssans' finder raises its cutoff until pixels are left, so with every pixel masked or no counts it never returns. One typed angle range can now mask the whole detector, so the binding refuses this. Two mask files with one name no longer lose a mask without a word. The detector has its own view. A plot whose input has gone names the input and says what to do: computing it again makes a new record, which the plotted record does not reference. Reading a plot's inputs needs no widget library, so it moves next to Plot. scippnexus is imported directly, so it is declared. Adds the tests that mutating the code showed were missing, such as the angle being measured from the sample rather than the origin. 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.
Part of #24. Motivated by interactive masking tools such as scipp/ess#834, which raised the question of how a small output, such as a mask or a beam centre, is shown on the large detector it belongs to.
What changes
MASKSandBEAM_CENTREeach returned a full detector image so that a plot could draw them. Now a new spec loads the detector once, and the other specs read it by reference and return only their small outputs:CREATE_MASKis a new example of such a spec. It masks ranges of the angle to the beam and adds to other masks.A configured plot is now a
Plot, andinputsnames the referenced values it draws on:Why
Alternatives not taken
Behaviour to review
find_beam_centrerefuses a detector with no counts outside the masks. The esssans finder loops forever on that input, and one typed angle range can now mask every pixel.MASKSandBEAM_CENTREstay at version 1 although their params changed, since nothing depends on the old form.Known gaps
DetectorImage (09:08), without the run, and only a hex prefix within the same minute. A proper fix changes output labels for every spec, which What a UI needs from the client: records that fit a type, and short record labels #95 tracks in general.applyandRulework on file fields, so per-run masks or centres need a hand-written chain. Automatic reduction with a per-run centre would need to persist a detector per run.find_beam_centreadds a length-1 dimension withsc.concat, because the esssans finder otherwise expects events. A small change in esssans would remove it.centre_on_imageis relative to the sample, so it is misplaced if the sample has a transverse offset. This is unchanged, and the Larmor test files have the sample at the origin.Review
Three independent reviews ran before this PR: scientific correctness, design and lifetimes, and test strength by mutation. The new bindings give the same counts, masks and centres as the old ones on run 60339, and the angle matches esssans'
two_thetawith gravity off. The reviews found the finder loop and the lost mask above, and 14 mutations that no test caught. The most relevant test gaps are now closed, such as measuring the angle from the sample rather than the origin.Test plan
essspecandessinstrumentstests pass, the latter on real LoKI files.essappspasses excepttest_the_slider_reads_only_the_cut_it_draws, which fails the same way without this change in my environment.loki-reduction.ipynbran to the end.🤖 Generated with Claude Code