11# SPDX-License-Identifier: BSD-3-Clause
22# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3+ import warnings
4+ from functools import wraps
5+
36import scipp as sc
47
58from ess .reduce import nexus
2528)
2629
2730
31+ def ignore_amor_warnings (func ):
32+ @wraps (func )
33+ def wrapped (* args , ** kwargs ):
34+ with warnings .catch_warnings ():
35+ warnings .filterwarnings (
36+ 'ignore' ,
37+ category = UserWarning ,
38+ message = r'Failed to convert .* into a transformation' ,
39+ )
40+ warnings .filterwarnings (
41+ 'ignore' ,
42+ category = UserWarning ,
43+ message = 'Invalid transformation, missing attribute' ,
44+ )
45+ return func (* args , ** kwargs )
46+
47+ return wrapped
48+
49+
50+ @ignore_amor_warnings
2851def load_detector (
2952 file_path : Filename [RunType ], detector_name : NeXusDetectorName [RunType ]
3053) -> LoadedNeXusDetector [RunType ]:
3154 return nexus .load_detector (file_path = file_path , detector_name = detector_name )
3255
3356
57+ @ignore_amor_warnings
3458def load_events (
3559 detector : LoadedNeXusDetector [RunType ], detector_rotation : DetectorRotation [RunType ]
3660) -> RawDetectorData [RunType ]:
@@ -108,6 +132,7 @@ def compute_tof(
108132 return ReducibleDetectorData [RunType ](data )
109133
110134
135+ @ignore_amor_warnings
111136def amor_chopper (f : Filename [RunType ]) -> RawChopper [RunType ]:
112137 return next (load_nx (f , "NXentry/NXinstrument/NXdisk_chopper" ))
113138
@@ -140,6 +165,7 @@ def load_amor_ch_frequency(ch: RawChopper[RunType]) -> ChopperFrequency[RunType]
140165 raise ValueError ("No unit was found for the chopper frequency" )
141166
142167
168+ @ignore_amor_warnings
143169def load_amor_sample_rotation (fp : Filename [RunType ]) -> SampleRotation [RunType ]:
144170 (mu ,) = load_nx (fp , "NXentry/NXinstrument/master_parameters/mu" )
145171 # Jochens Amor code reads the first value of this log
@@ -148,6 +174,7 @@ def load_amor_sample_rotation(fp: Filename[RunType]) -> SampleRotation[RunType]:
148174 return sc .scalar (mu ['value' ].data ['dim_1' , 0 ]['time' , 0 ].value , unit = 'deg' )
149175
150176
177+ @ignore_amor_warnings
151178def load_amor_detector_rotation (fp : Filename [RunType ]) -> DetectorRotation [RunType ]:
152179 (nu ,) = load_nx (fp , "NXentry/NXinstrument/master_parameters/nu" )
153180 # Jochens Amor code reads the first value of this log
0 commit comments