Skip to content

Commit

Permalink
Use new dim arg of scipp.bin
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHeybrock committed Sep 4, 2024
1 parent f18c3c6 commit 2fa9143
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ess/reflectometry/corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def compute_reference_intensity(
with the experiment parameters (such as sample rotation).
Therefore it can be used to normalize sample measurements.
"""
b = da.bins.concat(set(da.dims) - set(da.coords["z_index"].dims)).bin(wavelength=wb)
b = da.bin(wavelength=wb, dim=set(da.dims) - set(da.coords["z_index"].dims))
h = b.hist()
h.masks["too_few_events"] = h.data < sc.scalar(1, unit="counts")
# Add a Q coordinate to each bin, the Q is not completely unique in every bin,
Expand Down
5 changes: 2 additions & 3 deletions src/ess/reflectometry/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def normalization_factor(
"""
sample_q = (
da.bins.concat(set(da.dims) - set(da.coords["z_index"].dims))
.bin(wavelength=wbins)
da.bin(wavelength=wbins, dim=set(da.dims) - set(da.coords["z_index"].dims))
.bins.coords["Q"]
.bins.mean()
)
Expand Down Expand Up @@ -112,7 +111,7 @@ def reflectivity_over_q(
Reflectivity as a function of Q
"""
return NormalizedIofQ(
da.bins.concat().bin(Q=qbins) / sc.values(n.flatten(to="Q").hist(Q=qbins))
da.bin(Q=qbins, dim=da.dims) / sc.values(n.hist(Q=qbins, dim=n.dims))
)


Expand Down

0 comments on commit 2fa9143

Please sign in to comment.