@@ -44,11 +44,9 @@ def wavelength_resolution(
44
44
The angular resolution variable, as standard deviation.
45
45
"""
46
46
pixel_position = da .coords ["position" ]
47
- distance_between_choppers = (
48
- chopper_2_position .fields .z - chopper_1_position .fields .z
49
- )
50
47
chopper_midpoint = (chopper_1_position + chopper_2_position ) * sc .scalar (0.5 )
51
- chopper_detector_distance = pixel_position .fields .z - chopper_midpoint .fields .z
48
+ distance_between_choppers = sc .norm (chopper_2_position - chopper_1_position )
49
+ chopper_detector_distance = sc .norm (pixel_position - chopper_midpoint )
52
50
return WavelengthResolution (
53
51
fwhm_to_std (distance_between_choppers / chopper_detector_distance )
54
52
)
@@ -77,7 +75,11 @@ def sample_size_resolution(
77
75
"""
78
76
return fwhm_to_std (
79
77
sc .to_unit (sample_size , "m" )
80
- / sc .to_unit (da .coords ["position" ].fields .z , "m" , copy = False )
78
+ / sc .to_unit (
79
+ sc .norm (da .coords ["position" ] - da .coords ["sample_position" ]),
80
+ "m" ,
81
+ copy = False ,
82
+ )
81
83
)
82
84
83
85
@@ -109,7 +111,11 @@ def angular_resolution(
109
111
sc .to_unit (
110
112
sc .atan (
111
113
sc .to_unit (detector_spatial_resolution , "m" )
112
- / sc .to_unit (da .coords ["position" ].fields .z , "m" , copy = False )
114
+ / sc .to_unit (
115
+ sc .norm (da .coords ["position" ] - da .coords ["sample_position" ]),
116
+ "m" ,
117
+ copy = False ,
118
+ )
113
119
),
114
120
theta .bins .unit ,
115
121
copy = False ,
@@ -120,10 +126,11 @@ def angular_resolution(
120
126
121
127
122
128
def sigma_Q (
129
+ da : FootprintCorrectedData [SampleRun ],
123
130
angular_resolution : AngularResolution ,
124
131
wavelength_resolution : WavelengthResolution ,
125
132
sample_size_resolution : SampleSizeResolution ,
126
- q_bins : QBins ,
133
+ qbins : QBins ,
127
134
) -> QResolution :
128
135
"""
129
136
Combine all of the components of the resolution and add Q contribution.
@@ -144,9 +151,21 @@ def sigma_Q(
144
151
:
145
152
Combined resolution function.
146
153
"""
147
- return sc .sqrt (
148
- angular_resolution ** 2 + wavelength_resolution ** 2 + sample_size_resolution ** 2
149
- ).flatten (to = "detector_number" ).max ("detector_number" ) * sc .midpoints (q_bins )
154
+ h = da .bins .concat ().hist (Q = qbins )
155
+ s = (
156
+ (
157
+ da
158
+ * (
159
+ angular_resolution ** 2
160
+ + wavelength_resolution ** 2
161
+ + sample_size_resolution ** 2
162
+ )
163
+ * da .bins .coords ['Q' ] ** 2
164
+ )
165
+ .bins .concat ()
166
+ .hist (Q = qbins )
167
+ )
168
+ return sc .sqrt (sc .values (s / h ))
150
169
151
170
152
171
providers = (sigma_Q , angular_resolution , wavelength_resolution , sample_size_resolution )
0 commit comments