-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: include resolution in stitched curve if present #88
base: main
Are you sure you want to change the base?
Conversation
src/ess/reflectometry/tools.py
Outdated
q_res = ( | ||
sc.DataArray( | ||
data=c.coords.get( | ||
'Q_resolution', sc.scalar(float('nan')) * sc.values(c.data.copy()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd default. Is that really the unit you want? How about something like sc.full_like(c.coords['Q'], value=nan)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
src/ess/reflectometry/tools.py
Outdated
qs_avg = np.nansum(qs * inv_v, axis=0) / np.nansum( | ||
~np.isnan(qs) * inv_v, axis=0 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using np.nansum
instead of sc.nansum
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the way it was done in ess.reflectometry.tools.scale_curves_to_overlap
(for various reasons, we're using scipy there so it's easier to just convert to numpy types once instead of going back and forth in every iteration) and this was just copied from there.
Fixed now 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot say anything about the math, should be reviewed by the scientist(s).
# This might need to be revisited. The question about how to combine curves | ||
# with different Q-resolution is not completely resolved. | ||
# However, in practice the difference in Q-resolution between different curves | ||
# is small so it's not likely to make a big difference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be discussed in the docstring instead?
Adds a
Q_resolution
coordinate to the combined reflectivity curve if the provided curves have aQ_resolution
coordinate.