Storing repeating structures

Ray Osborn ROsborn at anl.gov
Tue Nov 2 15:10:40 GMT 1999


on 99/11/1 5:31 AM, Chris Moreton-Smith at C.M.Moreton-Smith at rl.ac.uk wrote:

> 
> As you know, there is no standard way in NeXus of storing an array of record
> structures, something which most programming languages including FORTRAN 90
> and C will create and use quite easily.  e.g.
> 
> main()
> {
> /* Define the record structure */
> typedef struct element_struct
> {
> int a;
> float b;
> char c[10];    /* Allocated in the struct */
> } elem;
> 
> elem my_array[100];
> 
> my_array[2].a = 1;
> my_array[55].b = 99.5;
> strcpy(my_array[33].c, "a string");
> 
> /* How do we now store "my_array" in a NeXus file? */
> }
> 

Firstly, I think that this discussion should take place in the NeXus mailing
list since it addresses a major issue in NeXus rather than a detailed
programming or internal policy question.  However, since it's got this far,
we might as well finish it here.

Record structures are certainly allowed in HDF5, so that may be the eventual
solution.  However, that would entail going beyond the simplest translation
of the current format, i.e. make each SDS in HDF4 an elemental datatype in
HDF5, so it would require a major extension of the format.  I think that it
would help if you gave a concrete example from the ISIS run file so that we
could see if there were another way of solving this.  We are not creating an
abstract data language in NeXus; we are merely storing neutron data in a
portable way, so I think we should be careful about arguing from general
computer-science principles.

> The obvious way is to simply do what we do with the "Entry_" Vgroups and
> just append the index of the array element creating a set similar but
> differently named Vgroups my_array_1, my_array_2 etc.  But what if the array
> is declared as a two dimensional array (e.g. in C my_array[25][4])?.  Would
> we then write out my_array_23_2 or my_array_2_23.
> 

Each NeXus group has been predefined with a class name that is given in the
current NeXus glossary.  They are designed to contain the information about
specific elements in the instrument; these elements were chosen so that
there would not be a huge number of them e.g. there may be of order five or
six detector banks requiring separate NXdetector and NXdata groups, but not
a hundred.  Other multiple items include monitors, collimators, choppers
etc.  I would be very reluctant to have an explosion of extra NeXus groups
defining small record structures, which is why I would like to see the
specific examples you are referring to.

By the way, the naming convention for multiple items is discussed in
<http://www.neutron.anl.gov/NeXus/NeXus_contents.html#Names>.  The
convention is to add the index without an underscore.  I quote:

=====
For sequentially indexed group names, the sequential number is simply
appended to the name, e.g. filter1, filter2. This convention should be used
only for data group names, and then sparingly, because of a potential for
confusion between indexed and non-indexed names.

The datasets with multiple instances of some primitive data record should be
stored in multi-dimensional arrays rather than in differently-named HDF data
elements. 
=====

Ray
-- 
Dr Ray Osborn                Tel: +1 (630) 252-9011
Materials Science Division   Fax: +1 (630) 252-7777
Argonne National Laboratory  E-mail: ROsborn at anl.gov
Argonne, IL 60439-4845





More information about the NeXus-developers mailing list