Skip to content

[ESSNMX] Mandi - #752

Open
YooSunYoung wants to merge 5 commits into
mainfrom
mandi
Open

YooSunYoung wants to merge 5 commits into
mainfrom
mandi

Conversation

@YooSunYoung

Copy link
Copy Markdown
Member

@aaronfinke I could use most of the mcstas xml helpers and essnmx-reduce code to make the mandi reduction tool.

There are still a few todos, like reducing monitor data but the detector banks could be saved in the NXLauetof file just like NMX files. Here is the command if you want to try:

essmandi-reduce \
  --input-file MANDI_10383.nxs.h5 \
  --verbose  #  --overwrite  # if you want to ignore safety check of the output file name.

Then it'll save the output to scipp_mandi_output.h5, if you don't specify the output.

@github-actions github-actions Bot added the essnmx Issues for essnmx. label Sep 16, 2026
@github-actions github-actions Bot changed the title Mandi [ESSNMX] Mandi Sep 16, 2026
@aaronfinke

Copy link
Copy Markdown
Contributor

Binned data look good, but the geometries are not in the binned file. From Claude:

The bug

src/ess/mandi/_idf_helper.py, DetectorDesc.pixel_positions:

return (
(pixel_n_slow * slow_axis_steps)
+ (pixel_n_fast * fast_axis_steps)
+ self.rotation_matrix * sc.vector([self.start_x, self.start_y, 0.0], ...)
)

self.position — declared on line 61 as # 'x', 'y', 'z' — is never added. It's used only for its .unit, on the line above. Same in assemble_detector_metadata, which takes a transformation parameter and reads only transformation.value.unit.

Adding + self.position should give origin = the bank's xyz (0.4138 m for bank1, matching the IDF exactly), and distance then becomes a real per-bank value. The sample is at (0,0,0) per the function's own comment, so relative and absolute coincide.

@aaronfinke

Copy link
Copy Markdown
Contributor

For mandi it would be good to include the instrument_xml data in the binned output, since mandi is still generally dependent on the mantid IDF. should be propagated throughout the workflow and included in the output.

@YooSunYoung

Copy link
Copy Markdown
Member Author

@aaronfinke thank you! Forgot the pixel offset.
Now I could reconstruct the geometry from the reduced file:

Screenshot from 2026-09-17 11-39-25

Is this correct...?

@aaronfinke

Copy link
Copy Markdown
Contributor

Looks right to me. Also loaded it in my new NMX 3D viewer (out soon!) and geometries all look correct. Excellent!

@YooSunYoung
YooSunYoung marked this pull request as ready for review September 17, 2026 13:44
@YooSunYoung

Copy link
Copy Markdown
Member Author

I think the implementation itself is okay based on the reduced data it produces.
I need add tests and such...

@aaronfinke can I use these Mandi file in our CI?
(most of events will be stripped out due to size issue)

Also need more fixes for monitors and crystal rotation later...

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

Labels

essnmx Issues for essnmx.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants