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 docs/user-guide/dream/dream-make-tof-lookup-table.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"id": "4",
"metadata": {},
"source": [
"Note that possible configurations are `high_flux`, `high_flux_BC215`, `high_flux_BC240`, and `high_resolution`.\n",
"\n",
"## Setting up the workflow"
]
},
Expand All @@ -60,13 +62,12 @@
"source": [
"wf = time_of_flight.TofLookupTableWorkflow()\n",
"\n",
"wf[time_of_flight.LtotalRange] = sc.scalar(60.0, unit=\"m\"), sc.scalar(80.0, unit=\"m\")\n",
"wf[time_of_flight.LtotalRange] = sc.scalar(5.0, unit=\"m\"), sc.scalar(80.0, unit=\"m\")\n",
"wf[time_of_flight.NumberOfSimulatedNeutrons] = 200_000 # Increase this number for more reliable results\n",
"wf[time_of_flight.SourcePosition] = sc.vector([0, 0, 0], unit='m')\n",
"wf[time_of_flight.DiskChoppers[AnyRun]] = disk_choppers\n",
"wf[time_of_flight.DistanceResolution] = sc.scalar(0.1, unit=\"m\")\n",
"wf[time_of_flight.TimeResolution] = sc.scalar(250.0, unit='us')\n",
"wf[time_of_flight.LookupTableRelativeErrorThreshold] = 0.02\n",
"wf[time_of_flight.PulsePeriod] = 1.0 / sc.scalar(14.0, unit=\"Hz\")\n",
"wf[time_of_flight.PulseStride] = 1\n",
"wf[time_of_flight.PulseStrideOffset] = None"
Expand All @@ -88,7 +89,7 @@
"outputs": [],
"source": [
"table = wf.compute(time_of_flight.TimeOfFlightLookupTable)\n",
"table"
"table.array"
]
},
{
Expand Down Expand Up @@ -116,7 +117,7 @@
"metadata": {},
"outputs": [],
"source": [
"table.save_hdf5('DREAM-high-flux-tof-lookup-table.h5')"
"table.save_hdf5('DREAM-high-flux-tof-lut-5m-80m.h5')"
]
}
],
Expand All @@ -135,7 +136,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.12.12"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ requires-python = ">=3.11"
# Make sure to list one dependency per line.
dependencies = [
"dask>=2022.1.0",
"essreduce>=25.12.1",
"essreduce>=26.2.1",
"graphviz",
"numpy>=2",
"plopp>=26.2.0",
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# --- END OF CUSTOM SECTION ---
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask>=2022.1.0
essreduce>=25.12.1
essreduce>=26.2.1
graphviz
numpy>=2
plopp>=26.2.0
Expand Down
12 changes: 6 additions & 6 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:303c70637d6536773db66ff40b4306cd86aee2c0
# SHA1:e8dc8a7c4338f6f02931f7cf0dd2408d0d0351db
#
# This file was generated by pip-compile-multi.
# To update, run:
Expand Down Expand Up @@ -35,13 +35,13 @@ dnspython==2.8.0
# via email-validator
email-validator==2.3.0
# via scippneutron
essreduce==26.2.0
essreduce==26.2.1
# via -r base.in
executing==2.2.1
# via stack-data
fonttools==4.61.1
# via matplotlib
fsspec==2026.1.0
fsspec==2026.2.0
# via dask
gemmi==0.7.4
# via ncrystal
Expand Down Expand Up @@ -117,13 +117,13 @@ packaging==26.0
# lazy-loader
# matplotlib
# pooch
parso==0.8.5
parso==0.8.6
# via jedi
partd==1.4.2
# via dask
pexpect==4.9.0
# via ipython
pillow==12.1.0
pillow==12.1.1
# via matplotlib
platformdirs==4.5.1
# via pooch
Expand Down Expand Up @@ -219,7 +219,7 @@ typing-inspection==0.4.2
# via pydantic
urllib3==2.6.3
# via requests
wcwidth==0.5.3
wcwidth==0.6.0
# via prompt-toolkit
widgetsnbextension==4.0.15
# via ipywidgets
Expand Down
4 changes: 2 additions & 2 deletions requirements/basetest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ packaging==26.0
# pytest
pandas==3.0.0
# via -r basetest.in
parso==0.8.5
parso==0.8.6
# via jedi
pexpect==4.9.0
# via ipython
Expand Down Expand Up @@ -81,7 +81,7 @@ typing-extensions==4.15.0
# via ipython
urllib3==2.6.3
# via requests
wcwidth==0.5.3
wcwidth==0.6.0
# via prompt-toolkit
widgetsnbextension==4.0.15
# via ipywidgets
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# requirements upgrade
#
cachetools==7.0.0
cachetools==7.0.1
# via tox
certifi==2026.1.4
# via requests
Expand Down
4 changes: 2 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jupyter-server==2.17.0
# notebook-shim
jupyter-server-terminals==0.5.4
# via jupyter-server
jupyterlab==4.5.3
jupyterlab==4.5.4
# via -r dev.in
jupyterlab-server==2.28.0
# via jupyterlab
Expand All @@ -77,7 +77,7 @@ overrides==7.7.0
# via jupyter-server
pip-compile-multi==3.2.2
# via -r dev.in
pip-tools==7.5.2
pip-tools==7.5.3
# via pip-compile-multi
plumbum==1.10.0
# via copier
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fastjsonschema==2.21.2
# via nbformat
imagesize==1.4.1
# via sphinx
ipykernel==7.1.0
ipykernel==7.2.0
# via -r docs.in
ipympl==0.10.0
# via -r docs.in
Expand Down
8 changes: 4 additions & 4 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ executing==2.2.1
# via stack-data
fonttools==4.61.1
# via matplotlib
fsspec==2026.1.0
fsspec==2026.2.0
# via dask
gemmi==0.7.4
# via ncrystal
Expand Down Expand Up @@ -127,13 +127,13 @@ packaging==26.0
# pytest
pandas==3.0.0
# via -r nightly.in
parso==0.8.5
parso==0.8.6
# via jedi
partd==1.4.2
# via dask
pexpect==4.9.0
# via ipython
pillow==12.1.0
pillow==12.1.1
# via matplotlib
platformdirs==4.5.1
# via pooch
Expand Down Expand Up @@ -237,7 +237,7 @@ typing-inspection==0.4.2
# via pydantic
urllib3==2.6.3
# via requests
wcwidth==0.5.3
wcwidth==0.6.0
# via prompt-toolkit
widgetsnbextension==4.0.15
# via ipywidgets
Expand Down
18 changes: 14 additions & 4 deletions src/ess/dream/beamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def choppers(configuration: InstrumentConfiguration) -> dict[str, DiskChopper]:
"""Return the chopper configuration for the given instrument configuration."""

match configuration:
case InstrumentConfiguration.high_flux:
case (
InstrumentConfiguration.high_flux
| InstrumentConfiguration.high_flux_BC215
| InstrumentConfiguration.high_flux_BC240
):
return {
"psc1": DiskChopper(
frequency=sc.scalar(14.0, unit="Hz"),
Expand Down Expand Up @@ -115,9 +119,15 @@ def choppers(configuration: InstrumentConfiguration) -> dict[str, DiskChopper]:
"bcc": DiskChopper(
frequency=sc.scalar(112.0, unit="Hz"),
beam_position=sc.scalar(0.0, unit="deg"),
phase=sc.scalar(215 - 180, unit="deg"),
# Use 240 to reduce overlap between frames
# phase=sc.scalar(240 - 180, unit="deg"),
phase=sc.scalar(
(
240
if configuration == InstrumentConfiguration.high_flux_BC240
else 215
)
- 180,
unit="deg",
),
axle_position=sc.vector(value=[0, 0, 9.78], unit="m"),
slit_begin=sc.array(
dims=["cutout"], values=[-36.875, 143.125], unit="deg"
Expand Down
19 changes: 13 additions & 6 deletions src/ess/dream/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_diam_in_can.dat": "md5:ef24f4a4186c628574046e6629e31611", # noqa: E501
"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_van_can.dat": "md5:2cdef7ad9912652149b7e687381d2e99", # noqa: E501
"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_vana_inc_coh.dat": "md5:701d66792f20eb283a4ce76bae0c8f8f", # noqa: E501
# BC215
# Time-of-flight lookup tables
"DREAM-high-flux-tof-lookup-table.h5": "md5:1b95a359fa7b0d8b4277806ece9bf279",
"DREAM-high-flux-tof-lookup-table-BC240-new0.h5": "md5:2cc9dc802082101933429a2ea3624126", # noqa: E501
"DREAM-high-flux-tof-lut-5m-80m.h5": "md5:0db099795027e283f70cb48f738a1c44",
"DREAM-high-flux-tof-lut-5m-80m-bc240.h5": "md5:85c0a8acd7ed7f9793ef29f47776f63f", # noqa: E501
# Smaller files for unit tests
"DREAM_simple_pwd_workflow/TEST_data_dream_diamond_vana_container_sample_union.csv.zip": "md5:405df9b5ade9d61ab71fe8d8c19bb51b", # noqa: E501
"DREAM_simple_pwd_workflow/TEST_data_dream_vana_container_sample_union.csv.zip": "md5:20186119d1debfb0c2352f9db384cd0a", # noqa: E501
Expand Down Expand Up @@ -265,9 +267,14 @@ def tof_lookup_table_high_flux(bc: Literal[215, 240] = 215) -> Path:

The table was created using the ``tof`` package and the chopper settings for the
DREAM instrument in high-resolution mode.
Note that the phase of the band-control chopper (BCC) was set to 240 degrees to
match that of the simulated data (this has since been found to be non-optimal as it
leads to time overlap between the two frames).
Can return tables for two different band-control chopper (BC) settings:
- ``bc=215``: corresponds to the settings of the choppers in the tutorial data.
- ``bc=240``: a setting with less time overlap between frames.

Note that the phase of the band-control chopper (BCC) was set to 215 degrees in the
Geant4 simulation which generated the data used in the documentation notebooks.
This has since been found to be non-optimal as it leads to time overlap between the
two frames, and a value of 240 degrees is now recommended.

This table was computed using `Create a time-of-flight lookup table for DREAM
<../../user-guide/dream/dream-make-tof-lookup-table.rst>`_
Expand All @@ -281,8 +288,8 @@ def tof_lookup_table_high_flux(bc: Literal[215, 240] = 215) -> Path:
"""
match bc:
case 215:
return get_path("DREAM-high-flux-tof-lookup-table.h5")
return get_path("DREAM-high-flux-tof-lut-5m-80m.h5")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, I decided to replace the tables and set the default threshold on the Dreamgeant4workflow to 0.02, so that the results are the same as before.

case 240:
return get_path("DREAM-high-flux-tof-lookup-table-BC240-new0.h5")
return get_path("DREAM-high-flux-tof-lut-5m-80m-bc240.h5")
case _:
raise ValueError(f"Unsupported band-control chopper (BC) value: {bc}")
2 changes: 2 additions & 0 deletions src/ess/dream/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
CaveMonitorPosition, # Should this be a DREAM-only parameter?
EmptyCanRun,
KeepEvents,
LookupTableRelativeErrorThreshold,
PixelMaskFilename,
Position,
ReducerSoftware,
Expand Down Expand Up @@ -209,6 +210,7 @@ def DreamGeant4Workflow(*, run_norm: RunNormalization, **kwargs) -> sciline.Pipe
AccumulatedProtonCharge[VanadiumRun]: charge,
AccumulatedProtonCharge[EmptyCanRun]: charge,
CaveMonitorPosition: sc.vector([0.0, 0.0, -4220.0], unit='mm'),
LookupTableRelativeErrorThreshold: 0.02,
}
for key, value in additional_parameters.items():
wf[key] = value
Expand Down
1 change: 1 addition & 0 deletions src/ess/powder/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
PulseStrideOffset = tof_t.PulseStrideOffset
TimeOfFlightLookupTable = tof_t.TimeOfFlightLookupTable
TimeOfFlightLookupTableFilename = tof_t.TimeOfFlightLookupTableFilename
LookupTableRelativeErrorThreshold = tof_t.LookupTableRelativeErrorThreshold

SampleRun = reduce_t.SampleRun
VanadiumRun = reduce_t.VanadiumRun
Expand Down
Loading