diff --git a/tools/dream-make-tof-lookup-table.ipynb b/docs/user-guide/dream/dream-make-tof-lookup-table.ipynb similarity index 83% rename from tools/dream-make-tof-lookup-table.ipynb rename to docs/user-guide/dream/dream-make-tof-lookup-table.ipynb index 2b07c15f..c3806aeb 100644 --- a/tools/dream-make-tof-lookup-table.ipynb +++ b/docs/user-guide/dream/dream-make-tof-lookup-table.ipynb @@ -5,7 +5,9 @@ "id": "0", "metadata": {}, "source": [ - "# Create a time-of-flight lookup table for DREAM" + "# Create a time-of-flight lookup table for DREAM\n", + "\n", + "This notebook shows how to create a time-of-flight lookup table for the DREAM instrument." ] }, { @@ -16,7 +18,6 @@ "outputs": [], "source": [ "import scipp as sc\n", - "import sciline as sl\n", "from ess.reduce import time_of_flight\n", "from ess.dream.beamline import InstrumentConfiguration, choppers" ] @@ -26,7 +27,9 @@ "id": "2", "metadata": {}, "source": [ - "## Select the choppers" + "## Select the choppers\n", + "\n", + "We select the choppers for the 'high-flux' configuration." ] }, { @@ -54,15 +57,12 @@ "metadata": {}, "outputs": [], "source": [ - "wf = sl.Pipeline(\n", - " time_of_flight.providers(), params=time_of_flight.default_parameters()\n", - ")\n", + "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.SimulationResults] = time_of_flight.simulate_beamline(\n", - " choppers=disk_choppers, neutrons=5_000_000, source_position=sc.vector([0, 0, 0], unit='m'),\n", - ")\n", - "\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] = 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", diff --git a/docs/user-guide/dream/index.md b/docs/user-guide/dream/index.md index 881a7c5c..8bcf519a 100644 --- a/docs/user-guide/dream/index.md +++ b/docs/user-guide/dream/index.md @@ -54,4 +54,5 @@ dream-instrument-view workflow-widget-dream dream-detector-diagnostics dream-visualize-absorption +dream-make-tof-lookup-table ``` diff --git a/pyproject.toml b/pyproject.toml index f329fe32..41191527 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ requires-python = ">=3.10" # Make sure to list one dependency per line. dependencies = [ "dask", - "essreduce>=25.05.3", + "essreduce>=25.07.0", "graphviz", "numpy", "plopp>=25.03.0", diff --git a/requirements/base.in b/requirements/base.in index f61ba7cb..6feed7c3 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -3,7 +3,7 @@ # --- END OF CUSTOM SECTION --- # The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY! dask -essreduce>=25.05.3 +essreduce>=25.07.0 graphviz numpy plopp>=25.03.0 diff --git a/requirements/base.txt b/requirements/base.txt index dec17364..1348723a 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,9 +1,9 @@ -# SHA1:81114073dd5e4b765405b54b3976f92d6a96439b +# SHA1:8f044677d4db96fd48743befd036bb0b7410e72f # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # annotated-types==0.7.0 # via pydantic @@ -21,7 +21,7 @@ cyclebane==24.10.0 # via sciline cycler==0.12.1 # via matplotlib -dask==2025.5.1 +dask==2025.7.0 # via -r base.in decorator==5.2.1 # via ipython @@ -29,13 +29,13 @@ dnspython==2.7.0 # via email-validator email-validator==2.2.0 # via scippneutron -essreduce==25.5.3 +essreduce==25.7.0 # via -r base.in exceptiongroup==1.3.0 # via ipython executing==2.2.0 # via stack-data -fonttools==4.58.4 +fonttools==4.58.5 # via matplotlib fsspec==2025.5.1 # via dask @@ -143,7 +143,7 @@ scipp==25.5.1 # scippneutron # scippnexus # tof -scippneutron==25.6.0 +scippneutron==25.7.0 # via # -r base.in # essreduce @@ -177,7 +177,7 @@ traitlets==5.14.3 # traittypes traittypes==0.2.1 # via ipydatawidgets -typing-extensions==4.14.0 +typing-extensions==4.14.1 # via # exceptiongroup # ipython diff --git a/requirements/basetest.txt b/requirements/basetest.txt index ca3cd275..e7f80574 100644 --- a/requirements/basetest.txt +++ b/requirements/basetest.txt @@ -1,11 +1,11 @@ # SHA1:c4f3e9aaa3abd10fcdf497bea14415857f62cc89 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # -certifi==2025.6.15 +certifi==2025.7.14 # via requests charset-normalizer==3.4.2 # via requests @@ -21,7 +21,7 @@ packaging==25.0 # via # pooch # pytest -pandas==2.3.0 +pandas==2.3.1 # via -r basetest.in platformdirs==4.3.8 # via pooch @@ -43,7 +43,7 @@ six==1.17.0 # via python-dateutil tomli==2.2.1 # via pytest -typing-extensions==4.14.0 +typing-extensions==4.14.1 # via exceptiongroup tzdata==2025.2 # via pandas diff --git a/requirements/ci.txt b/requirements/ci.txt index 80413abd..b97886a3 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -1,13 +1,13 @@ # SHA1:6344d52635ea11dca331a3bc6eb1833c4c64d585 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # cachetools==6.1.0 # via tox -certifi==2025.6.15 +certifi==2025.7.14 # via requests chardet==5.2.0 # via tox @@ -50,7 +50,7 @@ tomli==2.2.1 # tox tox==4.27.0 # via -r ci.in -typing-extensions==4.14.0 +typing-extensions==4.14.1 # via tox urllib3==2.5.0 # via requests diff --git a/requirements/dev.txt b/requirements/dev.txt index 3d156317..9169f67d 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,9 +1,9 @@ # SHA1:efd19a3a98c69fc3d6d6233ed855de7e4a208f74 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # -r base.txt -r ci.txt @@ -26,9 +26,9 @@ async-lru==2.0.5 # via jupyterlab cffi==1.17.1 # via argon2-cffi-bindings -copier==9.7.1 +copier==9.8.0 # via -r dev.in -dunamai==1.24.1 +dunamai==1.25.0 # via copier fqdn==1.5.1 # via jsonschema @@ -105,7 +105,7 @@ terminado==0.18.1 # jupyter-server-terminals toposort==1.10 # via pip-compile-multi -types-python-dateutil==2.9.0.20250516 +types-python-dateutil==2.9.0.20250708 # via arrow uri-template==1.3.0 # via jsonschema diff --git a/requirements/docs.txt b/requirements/docs.txt index 1881f381..074b7b89 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -1,9 +1,9 @@ # SHA1:f584be06df2929a863ef5490377cbfe43c8e99a0 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # -r base.txt accessible-pygments==0.0.5 @@ -26,7 +26,7 @@ beautifulsoup4==4.13.4 # pydata-sphinx-theme bleach[css]==6.2.0 # via nbconvert -certifi==2025.6.15 +certifi==2025.7.14 # via requests charset-normalizer==3.4.2 # via requests @@ -104,7 +104,7 @@ nbsphinx==0.9.7 # via -r docs.in nest-asyncio==1.6.0 # via ipykernel -pandas==2.3.0 +pandas==2.3.1 # via -r docs.in pandocfilters==1.5.1 # via nbconvert diff --git a/requirements/mypy.txt b/requirements/mypy.txt index 1d56fca3..eab9c63d 100644 --- a/requirements/mypy.txt +++ b/requirements/mypy.txt @@ -1,12 +1,12 @@ # SHA1:859ef9c15e5e57c6c91510133c01f5751feee941 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # -r test.txt -mypy==1.16.1 +mypy==1.17.0 # via -r mypy.in mypy-extensions==1.1.0 # via mypy diff --git a/requirements/nightly.txt b/requirements/nightly.txt index 8d7f6c05..0271ea7e 100644 --- a/requirements/nightly.txt +++ b/requirements/nightly.txt @@ -1,9 +1,9 @@ # SHA1:366263fa92dc0eb9f81d46f056e0c80a931f671e # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # --index-url https://pypi.anaconda.org/scipp-nightly-wheels/simple/ --extra-index-url https://pypi.org/simple @@ -12,7 +12,7 @@ annotated-types==0.7.0 # via pydantic asttokens==3.0.0 # via stack-data -certifi==2025.6.15 +certifi==2025.7.14 # via requests charset-normalizer==3.4.2 # via requests @@ -28,7 +28,7 @@ cyclebane==24.10.0 # via sciline cycler==0.12.1 # via matplotlib -dask==2025.5.1 +dask==2025.7.0 # via -r nightly.in decorator==5.2.1 # via ipython @@ -44,7 +44,7 @@ exceptiongroup==1.3.0 # pytest executing==2.2.0 # via stack-data -fonttools==4.58.4 +fonttools==4.58.5 # via matplotlib fsspec==2025.5.1 # via dask @@ -112,7 +112,7 @@ packaging==25.0 # matplotlib # pooch # pytest -pandas==2.3.0 +pandas==2.3.1 # via -r nightly.in parso==0.8.4 # via jedi @@ -212,7 +212,7 @@ traitlets==5.14.3 # traittypes traittypes==0.2.1 # via ipydatawidgets -typing-extensions==4.14.0 +typing-extensions==4.14.1 # via # exceptiongroup # ipython diff --git a/requirements/static.txt b/requirements/static.txt index 7dbd6032..34a766ef 100644 --- a/requirements/static.txt +++ b/requirements/static.txt @@ -1,9 +1,9 @@ # SHA1:5a0b1bb22ae805d8aebba0f3bf05ab91aceae0d8 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # cfgv==3.4.0 # via pre-commit diff --git a/requirements/test.txt b/requirements/test.txt index 6817392e..3c7454d8 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,9 +1,9 @@ # SHA1:ef2ee9576d8a9e65b44e2865a26887eed3fc49d1 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # -r base.txt -r basetest.txt diff --git a/requirements/wheels.txt b/requirements/wheels.txt index 651191e5..21d3cb06 100644 --- a/requirements/wheels.txt +++ b/requirements/wheels.txt @@ -1,9 +1,9 @@ # SHA1:80754af91bfb6d1073585b046fe0a474ce868509 # -# This file was generated by pip-compile-multi. +# This file is autogenerated by pip-compile-multi # To update, run: # -# requirements upgrade +# pip-compile-multi # build==1.2.2.post1 # via -r wheels.in diff --git a/src/ess/dream/data.py b/src/ess/dream/data.py index e0efebcd..fbdf0f21 100644 --- a/src/ess/dream/data.py +++ b/src/ess/dream/data.py @@ -279,8 +279,9 @@ def tof_lookup_table_high_flux(bc: Literal[215, 240] = 215) -> str: 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). - The notebook that was used to create the table can be found at - https://github.com/scipp/essdiffraction/blob/main/tools/dream-make-tof-lookup-table.ipynb + This table was computed using `Create a time-of-flight lookup table for DREAM + <../../user-guide/dream/dream-make-tof-lookup-table.rst>`_ + with ``NumberOfSimulatedNeutrons = 5_000_000``. Parameters ---------- diff --git a/src/ess/powder/types.py b/src/ess/powder/types.py index 54bff8ad..2d5eab75 100644 --- a/src/ess/powder/types.py +++ b/src/ess/powder/types.py @@ -38,16 +38,9 @@ DetectorTofData = tof_t.DetectorTofData MonitorTofData = tof_t.MonitorTofData -PulsePeriod = tof_t.PulsePeriod -PulseStride = tof_t.PulseStride PulseStrideOffset = tof_t.PulseStrideOffset -DistanceResolution = tof_t.DistanceResolution -TimeResolution = tof_t.TimeResolution -LtotalRange = tof_t.LtotalRange -LookupTableRelativeErrorThreshold = tof_t.LookupTableRelativeErrorThreshold TimeOfFlightLookupTable = tof_t.TimeOfFlightLookupTable TimeOfFlightLookupTableFilename = tof_t.TimeOfFlightLookupTableFilename -SimulationResults = tof_t.SimulationResults SampleRun = reduce_t.SampleRun VanadiumRun = reduce_t.VanadiumRun diff --git a/tests/dream/geant4_reduction_test.py b/tests/dream/geant4_reduction_test.py index eb8160a3..57458632 100644 --- a/tests/dream/geant4_reduction_test.py +++ b/tests/dream/geant4_reduction_test.py @@ -25,7 +25,6 @@ CaveMonitorPosition, CIFAuthors, CountsDspacing, - DistanceResolution, DspacingBins, EmptyCanRun, EmptyCanSubtractedIofDspacing, @@ -34,17 +33,14 @@ IofDspacing, IofDspacingTwoTheta, IofTof, - LookupTableRelativeErrorThreshold, - LtotalRange, MaskedData, MonitorFilename, NeXusDetectorName, Position, ReducedTofCIF, SampleRun, - SimulationResults, + TimeOfFlightLookupTable, TimeOfFlightLookupTableFilename, - TimeResolution, TofMask, TwoThetaBins, TwoThetaMask, @@ -138,28 +134,31 @@ def test_pipeline_can_compute_dspacing_result_using_lookup_table_filename(workfl @pytest.fixture(scope="module") -def simulation_dream_choppers(): - return time_of_flight.simulate_beamline( - choppers=dream.beamline.choppers( - dream.beamline.InstrumentConfiguration.high_flux - ), - source_position=dream_source_position, - neutrons=500_000, +def dream_tof_lookup_table(): + lut_wf = time_of_flight.TofLookupTableWorkflow() + lut_wf[time_of_flight.DiskChoppers] = dream.beamline.choppers( + dream.beamline.InstrumentConfiguration.high_flux ) + lut_wf[time_of_flight.SourcePosition] = dream_source_position + lut_wf[time_of_flight.NumberOfSimulatedNeutrons] = 500_000 + lut_wf[time_of_flight.SimulationSeed] = 555 + lut_wf[time_of_flight.PulseStride] = 1 + lut_wf[time_of_flight.LtotalRange] = ( + sc.scalar(60.0, unit="m"), + sc.scalar(80.0, unit="m"), + ) + lut_wf[time_of_flight.DistanceResolution] = sc.scalar(0.1, unit="m") + lut_wf[time_of_flight.TimeResolution] = sc.scalar(250.0, unit='us') + lut_wf[time_of_flight.LookupTableRelativeErrorThreshold] = 0.02 + return lut_wf.compute(time_of_flight.TimeOfFlightLookupTable) def test_pipeline_can_compute_dspacing_result_using_custom_built_tof_lookup( - workflow, simulation_dream_choppers + workflow, dream_tof_lookup_table ): - from ess.reduce.time_of_flight.eto_to_tof import compute_tof_lookup_table - - workflow.insert(compute_tof_lookup_table) workflow = powder.with_pixel_mask_filenames(workflow, []) - workflow[SimulationResults] = simulation_dream_choppers - workflow[LtotalRange] = sc.scalar(60.0, unit="m"), sc.scalar(80.0, unit="m") - workflow[DistanceResolution] = sc.scalar(0.1, unit="m") - workflow[TimeResolution] = sc.scalar(250.0, unit='us') - workflow[LookupTableRelativeErrorThreshold] = 0.02 + workflow[TimeOfFlightLookupTable] = dream_tof_lookup_table + result = workflow.compute(IofDspacing[SampleRun]) assert result.sizes == {'dspacing': len(params[DspacingBins]) - 1} assert sc.identical(result.coords['dspacing'], params[DspacingBins])