diff --git a/docs/api-reference/index.md b/docs/api-reference/index.md index a8bd1167..57d5d73e 100644 --- a/docs/api-reference/index.md +++ b/docs/api-reference/index.md @@ -10,6 +10,7 @@ :toctree: ../generated/attributes providers + with_pixel_mask_filenames ``` ### Submodules diff --git a/docs/user-guide/dream/dream-data-reduction.ipynb b/docs/user-guide/dream/dream-data-reduction.ipynb index 92bad4de..4e76e419 100644 --- a/docs/user-guide/dream/dream-data-reduction.ipynb +++ b/docs/user-guide/dream/dream-data-reduction.ipynb @@ -53,6 +53,8 @@ " # Mask in time-of-flight to crop to valid range\n", " TofMask: lambda x: (x < sc.scalar(0.0, unit=\"ns\"))\n", " | (x > sc.scalar(86e6, unit=\"ns\")),\n", + " TwoThetaMask: None,\n", + " WavelengthMask: None,\n", "}\n", "\n", "# Not available in simulated data\n", @@ -91,7 +93,8 @@ " *powder.providers,\n", ")\n", "\n", - "pipeline = sciline.Pipeline(providers, params=params)" + "pipeline = sciline.Pipeline(providers, params=params)\n", + "pipeline = powder.with_pixel_mask_filenames(pipeline, [])" ] }, { @@ -282,7 +285,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" } }, "nbformat": 4, diff --git a/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb b/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb index c6c55efb..208393e2 100644 --- a/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb +++ b/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb @@ -62,6 +62,8 @@ " # Mask in time-of-flight to crop to valid range\n", " TofMask: lambda x: (x < sc.scalar(0.0, unit=\"us\"))\n", " | (x > sc.scalar(16666.67, unit=\"us\")),\n", + " TwoThetaMask: None,\n", + " WavelengthMask: None,\n", "}" ] }, @@ -83,7 +85,8 @@ "outputs": [], "source": [ "providers = [*powder.providers, *powgen.providers]\n", - "pipeline = sciline.Pipeline(providers, params=params)" + "pipeline = sciline.Pipeline(providers, params=params)\n", + "pipeline = powder.with_pixel_mask_filenames(pipeline, [])" ] }, { @@ -382,7 +385,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index 6d99d653..d6d34002 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,9 +33,10 @@ dependencies = [ "dask", "essreduce", "graphviz", + "numpy<2.0.0", "plopp", "pythreejs", - "sciline>=23.9.1", + "sciline>=24.06.0", "scipp>=23.8.0", "scippneutron>=23.9.0", "scippnexus>=23.12.0", diff --git a/requirements/base.in b/requirements/base.in index 1e338471..5cc3daee 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -5,9 +5,10 @@ dask essreduce graphviz +numpy<2.0.0 plopp pythreejs -sciline>=23.9.1 +sciline>=24.06.0 scipp>=23.8.0 scippneutron>=23.9.0 scippnexus>=23.12.0 diff --git a/requirements/base.txt b/requirements/base.txt index d99d8114..86895049 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,4 +1,4 @@ -# SHA1:29c507e8f357aa38ed2ac5c664d04a700311abaa +# SHA1:4c50d46537635c6b5484ebc2993aec09597baf9c # # This file is autogenerated by pip-compile-multi # To update, run: @@ -7,7 +7,7 @@ # asttokens==2.4.1 # via stack-data -certifi==2024.2.2 +certifi==2024.6.2 # via requests charset-normalizer==3.3.2 # via requests @@ -19,19 +19,23 @@ comm==0.2.2 # via ipywidgets contourpy==1.2.1 # via matplotlib +cyclebane==24.6.0 + # via sciline cycler==0.12.1 # via matplotlib -dask==2024.5.1 +dask==2024.6.0 # via -r base.in decorator==5.1.1 # via ipython essreduce==24.3.11 # via -r base.in +exceptiongroup==1.2.1 + # via ipython executing==2.0.1 # via stack-data -fonttools==4.52.4 +fonttools==4.53.0 # via matplotlib -fsspec==2024.5.0 +fsspec==2024.6.0 # via dask graphviz==0.20.3 # via -r base.in @@ -41,9 +45,11 @@ h5py==3.11.0 # scippnexus idna==3.7 # via requests +importlib-metadata==7.1.0 + # via dask ipydatawidgets==4.3.5 # via pythreejs -ipython==8.24.0 +ipython==8.25.0 # via ipywidgets ipywidgets==8.1.3 # via @@ -61,8 +67,11 @@ matplotlib==3.9.0 # via plopp matplotlib-inline==0.1.7 # via ipython +networkx==3.3 + # via cyclebane numpy==1.26.4 # via + # -r base.in # contourpy # h5py # ipydatawidgets @@ -71,7 +80,7 @@ numpy==1.26.4 # scipp # scippneutron # scipy -packaging==24.0 +packaging==24.1 # via # dask # matplotlib @@ -90,9 +99,9 @@ plopp==24.5.0 # via # -r base.in # scippneutron -pooch==1.8.1 +pooch==1.8.2 # via scippneutron -prompt-toolkit==3.0.45 +prompt-toolkit==3.0.47 # via ipython ptyprocess==0.7.0 # via pexpect @@ -110,9 +119,9 @@ pythreejs==2.4.2 # via -r base.in pyyaml==6.0.1 # via dask -requests==2.32.2 +requests==2.32.3 # via pooch -sciline==24.4.1 +sciline==24.6.0 # via -r base.in scipp==24.5.1 # via @@ -151,9 +160,13 @@ traitlets==5.14.3 # traittypes traittypes==0.2.1 # via ipydatawidgets +typing-extensions==4.12.2 + # via ipython urllib3==2.2.1 # via requests wcwidth==0.2.13 # via prompt-toolkit widgetsnbextension==4.0.11 # via ipywidgets +zipp==3.19.2 + # via importlib-metadata diff --git a/requirements/basetest.in b/requirements/basetest.in index d5fe7467..64d0bcd4 100644 --- a/requirements/basetest.in +++ b/requirements/basetest.in @@ -1,5 +1,6 @@ # Dependencies that are only used by tests. # Do not make an environment from this file, use test.txt instead! +numpy<2.0.0 pandas pytest diff --git a/requirements/basetest.txt b/requirements/basetest.txt index 1874063d..6ede83d4 100644 --- a/requirements/basetest.txt +++ b/requirements/basetest.txt @@ -1,4 +1,4 @@ -# SHA1:2da4cc17c82e9ac0b3764abd55420a1e9d217c9d +# SHA1:1199eb6a71c82d0580b7a1a4178e0c3586ed7e67 # # This file is autogenerated by pip-compile-multi # To update, run: @@ -10,14 +10,16 @@ exceptiongroup==1.2.1 iniconfig==2.0.0 # via pytest numpy==1.26.4 - # via pandas -packaging==24.0 + # via + # -r basetest.in + # pandas +packaging==24.1 # via pytest pandas==2.2.2 # via -r basetest.in pluggy==1.5.0 # via pytest -pytest==8.2.1 +pytest==8.2.2 # via -r basetest.in python-dateutil==2.9.0.post0 # via pandas diff --git a/requirements/ci.txt b/requirements/ci.txt index 1c70b6a7..9c6e429f 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -7,7 +7,7 @@ # cachetools==5.3.3 # via tox -certifi==2024.2.2 +certifi==2024.6.2 # via requests chardet==5.2.0 # via tox @@ -17,7 +17,7 @@ colorama==0.4.6 # via tox distlib==0.3.8 # via virtualenv -filelock==3.14.0 +filelock==3.15.1 # via # tox # virtualenv @@ -27,7 +27,7 @@ gitpython==3.1.43 # via -r ci.in idna==3.7 # via requests -packaging==24.0 +packaging==24.1 # via # -r ci.in # pyproject-api @@ -40,7 +40,7 @@ pluggy==1.5.0 # via tox pyproject-api==1.6.1 # via tox -requests==2.32.2 +requests==2.32.3 # via -r ci.in smmap==5.0.1 # via gitdb @@ -48,7 +48,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.15.0 +tox==4.15.1 # via -r ci.in urllib3==2.2.1 # via requests diff --git a/requirements/dev.txt b/requirements/dev.txt index 4dca5808..077dbfc5 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -48,7 +48,7 @@ jinja2-ansible-filters==1.3.2 # via copier json5==0.9.25 # via jupyterlab-server -jsonpointer==2.4 +jsonpointer==3.0.0 # via jsonschema jsonschema[format-nongpl]==4.22.0 # via @@ -59,7 +59,7 @@ jupyter-events==0.10.0 # via jupyter-server jupyter-lsp==2.2.5 # via jupyterlab -jupyter-server==2.14.0 +jupyter-server==2.14.1 # via # jupyter-lsp # jupyterlab @@ -67,7 +67,7 @@ jupyter-server==2.14.0 # notebook-shim jupyter-server-terminals==0.5.3 # via jupyter-server -jupyterlab==4.2.1 +jupyterlab==4.2.2 # via -r dev.in jupyterlab-server==2.27.2 # via jupyterlab @@ -77,7 +77,7 @@ overrides==7.7.0 # via jupyter-server pathspec==0.12.1 # via copier -pip-compile-multi==2.6.3 +pip-compile-multi==2.6.4 # via -r dev.in pip-tools==7.4.1 # via pip-compile-multi @@ -87,9 +87,9 @@ prometheus-client==0.20.0 # via jupyter-server pycparser==2.22 # via cffi -pydantic==2.7.2 +pydantic==2.7.4 # via copier -pydantic-core==2.18.3 +pydantic-core==2.18.4 # via pydantic python-json-logger==2.0.7 # via jupyter-events @@ -119,7 +119,7 @@ types-python-dateutil==2.9.0.20240316 # via arrow uri-template==1.3.0 # via jsonschema -webcolors==1.13 +webcolors==24.6.0 # via jsonschema websocket-client==1.8.0 # via jupyter-server diff --git a/requirements/docs.txt b/requirements/docs.txt index 76a6f596..4d317a20 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -34,7 +34,7 @@ docutils==0.21.2 # nbsphinx # pydata-sphinx-theme # sphinx -fastjsonschema==2.19.1 +fastjsonschema==2.20.0 # via nbformat imagesize==1.4.1 # via sphinx @@ -133,7 +133,7 @@ sphinx==7.3.7 # sphinx-autodoc-typehints # sphinx-copybutton # sphinx-design -sphinx-autodoc-typehints==2.1.0 +sphinx-autodoc-typehints==2.1.1 # via -r docs.in sphinx-copybutton==0.5.2 # via -r docs.in @@ -155,7 +155,7 @@ tinycss2==1.3.0 # via nbconvert tomli==2.0.1 # via sphinx -tornado==6.4 +tornado==6.4.1 # via # ipykernel # jupyter-client diff --git a/requirements/nightly.in b/requirements/nightly.in index f621bc8d..a582e94c 100644 --- a/requirements/nightly.in +++ b/requirements/nightly.in @@ -4,6 +4,7 @@ dask essreduce graphviz +numpy<2.0.0 pythreejs https://github.com/scipp/scipp/releases/download/nightly/scipp-nightly-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl scippnexus @ git+https://github.com/scipp/scippnexus@main diff --git a/requirements/nightly.txt b/requirements/nightly.txt index dcc1da99..96c53048 100644 --- a/requirements/nightly.txt +++ b/requirements/nightly.txt @@ -1,4 +1,4 @@ -# SHA1:16b2b3d983c096ba312d853cbfe99af3c40ea8c1 +# SHA1:0dfa2ef646a3cba3ffca95624ad8e0aa8e443190 # # This file is autogenerated by pip-compile-multi # To update, run: @@ -8,7 +8,7 @@ -r basetest.txt asttokens==2.4.1 # via stack-data -certifi==2024.2.2 +certifi==2024.6.2 # via requests charset-normalizer==3.3.2 # via requests @@ -20,9 +20,11 @@ comm==0.2.2 # via ipywidgets contourpy==1.2.1 # via matplotlib +cyclebane==24.6.0 + # via sciline cycler==0.12.1 # via matplotlib -dask==2024.5.1 +dask==2024.6.0 # via -r nightly.in decorator==5.1.1 # via ipython @@ -30,9 +32,9 @@ essreduce==24.3.11 # via -r nightly.in executing==2.0.1 # via stack-data -fonttools==4.52.4 +fonttools==4.53.0 # via matplotlib -fsspec==2024.5.0 +fsspec==2024.6.0 # via dask graphviz==0.20.3 # via -r nightly.in @@ -46,7 +48,7 @@ importlib-metadata==7.1.0 # via dask ipydatawidgets==4.3.5 # via pythreejs -ipython==8.24.0 +ipython==8.25.0 # via ipywidgets ipywidgets==8.1.3 # via @@ -61,9 +63,15 @@ kiwisolver==1.4.5 locket==1.0.0 # via partd matplotlib==3.9.0 - # via plopp + # via + # mpltoolbox + # plopp matplotlib-inline==0.1.7 # via ipython +mpltoolbox==24.5.1 + # via scippneutron +networkx==3.3 + # via cyclebane parso==0.8.4 # via jedi partd==1.4.2 @@ -78,9 +86,9 @@ plopp @ git+https://github.com/scipp/plopp@main # via # -r nightly.in # scippneutron -pooch==1.8.1 +pooch==1.8.2 # via scippneutron -prompt-toolkit==3.0.45 +prompt-toolkit==3.0.47 # via ipython ptyprocess==0.7.0 # via pexpect @@ -94,7 +102,7 @@ pythreejs==2.4.2 # via -r nightly.in pyyaml==6.0.1 # via dask -requests==2.32.2 +requests==2.32.3 # via pooch sciline @ git+https://github.com/scipp/sciline@main # via -r nightly.in @@ -131,7 +139,7 @@ traitlets==5.14.3 # traittypes traittypes==0.2.1 # via ipydatawidgets -typing-extensions==4.12.0 +typing-extensions==4.12.2 # via ipython urllib3==2.2.1 # via requests @@ -139,5 +147,5 @@ wcwidth==0.2.13 # via prompt-toolkit widgetsnbextension==4.0.11 # via ipywidgets -zipp==3.19.0 +zipp==3.19.2 # via importlib-metadata diff --git a/requirements/static.txt b/requirements/static.txt index ea619e41..cb03fb85 100644 --- a/requirements/static.txt +++ b/requirements/static.txt @@ -9,11 +9,11 @@ cfgv==3.4.0 # via pre-commit distlib==0.3.8 # via virtualenv -filelock==3.14.0 +filelock==3.15.1 # via virtualenv identify==2.5.36 # via pre-commit -nodeenv==1.9.0 +nodeenv==1.9.1 # via pre-commit platformdirs==4.2.2 # via virtualenv diff --git a/requirements/wheels.txt b/requirements/wheels.txt index d1a95de4..a1fa46e2 100644 --- a/requirements/wheels.txt +++ b/requirements/wheels.txt @@ -7,7 +7,7 @@ # build==1.2.1 # via -r wheels.in -packaging==24.0 +packaging==24.1 # via build pyproject-hooks==1.1.0 # via build diff --git a/src/ess/powder/__init__.py b/src/ess/powder/__init__.py index 240592fc..0d25b3fa 100644 --- a/src/ess/powder/__init__.py +++ b/src/ess/powder/__init__.py @@ -15,6 +15,7 @@ smoothing, uncertainty, ) +from .masking import with_pixel_mask_filenames try: __version__ = importlib.metadata.version(__package__ or __name__) @@ -30,6 +31,7 @@ *grouping.providers, *masking.providers, ) + """Sciline providers for powder diffraction.""" __all__ = [ @@ -41,4 +43,5 @@ "providers", "smoothing", "uncertainty", + "with_pixel_mask_filenames", ] diff --git a/src/ess/powder/conversion.py b/src/ess/powder/conversion.py index 982ecf59..18637362 100644 --- a/src/ess/powder/conversion.py +++ b/src/ess/powder/conversion.py @@ -4,8 +4,6 @@ Coordinate transformations for powder diffraction. """ -from typing import Optional - import scipp as sc import scippneutron as scn @@ -86,7 +84,7 @@ def _consume_positions(position, sample_position, source_position): def to_dspacing_with_calibration( data: NormalizedByProtonCharge[RunType], - calibration: Optional[CalibrationData] = None, + calibration: CalibrationData, ) -> DspacingData[RunType]: """ Transform coordinates to d-spacing from calibration parameters. @@ -111,8 +109,7 @@ def to_dspacing_with_calibration( Input data in tof or wavelength dimension. Must have a tof coordinate. calibration: - Calibration data. If given, use it for the conversion. - Otherwise, the calibration data must be stored in `data`. + Calibration data. Returns ------- @@ -123,15 +120,10 @@ def to_dspacing_with_calibration( -------- ess.powder.conversions.dspacing_from_diff_calibration """ - if calibration is not None: - out = merge_calibration(into=data, calibration=calibration) - else: - out = data + out = merge_calibration(into=data, calibration=calibration) out = _restore_tof_if_in_wavelength(out) - graph = { - "dspacing": _dspacing_from_diff_calibration, - } + graph = {"dspacing": _dspacing_from_diff_calibration} # `_dspacing_from_diff_calibration` does not need positions but conceptually, # the conversion maps from positions to d-spacing. # The mechanism with `_tag_positions_consumed` is meant to ensure that, diff --git a/src/ess/powder/correction.py b/src/ess/powder/correction.py index 46363e7b..005e16a2 100644 --- a/src/ess/powder/correction.py +++ b/src/ess/powder/correction.py @@ -94,7 +94,7 @@ def _normalize_by_vanadium( def normalize_by_vanadium_dspacing( data: FocussedDataDspacing[SampleRun], vanadium: FocussedDataDspacing[VanadiumRun], - uncertainty_broadcast_mode: Optional[UncertaintyBroadcastMode] = None, + uncertainty_broadcast_mode: UncertaintyBroadcastMode, ) -> IofDspacing: """ Normalize sample data by a vanadium measurement and return intensity vs d-spacing. @@ -117,7 +117,7 @@ def normalize_by_vanadium_dspacing( def normalize_by_vanadium_dspacing_and_two_theta( data: FocussedDataDspacingTwoTheta[SampleRun], vanadium: FocussedDataDspacingTwoTheta[VanadiumRun], - uncertainty_broadcast_mode: Optional[UncertaintyBroadcastMode] = None, + uncertainty_broadcast_mode: UncertaintyBroadcastMode, ) -> IofDspacingTwoTheta: """ Normalize sample data by a vanadium measurement and return intensity vs diff --git a/src/ess/powder/masking.py b/src/ess/powder/masking.py index cd51ded8..1e5305b3 100644 --- a/src/ess/powder/masking.py +++ b/src/ess/powder/masking.py @@ -4,9 +4,10 @@ Masking functions for the powder workflow. """ -from typing import Optional +from typing import Iterable import numpy as np +import sciline import scipp as sc from .types import ( @@ -21,9 +22,7 @@ ) -def read_pixel_masks( - filename: Optional[PixelMaskFilename] = None, -) -> MaskedDetectorIDs: +def read_pixel_masks(filename: PixelMaskFilename) -> MaskedDetectorIDs: """Read a pixel mask from a Scipp hdf5 file. Parameters @@ -31,18 +30,15 @@ def read_pixel_masks( filename: Path to the hdf5 file. """ - masked_ids = {} - if filename is not None: - masked_ids = {filename: sc.io.load_hdf5(filename)} - return MaskedDetectorIDs(masked_ids) + return MaskedDetectorIDs({filename: sc.io.load_hdf5(filename)}) def apply_masks( data: DataWithScatteringCoordinates[RunType], masked_pixel_ids: MaskedDetectorIDs, - tof_mask_func: Optional[TofMask] = None, - wavelength_mask_func: Optional[WavelengthMask] = None, - two_theta_mask_func: Optional[TwoThetaMask] = None, + tof_mask_func: TofMask, + wavelength_mask_func: WavelengthMask, + two_theta_mask_func: TwoThetaMask, ) -> MaskedData[RunType]: """ """ out = data.copy(deep=False) @@ -71,3 +67,31 @@ def apply_masks( providers = (read_pixel_masks, apply_masks) + + +def _merge(*dicts: dict) -> dict: + return {key: value for d in dicts for key, value in d.items()} + + +def with_pixel_mask_filenames( + workflow: sciline.Pipeline, masks: Iterable[str] +) -> sciline.Pipeline: + """ + Return modified workflow with pixel mask filenames set. + + Parameters + ---------- + workflow: + Workflow to modify. + masks: + List or tuple of pixel mask filenames to set. + """ + workflow = workflow.copy() + # Workaround bug in Cyclebane, which does not allow empty maps + if len(masks) == 0: + workflow[MaskedDetectorIDs] = MaskedDetectorIDs({}) + return workflow + workflow[MaskedDetectorIDs] = ( + workflow[MaskedDetectorIDs].map({PixelMaskFilename: masks}).reduce(func=_merge) + ) + return workflow diff --git a/src/ess/powder/types.py b/src/ess/powder/types.py index 8887af7e..17d471c6 100644 --- a/src/ess/powder/types.py +++ b/src/ess/powder/types.py @@ -191,15 +191,15 @@ class SourcePosition(sciline.Scope[RunType, sc.Variable], sc.Variable): """Source position""" -TofMask = NewType("TofMask", Callable) +TofMask = NewType("TofMask", Callable | None) """TofMask is a callable that returns a mask for a given TofData.""" -TwoThetaMask = NewType("TwoThetaMask", Callable) +TwoThetaMask = NewType("TwoThetaMask", Callable | None) """TwoThetaMask is a callable that returns a mask for a given TwoThetaData.""" -WavelengthMask = NewType("WavelengthMask", Callable) +WavelengthMask = NewType("WavelengthMask", Callable | None) """WavelengthMask is a callable that returns a mask for a given WavelengthData.""" diff --git a/src/ess/powder/uncertainty.py b/src/ess/powder/uncertainty.py index f49a702e..0d7f1642 100644 --- a/src/ess/powder/uncertainty.py +++ b/src/ess/powder/uncertainty.py @@ -2,15 +2,13 @@ # Copyright (c) 2023 Scipp contributors (https://github.com/scipp) """Tools for handling statistical uncertainties.""" -from typing import Optional - import scipp as sc from .types import UncertaintyBroadcastMode def broadcast_uncertainties( - data: sc.DataArray, uncertainty_broadcast_mode: Optional[UncertaintyBroadcastMode] + data: sc.DataArray, uncertainty_broadcast_mode: UncertaintyBroadcastMode ) -> sc.DataArray: """Broadcast uncertainties using the specified mode. @@ -28,7 +26,6 @@ def broadcast_uncertainties( """ if ( not _has_variances(data) - or uncertainty_broadcast_mode is None or uncertainty_broadcast_mode == UncertaintyBroadcastMode.fail ): return data diff --git a/tests/dream/geant4_reduction_test.py b/tests/dream/geant4_reduction_test.py index 085fa5a0..3e492486 100644 --- a/tests/dream/geant4_reduction_test.py +++ b/tests/dream/geant4_reduction_test.py @@ -4,6 +4,7 @@ import pytest import sciline import scipp as sc +from ess import powder from ess.powder.types import ( AccumulatedProtonCharge, DspacingBins, @@ -58,6 +59,8 @@ def params(request): RawSource[VanadiumRun]: source, AccumulatedProtonCharge[SampleRun]: charge, AccumulatedProtonCharge[VanadiumRun]: charge, + TwoThetaMask: None, + WavelengthMask: None, } @@ -67,6 +70,7 @@ def test_can_create_pipeline(providers, params): def test_pipeline_can_compute_dspacing_result(providers, params): pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) result = pipeline.compute(IofDspacing) assert result.sizes == { 'dspacing': len(params[DspacingBins]) - 1, @@ -76,6 +80,7 @@ def test_pipeline_can_compute_dspacing_result(providers, params): def test_workflow_is_deterministic(providers, params): pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) # This is Sciline's default scheduler, but we want to be explicit here scheduler = sciline.scheduler.DaskScheduler() graph = pipeline.get(IofDspacing, scheduler=scheduler) @@ -86,6 +91,7 @@ def test_workflow_is_deterministic(providers, params): def test_pipeline_can_compute_intermediate_results(providers, params): pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) result = pipeline.compute(NormalizedByProtonCharge[SampleRun]) assert set(result.dims) == {'segment', 'wire', 'counter', 'strip', 'module'} @@ -95,6 +101,7 @@ def test_pipeline_group_by_two_theta(providers, params): dim='two_theta', unit='rad', start=0.8, stop=2.4, num=17 ) pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) result = pipeline.compute(IofDspacingTwoTheta) assert result.sizes == { 'two_theta': 16, @@ -109,6 +116,7 @@ def test_pipeline_wavelength_masking(providers, params): wmax = sc.scalar(0.21, unit="angstrom") params[WavelengthMask] = lambda x: (x > wmin) & (x < wmax) pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) masked_sample = pipeline.compute(MaskedData[SampleRun]) assert 'wavelength' in masked_sample.bins.masks sum_in_masked_region = ( @@ -127,6 +135,7 @@ def test_pipeline_two_theta_masking(providers, params): tmax = sc.scalar(1.2, unit="rad") params[TwoThetaMask] = lambda x: (x > tmin) & (x < tmax) pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) masked_sample = pipeline.compute(MaskedData[SampleRun]) assert 'two_theta' in masked_sample.bins.masks sum_in_masked_region = ( diff --git a/tests/powder/external/powgen/powgen_reduction_test.py b/tests/powder/external/powgen/powgen_reduction_test.py index a723a0e4..e9ad15c6 100644 --- a/tests/powder/external/powgen/powgen_reduction_test.py +++ b/tests/powder/external/powgen/powgen_reduction_test.py @@ -4,6 +4,7 @@ import pytest import sciline import scipp as sc +from ess import powder from ess.powder.types import ( CalibrationFilename, DspacingBins, @@ -44,6 +45,8 @@ def params(): DspacingBins: sc.linspace('dspacing', 0.0, 2.3434, 200, unit='angstrom'), TofMask: lambda x: (x < sc.scalar(0.0, unit="us")) | (x > sc.scalar(16666.67, unit="us")), + TwoThetaMask: None, + WavelengthMask: None, } @@ -53,6 +56,7 @@ def test_can_create_pipeline(providers, params): def test_pipeline_can_compute_dspacing_result(providers, params): pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) result = pipeline.compute(IofDspacing) assert result.sizes == { 'dspacing': len(params[DspacingBins]) - 1, @@ -62,6 +66,7 @@ def test_pipeline_can_compute_dspacing_result(providers, params): def test_workflow_is_deterministic(providers, params): pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) # This is Sciline's default scheduler, but we want to be explicit here scheduler = sciline.scheduler.DaskScheduler() graph = pipeline.get(IofDspacing, scheduler=scheduler) @@ -72,6 +77,7 @@ def test_workflow_is_deterministic(providers, params): def test_pipeline_can_compute_intermediate_results(providers, params): pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) result = pipeline.compute(NormalizedByProtonCharge[SampleRun]) assert set(result.dims) == {'bank', 'column', 'row'} @@ -81,6 +87,7 @@ def test_pipeline_group_by_two_theta(providers, params): dim='two_theta', unit='deg', start=25.0, stop=90.0, num=16 ).to(unit='rad') pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) result = pipeline.compute(IofDspacingTwoTheta) assert result.sizes == { 'two_theta': 15, @@ -95,6 +102,7 @@ def test_pipeline_wavelength_masking(providers, params): wmax = sc.scalar(0.21, unit="angstrom") params[WavelengthMask] = lambda x: (x > wmin) & (x < wmax) pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) masked_sample = pipeline.compute(MaskedData[SampleRun]) assert 'wavelength' in masked_sample.bins.masks sum_in_masked_region = ( @@ -113,6 +121,7 @@ def test_pipeline_two_theta_masking(providers, params): tmax = sc.scalar(1.0, unit="rad") params[TwoThetaMask] = lambda x: (x > tmin) & (x < tmax) pipeline = sciline.Pipeline(providers, params=params) + pipeline = powder.with_pixel_mask_filenames(pipeline, []) masked_sample = pipeline.compute(MaskedData[SampleRun]) assert 'two_theta' in masked_sample.masks sum_in_masked_region = (