5
5
from __future__ import annotations
6
6
7
7
from collections .abc import Callable , ItemsView , Iterable , Iterator , KeysView , Mapping
8
- from typing import NewType
9
8
10
9
import scipp as sc
11
10
import scipp .constants
12
11
13
12
from .types import DspacingData , SampleRun
14
13
15
14
16
- class ScalarCalibrationData (Mapping [int , sc .Variable ]):
15
+ class OutputCalibrationData (Mapping [int , sc .Variable ]):
17
16
r"""Calibration data for output ToF data.
18
17
19
- Only of value is stored per coefficient.
18
+ Only one value is stored per coefficient.
20
19
This means that individual detector pixels are *not* resolved but merged
21
20
into average quantities.
22
21
@@ -70,14 +69,14 @@ def d_to_tof(dspacing: sc.Variable) -> sc.Variable:
70
69
71
70
return d_to_tof
72
71
73
- def to_cif_units (self ) -> ScalarCalibrationData :
72
+ def to_cif_units (self ) -> OutputCalibrationData :
74
73
"""Convert to the units used in CIF pd_calib_d_to_tof."""
75
74
76
75
def unit (p : int ) -> sc .Unit :
77
76
base = sc .Unit (f'us / (angstrom^{ abs (p )} )' )
78
77
return sc .reciprocal (base ) if p < 0 else base
79
78
80
- return ScalarCalibrationData ({p : c .to (unit = unit (p )) for p , c in self .items ()})
79
+ return OutputCalibrationData ({p : c .to (unit = unit (p )) for p , c in self .items ()})
81
80
82
81
def to_cif_format (self ) -> sc .DataArray :
83
82
"""Convert to a data array that can be saved to CIF.
@@ -94,9 +93,6 @@ def to_cif_format(self) -> sc.DataArray:
94
93
)
95
94
96
95
97
- OutputCalibrationData = NewType ('OutputCalibrationData' , ScalarCalibrationData )
98
-
99
-
100
96
def assemble_output_calibration (
101
97
data : DspacingData [SampleRun ],
102
98
) -> OutputCalibrationData :
@@ -112,7 +108,7 @@ def assemble_output_calibration(
112
108
* sc .sin (0.5 * average_two_theta ),
113
109
unit = 'us / angstrom' ,
114
110
)
115
- return OutputCalibrationData (ScalarCalibrationData ( {1 : difc }) )
111
+ return OutputCalibrationData ({1 : difc })
116
112
117
113
118
114
providers = (assemble_output_calibration ,)
0 commit comments