Skip to content

Read source position from NXmoderator - #878

Merged
jl-wynen merged 7 commits into
mainfrom
source-position-from-moderator
Nov 19, 2026
Merged

jl-wynen merged 7 commits into
mainfrom
source-position-from-moderator

Conversation

@jl-wynen

Copy link
Copy Markdown
Member

Fixes #120

(Draft for now because I am using CI to run the tests)

I considered a couple of alternatives:

  1. Override NeXusClass[snx.NXsource] as we used to do for BIFROST. But as noted in Consider loading source from NXmoderator #120 (comment), this breaks code that expects Component[snx.NXsource] to be an actual NXsource.
  2. Override compute_position(transform: NeXusTransformation[snx.NXmoderator) -> Position[snx.NXsource] This would avoid the problem in point 1, but would still be strange because it hides the actual NXsource and could lead to confusion.
  3. Explicitly request moderator_position: Position[snx.NXmoderator] in all providers. This would be clean but would lock us in to using the moderator everywhere.
  4. (chosen) Make a distinct NeutronSourcePosition type. This allows us to provide positions from either the moderator or source, depending on what file we read (e.g., ESS vs McStas)
  • I opted to raise an exception whenever someone requests Position[snx.NXsource] because that is an easy mistake to make but hard to spot.

@YooSunYoung The NMX workflow tests fail because the test file does not contain a moderator. Are the tests designed for actual ESS files or for simulation data? In the former case, we should update the file. In the latter, we should update the workflow to load NXsource.

@github-actions github-actions Bot added essdiffraction Issues for essdiffraction. essimaging Issues for essimaging. essnmx Issues for essnmx. essreduce Issues for essreduce. essreflectometry Issues for essreflectometry. esssans Issues for esssans. essspectroscopy Issues for essspectroscopy. labels Nov 13, 2026
"neutron production (accelerator, target, etc.).\n\n"
"Use NeutronSourcePosition[RunType] or equivalently "
"Position[scippnexus.NXmoderator, RunType]. If this does not work for you, "
"insert your providder to overridethe one that produced this error."

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.

Suggested change
"insert your providder to overridethe one that produced this error."
"insert your provider to override the one that produced this error."

@jl-wynen
jl-wynen force-pushed the source-position-from-moderator branch from bcc607d to 2f9c09c Compare November 17, 2026 09:11
@jl-wynen

Copy link
Copy Markdown
Member Author

I fixed a couple of things. Can you take another look @nvaytet ?

@jl-wynen
jl-wynen marked this pull request as ready for review November 17, 2026 10:01
@jl-wynen
jl-wynen enabled auto-merge November 19, 2026 08:23
@jl-wynen
jl-wynen added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 19258d8 Nov 19, 2026
24 checks passed
@jl-wynen
jl-wynen deleted the source-position-from-moderator branch November 19, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

essdiffraction Issues for essdiffraction. essimaging Issues for essimaging. essnmx Issues for essnmx. essreduce Issues for essreduce. essreflectometry Issues for essreflectometry. esssans Issues for esssans. essspectroscopy Issues for essspectroscopy.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider loading source from NXmoderator

2 participants