Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/essspectroscopy/src/ess/bifrost/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
'ess/bifrost',
files={
"bifrost_260526T151446.repack.h5": "md5:0f60f5938b0dce87542dd525a2f9a5c4",
"computed_energy_data_simulated_5x2.h5": "md5:6fee639c3c05523dfa18262cf2b03958",
"computed_energy_data_simulated_5x2.h5": "md5:eca18246329f8e6c05154323f7af677a",
"BIFROST-simulation-lookup-table.h5": "md5:0a4df8039b9610df80fb7bd567736eeb",
"coda_bifrost_999999_00026862.stripped.hdf": (
"md5:bab18faa48de3b4617332a24dacd58a2"
),
},
version="10",
version="11",
)


Expand Down
12 changes: 12 additions & 0 deletions packages/essspectroscopy/src/ess/bifrost/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ def _fold_detector_to_arc_and_channel(
folded.coords['channel'] = sc.array(
dims=['channel'], values=channels[:n_channels], unit=None
)

# Transpose to make `detector_number` contiguous:
detector_dims = ['arc', 'tube', 'channel', 'length']
target_dims = [
*(d for d in folded.dims if d not in detector_dims),
*detector_dims,
]
folded = folded.transpose(target_dims).copy()
for name, coord in folded.coords.items():
folded.coords[name] = coord.transpose(
[d for d in target_dims if d in coord.dims]
).copy()
return folded
else:
# Not a rectangular subset, cannot fold.
Expand Down
16 changes: 16 additions & 0 deletions packages/essspectroscopy/tests/bifrost/workflow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Analyzers,
DataAtSample,
ElasticMonitor,
EmptyDetector,
EnergyQDetector,
Filename,
LookupTableFilename,
Expand Down Expand Up @@ -212,6 +213,21 @@ def test_simulation_workflow_produces_the_same_data_as_before(
)


def test_calibrated_detector_has_contiguous_detector_number() -> None:
# This test requires all detector pixels.
# (the `workflow` fixture only uses the first 10.)
workflow = bifrost.BifrostSimulationWorkflow()
workflow[Filename[SampleRun]] = simulated_elastic_incoherent_with_phonon()

detector = workflow.compute(EmptyDetector[SampleRun])
detector_number = detector.coords['detector_number']
# Both the memory layout and the actual values should be contiguous
assert detector_number.values.flags['C_CONTIGUOUS']

flat = detector_number.flatten(to='x')
sc.testing.assert_identical(flat, sc.arange('x', 1, 1 + len(flat), unit=None))


@pytest.fixture
def coda_workflow(detector_names: list[str]) -> sciline.Pipeline:
workflow = bifrost.BifrostWorkflow()
Expand Down