Skip to content

Commit eb2e4c7

Browse files
Merge pull request #183 from scipp/bc240-lut
Add BC240 TofLUT for DREAM
2 parents 3415c96 + 116c289 commit eb2e4c7

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

src/ess/dream/beamline.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88

99

1010
class InstrumentConfiguration(enum.Enum):
11-
"""Choose between high-flux and high-resolution configurations."""
11+
"""
12+
Choose between high-flux and high-resolution configurations.
1213
13-
high_flux = enum.auto()
14-
high_resolution = enum.auto()
14+
The high_flux setting is the same as the high_flux_BC215. Setting the band chopper
15+
phase explicitly should be favored over using the high_flux setting which is kept
16+
for backwards compatibility.
17+
"""
18+
19+
high_flux_BC215 = 1
20+
high_flux = 1 # Legacy alias for high_flux
21+
high_flux_BC240 = 2
22+
high_resolution = 3
1523

1624

1725
def choppers(configuration: InstrumentConfiguration) -> dict[str, DiskChopper]:

src/ess/dream/data.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
33
"""Data for tests and documentation with DREAM."""
44

5+
from typing import Literal
6+
57
_version = "2"
68

79
__all__ = ["get_path"]
@@ -27,7 +29,9 @@ def _make_pooch():
2729
"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_diam_in_can.dat": "md5:ef24f4a4186c628574046e6629e31611", # noqa: E501
2830
"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_van_can.dat": "md5:2cdef7ad9912652149b7e687381d2e99", # noqa: E501
2931
"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_vana_inc_coh.dat": "md5:701d66792f20eb283a4ce76bae0c8f8f", # noqa: E501
32+
# BC215
3033
"DREAM-high-flux-tof-lookup-table.h5": "md5:1b95a359fa7b0d8b4277806ece9bf279", # noqa: E501
34+
"DREAM-high-flux-tof-lookup-table-BC240-new0.h5": "md5:2cc9dc802082101933429a2ea3624126", # noqa: E501
3135
# Smaller files for unit tests
3236
"DREAM_simple_pwd_workflow/TEST_data_dream_diamond_vana_container_sample_union.csv.zip": "md5:405df9b5ade9d61ab71fe8d8c19bb51b", # noqa: E501
3337
"DREAM_simple_pwd_workflow/TEST_data_dream_vana_container_sample_union.csv.zip": "md5:20186119d1debfb0c2352f9db384cd0a", # noqa: E501
@@ -267,7 +271,7 @@ def simulated_monitor_empty_can() -> str:
267271
return get_path("DREAM_simple_pwd_workflow/Cave_TOF_Monitor_van_can.dat")
268272

269273

270-
def tof_lookup_table_high_flux() -> str:
274+
def tof_lookup_table_high_flux(bc: Literal[215, 240] = 215) -> str:
271275
"""Path to a HDF5 file containing a lookup table for high-flux ToF.
272276
273277
The table was created using the ``tof`` package and the chopper settings for the
@@ -278,5 +282,17 @@ def tof_lookup_table_high_flux() -> str:
278282
279283
The notebook that was used to create the table can be found at
280284
https://github.com/scipp/essdiffraction/blob/main/tools/dream-make-tof-lookup-table.ipynb
285+
286+
Parameters
287+
----------
288+
bc:
289+
Band-control chopper (BC) setting. The default is 215, which corresponds to the
290+
settings of the choppers in the tutorial data.
281291
"""
282-
return get_path("DREAM-high-flux-tof-lookup-table.h5")
292+
match bc:
293+
case 215:
294+
return get_path("DREAM-high-flux-tof-lookup-table.h5")
295+
case 240:
296+
return get_path("DREAM-high-flux-tof-lookup-table-BC240-new0.h5")
297+
case _:
298+
raise ValueError(f"Unsupported band-control chopper (BC) value: {bc}")

src/ess/dream/workflow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ def _get_lookup_table_filename_from_configuration(
5454
from .data import tof_lookup_table_high_flux
5555

5656
match configuration:
57-
case InstrumentConfiguration.high_flux:
58-
out = tof_lookup_table_high_flux()
57+
case InstrumentConfiguration.high_flux_BC215:
58+
out = tof_lookup_table_high_flux(bc=215)
59+
case InstrumentConfiguration.high_flux_BC240:
60+
out = tof_lookup_table_high_flux(bc=240)
5961
case InstrumentConfiguration.high_resolution:
6062
raise NotImplementedError("High resolution configuration not yet supported")
6163

src/ess/powder/correction.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ def normalize_by_monitor_integrated(
135135

136136
if monitor.coords[dim].min() > lo or monitor.coords[dim].max() < hi:
137137
raise ValueError(
138-
"Cannot normalize by monitor: The wavelength range of the monitor is "
139-
"smaller than the range of the detector."
138+
f"Cannot normalize by monitor: The wavelength range of the monitor "
139+
f"({monitor.coords[dim].min().value} to {monitor.coords[dim].max().value}) "
140+
f"is smaller than the range of the detector ({lo.value} to {hi.value})."
140141
)
141142
monitor = monitor[dim, lo:hi]
142143
# Strictly limit `monitor` to the range of `detector`.

tests/powder/correction_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def test_normalize_by_monitor_integrated_raises_if_monitor_range_too_narrow():
479479
'wavelength': sc.array(dims=['wavelength'], values=[1.0, 3, 4], unit='Å')
480480
},
481481
)
482-
with pytest.raises(ValueError, match="wavelength range of the monitor is smaller"):
482+
with pytest.raises(ValueError, match="smaller than the range of the detector"):
483483
normalize_by_monitor_integrated(
484484
CountsWavelength[SampleRun](detector),
485485
monitor=WavelengthMonitor[SampleRun, CaveMonitor](monitor),

0 commit comments

Comments
 (0)