7
7
import scippneutron as scn
8
8
9
9
from ..logging import get_logger
10
- from ..uncertainty import alpha_ratio
10
+ from ..uncertainty import variance_normalized_signal_over_monitor
11
11
12
12
13
13
def solid_angle_of_rectangular_pixels (data : sc .DataArray , pixel_width : sc .Variable ,
@@ -80,32 +80,33 @@ def transmission_fraction(data_monitors: Dict[str, sc.DataArray],
80
80
81
81
def _verify_normalization_alpha (numerator : sc .DataArray ,
82
82
denominator : sc .DataArray ,
83
- alpha_threshold : float = 0.1 ):
83
+ signal_over_monitor_threshold : float = 0.1 ):
84
84
"""
85
85
Verify that the ratio of sample detector counts to monitor counts is small, so
86
86
we can safely drop the variances of the monitor to avoid broadcasting issues.
87
87
See Heybrock et al. (2023).
88
88
"""
89
- alpha = alpha_ratio (numerator , denominator )
90
- if alpha > 0.25 * alpha_threshold :
89
+ alpha = variance_normalized_signal_over_monitor (numerator , denominator )
90
+ if alpha > 0.25 * signal_over_monitor_threshold :
91
91
logger = get_logger ('sans' )
92
92
logger .warning (
93
- f'alpha = { alpha } is close to the specified threshold of '
94
- f'{ alpha_threshold } . This means we are close to the regime where it is no '
95
- 'longer safe to drop the variances of the normalization term.' )
96
- if alpha > alpha_threshold :
93
+ f'signal_over_monitor = { alpha } is close to the specified threshold of '
94
+ f'{ signal_over_monitor_threshold } . This means we are close to the regime '
95
+ 'where it is no longer safe to drop the variances of the normalization '
96
+ 'term.' )
97
+ if alpha > signal_over_monitor_threshold :
97
98
raise ValueError (
98
- f'alpha = { alpha } > { alpha_threshold } ! This means that the ratio of '
99
- 'detector counts to monitor counts is too high, and the variances of the '
100
- 'monitor data cannot be safely dropped.' )
99
+ f'signal_over_monitor = { alpha } > { signal_over_monitor_threshold } ! '
100
+ 'This means that the ratio of detector counts to monitor counts is too '
101
+ 'high, and the variances of the monitor data cannot be safely dropped.' )
101
102
102
103
103
104
def iofq_denominator (data : sc .DataArray ,
104
105
data_transmission_monitor : sc .DataArray ,
105
106
direct_incident_monitor : sc .DataArray ,
106
107
direct_transmission_monitor : sc .DataArray ,
107
108
direct_beam : Optional [sc .DataArray ] = None ,
108
- alpha_threshold : float = 0.1 ) -> sc .DataArray :
109
+ signal_over_monitor_threshold : float = 0.1 ) -> sc .DataArray :
109
110
"""
110
111
Compute the denominator term for the I(Q) normalization. This is basically:
111
112
``solid_angle * direct_beam * data_transmission_monitor * direct_incident_monitor / direct_transmission_monitor``
@@ -131,7 +132,7 @@ def iofq_denominator(data: sc.DataArray,
131
132
The transmission monitor counts from the direct run (depends on wavelength).
132
133
direct_beam:
133
134
The DataArray containing the direct beam function (depends on wavelength).
134
- alpha_threshold :
135
+ signal_over_monitor_threshold :
135
136
The threshold for the ratio of detector counts to monitor counts above which
136
137
an error is raised because it is not safe to drop the variances of the monitor.
137
138
@@ -153,7 +154,7 @@ def iofq_denominator(data: sc.DataArray,
153
154
_verify_normalization_alpha (
154
155
numerator = data .hist (wavelength = denominator .coords ['wavelength' ]),
155
156
denominator = denominator ,
156
- alpha_threshold = alpha_threshold )
157
+ signal_over_monitor_threshold = signal_over_monitor_threshold )
157
158
158
159
solid_angle = solid_angle_of_rectangular_pixels (
159
160
data ,
0 commit comments