-
Notifications
You must be signed in to change notification settings - Fork 68
Fairmat 2024: use NXcoordinate_system together with NXtransformations #1415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lukaspie
merged 39 commits into
nexusformat:main
from
FAIRmat-NFDI:fairmat-2024-nxtransformations
May 9, 2025
Merged
Changes from 36 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
a44e789
Updates NXtransformations docs (#114)
domna 1427694
change @depends_on docstring in NXtransformations
lukaspie b1c770e
clarify docstring in NXtransformations depends_on attribute
lukaspie 03c0ece
regenerate nxdl files
lukaspie dceceed
ci/cd fix
lukaspie fe3910c
revert unintentional changes from cherry-pick
lukaspie f2dbbe9
remove unmerged docs update in NXtransformations
lukaspie e95cd7c
bring in NXcoordinate_system
lukaspie e7a818a
add NXcoordinate_system_set
lukaspie a758081
remove NXcoordinate_system_set from contributed
lukaspie 32a339c
separate rotation conventions and predefined coordinate systems
lukaspie f047610
port docs of NXcoordinate_system_set to NXcoordinate_system
lukaspie ed27280
clean up docs in NXrotation_conventions
lukaspie dbce912
rebase contributed
lukaspie 0d1d663
remove duplicated definition
lukaspie 5b58510
fix issues with links in nxdl files
lukaspie 6531735
remove specified coordinate systems for EM/APM
lukaspie 406caf3
typo fix
lukaspie ec69344
remove NXcoordinate_system/alias
lukaspie b40467d
use consistent underscores
lukaspie 9fe9d16
Merge remote-tracking branch 'upstream/main' into fairmat-2024-nxtran…
lukaspie 4465edf
use hyperreferences in NXrotation_conventions
lukaspie e58aca4
remove undefined as option from NXrotation_conventions
lukaspie 4c7d3a8
Apply suggestions from code review
lukaspie b3333b2
use more precise language for coordinate system docs
lukaspie f07acee
add hyperreference
lukaspie e1c3a61
Merge remote-tracking branch 'upstream/main' into fairmat-2024-nxtran…
lukaspie 3e8ab32
remove NXrotation_conventions for now
lukaspie 83e7b0c
remove handedness
lukaspie 58f6197
add explicit between CS and transformations
lukaspie ee872b5
connect transformations and coordinate systems
lukaspie 65bb31d
ensure rotation handedness is right handed in a given CS
lukaspie 08ac13d
add fallback mechanism for depends_on
lukaspie dbefd09
clean up language arounds depends_on
lukaspie f028a83
Apply suggestions from code review
lukaspie 34ff2cb
rename to Euclidean space
lukaspie 9c8a31f
Apply suggestions from code review
lukaspie cb286dc
add clarifications as review suggested
lukaspie 29e6c50
Update base_classes/NXcoordinate_system.nxdl.xml
lukaspie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,238 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <?xml-stylesheet type="text/xsl" href="nxdlformat.xsl"?> | ||
| <!-- | ||
| # NeXus - Neutron and X-ray Common Data Format | ||
| # | ||
| # Copyright (C) 2023-2025 NeXus International Advisory Committee (NIAC) | ||
| # | ||
| # This library is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU Lesser General Public | ||
| # License as published by the Free Software Foundation; either | ||
| # version 3 of the License, or (at your option) any later version. | ||
| # | ||
| # This library is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public | ||
| # License along with this library; if not, write to the Free Software | ||
| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| # | ||
| # For further information, see http://www.nexusformat.org | ||
| --> | ||
| <definition xmlns="http://definition.nexusformat.org/nxdl/3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" category="base" type="group" name="NXcoordinate_system" extends="NXobject" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd"> | ||
| <doc> | ||
| Base class to detail a coordinate system (CS). | ||
|
|
||
| Instances of ``NXcoordinate_system`` can be used to describe coordinate systems | ||
| other than the default `NeXus coordinate system <https://manual.nexusformat.org/design.html#the-nexus-coordinate-system>`_. | ||
|
|
||
| Whenever possible, all instances of :ref:`NXcoordinate_system` | ||
| should be used at the top-level (i.e, directly below ``NXentry``) | ||
| within an application definition or within a NeXus file. | ||
|
|
||
| ``NXcoordinate_system`` can be part of the transformations chain | ||
| using :ref:`NXtransformations`, where it acts as a linear | ||
| change-of-basis transformation (using a 3x3 matrix with the basis | ||
| vectors ``x``, `y``, and ``z`` as columns). | ||
|
|
||
| Any group that has an optional ``depends_on`` field or any field | ||
| that has an optional ``depends_on`` attribute has a fallback when | ||
| ``depends_on`` is not provided. The fallback behavior involves | ||
| traversing up the hierarchy until the first parent that contains one | ||
| and only one ``NXcoordinate_system`` group is found. If such a parent | ||
|
lukaspie marked this conversation as resolved.
Outdated
|
||
| exists, its coordinate system applies. If none is found, then the | ||
| current coordinate system is not defined with respect to anything | ||
| else. As an example, if there is only one NXcoordinate_system called | ||
|
PeterC-DLS marked this conversation as resolved.
Outdated
|
||
| "my_coordinate_system" defined directly under ``NXentry``, each | ||
| optional ``depends_on`` field/attribute that is not defined | ||
| automatically defaults to ``depends_on=my_coordinate_system``. | ||
|
|
||
| How many groups of type ``NXcoordinate_system`` should be used in | ||
| an application definition? | ||
|
|
||
| * 0; if there is no instance of ``NXcoordinate_system`` across the | ||
| application definition or the data tree, you can use ``depends_on="."`` | ||
|
PeterC-DLS marked this conversation as resolved.
Outdated
|
||
| to state that this transformation depends on the default | ||
| `NeXus coordinate system <https://manual.nexusformat.org/design.html#the-nexus-coordinate-system>`_ | ||
| (which is the same as the one used by `McStas <https://mcstas.org/>`_). | ||
|
|
||
| For the sake of clarity, even in this case it is better | ||
| to be explicit like for every other coordinate system definition | ||
|
lukaspie marked this conversation as resolved.
Outdated
|
||
| to support users with interpreting the content and logic behind | ||
| every instance of the tree. | ||
|
|
||
| The default NeXus coordinate system (i.e., the McStas coordinate | ||
| system) can be expressed as follows: | ||
|
|
||
| .. code-block:: | ||
|
|
||
| mcstas@NXcoordinate_system | ||
| x = [1, 0, 0] | ||
| y = [0, 1, 0] | ||
| z = [0, 0, 1] | ||
| @y_direction = "opposite to gravity" | ||
| @z_direction = "direction of the primary beam" | ||
|
PeterC-DLS marked this conversation as resolved.
|
||
|
|
||
| * 1; if only one :ref:`NXcoordinate_system` is defined, it should be | ||
| placed as high up in the tree hierarchy (ideally right below an | ||
| instance of NXentry) of the application definition tree as possible. | ||
| This coordinate system shall be named such that it is clear how this | ||
| coordinate system is typically referred to in a community. For the | ||
| NeXus McStas coordinate system, it is advised to call it ``mcstas`` | ||
| for the sake of improved clarity. | ||
|
|
||
| If this is the case, it is assumed that this ``NXcoordinate_system`` | ||
| overwrites the NeXus default McStas coordinate system, i.e. users | ||
| can thereby conveniently and explicitly specify the | ||
| coordinate system that they wish to use. | ||
|
|
||
| This case has the advantage that it is explicit and offers no | ||
| ambiguities. However, in reality typically multiple coordinate | ||
| systems have to be mastered especially for complex multi-signal | ||
| modality experiments. | ||
|
|
||
| If this case is realized, the best practice is that in every | ||
| case where this coordinate system should be referred to the respective | ||
| group has a ``depends_on`` field, to clearly indicate which | ||
| specific coordinate systems is referred to. | ||
|
|
||
| * 2 and more; as soon as more than one :ref:`NXcoordinate_system` | ||
| is specified somewhere in the tree, different interpretations are | ||
| possible as to which of these coordinate systems | ||
| apply or take preference. | ||
| While these ambiguities should be avoided if possible, the | ||
| opportunity for multiples instances enables to have coordinate | ||
| system conventions that are specific for some part of the NeXus | ||
| tree. This is especially useful for deep groups where | ||
| multiple scientific methods are combined or cases where having a | ||
| definition of global conversion tables how to convert between | ||
| representations in different coordinate systems is not desired | ||
| or available for now. | ||
|
|
||
| To resolve the possible ambiguities which specific coordinate systems | ||
| in an :ref:`NXtransformations` train is referred to, it is even more | ||
| important to use the ``depends_on`` field in groups and the ``depends_on`` | ||
| attribute in NXtransformations to refer to one of the ``NXcoordinate_system`` | ||
| instances. | ||
|
|
||
| In the case of two or more instances of ``NXcoordinate_system`` it | ||
| is advised to specify the relationship between the two coordinate | ||
| systems by using the :ref:`NXtransformations` group within | ||
| ``NXcoordinate_system``. | ||
|
|
||
| In any case, users are encouraged to write explicit and clean | ||
| ``depends_on`` fields in all groups that encode information for which | ||
| the interpretation of coordinate systems and transformations is relevant. | ||
| If these ``depends_on`` instances are not provided or no instance of | ||
| ``NX_coordinate_system`` exists in the upper part of the hierarchy, | ||
| the application definition is considered underconstrained. Note that this | ||
| is the case for all files that were created before ``NXcoordinate_system`` | ||
| was added. | ||
| </doc> | ||
| <field name="origin" type="NX_CHAR"> | ||
| <doc> | ||
| Human-readable field telling where the origin of this CS is. | ||
|
lukaspie marked this conversation as resolved.
Outdated
|
||
| Exemplar values could be *left corner of the lab bench*, *door handle* | ||
| *pinhole through which the electron beam exits the pole piece*, | ||
| *barycenter of the triangle*, *center of mass of the stone*. | ||
| </doc> | ||
| </field> | ||
| <field name="type" type="NX_CHAR"> | ||
| <doc> | ||
| Coordinate system type. | ||
| </doc> | ||
| <enumeration open="true"> | ||
| <item value="undefined"/> | ||
| <item value="cartesian"/> | ||
| </enumeration> | ||
| </field> | ||
| <field name="x_alias" type="NX_CHAR"> | ||
| <doc> | ||
| Opportunity to define an alias for the name of the x-axis. | ||
| </doc> | ||
| </field> | ||
| <field name="x_direction" type="NX_CHAR"> | ||
| <doc> | ||
| Human-readable field telling in which direction the x-axis points if that | ||
| instance of :ref:`NXcoordinate_system` has no reference to any parent and as such | ||
| is the mighty world reference frame. | ||
|
lukaspie marked this conversation as resolved.
Outdated
|
||
|
|
||
| Exemplar values could be direction of gravity. | ||
| </doc> | ||
| </field> | ||
| <field name="x" type="NX_NUMBER" units="NX_LENGTH"> | ||
| <doc> | ||
| Basis unit vector along the first axis which spans the coordinate system. | ||
| This axis is frequently referred to as the x-axis in Euclidean space and | ||
| the i-axis in reciprocal space. | ||
|
|
||
| Note that `x``, ``y``, and ``z`` must constitute a basis, i.e., a set of linearly | ||
| independent vectors that span the vector space. | ||
| </doc> | ||
| <dimensions rank="1"> | ||
| <dim index="1" value="3"/> | ||
|
PeterC-DLS marked this conversation as resolved.
|
||
| </dimensions> | ||
| </field> | ||
| <field name="y_alias" type="NX_CHAR"> | ||
| <doc> | ||
| Opportunity to define an alias for the name of the y-axis. | ||
| </doc> | ||
| </field> | ||
| <field name="y_direction" type="NX_CHAR"> | ||
| <doc> | ||
| Human-readable field telling in which direction the y-axis points if that | ||
| instance of :ref:`NXcoordinate_system` has no reference to any parent and as such | ||
| is the mighty world reference frame. | ||
|
|
||
| See docstring of ``x_direction`` for further details. | ||
| </doc> | ||
| </field> | ||
| <field name="y" type="NX_NUMBER" units="NX_LENGTH"> | ||
| <doc> | ||
| Basis unit vector along the second axis which spans the coordinate system. | ||
| This axis is frequently referred to as the y-axis in Euclidean space and | ||
| the j-axis in reciprocal space. | ||
| </doc> | ||
| <dimensions rank="1"> | ||
| <dim index="1" value="3"/> | ||
| </dimensions> | ||
| </field> | ||
| <field name="z_alias" type="NX_CHAR"> | ||
| <doc> | ||
| Opportunity to define an alias for the name of the z-axis. | ||
| </doc> | ||
| </field> | ||
| <field name="z_direction" type="NX_CHAR"> | ||
| <doc> | ||
| Human-readable field telling in which direction the z-axis points if that | ||
| instance of :ref:`NXcoordinate_system` has no reference to any parent and as such | ||
| is the mighty world reference frame. | ||
|
|
||
| See docstring of x_alias for further details. | ||
| </doc> | ||
| </field> | ||
| <field name="z" type="NX_NUMBER" units="NX_LENGTH"> | ||
| <doc> | ||
| Basis unit vector along the third axis which spans the coordinate system. | ||
| This axis is frequently referred to as the z-axis in Euclidean space and | ||
| the k-axis in reciprocal space. | ||
| </doc> | ||
| <dimensions rank="1"> | ||
| <dim index="1" value="3"/> | ||
| </dimensions> | ||
| </field> | ||
| <field name="depends_on" type="NX_CHAR"> | ||
| <doc> | ||
| This specifies the relation to another coordinate system by pointing to the last | ||
| transformation in the transformation chain in the NXtransformations group. | ||
| </doc> | ||
| </field> | ||
| <group type="NXtransformations"> | ||
| <doc> | ||
| Collection of axis-based translations and rotations to describe this coordinate system | ||
| with respect to another coordinate system. | ||
| </doc> | ||
| </group> | ||
| </definition> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.