[Nexus] Correct way to specify multiple signals
V. Armando Solé
sole at esrf.fr
Fri Jan 12 16:32:18 GMT 2018
Hi Ray,
On 12/01/2018 15:53, Osborn, Raymond wrote:
> Here’s one that needs clarification. In Pete Jemian’s SPEC importer,
> he converts meshes into 2D data, producing an NXdata like this:
>
> data:NXdata
> @axes = [‘K’ ‘H']
> @signal = ‘NaI'
> @auxiliary = [‘detector’ ‘ic0’ ‘ic1’ ‘ic2’ ic3’]
> @auxiliary_axes = [[‘K’ ‘H’] [‘K’ ‘H’] [‘K’ ‘H’] [‘K’ ‘H’] [‘K’ ‘H’]]
> Epoch = float64(16x16)
> H = float64(16)
> K = float64(16)
> L = float64(16x16)
> NaI = float64(16x16)
> Ring = float64(16x16)
> Seconds = float64(16x16)
> detector = float64(16x16)
> ic0 = float64(16x16)
> ic1 = float64(16x16)
> ic2 = float64(16x16)
> ic3 = float64(16x16)
>
> As you can see, I added attributes following what I believe is one of
> the suggestions for allowing extra signals. Since the data is 2-D, the
> axes are size-2 arrays, so each auxiliary axis also has to be an array
> of size-2 arrays matching the axes.
It seems the one that wants to anticipate any possible plot is you :-)
Concerning your example:
- It is obvious that since axes is an array, auxiliary_axes would always
have to be an array of arrays when needed.
- If all the signals share the same axes (*my original proposal and with
which I would be satisfied*), specifying auxiliary_signals is enough.
As Jacob pointed out, to support different number of points is a new
feature that needs approval first prior to decide about its implementation.
Concerning your example, I do not see any problem visualizing that plot
except that you would have several images sharing the same axes. How to
visualize that is a choice of the visualization program. The simplest
solution would be to visualize the first signal and the rest of signals
browsed with a slider. Allowing cuts in depth and so on. Easy.
BTW I find very unfortunate the choice of the conversion program from
Pete to try to force image plots when what you have there is a scatter
plot and it should be visualized as such. In your original file you
surely had either 16x16 values of H, K and L or 1 (if not changed).
Again adding multiple scatter plots is also easy.
If your limitations come from a very simplified use of matplotlib, then
your visualization tool can keep visualizing the original signal. To
have that plot with our tools (silx which uses matplotlib or OpenGL at
wish) is not a problem. If it makes sense or not is a different thing,
but that would have been the choice of the guy that wrote the NXdata
group and the visualization program could always default to what it is
able to do. That is the beauty of the solution.
Again, with auxiliary_signals we would have enough and in this example
auxiliary_axes is not needed.
> (By the way, the latest version of the standard requires extra
> attributes of the form ‘Two_Theta_indices’ stating what dimension they
> refer to - it’s not an aspect of the standard that I support, but it
> would make the above example much more complicated).
>
> Note that, without the auxiliary attributes, the above is a
> NeXus-conforming data set, so it already contains multiple signals and
> multiple axes.
>
> OK - I think everyone is thinking of 1-D arrays, because it’s
> difficult to overplot 2-D arrays, but 1D arrays have their
> difficulties as well.
>
> data:NXdata
> @axes = 'Two_Theta'
> @signal = 'NaI'
> @auxiliary = [‘detector’ ‘ic0’ ‘ic1’ ‘ic2’ ic3’]
> @auxiliary_axes = [’Seconds’, ‘Epoch’, ‘Epoch’, ’Two_Theta']
Again, it seems the one that wants to anticipate any possible plot is
you :-)
Your number of auxiliary_signals and auxiliary_axes do not match.
For auxiliary_axes to work it has two be always 2D array:
In your case it would be (I have added one):
@auxiliary_axes = [[’Seconds’], [‘Epoch’], [‘Epoch’], [’Two_Theta'],
[’Two_Theta']]
Concerning the difficulty to do those things with matplotlib, I invite
you to use our silx library.
If you want to put the things more challenging (honestly I find your
examples were too easy), you should have provided an example containing
1D and 2D data on the same NXdata (1D data requiring one axis, 2D data
requiring two axes) and still we would be able to visualize it. If no
limit is set, the specification support mixing lines, scatter plots and
images on the same plot. We are able to do all that while still using
matplotlib. Again, if it makes sense or not is a different thing, but
that would have been the choice of the guy that wrote the NXdata group
and not the choice of this community or of a program that does not know
how to visualize those plots.
The beauty of the solution is that any NeXus visualization program can
always default to what it is able to do. It some cases it will be to
plot a single miserable signal.
Armando
More information about the NeXus
mailing list