Skip to content

Conversation

@jokasimr
Copy link
Contributor

Fixes #130

sample,
reference,
reference.coords['wavelength'],
)
Copy link
Member

Choose a reason for hiding this comment

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

Can you check that the result is reasonable, not just that the function doesn't raise? If you can't check the values directly, you can at least check the sizes and that the right coords are present.

Copy link
Contributor Author

@jokasimr jokasimr Mar 11, 2025

Choose a reason for hiding this comment

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

The intent of the test is to check that the function doesn't raise if we have non-count weights, because that was the bug that prompted this issue.

Adding a bunch of extra checks for no apparent reason doesn't make sense in my opinion.

Copy link
Member

Choose a reason for hiding this comment

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

Well, the reason is that the function can still misbehave without raising. In any case, there should be at least one more test to make sure that it produces a meaningful result.

Returns reflectivity as a function of ``blade``, ``wire`` and :math:`\\wavelength`.
"""
R = sample.bins.concat(('stripe',)).bin(wavelength=wbins) / reference.data
R.masks["too_few_events"] = reference.data < sc.scalar(1, unit="counts")
Copy link
Member

Choose a reason for hiding this comment

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

Is the mask not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that's right. It was needed when we normalized on the z-wavelength grid, but we don't do that anymore.

Copy link
Member

Choose a reason for hiding this comment

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

What do you do instead? And why is there still a 'zw' in the function name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We normalize on the Q-grid. But that's not done in this function.

This function still normalizes on the zw grid, but that is not used for the reduction, only for visualization purposes, and for visualization masking is not necessary.

@jokasimr jokasimr requested a review from jl-wynen March 11, 2025 10:31
@jokasimr jokasimr enabled auto-merge March 11, 2025 12:17
@jokasimr jokasimr merged commit 91be8ba into main Mar 11, 2025
4 checks passed
@jokasimr jokasimr deleted the zw-figure-fix branch March 11, 2025 12: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.

zw figure throws error when the data is weighted by proton current

3 participants