.. auto-generated by dev_tools.docs.nxdl from the NXDL source base_classes/NXdata.nxdl.xml -- DO NOT EDIT .. index:: ! NXdata (base class) ! data (base class) see: data (base class); NXdata .. _NXdata: ====== NXdata ====== .. Contributors List .. |contrib_name| replace:: Thomas A Caswell|tacaswell|https://avatars.githubusercontent.com/u/199813?v=4|2025-03-12 .. |contrib_name| replace:: Woutdenolf|woutdenolf|https://avatars.githubusercontent.com/u/7264703?v=4|2025-01-06 .. |contrib_name| replace:: Pete R Jemian|prjemian|https://avatars.githubusercontent.com/u/2279984?v=4|2024-09-30 **Status**: base class, extends :ref:`NXobject` **Description**: .. collapse:: The :ref:`NXdata` class is designed to encapsulate all the information required ... The :ref:`NXdata` class is designed to encapsulate all the information required for a set of data to be plotted. NXdata groups contain plottable data (also referred to as *signals* or *dependent variables*) and their associated axis coordinates (also referred to as *axes* or *independent variables*). The actual names of the :ref:`DATA ` and :ref:`AXISNAME ` fields can be chosen :ref:`freely `, as indicated by the upper case (this is a common convention in all NeXus classes). .. note:: ``NXdata`` provides data and coordinates to be plotted but does not describe how the data is to be plotted or even the dimensionality of the plot. https://www.nexusformat.org/NIAC2018Minutes.html#nxdata-plottype--attribute .. include:: data/index.rst :start-line: 1 .. admonition:: Example of a simple curve plot .. code-block:: data:NXdata @signal = "data" @axes = ["x"] data: float[100] x: float[100] More complex cases are supported * histogram data: ``x`` has one more value than ``data``. * alternative axes: instead of a single ``x`` axis you can have several axes, one of which being the default. * signals with more than one dimension: ``data`` could be 2D with axes ``x`` and ``y`` along each dimension. * axes with more than one dimension: ``data`` could be 2D with axes ``x`` and ``y`` also being 2D, providing a unique ``(x, y)`` coordinate for each ``data`` point. **Signals:** .. index:: plotting .. admonition:: Defined by * :ref:`DATA ` fields * the :ref:`signal ` attribute * the :ref:`auxiliary_signals` attribute The :ref:`DATA ` fields contain the signal values to be plotted. The name of the field to be used as the *default plot signal* is provided by the :ref:`signal ` attribute. The names of the fields to be used as *secondary plot signals* are provided by the :ref:`auxiliary_signals` attribute. .. admonition:: An example with three signals, one of which being the default .. code-block:: data:NXdata @signal = "data1" @auxiliary_signals = ["data2", "data3"] data1: float[10,20,30] # the default signal data2: float[10,20,30] data3: float[10,20,30] **Axes:** .. index:: axes (attribute) .. index:: coordinates .. admonition:: Defined by * :ref:`AXISNAME ` fields * the :ref:`axes ` attribute * :ref:`AXISNAME_indices ` attributes The fields and attributes are defined as follows 1. The :ref:`AXISNAME ` fields contain the axis coordinates associated with the signal values. 2. The :ref:`axes ` attribute provides the names of the :ref:`AXISNAME ` fields to be used as the `default axis` for each dimension of the :ref:`DATA ` fields. 3. The :ref:`AXISNAME_indices ` attributes describe the :ref:`DATA ` dimensions spanned by the corresponding :ref:`AXISNAME ` fields. The fields and attributes have the following constraints 1. The length of the :ref:`axes ` attribute must be equal to the rank of the :ref:`DATA ` fields. When a particular dimension has no default axis, the string “.” is used in that position. 2. The number of values in :ref:`AXISNAME_indices ` must be equal to the rank of the corresponding :ref:`AXISNAME ` field. 3. When :ref:`AXISNAME_indices ` is missing for a given :ref:`AXISNAME ` field, the positions of the :ref:`AXISNAME ` field name in the :ref:`axes ` attribute are used. 4. When :ref:`AXISNAME_indices ` is the same as the indices of "AXISNAME" in the :ref:`axes ` attribute, there is no need to provide :ref:`AXISNAME_indices `. 5. The indices of "AXISNAME" in the :ref:`axes ` attribute must be a subset of :ref:`AXISNAME_indices `. 6. The shape of an :ref:`AXISNAME ` field must correspond to the shape of the :ref:`DATA ` dimensions it spans. This means that for each dimension ``i`` in ``[0, AXISNAME.ndim)`` spanned by axis field :ref:`AXISNAME `, the number of axis values ``AXISNAME.shape[i]`` along dimension ``i`` must be equal to the number of data points ``DATA.shape[AXISNAME_indices[i]]`` along dimension ``i`` or one more than the number of data points ``DATA.shape[AXISNAME_indices[i]]+1`` in case the :ref:`AXISNAME ` field contains histogram bin edges along dimension ``i``. Highlight consequences of these constraints 1. An :ref:`AXISNAME ` field can have more than one dimension and can therefore span more than one :ref:`DATA ` dimension. Conversely, one :ref:`DATA ` dimension can be spanned by more than one :ref:`AXISNAME ` field. The default axis name (if any) of each dimension can be found in the :ref:`axes ` attribute. 2. A list of all available axes is not provided directly. All strings in the :ref:`axes ` attribute (excluding the “.” string) are axis field names. In addition the prefix of an attribute ending with the string "_indices" is also an axis field name. .. admonition:: The following example covers all axes features supported (see :ref:`sphx_glr_classes_base_classes_data_plot_fscan2d.py`) .. code-block:: data:NXdata @signal = "data" @axes = ["x_set", "y_set", "."] # default axes for all three dimensions @x_encoder_indices = [0, 1] @y_encoder_indices = 1 # or [1] data: float[10,7,1024] x_encoder: float[11,7] # coordinates along the first and second dimensions y_encoder: float[7] # coordinates along the second dimension x_set: float[10] # default coordinates along the first dimension y_set: float[7] # default coordinates along the second dimension **Uncertainties:** .. admonition:: Defined by * :ref:`FIELDNAME_errors ` fields Standard deviations on data values as well as coordinates can be provided by :ref:`FIELDNAME_errors ` fields where ``FIELDNAME`` is the name of a :ref:`DATA ` field or an :ref:`AXISNAME ` field. .. admonition:: An example of uncertainties on the signal, auxiliary signals and axis coordinates .. code-block:: data:NXdata @signal = "data1" @auxiliary_signals = ["data2", "data3"] @axes = ["x", ".", "z"] data1: float[10,20,30] data2: float[10,20,30] data3: float[10,20,30] x: float[10] z: float[30] data1_errors: float[10,20,30] data2_errors: float[10,20,30] data3_errors: float[10,20,30] x_errors: float[10] z_errors: float[30] **Symbols**: These symbols will be used below to coordinate fields with the same shape. **dataRank**: rank of the ``DATA`` field(s) **nx**: length of the ``x`` field **ny**: length of the ``y`` field **nz**: length of the ``z`` field **Groups cited**: none **Structure**: .. _/NXdata@signal-attribute: .. index:: signal (file attribute) **@signal**: (optional) :ref:`NX_CHAR ` .. collapse:: The value is the :ref:`name ` of the signal that contains ... .. index:: find the default plottable data .. index:: plotting .. index:: signal attribute value The value is the :ref:`name ` of the signal that contains the default plottable data. This field or link *must* exist and be a direct child of this NXdata group. It is recommended (as of NIAC2014) to use this attribute rather than adding a signal attribute to the field. See https://www.nexusformat.org/2014_How_to_find_default_data.html for a summary of the discussion. .. _/NXdata@auxiliary_signals-attribute: .. index:: auxiliary_signals (file attribute) **@auxiliary_signals**: (optional) :ref:`NX_CHAR ` .. collapse:: Array of strings holding the :ref:`names ` of additional ... .. index:: plotting Array of strings holding the :ref:`names ` of additional signals to be plotted with the :ref:`default signal `. These fields or links *must* exist and be direct children of this NXdata group. Each auxiliary signal needs to be of the same shape as the default signal. .. NIAC2018: https://www.nexusformat.org/NIAC2018Minutes.html .. _/NXdata@default_slice-attribute: .. index:: default_slice (file attribute) **@default_slice**: (optional) :ref:`NX_CHAR_OR_NUMBER ` .. collapse:: Which slice of data to show in a plot by default. This is useful especially fo ... Which slice of data to show in a plot by default. This is useful especially for datasets with more than 2 dimensions. Should be an array of length equal to the number of dimensions in the data, with the following possible values: * ".": All the data in this dimension should be included * Integer: Only this slice should be used. * String: Only this slice should be used. Use if ``AXISNAME`` is a string array. Example:: data:NXdata @signal = "data" @axes = ["image_id", "channel", ".", "."] @image_id_indices = 0 @channel_indices = 1 @default_slice = [".", "difference", ".", "."] image_id = [1, ..., nP] channel = ["threshold_1", "threshold_2", "difference"] data = uint[nP, nC, i, j] Here, a data array with four dimensions, including the number of images (nP) and number of channels (nC), specifies more dimensions than can be visualized with a 2D image viewer for a given image. Therefore the default_slice attribute specifies that the "difference" channel should be shown by default. Alternate version using an integer would look like this (note 2 is a string):: data:NXdata @signal = "data" @axes = ["image_id", "channel", ".", "."] @image_id_indices = 0 @channel_indices = 1 @default_slice = [".", "2", ".", "."] image_id = [1, ..., nP] channel = ["threshold_1", "threshold_2", "difference"] data = uint[nP, nC, i, j] .. _/NXdata@AXISNAME_indices-attribute: .. index:: AXISNAME_indices (file attribute) **@**\ :bolditalic:`AXISNAME`\ **_indices**: (optional) :ref:`NX_INT ` .. collapse:: The ``AXISNAME_indices`` attribute is a single integer or an array of integers ... The ``AXISNAME_indices`` attribute is a single integer or an array of integers that defines which :ref:`DATA ` dimensions are spanned by the corresponding axis. The first dimension index is ``0`` (zero). The number of indices must be equal to the rank of the :ref:`AXISNAME ` field. When the ``AXISNAME_indices`` attribute is missing for a given :ref:`AXISNAME ` field, its value becomes the index (or indices) of the :ref:`AXISNAME ` name in the :ref:`axes ` attribute. .. note:: When ``AXISNAME_indices`` contains multiple integers, it must be saved as an actual array of integers and not a comma separated string. .. _/NXdata@axes-attribute: .. index:: axes (file attribute) **@axes**: (optional) :ref:`NX_CHAR ` .. collapse:: The ``axes`` attribute is a list of strings which are the names of the :ref:`A ... .. index:: plotting The ``axes`` attribute is a list of strings which are the names of the :ref:`AXISNAME ` fields to be used as the default axis along every :ref:`DATA ` dimension. As a result the length must be equal to the rank of the :ref:`DATA ` fields. The string "." can be used for dimensions without a default axis. .. note:: When ``axes`` contains multiple strings, it must be saved as an actual array of strings and not a single comma separated string. .. _/NXdata/AXISNAME-field: .. index:: AXISNAME (field) :bolditalic:`AXISNAME`: (optional) :ref:`NX_CHAR_OR_NUMBER ` .. collapse:: Coordinate values along one or more :ref:`DATA ` dimension ... Coordinate values along one or more :ref:`DATA ` dimensions. The shape of an ``AXISNAME`` field must correspond to the shape of the :ref:`DATA ` dimensions it spans. This means that for each ``i`` in ``[0, AXISNAME.ndim)`` the number of data points ``DATA.shape[AXISNAME_indices[i]]`` must be equal to the number of coordinates ``AXISNAME.shape[i]`` or the number of bin edges ``AXISNAME.shape[i]+1`` in case of histogram data. As the upper case ``AXISNAME`` indicates, the names of the ``AXISNAME`` fields can be chosen :ref:`freely `. Most ``AXISNAME`` fields will be sequences of numbers but if an axis is better represented using names, such as channel names, an array of NX_CHAR can be provided. .. _/NXdata/AXISNAME@long_name-attribute: .. index:: long_name (field attribute) **@long_name**: (optional) :ref:`NX_CHAR ` Axis label .. _/NXdata/AXISNAME@units-attribute: .. index:: units (field attribute) **@units**: (optional) :ref:`NX_CHAR ` .. collapse:: Unit in which the coordinate values are expressed. ... Unit in which the coordinate values are expressed. See the section :ref:`Design-Units` for more information. .. _/NXdata/AXISNAME@distribution-attribute: .. index:: distribution (field attribute) **@distribution**: (optional) :ref:`NX_BOOLEAN ` .. collapse:: ``0|false``: single value, ... ``0|false``: single value, ``1|true``: multiple values .. _/NXdata/AXISNAME@first_good-attribute: .. index:: first_good (field attribute) **@first_good**: (optional) :ref:`NX_INT ` Index of first good value .. _/NXdata/AXISNAME@last_good-attribute: .. index:: last_good (field attribute) **@last_good**: (optional) :ref:`NX_INT ` Index of last good value .. _/NXdata/AXISNAME@axis-attribute: .. index:: axis (field attribute) **@axis**: (optional) :ref:`NX_POSINT ` .. collapse:: Index (positive integer) identifying this specific set of numbers. ... Index (positive integer) identifying this specific set of numbers. N.B. The ``axis`` attribute is the old way of designating a link. Do not use the :ref:`axes ` attribute with the ``axis`` attribute. The :ref:`axes ` attribute is now preferred. .. _/NXdata/DATA-field: .. index:: DATA (field) :bolditalic:`DATA`: (optional) :ref:`NX_NUMBER ` (Rank: dataRank) .. collapse:: Data values to be used as the NeXus *plottable data*. As the upper case ``DATA ... .. index:: plotting Data values to be used as the NeXus *plottable data*. As the upper case ``DATA`` indicates, the names of the ``DATA`` fields can be chosen :ref:`freely `. The :ref:`signal attribute ` and :ref:`auxiliary_signals attribute` can be used to find all datasets in the ``NXdata`` that contain data values. The maximum rank is ``32`` for compatibility with backend file formats. .. _/NXdata/DATA@signal-attribute: .. index:: signal (field attribute) **@signal**: (optional) :ref:`NX_POSINT ` .. collapse:: Plottable (independent) axis, indicate index number. ... .. index:: plotting Plottable (independent) axis, indicate index number. Only one field in a :ref:`NXdata` group may have the ``signal=1`` attribute. Do not use the ``signal`` attribute with the ``axis`` attribute. .. _/NXdata/DATA@axes-attribute: .. index:: axes (field attribute) **@axes**: (optional) :ref:`NX_CHAR ` .. collapse:: Defines the names of the coordinates ... Defines the names of the coordinates (independent axes) for this data set as a colon-delimited array. NOTE: The :ref:`axes ` attribute is the preferred method of designating a link. Do not use the :ref:`axes ` attribute with the ``axis`` attribute. .. _/NXdata/DATA@long_name-attribute: .. index:: long_name (field attribute) **@long_name**: (optional) :ref:`NX_CHAR ` data label .. _/NXdata/FIELDNAME_errors-field: .. index:: FIELDNAME_errors (field) :bolditalic:`FIELDNAME`\ **_errors**: (optional) :ref:`NX_NUMBER ` :ref:`⤆ ` .. collapse:: "Errors" (meaning *uncertainties* or *standard deviations*) ... "Errors" (meaning *uncertainties* or *standard deviations*) associated with any field named ``FIELDNAME`` in this ``NXdata`` group. This can be a :ref:`DATA ` field (signal or auxiliary signal) or a :ref:`AXISNAME ` field (axis). The dimensions of the ``FIELDNAME_errors`` field must match the dimensions of the corresponding ``FIELDNAME`` field. .. _/NXdata/errors-field: .. index:: errors (field) **errors**: (optional) :ref:`NX_NUMBER ` (Rank: dataRank) .. index:: deprecated **DEPRECATED**: Use ``DATA_errors`` instead (NIAC2018) .. collapse:: Standard deviations of data values - ... Standard deviations of data values - the data array is identified by the group attribute ``signal``. The ``errors`` array must have the same dimensions as ``DATA``. Client is responsible for defining the dimensions of the data. .. _/NXdata/FIELDNAME_scaling_factor-field: .. index:: FIELDNAME_scaling_factor (field) :bolditalic:`FIELDNAME`\ **_scaling_factor**: (optional) :ref:`NX_NUMBER ` .. collapse:: An optional scaling factor to apply to the values in any field named ``FIELDNA ... An optional scaling factor to apply to the values in any field named ``FIELDNAME`` in this ``NXdata`` group. This can be a :ref:`DATA ` field (signal or auxiliary signal) or a :ref:`AXISNAME ` field (axis). The elements stored in NXdata datasets are often stored as integers for efficiency reasons and need further correction or conversion, generating floats. For example, raw values could be stored from a device that need to be converted to values that represent the physical values. The two fields FIELDNAME_scaling_factor and FIELDNAME_offset allow linear corrections using the following convention: .. code-block:: corrected values = (FIELDNAME + offset) * scaling_factor This formula will derive the values to use in downstream applications, when necessary. When omitted, the scaling factor is assumed to be 1. .. _/NXdata/FIELDNAME_offset-field: .. index:: FIELDNAME_offset (field) :bolditalic:`FIELDNAME`\ **_offset**: (optional) :ref:`NX_NUMBER ` .. collapse:: An optional offset to apply to the values in FIELDNAME (usually the signal). ... An optional offset to apply to the values in FIELDNAME (usually the signal). When omitted, the offset is assumed to be 0. See :ref:`FIELDNAME_scaling_factor ` for more information. .. _/NXdata/scaling_factor-field: .. index:: scaling_factor (field) **scaling_factor**: (optional) :ref:`NX_FLOAT ` .. index:: deprecated **DEPRECATED**: Use FIELDNAME_scaling_factor instead .. collapse:: The scaling_factor and FIELDNAME_scaling_factor fields have similar semantics. ... The scaling_factor and FIELDNAME_scaling_factor fields have similar semantics. However, scaling_factor is ambiguous in the case of multiple signals. Therefore scaling_factor is deprecated. Use FIELDNAME_scaling_factor instead, even when only a single signal is present. .. _/NXdata/offset-field: .. index:: offset (field) **offset**: (optional) :ref:`NX_FLOAT ` .. index:: deprecated **DEPRECATED**: Use FIELDNAME_offset instead .. collapse:: The offset and FIELDNAME_offset fields have similar semantics. ... The offset and FIELDNAME_offset fields have similar semantics. However, offset is ambiguous in the case of multiple signals. Therefore offset is deprecated. Use FIELDNAME_offset instead, even when only a single signal is present. .. _/NXdata/title-field: .. index:: title (field) **title**: (optional) :ref:`NX_CHAR ` Title for the plot. .. _/NXdata/x-field: .. index:: x (field) **x**: (optional) :ref:`NX_FLOAT ` (Rank: 1, Dimensions: [nx]) {units=\ :ref:`NX_ANY `} .. collapse:: This is an array holding the values to use for the x-axis of ... This is an array holding the values to use for the x-axis of data. The units must be appropriate for the measurement. This is a special case of a :ref:`AXISNAME field ` kept for backward compatibility. .. _/NXdata/y-field: .. index:: y (field) **y**: (optional) :ref:`NX_FLOAT ` (Rank: 1, Dimensions: [ny]) {units=\ :ref:`NX_ANY `} .. collapse:: This is an array holding the values to use for the y-axis of ... This is an array holding the values to use for the y-axis of data. The units must be appropriate for the measurement. This is a special case of a :ref:`AXISNAME field ` kept for backward compatibility. .. _/NXdata/z-field: .. index:: z (field) **z**: (optional) :ref:`NX_FLOAT ` (Rank: 1, Dimensions: [nz]) {units=\ :ref:`NX_ANY `} .. collapse:: This is an array holding the values to use for the z-axis of ... This is an array holding the values to use for the z-axis of data. The units must be appropriate for the measurement. This is a special case of a :ref:`AXISNAME field ` kept for backward compatibility. Hypertext Anchors ----------------- List of hypertext anchors for all groups, fields, attributes, and links defined in this class. * :ref:`/NXdata/AXISNAME-field ` * :ref:`/NXdata/AXISNAME@axis-attribute ` * :ref:`/NXdata/AXISNAME@distribution-attribute ` * :ref:`/NXdata/AXISNAME@first_good-attribute ` * :ref:`/NXdata/AXISNAME@last_good-attribute ` * :ref:`/NXdata/AXISNAME@long_name-attribute ` * :ref:`/NXdata/AXISNAME@units-attribute ` * :ref:`/NXdata/DATA-field ` * :ref:`/NXdata/DATA@axes-attribute ` * :ref:`/NXdata/DATA@long_name-attribute ` * :ref:`/NXdata/DATA@signal-attribute ` * :ref:`/NXdata/errors-field ` * :ref:`/NXdata/FIELDNAME_errors-field ` * :ref:`/NXdata/FIELDNAME_offset-field ` * :ref:`/NXdata/FIELDNAME_scaling_factor-field ` * :ref:`/NXdata/offset-field ` * :ref:`/NXdata/scaling_factor-field ` * :ref:`/NXdata/title-field ` * :ref:`/NXdata/x-field ` * :ref:`/NXdata/y-field ` * :ref:`/NXdata/z-field ` * :ref:`/NXdata@auxiliary_signals-attribute ` * :ref:`/NXdata@axes-attribute ` * :ref:`/NXdata@AXISNAME_indices-attribute ` * :ref:`/NXdata@default_slice-attribute ` * :ref:`/NXdata@signal-attribute ` **NXDL Source**: https://github.com/nexusformat/definitions/blob/main/base_classes/NXdata.nxdl.xml