Skip to content

Commit

Permalink
pull out base classes cited in NXprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Sep 23, 2024
1 parent 8dc889b commit e9b946c
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 0 deletions.
220 changes: 220 additions & 0 deletions base_classes/NXcalibration.nxdl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
<?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) 2014-2024 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="NXcalibration" extends="NXobject" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd">
<symbols>
<doc>
The symbols used in the schema to specify e.g. dimensions of arrays
</doc>
<symbol name="ncoeff">
<doc>
Number of coefficients of the calibration function
</doc>
</symbol>
<symbol name="ncal">
<doc>
Number of points of the calibrated and uncalibrated axes
</doc>
</symbol>
</symbols>
<doc>
Subclass of NXprocess to describe post-processing calibrations.
</doc>
<field name="description" type="NX_CHAR">
<doc>
A description of the procedures employed.
</doc>
</field>
<field name="physical_quantity">
<doc>
The physical quantity of the calibration, e.g.,
energy, momentum, time, etc.
</doc>
</field>
<group name="calibration_method" type="NXidentifier">
<doc>
A digital persistent identifier (e.g., DOI, ISO standard) referring to a detailed description of a
calibration method but no actual calibration data.
</doc>
</group>
<group name="calibration_reference" type="NXidentifier">
<doc>
A digital persistent identifier (e.g., a DOI) referring to a publicly available calibration measurement
used for this instrument, e.g., a measurement of a known standard containing calibration information.
The axis values may be copied or linked in the appropriate NXcalibration fields for reference.
</doc>
</group>
<group name="calibration_object" type="NXserialized">
<doc>
A file serialisation of a calibration which may not be publicly available (externally from the nexus file).

This metadata can be a documentation of the source (file) or database (entry) from which pieces
of information have been extracted for consumption (e.g. in a research data management system (RDMS)).
It is also possible to include the actual file by using the `file` field.

The axis values may be copied or linked in the appropriate NXcalibration fields for reference.
</doc>
</group>
<field name="last_process" type="NX_CHAR">
<doc>
Indicates the name of the last operation applied in the NXprocess sequence.
</doc>
</field>
<field name="applied" type="NX_BOOLEAN">
<doc>
Has the calibration been applied?
</doc>
</field>
<field name="calibration_software">
<doc>
Name of the software used for this calibration.
</doc>
<attribute name="version">
<doc>
Software version.
</doc>
</attribute>
</field>
<field name="original_axis" type="NX_FLOAT" units="NX_ANY">
<doc>
Vector containing the data coordinates in the original uncalibrated axis
</doc>
<dimensions rank="1">
<dim index="1" value="ncal"/>
</dimensions>
<attribute name="symbol">
<doc>
The symbol of the axis to be used in the fit_function, e.g., `energy`, `E`.
This should comply to the following naming rules (similar to python's naming rules):

* A variable name must start with a letter or the underscore character
* A variable name cannot start with a number
* A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
* Variable names are case-sensitive (age, Age and AGE are three different variables)
</doc>
</attribute>
<attribute name="input_path">
<doc>
The path from which this data is derived, e.g., raw detector axis.
Should be a valid NeXus path name, e.g., /entry/instrument/detector/raw.
</doc>
</attribute>
</field>
<field name="input_SYMBOL" type="NX_FLOAT" units="NX_ANY">
<doc>
Additional input axis to be used in the formula.
The part after `input_` is used as the symbol to be used in the `fit_function`, i.e.,
if the field name is `input_my_field` you should refer to this axis by `my_field` in the `fit_function`.
</doc>
<dimensions rank="1">
<dim index="1" value="ncal"/>
</dimensions>
<attribute name="input_path">
<doc>
The path from which this data is derived, e.g., raw detector axis.
Should be a valid NeXus path name, e.g., /entry/instrument/detector/raw.
</doc>
</attribute>
</field>
<field name="coefficients" type="NX_FLOAT" units="NX_ANY">
<doc>
For non-linear energy calibrations, e.g. in a TOF, a polynomial function is fit
to a set of features (peaks) at well defined energy positions to determine
E(TOF). Here we can store the array of fit coefficients.
</doc>
<dimensions rank="1">
<dim index="1" value="ncoeff"/>
</dimensions>
</field>
<field name="fit_function" type="NX_CHAR">
<doc>
For non-linear energy calibrations. Here we can store the formula of the
fit function.

Use a0, a1, ..., an for the coefficients, corresponding to the values in the coefficients field.

Use x0, x1, ..., xn for the nth position in the `original_axis` field.
If there is the symbol attribute specified for the `original_axis` this may be used instead of x.
If you want to use the whole axis use `x`.
Alternate axis can also be available as specified by the `input_SYMBOL` field.
The data should then be referred here by the `SYMBOL` name, e.g., for a field
name `input_my_field` it should be referred here by `my_field` or `my_field0` if
you want to read the zeroth element of the array.

The formula should be numpy compliant.
</doc>
</field>
<field name="scaling" type="NX_FLOAT" units="NX_ANY">
<doc>
For linear calibration. Scaling parameter.
This should yield the relation `calibrated_axis` = `scaling` * `original_axis` + `offset`.
</doc>
</field>
<field name="offset" type="NX_FLOAT" units="NX_ANY">
<doc>
For linear calibration. Offset parameter.
This should yield the relation `calibrated_axis` = `scaling` * `original_axis` + `offset`.
</doc>
</field>
<field name="mapping_MAPPING" type="NX_FLOAT">
<doc>
Mapping data for calibration.

This can be used to map data points from uncalibrated to calibrated values,
i.e., by multiplying each point in the input axis by the corresponding point in the mapping data.
</doc>
</field>
<field name="calibrated_axis" type="NX_FLOAT" units="NX_ANY">
<doc>
A vector representing the axis after calibration, matching the data length
</doc>
<dimensions rank="1">
<dim index="1" value="ncal"/>
</dimensions>
<attribute name="output_path">
<doc>
The path to which this data is written, e.g., the calibrated energy.
Should be a valid NeXus path name, e.g., /entry/data/energy.
</doc>
</attribute>
</field>
<group type="NXdata">
<doc>
Any data acquired/used during the calibration that does not fit the `NX_FLOAT` fields above.
NXdata groups can be used for multidimensional data which are relevant to the calibration
</doc>
</group>
<attribute name="default">
<doc>
.. index:: plotting

Declares which child group contains a path leading
to a :ref:`NXdata` group.

It is recommended (as of NIAC2014) to use this attribute
to help define the path to the default dataset to be plotted.
See https://www.nexusformat.org/2014_How_to_find_default_data.html
for a summary of the discussion.
</doc>
</attribute>
</definition>
111 changes: 111 additions & 0 deletions base_classes/NXdistortion.nxdl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?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) 2014-2024 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" name="NXdistortion" extends="NXobject" type="group" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd">
<symbols>
<doc>
The symbols used in the schema to specify e.g. dimensions of arrays
</doc>
<symbol name="nsym">
<doc>
Number of symmetry points used for distortion correction
</doc>
</symbol>
<symbol name="ndx">
<doc>
Number of points of the matrix distortion field (x direction)
</doc>
</symbol>
<symbol name="ndy">
<doc>
Number of points of the matrix distortion field (y direction)
</doc>
</symbol>
</symbols>
<doc>
Subclass of NXprocess to describe post-processing distortion correction.
</doc>
<field name="last_process" type="NX_CHAR">
<doc>
Indicates the name of the last operation applied in the NXprocess sequence.
</doc>
</field>
<field name="applied" type="NX_BOOLEAN">
<doc>
Has the distortion correction been applied?
</doc>
</field>
<field name="symmetry" type="NX_INT" units="NX_UNITLESS">
<doc>
For `symmetry-guided distortion correction`_,
where a pattern of features is mapped to the regular geometric structure expected
from the symmetry. Here we record the number of elementary symmetry operations.

.. _symmetry-guided distortion correction: https://www.sciencedirect.com/science/article/abs/pii/S0304399118303474?via%3Dihub
</doc>
</field>
<field name="original_centre" type="NX_FLOAT" units="NX_UNITLESS">
<doc>
For symmetry-guided distortion correction. Here we record the coordinates of the
symmetry centre point.
</doc>
<dimensions rank="1">
<dim index="1" value="2"/>
</dimensions>
</field>
<field name="original_points" type="NX_FLOAT" units="NX_UNITLESS">
<doc>
For symmetry-guided distortion correction. Here we record the coordinates of the
relevant symmetry points.
</doc>
<dimensions rank="2">
<dim index="1" value="nsym"/>
<dim index="2" value="2"/>
</dimensions>
</field>
<field name="cdeform_field" type="NX_FLOAT" units="NX_UNITLESS">
<doc>
Column deformation field for general non-rigid distortion corrections. 2D matrix
holding the column information of the mapping of each original coordinate.
</doc>
<dimensions rank="2">
<dim index="1" value="ndx"/>
<dim index="2" value="ndy"/>
</dimensions>
</field>
<field name="rdeform_field" type="NX_FLOAT" units="NX_UNITLESS">
<doc>
Row deformation field for general non-rigid distortion corrections. 2D matrix
holding the row information of the mapping of each original coordinate.
</doc>
<dimensions rank="2">
<dim index="1" value="ndx"/>
<dim index="2" value="ndy"/>
</dimensions>
</field>
<field name="description" type="NX_CHAR">
<doc>
Description of the procedures employed.
</doc>
</field>
</definition>
55 changes: 55 additions & 0 deletions base_classes/NXregistration.nxdl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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) 2014-2024 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" name="NXregistration" extends="NXobject" type="group" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd">
<doc>
Describes image registration procedures.
</doc>
<field name="applied" type="NX_BOOLEAN">
<doc>
Has the registration been applied?
</doc>
</field>
<field name="last_process" type="NX_CHAR">
<doc>
Indicates the name of the last operation applied in the NXprocess sequence.
</doc>
</field>
<field name="depends_on" type="NX_CHAR">
<doc>
Specifies the position by pointing to the last transformation in the
transformation chain in the NXtransformations group.
</doc>
</field>
<group type="NXtransformations">
<doc>
To describe the operations of image registration (combinations of rigid
translations and rotations)
</doc>
</group>
<field name="description" type="NX_CHAR">
<doc>
Description of the procedures employed.
</doc>
</field>
</definition>

0 comments on commit e9b946c

Please sign in to comment.