Skip to content

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 +285
# 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?

@nvaytet
Copy link
Member

nvaytet commented Mar 4, 2025

This has been inactive for a while now. We should either revive or close?

@jokasimr
Copy link
Contributor Author

jokasimr commented Aug 1, 2025

I'll bring it up with Nico and ask him to review the procedure 👍

@nvaytet
Copy link
Member

nvaytet commented Dec 1, 2025

@paracini were you notified to review this one?
(trying to tidy up loose ends...)

@nvaytet
Copy link
Member

nvaytet commented Dec 17, 2025

@paracini ping?

@paracini
Copy link
Collaborator

paracini commented Dec 17, 2025

On Estia delta lambda varies between 4% (12Å) and 8% (3.5Å). The approach to combine curves with different resolutions used here, between measurements performed at multiple sample rotations, is similar to the way we are combining different wavelength resolution when integrating along lines of constant Q within one lambda-theta map (measured at a single sample rotation). It's a sensible way to go about it but it's important to remember the following:

In the case of a single sample rotation there does not seem to be any major discrepancies in resolution in the overlap regions obtained by stitching neighbouring wavelength bands of a single lambda-theta map (first figure below) so combining resolutions at a single rotation should not cause any significant loss of information in the data. In the case of combining multiple sample rotations (this PR, second figure below) the resolution effects in the overlap regions is a lot more noticeable so care must be taken when stitching together curves with different resolutions. It is inherent to the variable lambda resolution that information is lost when higher resolution is combined with lower resolution curves and this is typically not done, if this affects the information content in the data (sharp features) then multiple rotations should not be stitched together.

Stitching different wavelength bands from a measurement at a single sample rotation, good overlap, no major resolution effects in the overlap regions:
Figure 1(69)

Combining multiple sample rotations, can lead to loss of information in the overlap regions, overlap regions show significant resolution effects:
Figure 1(70)

@paracini paracini closed this Dec 17, 2025
@paracini paracini reopened this Dec 17, 2025
@jokasimr
Copy link
Contributor Author

jokasimr commented Dec 18, 2025

Adding to this, here is a comparison of the Q resolution for each separate measurement (per sample rotation value) and the Q resolution of the combined curve (calculated using the procedure in this PR):

Figure 1(71)

@jokasimr
Copy link
Contributor Author

Here is the same kind of figure displaying the reflectivity of each separate measurement compared to the combined curve from all measurements:

Figure 1(74)

Note that the combined curve overlaps the "highest angle" curve relatively closely in every part of the Q-range.

@jokasimr jokasimr merged commit 7921b91 into main Dec 18, 2025
4 checks passed
@jokasimr jokasimr deleted the add-resolution branch December 18, 2025 13:24
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.

5 participants