@@ -44,11 +44,9 @@ def wavelength_resolution(
4444 The angular resolution variable, as standard deviation.
4545 """
4646 pixel_position = da .coords ["position" ]
47- distance_between_choppers = (
48- chopper_2_position .fields .z - chopper_1_position .fields .z
49- )
5047 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 )
5250 return WavelengthResolution (
5351 fwhm_to_std (distance_between_choppers / chopper_detector_distance )
5452 )
@@ -77,7 +75,11 @@ def sample_size_resolution(
7775 """
7876 return fwhm_to_std (
7977 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+ )
8183 )
8284
8385
@@ -109,7 +111,11 @@ def angular_resolution(
109111 sc .to_unit (
110112 sc .atan (
111113 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+ )
113119 ),
114120 theta .bins .unit ,
115121 copy = False ,
@@ -120,10 +126,11 @@ def angular_resolution(
120126
121127
122128def sigma_Q (
129+ da : FootprintCorrectedData [SampleRun ],
123130 angular_resolution : AngularResolution ,
124131 wavelength_resolution : WavelengthResolution ,
125132 sample_size_resolution : SampleSizeResolution ,
126- q_bins : QBins ,
133+ qbins : QBins ,
127134) -> QResolution :
128135 """
129136 Combine all of the components of the resolution and add Q contribution.
@@ -144,9 +151,21 @@ def sigma_Q(
144151 :
145152 Combined resolution function.
146153 """
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 ))
150169
151170
152171providers = (sigma_Q , angular_resolution , wavelength_resolution , sample_size_resolution )
0 commit comments