Skip to content

Commit ef62a97

Browse files
authored
Merge pull request #231 from scipp/nightly-reduced-data-fix
Produce better reduced data in nightly runs
2 parents b87685f + 09041c8 commit ef62a97

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

tests/dream/geant4_reduction_test.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sciline
99
import scipp as sc
1010
import scipp.testing
11-
import scippnexus as snx
1211
from scippneutron import metadata
1312
from scippneutron._utils import elem_unit
1413

@@ -20,9 +19,7 @@
2019
DreamGeant4ProtonChargeWorkflow,
2120
)
2221
from ess.powder.types import (
23-
AccumulatedProtonCharge,
2422
CalibrationFilename,
25-
CaveMonitorPosition,
2623
CIFAuthors,
2724
CorrectedDetector,
2825
DspacingBins,
@@ -36,7 +33,6 @@
3633
KeepEvents,
3734
MonitorFilename,
3835
NeXusDetectorName,
39-
Position,
4036
ReducedTofCIF,
4137
SampleRun,
4238
TimeOfFlightLookupTable,
@@ -52,11 +48,6 @@
5248
from ess.reduce import workflow as reduce_workflow
5349
from ess.reduce.nexus.types import AnyRun
5450

55-
sample_position = sc.vector([0.0, 0.0, 0.0], unit='mm')
56-
source_position = sc.vector([-3.478, 0.0, -76550], unit='mm')
57-
proton_charge = sc.scalar(1.0, unit='µAh')
58-
dream_source_position = sc.vector(value=[0, 0, -76.55], unit="m")
59-
6051
params = {
6152
Filename[SampleRun]: dream.data.simulated_diamond_sample(small=True),
6253
Filename[VanadiumRun]: dream.data.simulated_vanadium_sample(small=True),
@@ -70,15 +61,8 @@
7061
DspacingBins: sc.linspace('dspacing', 0.0, 2.3434, 201, unit='angstrom'),
7162
TofMask: lambda x: (x < sc.scalar(0.0, unit='us').to(unit=elem_unit(x)))
7263
| (x > sc.scalar(86e3, unit='us').to(unit=elem_unit(x))),
73-
Position[snx.NXsample, SampleRun]: sample_position,
74-
Position[snx.NXsample, VanadiumRun]: sample_position,
75-
Position[snx.NXsource, SampleRun]: source_position,
76-
Position[snx.NXsource, VanadiumRun]: source_position,
77-
AccumulatedProtonCharge[SampleRun]: proton_charge,
78-
AccumulatedProtonCharge[VanadiumRun]: proton_charge,
7964
TwoThetaMask: None,
8065
WavelengthMask: None,
81-
CaveMonitorPosition: sc.vector([0.0, 0.0, -4220.0], unit='mm'),
8266
CIFAuthors: CIFAuthors(
8367
[
8468
metadata.Person(
@@ -140,7 +124,7 @@ def dream_tof_lookup_table():
140124
lut_wf[time_of_flight.DiskChoppers[AnyRun]] = dream.beamline.choppers(
141125
dream.beamline.InstrumentConfiguration.high_flux
142126
)
143-
lut_wf[time_of_flight.SourcePosition] = dream_source_position
127+
lut_wf[time_of_flight.SourcePosition] = sc.vector(value=[0, 0, -76.55], unit="m")
144128
lut_wf[time_of_flight.NumberOfSimulatedNeutrons] = 500_000
145129
lut_wf[time_of_flight.SimulationSeed] = 555
146130
lut_wf[time_of_flight.PulseStride] = 1
@@ -304,9 +288,26 @@ def test_pipeline_can_save_data(workflow):
304288
_assert_contains_tof_data(content)
305289

306290

307-
def test_pipeline_save_data_to_disk(workflow, output_folder: Path):
308-
workflow = powder.with_pixel_mask_filenames(workflow, [])
309-
result = workflow.compute(ReducedTofCIF)
291+
def test_pipeline_save_data_to_disk(output_folder: Path):
292+
"""
293+
This test saves a reduced CIF file to disk using the DREAM workflow.
294+
The reduced results are uploaded as an artifact in GH actions, and is subsequently
295+
used by analysis software as part of the integration tests. Therefore, we need
296+
to have enough signal: we thus use the large files instead of small, and use the
297+
mantle detector bank.
298+
"""
299+
wf = make_workflow(
300+
{**params, NeXusDetectorName: "mantle"},
301+
run_norm=powder.RunNormalization.proton_charge,
302+
)
303+
304+
wf[Filename[SampleRun]] = dream.data.simulated_diamond_sample(small=False)
305+
wf[Filename[VanadiumRun]] = dream.data.simulated_vanadium_sample(small=False)
306+
wf[Filename[EmptyCanRun]] = dream.data.simulated_empty_can(small=False)
307+
wf[DspacingBins] = sc.linspace('dspacing', 0.3, 2.3434, 2001, unit='angstrom')
308+
wf = powder.with_pixel_mask_filenames(wf, [])
309+
310+
result = wf.compute(ReducedTofCIF)
310311
result.comment = """This file was generated with the DREAM data reduction user guide
311312
in the documentation of ESSdiffraction.
312313
See https://scipp.github.io/essdiffraction/

0 commit comments

Comments
 (0)