Skip to content
Merged
Show file tree
Hide file tree
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 Jan 9, 2024
1427694
change @depends_on docstring in NXtransformations
lukaspie Jan 9, 2024
b1c770e
clarify docstring in NXtransformations depends_on attribute
lukaspie Jan 12, 2024
03c0ece
regenerate nxdl files
lukaspie Jul 3, 2024
dceceed
ci/cd fix
lukaspie Jul 3, 2024
fe3910c
revert unintentional changes from cherry-pick
lukaspie Sep 16, 2024
f2dbbe9
remove unmerged docs update in NXtransformations
lukaspie Sep 23, 2024
e95cd7c
bring in NXcoordinate_system
lukaspie Sep 29, 2024
e7a818a
add NXcoordinate_system_set
lukaspie Sep 30, 2024
a758081
remove NXcoordinate_system_set from contributed
lukaspie Oct 17, 2024
32a339c
separate rotation conventions and predefined coordinate systems
lukaspie Jan 16, 2025
f047610
port docs of NXcoordinate_system_set to NXcoordinate_system
lukaspie Jan 16, 2025
ed27280
clean up docs in NXrotation_conventions
lukaspie Jan 16, 2025
dbce912
rebase contributed
lukaspie Jan 16, 2025
0d1d663
remove duplicated definition
lukaspie Jan 16, 2025
5b58510
fix issues with links in nxdl files
lukaspie Jan 16, 2025
6531735
remove specified coordinate systems for EM/APM
lukaspie Jan 16, 2025
406caf3
typo fix
lukaspie Feb 13, 2025
ec69344
remove NXcoordinate_system/alias
lukaspie Feb 13, 2025
b40467d
use consistent underscores
lukaspie Feb 13, 2025
9fe9d16
Merge remote-tracking branch 'upstream/main' into fairmat-2024-nxtran…
lukaspie Feb 13, 2025
4465edf
use hyperreferences in NXrotation_conventions
lukaspie Feb 14, 2025
e58aca4
remove undefined as option from NXrotation_conventions
lukaspie Feb 14, 2025
4c7d3a8
Apply suggestions from code review
lukaspie Feb 14, 2025
b3333b2
use more precise language for coordinate system docs
lukaspie Feb 14, 2025
f07acee
add hyperreference
lukaspie Feb 14, 2025
e1c3a61
Merge remote-tracking branch 'upstream/main' into fairmat-2024-nxtran…
lukaspie Mar 4, 2025
3e8ab32
remove NXrotation_conventions for now
lukaspie Apr 14, 2025
83e7b0c
remove handedness
lukaspie Apr 14, 2025
58f6197
add explicit between CS and transformations
lukaspie Apr 14, 2025
ee872b5
connect transformations and coordinate systems
lukaspie Apr 14, 2025
65bb31d
ensure rotation handedness is right handed in a given CS
lukaspie Apr 14, 2025
08ac13d
add fallback mechanism for depends_on
lukaspie Apr 15, 2025
dbefd09
clean up language arounds depends_on
lukaspie Apr 15, 2025
f028a83
Apply suggestions from code review
lukaspie May 5, 2025
34ff2cb
rename to Euclidean space
lukaspie May 5, 2025
9c8a31f
Apply suggestions from code review
lukaspie May 6, 2025
cb286dc
add clarifications as review suggested
lukaspie May 6, 2025
29e6c50
Update base_classes/NXcoordinate_system.nxdl.xml
lukaspie May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions base_classes/NXcomponent.nxdl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@
via the NXtransformations group.

NeXus positions components by applying a set of translations and rotations
to apply to the component starting from 0, 0, 0. The order of these operations
to the component starting from 0, 0, 0. The order of these operations
is critical and forms what NeXus calls a dependency chain. The depends_on
field defines the path to the top most operation of the dependency chain or the
string "." if located in the origin. Usually these operations are stored in a
NXtransformations group. But NeXus allows them to be stored anywhere.
string "." if located in the origin. The depends_on can also point to an instance
of ``NX_coordinate_system`` if the transformations of the component depend on that
coordinate system.

Usually these operations are stored in a NXtransformations group.
But NeXus allows them to be stored anywhere.
</doc>
</field>
<group type="NXtransformations">
Expand Down
238 changes: 238 additions & 0 deletions base_classes/NXcoordinate_system.nxdl.xml
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 &lt;https://manual.nexusformat.org/design.html#the-nexus-coordinate-system&gt;`_.

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
Comment thread
lukaspie marked this conversation as resolved.
Outdated
and only one ``NXcoordinate_system`` group is found. If such a parent
Comment thread
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
Comment thread
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="."``
Comment thread
PeterC-DLS marked this conversation as resolved.
Outdated
to state that this transformation depends on the default
`NeXus coordinate system &lt;https://manual.nexusformat.org/design.html#the-nexus-coordinate-system&gt;`_
(which is the same as the one used by `McStas &lt;https://mcstas.org/&gt;`_).

For the sake of clarity, even in this case it is better
to be explicit like for every other coordinate system definition
Comment thread
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"
Comment thread
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.
Comment thread
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.
Comment thread
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"/>
Comment thread
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>
31 changes: 24 additions & 7 deletions base_classes/NXtransformations.nxdl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
type has been specified.

The entry point (``depends_on``) will be outside of this class and point to a
field in here. Following the chain may also require following ``depends_on``
links to transformations outside, for example to a common base table. If
a relative path is given, it is relative to the group enclosing the ``depends_on``
specification.
field in here (or to an instance of ``NX_coordinate_system``). Following the
chain may also require following ``depends_on`` links to transformations outside,
for example to a common base table. If a relative path is given, it is relative
to the group enclosing the ``depends_on`` specification.

For a chain of three transformations, where :math:`T_1` depends on :math:`T_2`
and that in turn depends on :math:`T_3`, the final transformation :math:`T_f` is
Expand Down Expand Up @@ -108,6 +108,14 @@
* depends_on

as needed.

NOTE

NXtransformations follows the **active** transformation convention. This means that the transformation describes
how an object is moved or rotated within the coordinate system. In other words, the transformation
actively changes the position or orientation of the object itself. This is in contrast to a **passive** transformation,
which changes the frame of reference or coordinate system, while the object remains fixed. In case it is needed
to describe multiple coordinate systems, it is strongly suggested to use the :ref:`NXcoordinate_system` base class.
</doc>
<field name="AXISNAME" nameType="any" units="NX_TRANSFORMATION" type="NX_NUMBER" maxOccurs="unbounded">
<doc>
Expand Down Expand Up @@ -148,6 +156,11 @@
For ``translation`` axes the direction should be chosen for
increasing displacement. For general axes, an appropriate direction
should be chosen.

Note that if the ``NXtransformation`` depends on a coordinate system
(i.e., its ``depends_on`` attribute points to an instance :ref:`NXcoordinate_system`),
Comment thread
PeterC-DLS marked this conversation as resolved.
the rotation is right handed in that coordinate system, even if the the coordinate system
itself is left-handed (as defined by the determinant of its base vectors).
</doc>
<dimensions rank="1">
<dim index="1" value="3" />
Expand All @@ -170,8 +183,12 @@
</attribute>
<attribute name="depends_on" type="NX_CHAR">
<doc>
Points to the path to a field defining the axis on which this
depends or the string ".".
Points to the path of a field defining the axis on which this instance of
NXtransformations depends or the string ".". It can also point to an instance of
Comment thread
lukaspie marked this conversation as resolved.
``NX_coordinate_system`` if this transformation depends on it.

If it is the string ".", it is explicitly pointing towards the default
`NeXus coordinate system &lt;https://manual.nexusformat.org/design.html#the-nexus-coordinate-system&gt;`_.
</doc>
</attribute>
<attribute name="equipment_component" type="NX_CHAR">
Expand Down Expand Up @@ -202,7 +219,7 @@
the corresponding axis moves during the exposure of a frame. Ideally, the
value of this field added to each value of ``AXISNAME`` would agree with the
corresponding values of ``AXISNAME_end``, but there is a possibility of significant
differences. Use of ``AXISNAME_end`` is recommended.
differences. Use of ``AXISNAME_end`` is recommended.
</doc>
</field>
</definition>