Repository navigation
Conversation
|
This is fine. The mirror is before the last slit before the sample. |
|
This is ready for review now 👍 |
|
This PR adds two changes:
The effect of gravity is summarized in a coefficient called Before this change there was a mechanism to "look up" the nominal incident angle based on what beam path defines the incident beam. Now the same mechanism is used to look up both the nominal incident angle and the |
| filename: Filename[RunType], | ||
| ) -> SampleSurfaceNormal[RunType]: | ||
| """Load the normal pointing out of the sample's underside in inversion mode.""" | ||
| return SampleSurfaceNormal[RunType](-mcstas_sample_surface_normal(filename)) |
There was a problem hiding this comment.
I think it is better to have a separate type for the inverted normal.
- It allows you to derive it from the normal
- It prevents accidentally using the wrong vector. Changing the normal like this may break code in hard to detect ways
There was a problem hiding this comment.
Conceptually there is no such thing as an "inverted normal" in the workflow. The helper is just there to be used for testing. I'll move it to the test module to make it less confusing.
| length = sc.norm(normal) | ||
| if not sc.isfinite(length).value or length.value == 0: | ||
| raise ValueError('MirrorNormal must have a finite, nonzero norm.') | ||
| return MirrorGeometry(position=position, normal=normal / length) |
There was a problem hiding this comment.
This is risky because you end up with two normal vectors in the workflow, MirrorNormal and MirrorGeometry.normal and they are different. Can we do away with the two separate inputs and require loaders and users to specify MirrorGeometry? It's __post_init__ can then check and normalise its inputs.
| interval: TimeInterval[RunType], | ||
| time_filter: TransformationTimeFilter[ | ||
| snx.NXmirror, RunType | ||
| ] = reject_time_dependent_transform, |
There was a problem hiding this comment.
Instead of reimplementing the transform chain logic, can you use ess.reduce.nexus's component loader? You should be able to request Component[snx.NXmirror] and its chain if you provide the right nexus class.
|
|
||
| def mirror_position( | ||
| transformation: NeXusTransformation[snx.NXmirror, RunType], | ||
| ) -> MirrorPosition[RunType]: |
There was a problem hiding this comment.
Similarly to above, you should be able to request Position[snx.NXmirror]. And if you keep it, MirrorPosition could be an alias to that.
| """Rotate local -z, the NXmirror reference-plane normal, to the lab frame.""" | ||
| origin = mirror_position(transformation) | ||
| tip = transformation.value * sc.vector([0.0, 0.0, -1.0], unit='m') | ||
| normal = tip - origin |
There was a problem hiding this comment.
How does this work? It looks to me like top - origin will point in -z direction because both vectors are translated the same way. Or does the transform encode a rotation as well? If so, I think you are sensitive to whether to rotates first or translates first.
There was a problem hiding this comment.
The transform encodes a combined translation and rotation. Only the rotation is relevant to determine the mirror normal in the lab coordinate system. The translation term is a nuisance in this case, and it is removed by subtracting the origin. The result is
There is no assumption about what order the operations occur in, the only assumption is that the origin is the transformation of the origin in the mirror local coordinate system to the lab system.
There was a problem hiding this comment.
Ok. Is there a convention in nexus that without rotation, mirrors are in the x-y plane? Or how come you use [0,0,-z]? Also, why negative? It says elsewhere that the direction of the mirror normal does not matter.
There was a problem hiding this comment.
Yes the Nexus standard specifies the orientation of the mirror in the component local coordinate system: https://manual.nexusformat.org/classes/base_classes/NXmirror.html "The mirror faces negative z values."
|
|
||
| def no_mirror() -> MirrorGeometry[RunType] | None: | ||
| """Use the ordinary geometry when inversion is disabled.""" | ||
| return None |
There was a problem hiding this comment.
Why do you need this? If the user sets inversion = False, can't you just omit the mirror entirely from the pipeline?
There was a problem hiding this comment.
Yes that is better 👍
There was a problem hiding this comment.
There is too much here for me to review on a Friday afternoon. Do you have notes on this with graphs?
There was a problem hiding this comment.
I have these AI generated notes:
They are actually not terrible, but should be taken with a grain of salt.
There was a problem hiding this comment.
Not gonna look at them because I don't have a reference. If you don't have something you or a scientist checked, I'm better off not risking looking at something potentially wrong.
There was a problem hiding this comment.
Have checked them extensively and they seem correct to me. There might be details wrong or confusing, of course. But they are certainly useful for understanding the ideas behind the implementation.
Fixes #852