Add DESY P03 detector adapters (CBF + Lambda NeXus) - #12
Open
Wiebke wants to merge 7 commits into
Open
Conversation
Adds a desy-p03 pixi environment/feature (fabio, h5py, ndindex), a desy_p03 pyproject extra, a Containerfile.desy and minimal tiled_config_desy/config.yaml for the DESY deployment, and a build-and-push-desy CI job. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Covers the CBF and Lambda NeXus adapters added earlier: header/data reading for CBF, and module registration, stitching, single-frame scans, flatfield application, and zero-frame scans for the Lambda walker/adapter. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
When a physical Lambda module is switched off mid-scan, no file is written for it at all, and the files that ARE written get renumbered sequentially -- so a written file's name says nothing about which physical module it is, and nothing on disk reveals whether the missing module was the one defining the detector's full extent. Without any signal of this, assembled_shape silently shrinks instead of leaving a fill_value gap the way a missing middle module does. Adds an opt-in pad_to_detector_size constructor parameter (by name, via LAMBDA_KNOWN_DETECTOR_SIZES, or as an explicit (dim0, dim1)) that guarantees the assembled shape covers the true full detector regardless of which modules are present. from_uris now forwards kwargs so this (and other existing options) can actually reach the adapter. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
num_frames was taken only from the first module file. Real scans have been observed where one module logs one more frame than the others; trusting a single module's count risks asking a shorter module for a frame index it doesn't have, raising IndexError. Use the minimum across all modules instead, and add a regression test covering the vulnerable ordering (the first-opened module has the higher count). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Shortens the fixture's real-data-survey comment block (no need to enumerate exact scan/file counts and per-pixel gap ranges), and fixes grammar slips left over from an earlier trim. Also corrects MASK_BAD_THRESHOLD's comment: it was described as an arbitrary "magic number", but real data shows it isolates a specific pixel_mask flag (bit 31) from the other, still-undocumented codes -- not arbitrary, just unconfirmed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tiled_config_desy/ as a whole new top-level folder for one file was unnecessary -- it's not referenced by the CI build or Containerfile.desy (config gets mounted at runtime, not baked into the image), so this is a plain rename. Co-Authored-By: Claude Sonnet 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.
Adds two adapters for DESY beamline P03 detectors, plus the packaging/CI to build and test them:
CBFAdapter: reads.cbffiles viafabio, merging the CBF header into metadata. SubclassesArrayAdapter, same pattern as the existing bl733 adapters.LambdaDetectorNexusAdapter+walk: the Lambda detector splits each frame across up to 11 module NeXus files; the walker groups a scan's module files into one node, and the adapter stitches them into a single array using each module's owntranslation/distanceoffset. Applies flatfield correction (skipped if already applied upstream), and supports an opt-inpad_to_detector_sizeto guarantee the full detector extent even when a module was switched off mid-scan.Tests cover both adapters via round-trip registration + read through the tiled client, plus unit tests for stitching, flatfield, and frame-count logic. Fixtures are synthetic, sized down from the real module geometry.
Requires
pip install ".[desy_p03]"(fabio, h5py, ndindex), orpixi run -e desy-p03 ....To use the example config:
The Lambda walker is not picked up by
tiled serve config(nowalkersslot there) -- registering Lambda data needs an explicittiled registercall:Some considerations
translation/distance, not a fixed table -- a switched-off module writes no file at all, and the remaining files get renumbered, so filenames can't identify which module is missing.pad_to_detector_sizeis opt-in rather than automatic since a missing module's geometry can't be safely reconstructed from data alone; the caller has to say which known unit ("2M"/"9M", or an explicit shape) applies.pixel_mask's bit meanings are currently not known, bit 31 looks like an inter-chip gap marker, others are likely hot pixels etc.apply_maskdefaults off.