Does scipp support dependent/conditional indices across dimensions? #3165
-
This may be answered by working through docs, but I thought I'd just ask about the feature here. Does With this I mean, an index set that may be conditional on an index in a lower level/dimension. An example would be a collection of measurements at temperature/pressure points. Where the pressure range you are able to measure depends on the temperature, and where the granularity (step size) of pressure you measure at depends on temperature. Because otherwise your device explodes or whatever. This would be a great feature to have! On the code side, I explicitly mean conditional index sets, not using "NA" or similar in a Cartesian product index. Because NA can mean many things, for instance one can't easily distinguish whether it corresponds to a failed measurement, or whether the measurement wasn't even attempted (or makes no sense). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
There is some support for this in form of "multi-dimensional coordinates", albeit potentially too limited for some applications. The main limitation is that the array sizes have to be regular, i.e. rectangular. Here is an example: import scipp as sc
temperature = sc.linspace('T', 1, 4, num=3, unit='K')
pressure = sc.array(
dims=('T', 'p'), unit='MPa', values=[[1, 2, 3], [1.5, 2.5, 3.5], [2, 4, 6]]
)
da = sc.DataArray(temperature * pressure, coords={'T': temperature, 'p': pressure})
da.plot() Note some more limitations:
Aside from this, Scipp supports Binned Data. This may be the right choice if you have measurements of more random nature, which you later want to histogram. This would also allow for storing data with sub-lists of unequal length.
In case the requirement for rectangular arrays with multi-dim coordinates is too limiting, also note Scipp's support for Masking. This is more powerful than Numpy's masked arrays, since Scipp uses a dictionary of masks. With this one could use NAN for values that were not measured while maintaining a named mask that indicates the meaning of those NAN values. This would allow for distinguishing different reasons for NAN values. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the swift reply, @SimonHeybrock! The array index feature is nice! Slightly disappointed that it's not possible without nans, but that's how it usually is. Multi-column index for long format is of course always an option. |
Beta Was this translation helpful? Give feedback.
There is some support for this in form of "multi-dimensional coordinates", albeit potentially too limited for some applications.
The main limitation is that the array sizes have to be regular, i.e. rectangular. Here is an example:
Note some more limitations: