Skip to content

fix: keep analyzer crystals and inputs in geometry artifacts - #1428

Merged
SimonHeybrock merged 1 commit into
mainfrom
1427-geometry-nexus-analyzers
Oct 26, 2026
Merged

SimonHeybrock merged 1 commit into
mainfrom
1427-geometry-nexus-analyzers

Conversation

@SimonHeybrock

Copy link
Copy Markdown
Member

Part of #1427.

BIFROST finds each detector's analyzer by following inputs from the detector to an NXcrystal, then takes the crystal's d_spacing and computes its position from depends_on. The geometry artifact broke this in two ways. First, NXcrystal groups existed only as empty parents of their transformations, without d_spacing or depends_on. Second, the inputs dataset used by 2026-10 run files was dropped. On the 2026-10 artifact the lookup therefore fails with "No NXcrystal found in the inputs of channel_1_1_triplet". On artifacts from older files (inputs stored as an attribute, which the script already kept) the crystal is found, but it cannot be placed.

The rules are generic rather than BIFROST-specific:

  • NXcrystal is a copied component class. It keeps depends_on and d_spacing. Its transformations are already copied like those of every other component.
  • Every group the script creates keeps its inputs dataset, just as it already keeps its attributes. Intermediate groups on the chain from detector to crystal (e.g. channel_*_detector_angle) already exist in the artifact because their transformations are copied, so they need no separate handling.

inputs on groups that point at components the artifact does not keep (guides, collimators) are left dangling. This does no harm: the lookup stops at the first crystal.

Artifact size for the 2026-10 reference run file grows from 2.15 MB to 2.21 MB.

The 2026-10 files store inputs as a scalar dataset, which the released essspectroscopy lookup cannot read. Using this with those files needs scipp/ess#827. On its own, the change fixes artifacts from files with the older attribute encoding: before it, crystal placement failed there with any essspectroscopy version.

Test plan

  • New unit tests check that the artifact keeps the inputs chain (dataset and attribute encoding, through an intermediate group) and the crystal fields. One test runs load_analyzer_for_detector on the artifact.
  • Generated artifacts from the 2026-10 BIFROST run file (coda_bifrost_999999_00026862.hdf) and the older McStas file. On the 2026-10 artifact, with the [ESSSPECTROSCOPY] fix: BIFROST loaders for 2026-10 run files ess#827 lookup, all 45 detectors resolve to distinct crystals (channel_1_1_triplet → channel_1_1_monochromator, d_spacing 3.355 Å), and the crystal position computes, as an empty time series because the tank angle is an NXlog the artifact trims. On the McStas artifact all 45 detectors resolve and place with both the released and the fixed lookup. Before the change, both artifacts failed.

🤖 Generated with Claude Code

BIFROST finds each detector's analyzer by following `inputs` from the
detector to an NXcrystal, then uses the crystal's `d_spacing` and
`depends_on` placement. The geometry artifact dropped the crystal fields
(the group only existed as parent of its transformations) and the
`inputs` dataset used by 2026-10 run files, so the lookup failed on the
artifact.

NXcrystal is now a copied component class (placement and `d_spacing`),
and every group the artifact creates keeps its `inputs` dataset, as it
already kept the older `inputs` attribute.

Part of #1427

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SimonHeybrock SimonHeybrock self-assigned this Oct 26, 2026
@SimonHeybrock

Copy link
Copy Markdown
Member Author

LGTM

@SimonHeybrock
SimonHeybrock merged commit 84fd825 into main Oct 26, 2026
20 checks passed
@SimonHeybrock
SimonHeybrock deleted the 1427-geometry-nexus-analyzers branch October 26, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant