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
8 changes: 7 additions & 1 deletion docs/user-guide/amor/amor-reduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@
"metadata": {},
"outputs": [],
"source": [
"import warnings\n",
"import scipp as sc\n",
"from ess import amor\n",
"from ess.amor import data # noqa: F401\n",
"from ess.reflectometry.types import *\n",
"from ess.amor.types import *"
"from ess.amor.types import *\n",
"\n",
"# The files used in this tutorial have some issues that makes scippnexus\n",
"# raise warnings when loading them. To avoid noise in the notebook the warnings are silenced.\n",
"warnings.filterwarnings('ignore', 'Failed to convert .* into a transformation')\n",
"warnings.filterwarnings('ignore', 'Invalid transformation, missing attribute')"
]
},
{
Expand Down
10 changes: 8 additions & 2 deletions docs/user-guide/amor/compare-to-eos.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"metadata": {},
"outputs": [],
"source": [
"import warnings\n",
"import orsopy\n",
"import matplotlib.pyplot as plt\n",
"\n",
Expand All @@ -26,7 +27,12 @@
"from ess import amor\n",
"from ess.amor import data # noqa: F401\n",
"from ess.reflectometry.types import *\n",
"from ess.amor.types import ChopperPhase"
"from ess.amor.types import ChopperPhase\n",
"\n",
"# The files used in this tutorial have some issues that makes scippnexus\n",
"# raise warnings when loading them. To avoid noise in the notebook the warnings are silenced.\n",
"warnings.filterwarnings('ignore', 'Failed to convert .* into a transformation')\n",
"warnings.filterwarnings('ignore', 'Invalid transformation, missing attribute')"
]
},
{
Expand Down Expand Up @@ -225,7 +231,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
27 changes: 0 additions & 27 deletions src/ess/amor/load.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
import warnings
from functools import wraps

import scipp as sc

from ..reflectometry.load import load_nx
Expand All @@ -26,33 +23,12 @@
)


def ignore_amor_warnings(func):
@wraps(func)
def wrapped(*args, **kwargs):
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore',
category=UserWarning,
message=r'Failed to convert .* into a transformation',
)
warnings.filterwarnings(
'ignore',
category=UserWarning,
message='Invalid transformation, missing attribute',
)
return func(*args, **kwargs)

return wrapped


@ignore_amor_warnings
def load_detector(
file_path: Filename[RunType], detector_name: NeXusDetectorName[RunType]
) -> LoadedNeXusDetector[RunType]:
return next(load_nx(file_path, f"NXentry/NXinstrument/{detector_name}"))


@ignore_amor_warnings
def load_events(
detector: LoadedNeXusDetector[RunType], detector_rotation: DetectorRotation[RunType]
) -> RawDetectorData[RunType]:
Expand Down Expand Up @@ -130,7 +106,6 @@ def compute_tof(
return ReducibleDetectorData[RunType](data)


@ignore_amor_warnings
def amor_chopper(f: Filename[RunType]) -> RawChopper[RunType]:
return next(load_nx(f, "NXentry/NXinstrument/NXdisk_chopper"))

Expand Down Expand Up @@ -163,7 +138,6 @@ def load_amor_ch_frequency(ch: RawChopper[RunType]) -> ChopperFrequency[RunType]
raise ValueError("No unit was found for the chopper frequency")


@ignore_amor_warnings
def load_amor_sample_rotation(fp: Filename[RunType]) -> SampleRotation[RunType]:
(mu,) = load_nx(fp, "NXentry/NXinstrument/master_parameters/mu")
# Jochens Amor code reads the first value of this log
Expand All @@ -172,7 +146,6 @@ def load_amor_sample_rotation(fp: Filename[RunType]) -> SampleRotation[RunType]:
return sc.scalar(mu['value'].data['dim_1', 0]['time', 0].value, unit='deg')


@ignore_amor_warnings
def load_amor_detector_rotation(fp: Filename[RunType]) -> DetectorRotation[RunType]:
(nu,) = load_nx(fp, "NXentry/NXinstrument/master_parameters/nu")
# Jochens Amor code reads the first value of this log
Expand Down
4 changes: 4 additions & 0 deletions tests/amor/pipeline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ def amor_pipeline() -> sciline.Pipeline:
return pl


@pytest.mark.filterwarnings("ignore:Failed to convert .* into a transformation")
@pytest.mark.filterwarnings("ignore:Invalid transformation, missing attribute")
def test_run_data_pipeline(amor_pipeline: sciline.Pipeline):
res = amor_pipeline.compute(ReflectivityOverQ)
assert "Q" in res.coords
assert "Q_resolution" in res.coords


@pytest.mark.filterwarnings("ignore:Failed to convert .* into a transformation")
@pytest.mark.filterwarnings("ignore:Invalid transformation, missing attribute")
def test_run_full_pipeline(amor_pipeline: sciline.Pipeline):
res = amor_pipeline.compute(orso.OrsoIofQDataset)
assert res.info.data_source.experiment.instrument == "Amor"
Expand Down