NeXus SDS

Eric Boucher boucher at aps.anl.gov
Tue Jan 11 22:59:09 GMT 2000



> -----Original Message-----
> From: owner-nexus at anpns1.pns.anl.gov
> [mailto:owner-nexus at anpns1.pns.anl.gov]On Behalf Of Ray Osborn
> Sent: Monday, January 10, 2000 11:02 AM
> To: NEXUS at anpns1.pns.anl.gov; boucher at APS.ANL.GOV
> Subject: Re: NeXus SDS
>
>
> on 2000/1/10 10:05 AM, Eric Boucher at boucher at aps.anl.gov wrote:
>
> >
> >
> > Hi all,
> >
> > What is the apropriate way to store NeXus SDS.
> > Is it the C style   : array[z,y,x]
> > or the fortran style: array[x,y,z]
> >
> > I know that it does not make much difference if the axis SDS are stored
> > accordingly, but since user usually want to have the X axis
> horizontal, I
> > would like to know how NeXus browser are going to use the axis
> information
> > in order to have the "right" plot by default.
> > The Fortner browser and the java HDF browser use the C style,
> but I don't
> > know for the other browsers and plotting tools.
> >
>
> In fact, it's both.  I usually have to sit down quietly for a
> while to make
> sure that I have got this right whenever this subject comes up.  The basic
> message is that if you are using the Fortran API, use the Fortran
> convention; if you're using the C API, use the C convention.  The Fortran
> wrapper API automatically reverses the order of the array indices when
> passing the data to and from the C API.
>
> This makes sense, of course, because the Fortran array, a(i,j), is
> physically  stored in the same way as the C array, a[j][i].  NeXus passes
> the same data back to both API's.  You just have to reference it
> differently.  As long as you know that, there shouldn't be any problems.
>
> The main complication is with the "axis" attribute that links a dimension
> scale SDS to the relevant multidimensional data SDS.  This has
> values 1, 2,
> 3 etc. to show that it refers to the x, y, z ... etc. axes of the
> data.  In
> the Fortran API, axis = 1 means that it refers to the first dimension that
> you write down (i in the above example), whereas in the C API, axis = 1
> means that it refers to the last dimension that you write (still i in the
> above example).  In both cases, these are the fastest varying
> indices of the
> data, so it's best to think in these terms :
>
> axis = 1 - fastest-varying dimension
> axis = 2 - next-fastest-varying dimension
> etc.
>
> As you say, the other case it becomes a problem is with generic
> browsers.  I
> released a Fortran 90 terminal browser a few months ago which used the
> Fortran convention.  However, I've just finished writing a C version in
> which the arrays have the order reversed.  You have to know which version
> you are using in order to interpret the output array indices correctly.  I
> tried to make it clear by using square brackets for the C version, round
> brackets for the Fortran version.  The Fortran version is
> probably not going
> to be maintained now anyway, so perhaps we should make the C
> convention the
> usual one for generic browsers, and warn Fortran programmers to do the
> switch.
>
> This is a mine field that all mixed-language projects encounter.  If you
> have any comments on the design choices, please let us know.
>


So to sumarize we'll end up with something like that for a dataset stored
with the C style, ie A is the slowest varying dimension and D is the fastest
varying one.

signal[A     , B      , C      , D]
       ^       ^        ^        ^
dim: 	dim[0]   dim[1]   dim[2]   dim[3]
NeXus:axis=4   axis=3   axis=2   axis=1
HDF:  fakeDim0 fakeDim1 fakeDim2 fakeDim3  (will desapear)

Isn't it counter intuitive ?
I think it would be better not to mix the standards. Either use one or the
other, and since the fortran style might not be supported in the future, why
not choose the C style for the dimensions AND the axis attribute:
The data set with the highest axis attribute corresponds to the fastest
varying dimension.

This will be a big help for our NeXus files because we can have different
signal that could share the same axis data sets instead of duplicating them
and giving them different axis info.

A file that now looks like that:
NXentry
	NXdata
		signal1D[A]: signa=1
		dimension1: axis=1
	NXdata
		signal2D[A,B]: signal=1
		dimension1: axis=2   (identical as the dimension1 above but with a
different axis attr).
		dimension2: axis=1

would look like:

NXentry
	NXdata
		signal1D[A]: signal=1
		link to dimension1
	NXdata
		signal2D[A,B]: signal=1
		link to dimension1
		link to dimension2

	AXIS
		dimension1: axis=1
		dimension2: axis=2


Regards,

Eric.






More information about the NeXus mailing list