nexusformat / NIAC

Issue for the NIAC to discuss (no code)
2 stars 0 forks source link

Support for non-dimensional coordinates in NXdata #139

Open sanbrock opened 1 year ago

sanbrock commented 1 year ago

The python library xarrays specifies the so called non-dimension coordinates

Let us imagine we make a 2D mesh scan and collect the results in a 2D array (x,y). Also, we make another 2D array (x,y) for the timestamps of each measurements at the given location. We may want to plot the results (from their original 2D (x,y) array) against the time. So we need to build a new coordinate of time from its 2D array. The same transformation needed for the time array linearisation should be also applied on the results array. Another example from xarrays

Such description would also support describing sheared axes and make proper plots when axes are not orthogonal to one another, etc. #102

sanbrock commented 1 year ago

A possibility to implement this in NXdata.nxdl is a new attribute:

@NON_DIMENSION_axis:NX_CHAR This represents a coordinate axis which can be referenced among @AXES. The labels on this axis is the collection of values of the Field with the same name.

The value of this attribute is a string array listing the coordinate axes corresponding to the dimensions of the Field.

The transformation required to linearize the Field need to be applied to all data points following the listed referenced coordinate axes.

E.g. data:NXdata @signal="measurement" @axes=["x","y","time_axis"] @x_indices=0 @y_indices=1 @time_axis_indices=0 @time_axis=["x","y"] measurement: float[200,100] time_axis: float[200,100] x: float[200] y: float[100]

Since "measurement" data axes are connected to "x"and "y", when plotting against "time_axis", a 1D curve needs to be generated from the linearized "measurement" data.

benajamin commented 1 year ago

Please indicate if you would like to see this included in NeXus

benajamin commented 1 year ago

I feel that NeXus should only provide the data to be plotted and should not go so far as to give instructions on how the data should be presented.

mkoennecke commented 1 year ago

I think this goes a long way down the road of very specialized data analysis. We need to make sure that all necessary data is stored in order to make that specialized data analysis possible but not to do it in NeXus. And the data storage requirement is fulfilled.

woutdenolf commented 1 year ago

This can currently be achieved by

data:NXdata
@signal="measurement"
@axes=["x","y"]
measurement: float[200,100]
x: float[200]
y: float[100]

and

data:NXdata
@signal="measurement"
@axes=["time_axis"]
measurement: float[20000]
time_axis: float[20000]

The measurement dataset in the second NXdata group could be a virtual datasets which links to the measurement dataset in the first NXdata group. In this case if you need both NXdata groups, you are not duplicating data.