Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jokasimr
Copy link
Contributor

@jokasimr jokasimr commented Oct 7, 2024

Adds a Q_resolution coordinate to the combined reflectivity curve if the provided curves have a Q_resolution coordinate.

@jokasimr jokasimr requested a review from nvaytet October 7, 2024 10:32
q_res = (
sc.DataArray(
data=c.coords.get(
'Q_resolution', sc.scalar(float('nan')) * sc.values(c.data.copy())
Copy link
Member

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Comment on lines 289 to 291
qs_avg = np.nansum(qs * inv_v, axis=0) / np.nansum(
~np.isnan(qs) * inv_v, axis=0
)
Copy link
Member

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?

Copy link
Contributor Author

@jokasimr jokasimr Oct 10, 2024

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 👍

Copy link
Member

@SimonHeybrock SimonHeybrock left a 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).

Comment on lines +275 to +278
# 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.
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants