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
12 changes: 7 additions & 5 deletions src/ess/sans/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
WavelengthBands,
WavelengthMask,
WavelengthScaledQ,
WavelengthScaledQxy,
)


Expand Down Expand Up @@ -99,11 +100,12 @@ def _set_runs(
pipeline = pipeline.copy()
runs = pd.DataFrame({Filename[key]: runs}).rename_axis(axis_name)
for part in (Numerator, Denominator):
pipeline[WavelengthScaledQ[key, part]] = (
pipeline[WavelengthScaledQ[key, part]]
.map(runs)
.reduce(index=axis_name, func=merge_contributions)
)
for qtype in (WavelengthScaledQ, WavelengthScaledQxy):
pipeline[qtype[key, part]] = (
pipeline[qtype[key, part]]
.map(runs)
.reduce(index=axis_name, func=merge_contributions)
)
return pipeline


Expand Down
7 changes: 7 additions & 0 deletions tests/loki/iofq_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
from ess import loki, sans
from ess.sans.conversions import ElasticCoordTransformGraph
from ess.sans.types import (
BackgroundRun,
BackgroundSubtractedIofQ,
BackgroundSubtractedIofQxy,
BeamCenter,
CleanWavelength,
CorrectForGravity,
Denominator,
DimsToKeep,
Filename,
IofQ,
IofQxy,
MaskedData,
Expand Down Expand Up @@ -192,11 +194,16 @@ def test_pipeline_can_compute_IofQ_merging_events_from_multiple_runs():
pipeline = make_workflow()
pipeline[BeamCenter] = _compute_beam_center()

# Remove previously set runs so we can be sure that below we use the mapped ones
pipeline[Filename[SampleRun]] = None
pipeline[Filename[BackgroundRun]] = None
pipeline = sans.with_sample_runs(pipeline, runs=sample_runs)
pipeline = sans.with_background_runs(pipeline, runs=background_runs)

result = pipeline.compute(BackgroundSubtractedIofQ)
assert result.dims == ('Q',)
result = pipeline.compute(BackgroundSubtractedIofQxy)
assert result.dims == ('Qy', 'Qx')


def test_pipeline_can_compute_IofQ_by_bank():
Expand Down
Loading