Skip to content

[ESSREFLECTOMETRY] fix: use transformations to figure out orientation - #857

Open
jokasimr wants to merge 6 commits into
mainfrom
update-estia-orientations
Open

jokasimr wants to merge 6 commits into
mainfrom
update-estia-orientations

Conversation

@jokasimr

@jokasimr jokasimr commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

The Estia workflow previously hard coded how to read sample orientation and detector orientation from a log, this PR makes it use the transformations derived from the nexus structure instead.

@github-actions github-actions Bot added the essreflectometry Issues for essreflectometry. label Nov 4, 2026
@github-actions github-actions Bot changed the title fix: use transformations to figure out orientation [ESSREFLECTOMETRY] fix: use transformations to figure out orientation Nov 4, 2026
def _orientation_axis(
transform: sc.Variable | sc.DataArray, axis: tuple[int, int, int]
) -> sc.Variable:
if isinstance(transform, sc.DataArray) or transform.ndim != 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is a log with just one value allowed? It would still have a dimension but a length of 1 in that dimension.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree that it's strange that this function is somehow "responsible" for handling the potential time dependence. I think it would make most sense to just make it agnostic to the dimensions of the input.

I don't think that makes sense to specifically accept scalar or length one. Because length one doesn't mean the same as scalar. Scalar means "time independent", but length one means "time dependent, unknown before timestamp and constant after".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the DiskChopper constructor, we allow both scalar and length 1.
That's why I brought this up here. But fine if you'd rather keep the distinction clear between the two.


Use the same composed, time-filtered transform as the detector positions.
"""
direction = _orientation_axis(transform.value, (0, 0, 1))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems from the docstring above that having z as the direction here while it is x in load_sample_rotation is intentional, but I'm just double-checking that it was not a typo.
Maybe expanding the docstring a little with a small explanation would help?

roll = sc.spatial.rotations_from_rotvecs(sc.vector([0, 0, 45], unit='deg'))
translation = sc.spatial.translation(value=[123, 0, 0], unit='mm')
transform = NeXusTransformation(yaw * translation * pitch * roll)
# For the sample surface, yaw = 1.25 - atan(sin(30) * tan(45)).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did I understand correctly that this is where the number -25.3150511771 comes from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right. But I removed this test, it didn't seem very useful.

@jokasimr
jokasimr requested a review from nvaytet November 5, 2026 13:17
@nvaytet nvaytet self-assigned this Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

essreflectometry Issues for essreflectometry.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants