Skip to content

Estia #108

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

Merged
merged 53 commits into from
Mar 18, 2025
Merged

Estia #108

merged 53 commits into from
Mar 18, 2025

Conversation

jokasimr
Copy link
Contributor

Fixes #91

Initial draft for the ESTIA data reduction workflow.


providers = (
*reflectometry_providers,
# *load.providers,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# *load.providers,

"""
p = position - sample_position.to(unit=position.unit)
return (
sc.atan2(y=p.fields.x, x=p.fields.z)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sc.atan2(y=p.fields.x, x=p.fields.z)
sc.atan2(y=p.fields.y, x=p.fields.z)

Not sure I followed everything, but I am wondering if it should be y here?
Are we talking about this figure:
fig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Amor scatters vertically but Estia scatters horizontally, that's what makes the difference.


Computes the angle between the scattering direction of
the neutron and the sample surface.
'''
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 also add descriptions of the parameters in the docstring?

Comment on lines 28 to 56
def divergence_angle(
position, sample_position, detector_rotation, incident_angle_of_center_of_beam
):
"""
Angle between the scattering direction and
the ray from the sample to the center of the detector.
"""
Copy link
Member

Choose a reason for hiding this comment

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

Type hints and params in docstring.

return wf


def test_mcstas_loading(estia_mcstas_pipeline: sciline.Pipeline):
Copy link
Member

Choose a reason for hiding this comment

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

Seems this test is doing a bit more than loading. It's also adding a bunch of coordinates.

assert 'detector_rotation' in da.coords
assert 'theta' in da.coords
assert 'wavelength' in da.bins.coords
assert 'Q' in da.bins.coords
Copy link
Member

Choose a reason for hiding this comment

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

So Q is already in the coordinates? I always thought that computing Q was the goal of the reduction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Computing the reflectivity as a function of Q is the goal of the reduction. But Q is just a coordinate associated with every event like wavelength or anything else.

assert 'Q' in da.bins.coords


def test_can_compute_reflectivity_curve(estia_mcstas_pipeline: sciline.Pipeline):
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, how long does this test take to run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already trimmed the McStas files quite a bit, so it's fast.

).nanmax()

assert max_q > sc.scalar(0.075, unit='1/angstrom')
assert min_q < sc.scalar(0.007, unit='1/angstrom')
Copy link
Member

Choose a reason for hiding this comment

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

I feel we could benefit from more tests which check that the different parameters do what they are supposed to do (e.g. changing the masks or something else).
But it's also ok to do that in a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it would be good to have more tests.

@@ -0,0 +1,82 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
# flake8: noqa: F403, F405
Copy link
Member

Choose a reason for hiding this comment

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

Why the global flake8?
Also, I thought we had moved to ruff everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know, I copied the file from one of the amor tests. I'll try to remove it here and from the amor tests.

Copy link
Member

@nvaytet nvaytet left a comment

Choose a reason for hiding this comment

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

Couple of remaining things (summarizing here as it can get lost in the noise):

  • move masking to a separate file
  • unresolved (?) discussion about variances on mcstas data (waiting for simon to reply)

Otherwise, I think everything else has been addressed?

jokasimr and others added 2 commits March 11, 2025 12:55
Co-authored-by: Neil Vaytet <39047984+nvaytet@users.noreply.github.com>
@jokasimr
Copy link
Contributor Author

I'll add an example notebook for reducing Estia McStas data

@jokasimr jokasimr requested a review from nvaytet March 13, 2025 14:48
"q_theta_figure(results, q_bins=300, theta_bins=200)"
]
}
],
Copy link
Member

Choose a reason for hiding this comment

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

The notebook makes a lot a plots. I think it would really benefit from some short explanations between the figures, explaining what we are showing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you, but I think it's good to not make this PR any longer now. It's a basic notebook that someone experienced in the technique will at least get the gist of. Let's postpone this step to a separate PR for improving the docs.

Copy link
Member

Choose a reason for hiding this comment

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

I disagree, I think leaving it til later will increase the chances of us forgetting.

I don't think it's so much work to add small sentences and sections explaining a little what we are doing, especially if this is going to appear in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are some explanations already added, maybe take a look at those and see if that's what you wanted to see there.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, sorry I had missed those.

@SimonHeybrock
Copy link
Member

* unresolved (?) discussion about variances on mcstas data (waiting for simon to reply)

@nvaytet You are the main reviewer here, if you are confident that it is correct and adequately explained, go ahead!

@jokasimr jokasimr merged commit 2706ec5 into main Mar 18, 2025
4 checks passed
@jokasimr jokasimr deleted the estia branch March 18, 2025 14:03
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.

[ESTIA] Data reduction workflow for Estia
3 participants