Skip to content

Commit

Permalink
fix: q-uncertainty
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Aug 20, 2024
1 parent 342f89f commit 0a0d008
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/ess/amor/resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ def angular_resolution(


def sigma_Q(
da: FootprintCorrectedData[SampleRun],
angular_resolution: AngularResolution,
wavelength_resolution: WavelengthResolution,
sample_size_resolution: SampleSizeResolution,
q_bins: QBins,
qbins: QBins,
) -> QResolution:
"""
Combine all of the components of the resolution and add Q contribution.
Expand All @@ -144,9 +145,21 @@ def sigma_Q(
:
Combined resolution function.
"""
return sc.sqrt(
angular_resolution**2 + wavelength_resolution**2 + sample_size_resolution**2
).flatten(to="detector_number").max("detector_number") * sc.midpoints(q_bins)
h = da.bins.concat().hist(Q=qbins)
s = (
(
da
* (
angular_resolution**2
+ wavelength_resolution**2
+ sample_size_resolution**2
)
* da.bins.coords['Q'] ** 2
)
.bins.concat()
.hist(Q=qbins)
)
return sc.sqrt(sc.values(s / h))


providers = (sigma_Q, angular_resolution, wavelength_resolution, sample_size_resolution)

0 comments on commit 0a0d008

Please sign in to comment.