Skip to content

Nxlauetof exporter and loader update for easier geometry reconstruction.#201

Merged
YooSunYoung merged 26 commits intomainfrom
nxlauetof-loader
Feb 27, 2026
Merged

Nxlauetof exporter and loader update for easier geometry reconstruction.#201
YooSunYoung merged 26 commits intomainfrom
nxlauetof-loader

Conversation

@YooSunYoung
Copy link
Copy Markdown
Member

It was a bit hard to validate the result without custom loader for the NMX output file (nxlauetof).

Most changes is related to adjusting the in-memory result data structure, so it should not affect the output file.
Output files are meant to be read by DIALS and it won't use this loader so regression tests won't be necessary.
The loader is only for the IDS member and developers.

The loader adjust and reconstruct some coordinates from the file.
And there is a test that checks if the reconstructed positions are good enough (i.e. difference less than 10th of pixel size.)

@YooSunYoung YooSunYoung changed the base branch from main to geometry February 25, 2026 15:45
@YooSunYoung
Copy link
Copy Markdown
Member Author

@aaronfinke I found the wrong calculation in the code and fixed it...! Now it gives the correct position.
It still has a very small difference of 4.209804057220788e-11 mm from the original positions in distance.
It is using origin position instead of the first_pixel_position.

Comment thread src/ess/nmx/types.py
reducer: NMXProgram = field(default_factory=NMXProgram)
"Information of the reduction software."

def to_datagroup(self) -> sc.DataGroup:
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.

If this is just for display, can you turn this into _repr_mimebundle_?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not exactly. Because when it's a DataGroup the display repr says that it's sc.DataGroup, which is not really true.

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.

I don't understand.

Because when it's a DataGroup

When what is a data group?

I am suggesting something like

def _repr_mimebundle_(self):
    return to_datagroup(self)._repr_mimebundle_()

Does this not work?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Data group does not have any repr_mimebundle though.

File [~/Projects/essnmx/src/ess/nmx/types.py:280](http://localhost:8888/lab/tree/src/ess/nmx/types.py#line=279), in NMXLauetof._repr_mimebundle_(self, include, exclude)
    279 def _repr_mimebundle_(self, include=None, exclude=None):
--> 280     return to_datagroup(self)._repr_mimebundle_(include=include, exclude=exclude)

AttributeError: 'DataGroup' object has no attribute '_repr_mimebundle_'

I could do sth like

def _repr_mimebundle_(self, include=None, exclude=None):
    return {'text/html': to_datagroup(self)._repr_html_()}

But then the html representation says that it's a scipp DataGroup like this.

image

But that's not true. It's a dataclass and also the children are dataclasses.
It'll be confusing to users.

Comment thread docs/user-guide/workflow.ipynb Outdated
"metadata": {},
"outputs": [],
"source": [
"!cp '/home/sunyoungyoo/.cache/scippnexus/1/PG3_4844_event.nxs' ./"
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.

Please remove this and use portable code instead.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh this is accidentally added... thanks

Comment thread docs/user-guide/workflow.ipynb Outdated
Comment thread src/ess/nmx/types.py


@dataclass(kw_only=True)
class NMXSourceMetadata:
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.

You could use scippneutron.metadata.Source (newly released) here. If you want inline fields, you could inherit from it. The only problem is that the classes in scippneutron are pydantic models, not dataclasses.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As we discussed before you went home, I used the scippneutron.metadata SourceType and RadiationProbe but not the Source. I added comments about that too.

@YooSunYoung YooSunYoung changed the base branch from geometry to main February 27, 2026 13:41
@YooSunYoung YooSunYoung changed the title Nxlauetof loader Nxlauetof exporter and loader update for easier geometry reconstruction. Feb 27, 2026
@YooSunYoung YooSunYoung merged commit 340bb21 into main Feb 27, 2026
4 checks passed
@YooSunYoung YooSunYoung deleted the nxlauetof-loader branch February 27, 2026 13:43
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.

2 participants