Skip to content

NXxas refactoring#1352

Draft
woutdenolf wants to merge 41 commits intonexusformat:mainfrom
XraySpectroscopy:main
Draft

NXxas refactoring#1352
woutdenolf wants to merge 41 commits intonexusformat:mainfrom
XraySpectroscopy:main

Conversation

@woutdenolf
Copy link
Copy Markdown
Contributor

@woutdenolf woutdenolf commented Feb 10, 2024

WIP: everything will be moved to contributed_definitions once this is up for review.

Contributing: PR to the main branch of https://github.com/XraySpectroscopy/nexus_definitions (merge commits will be removed regularly).

Rendering: https://hdf5.gitlab-pages.esrf.fr/nexus/nxxas/classes/applications/NXxas_new.html

Example files: https://pynxxas.readthedocs.io/

NXDL questions:

- how to re-use an enum
- when enum field X has a specific value, make field Y required OR how to define enum properties
- possibly link to
- how to make a field required in a base class

@lukaspie
Copy link
Copy Markdown
Contributor

Hi @woutdenolf, I came across this PR by chance and noticed that you are working on a base class for describing an electron level. In the context of photoemission spectroscopy, we in FAIRmat have also been working on something very similar: https://github.com/FAIRmat-NFDI/nexus_definitions/blob/fairmat/contributed_definitions/NXelectron_level.nxdl.xml. In fact, some of the base class we developed was originally adapated from another XAS-related PR: #1293. Would you be open to harmonizing the concept that we were developing with your approach here? I think the two approaches are already very similar right now.

@woutdenolf
Copy link
Copy Markdown
Contributor Author

@lukaspie Yes since we are doing the same thing we should try to converge. We are currently discussing this very topic: XraySpectroscopy#2. Feel free to get involved.

The XAS working group will work in https://github.com/XraySpectroscopy/nexus_definitions. It would be helpful to add comments in that repo. This PR will be a draft and is subject to lots of changes until we are finished.

@lukaspie
Copy link
Copy Markdown
Contributor

@woutdenolf great, thanks for the pointers. I will add some comments there.

@woutdenolf
Copy link
Copy Markdown
Contributor Author

another XAS-related PR: #1293

This was the first attempt before we created the XAS working group. It will most likely be closed.

@whs92
Copy link
Copy Markdown

whs92 commented Mar 13, 2024

@woutdenolf after asking a question to the nexus mailing list and reading:

#1011
#1293

I arrived here :)

I have had a look at the proposal you made to the NXxas_new

I am particularly interested in the topic raised in #1011 of adding the ability to work with multiple detectors. I see that you've added the entry intensity that is still tied to a single mode (TFY, PFY, TEY etc). How might I add other signals acquired at the same time? How might I add more than one PFY signal?

Do you plan to include the suggestions from @padraic-shafer in https://github.com/padraic-shafer/definitions/blob/1011-multixas/contributed_definitions/NXmultixas.nxdl.xml

When is the next planned meeting of the working group? Can I come along?

@woutdenolf
Copy link
Copy Markdown
Contributor Author

Currently we only support a single XAS spectrum. I'm very much open to support multi-detector and/or multi-scan. You are very welcome to join the XAS working group. I'll contact you directly.

<field name="name"/>
<field name="probe">
<enumeration>
<item value="x-ray"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you want to allow the "electron energy loss" mode, then you should also allow an "electron" probe type.

</enumeration>
</field>
<group type="NXelement" name="element">
<doc>Excited element</doc>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if I want to do a scan that includes multiple absorption edges (e.g. Carbon K-edge and K L-edge)? Can I specify multiple elements?

</item>
<item value="electron yield">
<doc>
TODO total or partial electron yield
Copy link
Copy Markdown
Contributor

@benajamin benajamin Sep 27, 2024

Choose a reason for hiding this comment

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

Does this include Auger electron yield? Can we include a way to specify the observed electron energy range? Or should that be a detail for NXdetector?

</dimensions>
</field>
</group>
<group type="NXdetector" name="i0" optional="true">
Copy link
Copy Markdown
Contributor

@benajamin benajamin Sep 27, 2024

Choose a reason for hiding this comment

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

The i0 should have a corresponding NXmonitor group. There are also many ways of measuring an i0 that is useful to document in the file. For example, is the i0 measured in parallel with the sample absorption (or its proxy), or is it measured in sequence (e.g. before or after the sample), or is it sequential, but interleaved?

There is also question of how "clean" the i0 data is, as in how directly/accurately does the i0 measurement follow the ideal incident flux signal? This issue is particularly significant for C K-edge measurements - one can read my article on the topic to further understand this issue.

@ounsy
Copy link
Copy Markdown

ounsy commented Sep 29, 2024

#1352 (comment)
@whs92
@woutdenolf
I also got a request for that from one of our beamlines at SOLEIL

samtygier-stfc and others added 15 commits February 7, 2026 16:46
Tomography software typically outputs floating point arrays for reconstructed data, so it is useful to store without further transformation.

Closes nexusformat#1241

As discussed in Telco 20230213
* `wavelength_shifter` added to the list of `type` of `NXinsertion_device`

* Create pages.yml

* adding docs string for insertation device type

* fix docs entry position

* Update base_classes/NXinsertion_device.nxdl.xml

Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>

* Delete .github/workflows/pages.yml

Reverting dae1fd6. .github/workflows/pages.yml should ot be included in this PR.

---------

Co-authored-by: Sonal R. Patel <sonalpatel.982@gmail.com>
Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>
Co-authored-by: mkuehbach <markus.kuehbach@physik.hu-berlin.de>
* modify moving of existing docs

* remove commented CI code that is not needed anymore

* Opened NXem_conventions for usage in methods other than electron microscopy

* Consolidated based classes related to NXem_conventions into NXcoordinate_system_set because that is what these conventions only talk about

* Refactored NXmicrostructure_score_config

* Refactored NXmicrostructure_gragles_config

* Even make html runs through locally

* remove _source build artifacts before docs deployment

* Finished NXmicrostructure_score_results and hope that commenting out the rollett-holm formula fixes the build error with latex, locally at least it does

* Fixed the too stiff name of microstructure1

* Initial version of NXmicrostructure_gragles_results

* Fixed grammar issue

* Finished NXmicrostructure_gragles_results

* Implemented suggestions from @lukaspie

* nxdl

* NXdata linking of signal (nexusformat#205)

* Add depends for data field

* Use `@reference`

* use reference attribute in NXmpes and NXmpes_arpes

* change text style

* fix duplicated in reference attribute

---------

Co-authored-by: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com>

* Roll back changes to NXmpes/instrument/pressure_gauge

* fix 2theta and use NXobject instead of collection.

* reproducibity check.

* add radius to NXenergydispersion

* Xrd modification (nexusformat#274)

* Including scattering vector components perpendicular and parallel to the surface of the sample those are mainly used for RSM diffraction technique.

---------

Co-authored-by: Florian Dobener <florian.dobener@physik.hu-berlin.de>

* Implementing suggestions from lukaspie

* Refactored NXcoordinate_system_em_ebsd into NXem_ebsd

* Fix naming bug for monochromator_em

* Bug fixes in images and spectrum and renaming of groups, refining precision of concept image and how this is connected to tilings

* Add circuit to component

* Adding routine tests for py3.12

* Added circuit and corrected laziness error

* Editing NXem for aberrations in event data

* Extension of Doc for Optical spectroscopy and Raman

* Update webpage for optical spectroscopy

* Further simplification of where and how to store aberrations

* change ellips name to optical spec

* Use something from lensID

* Correcting units for complex aberrations

* Removed mandatory model for aberrations as clear for naming conventions used

* Reference Rafal for aberration function

* Fixed time(NX_TIME) bug

* fix_renaming_of_ellipsometry_to_optical_spec

* add missed links

* add missing ####  in title...

* Clarified issues with depends_on, fixed typo pID for pfID in NXem_ebsd

* Hooked in examples for usage of NXem_ebsd and NXem_eds into NXem

* Last cleaning for depends_on on this feature branch

* Initial draft of NXmpes_xps sub app-def

* Prepare NXmpes_xps for extending NXmpes

* Removed information already given in base classes

* Removed some unneeded comments

* Add description of instrument orientation

- Angle between beam and sample normal-> needed for determination of probing depth
- Angle between beam and analyzer axes -> needed for data analysis

* Move orientation of instrument parts

Instead of having two fields on the instrument for the angle between beam and sample and the angle between beam and analyser, this information is stored in depends_on and NXtransformations in NXinstrument and NXsample, respectively.

* Update transmission function information

 - The transmission function contains an additional NXnote field "file" describing the file in which the TF data is stored.

* Update documentation, add comments for discussion

* Initial draft of NXmpes_xps sub app-def

* Prepare NXmpes_xps for extending NXmpes

* Removed information already given in base classes

* Removed some unneeded comments

* Add description of instrument orientation

- Angle between beam and sample normal-> needed for determination of probing depth
- Angle between beam and analyzer axes -> needed for data analysis

* Move orientation of instrument parts

Instead of having two fields on the instrument for the angle between beam and sample and the angle between beam and analyser, this information is stored in depends_on and NXtransformations in NXinstrument and NXsample, respectively.

* Update transmission function information

 - The transmission function contains an additional NXnote field "file" describing the file in which the TF data is stored.

* Update documentation, add comments for discussion

* fix NXmpes yaml

* update to current NXmpes status

* refine NXtransformations

* add coordinate system and coordinate_system_set

* Adds mpes_xps to mpes structure

* rename to NXxps

* initial attempt at modeling XPS peak fitting

* add lineshape to NXpeak

* update lineshape in NXpeak

* add NXbackground to NXfit_region

* add fitting method to NXpeak_model

* remove NXtransformations from NXcoordinate_system

* restructure NXfit with background and peaks

* change to NXcoordinate_system_set, use NXfit in NXxps

* add fit_function and parameters

* use NXfit_function for peaks and backgrounds

* use NXdata in NXfit

* use new peak fitting in NXxps

* add missing class name in NXxps

* remove underscores from variable names in NXfit

* update nyamls

* switch axes docs in NXfit

* use old nyaml dim notation for now

* fix math notation

* make nxdls

* regenerate with nyaml==0.0.8

* make NXfit, NXpeak multi-dimensional

* redefine XPS coordinate system, small changes to XPS peak fitting

* required energy axis in XPS

* fix dimensions issues

* regenerate NXxps

* make energy an NX_NUMBER

* remove unneeded depends_on enumerations

* align symbols across all fit-related definitions

* remove single and repeated parameters in fit

* fix dimensions in NXpeak and NXfit_background

* use globlal_fit and error_function in NXfit, fix dimensions

* docstring fixes in NXfit

* NXfit extends NXprocess

* fix math notation in NXfit_function

* fix link in NXfit_function

* change requiredness for formulas in XPS fit

* small fixes for links

* fix issues with manual build

* fix math notation

* more math fixes

* regenerate NXxps and NXpeak nxdl files

* fix rebasing issues

* make NXpeak spectrum-independent

* fix rebase conflicts

* fix nyaml-nxdl inconsistency

* add notes from both workshops

* added make nxdl and make local

* lowercase enumeration, source_type todo added, doc for ellipsometry_type

* HOW LONG? does it take to learn to make nxdl and local before commiting >.<

* Fixes in EM

* Merging NXem_adf into NXem_img, enabling microstructure reconstructions as dependants of specific method results, introduction of NXatom_set to discuss generalization of NXion towards enabling descriptions of groups of atoms, also to lias with FAIRmat Area C

* Removal of non-standardized assumption that i, j, k can be used as counter variables in case one does not know the actual dimensions but one is sure it is not a scalar

* add missing elements in ellipsometry from specialized NXlens_opt

* Add todo notes for beamsize and shape  description

* typo and note for possible rework/reconsideration of NXfabrication

* Suggestions from lukaspie

* Fixes apm

* Added undefined enum in NXidentifier

* use NXidentifier in NXsample and NXfabrication

* rename sample name in NXoptical spectroscopy

* make ellipsometer_type optional

* NXidentifier in NXoptical_spectroscopy instrument

* remove NXsample name docs from NXoptical_spectroscopy

* add serial_number to NXfabrication

* use NXidentifier in NXmpes

* use NXidentifier consistently across all our contributed definitions

* decode binary strings in nxdl_utils.py

* add function for decoding

* use NXidentifier in NXentry

* small changes to NXbeam and NXmonochromator

* typo fixes

* proper string decoding

* remove unneeded imports

* black formatting

* remove code and move to pynxtools

* remove unneeded requirements

* escape black check

* ignore flake8 issue

* isort imports

* use less strict version of str decoding

* slightly enhanced version of str decoding, test

* remove flake error catching

* reset requirements.txt

* reformatting

* remove strict type checking

* add support for list of bytes

* formatting

* add pulse_delay to NXbeam

* recreate nyaml file

* regenerate nyaml files

* various small fixes are merging main and fairmat

* fix string No in NXelectron_level

* remove unused MANIFEST.in

* manually reset NXem yaml file

* format base classes and applications in accordance to existing NIAC version

* revert changes to NXtransformations docs

* add CSS tweak to hide summary

* add css file

* Suggestions from Lukas

* fix dev_tools tests
black code style

* remove use of details_summary_hide

* change refs in NXarpes

* move doc bundles to applications and base_classes

* Reverting the proposal that NXmicrostructure is not just proposed for contributed but implicitly as a dependency of NXem, NXem_ebsd, NXem_img proposed for voting and acceptance

* Revert one more microstructure

* move new definitions to application and base_classes

* small update to mpes-structure

* update category for NXxrd.nxdl. (nexusformat#296)

* remove fairmat-specific files

* remove nyaml files

* move NXdata_mpes* classes back to contributed

* revert small changes to the dev_tools

black formatting

isort dev_tools

* change docs in NXcircuit

* pull out modifications for fairmat-2024-contributed

* bring in multi line doc handling in dev_tools

* remove renamed classes

* bring in latest NXxrd from fairmat repo

* bring in changes from fairmat repo

* bring in changes to optical spectroscopy classes

* modify dispersion models

* bring in NXmicrostructure from fairmat repo

* small changes to NXtransmission

* bring in NXspatial_filter from fairmat repo

* bring in NXmatch_filter from fairmat repo

* bring in NXisocontour from fairmat

* bring in NXdelocalization from fairmat

* bring in NXem_calorimetry from fairmat

* remove NXlab* classes

* bring in NXsubsampling_filter from fairmat branch

* bring in NXsimilarity_grouping from fairmat branch

* bring in NXapm_paraprobe classes

* bring in NXapm_compositonspace* classes from fairmat

* remove NXamplifier (part of SPM proposal)

* fix various issues with the documentation build

* typo fixes

* Clarify situation wrt to NXclustering

* Fix error in cgms docs

* Removed NXcs_ classes that in the process of the acceptance of NXapm have were refactored as base classes, e.g. NXcs_computer

* Capitalization, typos and header docstring for electrostatic kicker

* Capitalization, typos and header docstring for magnetic kicker

* Capitalization, typos and header docstring for quadrupole magnet

* Capitalization, typos and header docstring for separator

* Capitalization, typos and header docstring for spin_rotator, substance, and xpcs

* review comments

* Latest development stage of FAIRmat for the contributed definitions for atom probe and microstructure

* Reset NXtransmission and NXoptical_polarizer to commits before today

* Sync up that the hash rule for nuclid_hash defined in NXdelocalization and NXatom match up

* Fix typos in dispersive material

---------

Co-authored-by: mkuehbach <markus.kuehbach@physik.hu-berlin.de>
Co-authored-by: mkuehbach <markus.kuehbach@hu-berlin.de>
Co-authored-by: Florian Dobener <florian.dobener@physik.hu-berlin.de>
Co-authored-by: Rubel <rubel.mozumder@outlook.com>
Co-authored-by: RubelMozumder <32923026+RubelMozumder@users.noreply.github.com>
Co-authored-by: Markus Kühbach <mkuehbach@users.noreply.github.com>
Co-authored-by: Ron Hildebrandt <RonHildebrandt@uni-leipzig.de>
Co-authored-by: Ron <139139971+RonHildebrandt@users.noreply.github.com>
Co-authored-by: rettigl <l.rettig@web.de>
Co-authored-by: mkuehbach <markus.kuehbach@physik.hu-berlin.de>
Co-authored-by: Markus Kühbach <mkuehbach@users.noreply.github.com>
Co-authored-by: Lukas Pielsticker <you@example.com>
* initialize the NXazint contribution

* parse MAXIV proposal

* Renaming momentum transfer magnitude to scattering vector magnitude

* separating out the 2D case and minor refactoring

* 2d NXazint example ala Danmax

* Update NXazint2d.nxdl.xml

Updated based on implementation at DanMAX. Changed to US spelling. Lower case spelling for long names.
Long name for 'norn' must be changed!

* Update NXazint2d.nxdl.xml

Added I_errors field.

* Add nEtaEdge in symbols

Fixed symbols by adding nEtaEdge

* Align 1D and 2D definition

Through update of the NXazint1d definition based on the NXazint2d definition

* Remove nImg from norm

Removing the nImg value from norm and decrease the rank

* long name for norm

added a descriptive long name for the norm

* added long name for norm

added a descriptive long name for the norm

* Fixed syntax error in line 46

* FIX syntax error in line 155

* Update NXazint2d.nxdl.xml

Change units for azimuthal_axis to NX_ANGLE

* capitals, monitor, fix mention of eta bins

* stupid mistake in monitor dimensions

* monitor data

* Update NXazint1d.nxdl.xml

Changed NX_CHAR types to NX_ANY

* Update NXazint2d.nxdl.xml

Changed the unit types deom NX_CHAR to NX_ANY

* update 2d align with 1d

bold for some field names, add normalisation boolean

* fix typos in 2d

* add links in description

* NXazint1d without explicit NXsubgroup and polished

* indent cleaning

* 1d: \t replaced by 2 spaces

* 1d: commas in NXentry description

* NXazint2d with NXsubentry removed

* NXazint2d: indent and white chars

* adding NX_WAVENUMBER alternative for NX_PER_LENGTH

* Fix mostly typos in 1D case.

Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>

* Fix typos also in 2D case

* doc for normalization_applied and adding optional monitor_applied

* adding fixed/restricted units in monochromator

* moving NXazint(s) to applications definitions

* cosmetic changes in NXazzint(s) documentation

* NXazint(s) - only changes in the documentation of the corrections: 1) removed comments using undefined notation, some statements made more definitive, adding a Note label

* Making the note about normalization strategy more explicit.

* making 'reduction' field lowercase

* Update applications/NXazint1d.nxdl.xml

Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>

* Update applications/NXazint1d.nxdl.xml

Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>

* Update applications/NXazint1d.nxdl.xml

Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>

* Remuving capitalized names of NXclass instances where not needed.

* adding word 'effective' in the long description of norm

* restructured documentation of normalization_applied

---------

Co-authored-by: Zdenek <zdenek.matej@maxiv.lu.se>
Co-authored-by: Paul Bell <paul.bell@maxiv.lu.se>
Co-authored-by: mrvj <mads@chem.au.dk>
Co-authored-by: Frederik <47137695+fgjorup@users.noreply.github.com>
Co-authored-by: Zdeněk Matěj <zmatej@centrum.cz>
Co-authored-by: Zdenek <32390711+zdemat@users.noreply.github.com>
Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>
Also, update and fix release note creator script, tweak base class text
to not use too long footnote (otherwise PDF output has ugly overlap)
Move tomography definitions to a new imaging category and move scattering definitions to diffraction
@mretegan
Copy link
Copy Markdown

mretegan commented Mar 17, 2026

The two options for the updated application definition described above and in Telco 20260211 are implemented below.

  1. Inheritance - NXxas is a parent class. Each mode is a separate application definition that extends NXxas and adds mode-specific fields.
NXobject
 `-- NXxas (parent)
      |-- NXxas_trans
      |-- NXxas_tfy
      |-- NXxas_pfy
      |-- NXxas_herfd
      |-- NXxas_tey
      |-- NXxas_pey
      `-- ...

Rendered documentation: https://nexus-definitions.readthedocs.io/en/xas-using-inheritance/classes/applications/NXxas.html

  1. Composition - a single NXxas application definition. Each measurement mode is a base class that extends NXobject (e.g., NXherfd) included as a group. The mode group carries all mode-specific metadata and optional instrument details.
NXobject
  |-- NXtrans  
  |-- NXtfy  
  |-- NXpfy  
  |-- NXherfd 
  |-- NXtey 
  |-- NXpey  
  `-- ...

NXxas (single application definition, extends NXobject)
  `-- uses any of the above modes

Rendered documentation: https://nexus-definitions.readthedocs.io/en/xas-using-modes/classes/applications/NXxas.html

@newville
Copy link
Copy Markdown

@mretegan strongly opposed to having separate NXpey, Nxtey - etc.

NXxas is sufficient. We are communicating normalized mu(E), and indicating how it was collected.

The subclasses could be fine, but they have proven to be a distraction.

@maurov
Copy link
Copy Markdown

maurov commented Mar 18, 2026

@mretegan strongly opposed to having separate NXpey, Nxtey - etc.

NXxas is sufficient. We are communicating normalized mu(E), and indicating how it was collected.

The subclasses could be fine, but they have proven to be a distraction.

@newville I personally prefer the separate NX classes and I think there are good arguments for it. Over all, the fact that can be reused in other application definitions, like NXXmcd, independent of NXXas. I think the best would be to have a meeting for discussing this.

@newville
Copy link
Copy Markdown

@maurov in general, it is OK to have subclasses. Are these meant to be complete? People measure XAS-like data in lots of different ways that develop and change.

The NXxas definition should communicate normalized mu(E). Yes, different modes may need different kinds of corrections or have different interpretations (surface-sensitivity, energy resolution, magnetic moment).

Still, most of these can be communicated as normalized mu(E), and so be useful in comparison to some other normalized mu(E) data. Just calling them XAS and listing a named mode would be fine, at least for the overwhelming majority of data. With 4 or 10 "XAS modes", now you have a problem that people will forever be unsure whether NXxeol can be compared to NXpey.

Adoption of NXxas was always going to be difficult. NeXuS has very real problems of coming from a tiny, self-selected group that claims the expertise to be a standards body. The current NXxas definition is utterly useless and demonstrates that core weakness of NeXuS. A revised definition for NXxas has to overcome all this baggage and demonstrate value in the result and in the process.

The longer it takes, the more it appears to come from a small group of people, the more it appears to come from one facility, the harder it is to convince people. Months were spent on how to spell the names of emission lines, and adding the complexity of subclasses, and yet there is currently no usable definition. I think that "perfect" has defeated "good".

@rayosborn
Copy link
Copy Markdown
Contributor

@newville, I can't comment on the substance of your criticisms because I'm not an XAS expert and have not been involved in the NXxas discussions, but I have to push back on your characterization of the NeXus standard body. The current NIAC has members from twenty facilities, all of whom have been approved by their management to represent them. They are dedicated to advancing the standard, even if they cannot claim to have expertise in every single neutron and x-ray scattering technique. However, they are committed to supporting those who do. If the NXxas effort has stalled for some reason, then I encourage you to attend the next NIAC teleconference explaining what you believe the problems are. I think you will find the committee very receptive to constructive criticism.

Creating consensus around standards such as NeXus is hard, but the payoffs of having metadata-rich data formats are worth it at a time when we are being mandated to provide shareable data repositories. Please encourage your colleagues to get involved. Things won't improve without people committing their own time and effort.

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

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.