|
30 | 30 | DspacingData, |
31 | 31 | EmptyCanSubtractedIofDspacing, |
32 | 32 | Filename, |
| 33 | + FocussedDataDspacing, |
33 | 34 | IofDspacing, |
34 | 35 | IofDspacingTwoTheta, |
35 | 36 | IofTof, |
|
55 | 56 | from ess.reduce import time_of_flight |
56 | 57 | from ess.reduce import workflow as reduce_workflow |
57 | 58 |
|
58 | | -sample = sc.vector([0.0, 0.0, 0.0], unit='mm') |
59 | | -source = sc.vector([-3.478, 0.0, -76550], unit='mm') |
60 | | -charge = sc.scalar(1.0, unit='µAh') |
| 59 | +sample_position = sc.vector([0.0, 0.0, 0.0], unit='mm') |
| 60 | +source_position = sc.vector([-3.478, 0.0, -76550], unit='mm') |
| 61 | +proton_charge = sc.scalar(1.0, unit='µAh') |
61 | 62 | dream_source_position = sc.vector(value=[0, 0, -76.55], unit="m") |
62 | 63 |
|
63 | 64 | params = { |
|
73 | 74 | DspacingBins: sc.linspace('dspacing', 0.0, 2.3434, 201, unit='angstrom'), |
74 | 75 | TofMask: lambda x: (x < sc.scalar(0.0, unit='us').to(unit=elem_unit(x))) |
75 | 76 | | (x > sc.scalar(86e3, unit='us').to(unit=elem_unit(x))), |
76 | | - Position[snx.NXsample, SampleRun]: sample, |
77 | | - Position[snx.NXsample, VanadiumRun]: sample, |
78 | | - Position[snx.NXsource, SampleRun]: source, |
79 | | - Position[snx.NXsource, VanadiumRun]: source, |
80 | | - AccumulatedProtonCharge[SampleRun]: charge, |
81 | | - AccumulatedProtonCharge[VanadiumRun]: charge, |
| 77 | + Position[snx.NXsample, SampleRun]: sample_position, |
| 78 | + Position[snx.NXsample, VanadiumRun]: sample_position, |
| 79 | + Position[snx.NXsource, SampleRun]: source_position, |
| 80 | + Position[snx.NXsource, VanadiumRun]: source_position, |
| 81 | + AccumulatedProtonCharge[SampleRun]: proton_charge, |
| 82 | + AccumulatedProtonCharge[VanadiumRun]: proton_charge, |
82 | 83 | TwoThetaMask: None, |
83 | 84 | WavelengthMask: None, |
84 | 85 | CaveMonitorPosition: sc.vector([0.0, 0.0, -4220.0], unit='mm'), |
@@ -187,6 +188,31 @@ def test_pipeline_can_compute_dspacing_result_with_integrated_monitor_norm( |
187 | 188 | assert sc.identical(result.coords['dspacing'], params[DspacingBins]) |
188 | 189 |
|
189 | 190 |
|
| 191 | +def test_pipeline_normalizes_and_subtracts_empty_can_as_expected( |
| 192 | + workflow: sciline.Pipeline, |
| 193 | +) -> None: |
| 194 | + workflow[UncertaintyBroadcastMode] = UncertaintyBroadcastMode.drop |
| 195 | + workflow = powder.with_pixel_mask_filenames(workflow, []) |
| 196 | + results = workflow.compute( |
| 197 | + [ |
| 198 | + EmptyCanSubtractedIofDspacing[SampleRun], |
| 199 | + FocussedDataDspacing[SampleRun], |
| 200 | + FocussedDataDspacing[VanadiumRun], |
| 201 | + FocussedDataDspacing[BackgroundRun], |
| 202 | + ] |
| 203 | + ) |
| 204 | + result = results[EmptyCanSubtractedIofDspacing[SampleRun]] |
| 205 | + |
| 206 | + sample = results[FocussedDataDspacing[SampleRun]] |
| 207 | + empty_can = results[FocussedDataDspacing[BackgroundRun]] |
| 208 | + vanadium = results[FocussedDataDspacing[VanadiumRun]] |
| 209 | + |
| 210 | + expected = powder.correction.normalize_by_vanadium_dspacing( |
| 211 | + sample.bins.concatenate(-empty_can), vanadium, UncertaintyBroadcastMode.drop |
| 212 | + ) |
| 213 | + sc.testing.assert_allclose(result, expected) |
| 214 | + |
| 215 | + |
190 | 216 | def test_workflow_is_deterministic(workflow): |
191 | 217 | workflow = powder.with_pixel_mask_filenames(workflow, []) |
192 | 218 | # This is Sciline's default scheduler, but we want to be explicit here |
|
0 commit comments