Skip to content
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

Adds multiple input axis and doi reference #98

Merged
merged 14 commits into from
Nov 2, 2023
108 changes: 94 additions & 14 deletions contributed_definitions/NXcalibration.nxdl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# 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="NXcalibration" extends="NXobject" type="group" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd">
<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
Expand All @@ -45,6 +45,36 @@
<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>
<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 in e.g. 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.
Expand All @@ -55,6 +85,47 @@
Has the calibration been applied?
</doc>
</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
Expand All @@ -72,40 +143,49 @@

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

Use x0, x1, ..., xn for the variables.
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 is 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 is should yield the relation `calibrated_axis` = `scaling` * `original_axis` + `offset`.
</doc>
</field>
<field name="calibrated_axis" type="NX_FLOAT" units="NX_ANY">
<field name="MAPPING" type="NX_FLOAT">
<doc>
A vector representing the axis after calibration, matching the data length
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>
<dimensions rank="1">
<dim index="1" value="ncal"/>
</dimensions>
</field>
<field name="original_axis" type="NX_FLOAT" units="NX_ANY">
<field name="calibrated_axis" type="NX_FLOAT" units="NX_ANY">
<doc>
Vector containing the data coordinates in the original uncalibrated axis
A vector representing the axis after calibration, matching the data length
</doc>
<dimensions rank="1">
<dim index="1" value="ncal"/>
</dimensions>
</field>
<field name="description" type="NX_CHAR">
<doc>
A description of the procedures employed.
</doc>
<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>
</definition>
59 changes: 59 additions & 0 deletions contributed_definitions/NXidentifier.nxdl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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-2022 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="NXidentifier" extends="NXobject" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd">
<doc>
An identifier for a (persistent) resource, e.g., a DOI or orcid.
</doc>
<field name="service" type="NX_CHAR">
<doc>
The service by which the resouce can be resolved.
If the service is not in the list a simple `url` may be used.
The `url` can either be a resolving service for the `identifier`
or a fully qualified identification in itself.
</doc>
<enumeration>
<item value="doi"/>
<item value="urn"/>
<item value="hdl"/>
<item value="purl"/>
<item value="orcid"/>
<item value="iso"/>
<item value="url"/>
</enumeration>
</field>
<field name="identifier" type="NX_CHAR">
<doc>
The unique code, IRI or hash to resolve this reference.
Typically, this is stated by the service which is considered a complete
identifier, e.g., for a DOI it's something of the form `10.1107/S1600576714027575`
or `https://doi.org/10.1107/S1600576714027575`, which are both resolvable.
</doc>
</field>
<field name="is_persistent" type="NX_BOOLEAN">
<doc>
True if the identifier is persistent (i.e., unique and available indefinetely),
False otherwise.
</doc>
</field>
</definition>
76 changes: 76 additions & 0 deletions contributed_definitions/NXserialized.nxdl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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-2022 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="NXserialized" extends="NXobject" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd">
<doc>
Metadata to a set of pieces of information of a resource that has been serialized.

A typical use case is the documentation of the source (file) or database (entry)
from which pieces of information have been extracted for consumption in e.g. a
research data management system (RDMS). This may be for reasons of enabling
services such as providing access to normalized information for which reading
again from the resource may not be desired, possibe, or feasible.

Possible reasons could be the extraction of specific information for caching,
performance reasons, or re-evaluate given pieces of information based on other
views and interaction patterns with the data where information has been formatted
differently by tools than how these pieces of information were originally
serialized.
</doc>
<field name="type" type="NX_CHAR">
<doc>
Answers into what resource the information was serialized.
</doc>
<enumeration>
<item value="file"/>
<item value="database"/>
</enumeration>
</field>
<field name="path" type="NX_CHAR">
<doc>
Path to the resource.

E.g. the name of a file or its absolute or relative path, or the
identifier to a resource in another database.
</doc>
</field>
<field name="checksum" type="NX_CHAR">
<doc>
Value of the checksum obtain when running algorithm on the resource.
</doc>
</field>
<field name="algorithm" type="NX_CHAR">
<doc>
Name of the algorithm whereby the checksum was computed.
</doc>
<enumeration>
<item value="md5"/>
<item value="sha256"/>
</enumeration>
</field>
<group name="file" type="NXnote">
<doc>
Extracted file containing the serialized information.
</doc>
</group>
</definition>
Loading
Loading