[NeXus-committee] NeXus data file inspection tool. NeXus at ILL. We need to be more flexible.

Osborn, Raymond rosborn at anl.gov
Tue Sep 2 17:04:13 BST 2014


On Sep 2, 2014, at 8:32 AM, Pete Jemian <prjemian at gmail.com> wrote:

> NeXpy's implementation of the tree API was designed for use on NeXus files.  It is likely to complain about structure in an HDF5 file that is not compliant with the NeXus standard (for example: the appearance of an HDF group with attribute NX_class="NXpete" since there is no such NeXus NXDL).


NeXpy never complains. It is designed to be as liberal as possible, while still encouraging conformation with existing definitions by showing valid field names and group classes according to the context.  It won’t offer ‘NXpete' as a class in any pull-down menu - those are automatically produced by the NXDL files - but you could create one with that class and it would inherit all the attributes and functions of the base NXgroup class. In fact, it will read in an HDF5 file without any classes defined at all.

>>> import h5py as h5
>>> a=h5.File('test.h5','w')
>>> a['b/c']=np.array((1,2,3,4,5))
>>> a.close()
>>> c=nx.load('test.h5')
>>> print d.tree
root:NXroot
  b:NXgroup
    c = [1 2 3 4 5]

If you want to create your own classes, you are able to do so:

>>>  e=NXroot(NXgroup(nxclass='NXpete'))
>>> print e.tree
root:NXroot
  pete:NXpete

This is a frivolous example, but this feature can be very useful. I want NeXpy to be used as  a testbed for new ideas - if someone wants to try out a new class before getting it formally ratified, then I don’t want to stop them. 

Ray
-- 
Ray Osborn, Senior Scientist
Materials Science Division
Argonne National Laboratory
Argonne, IL 60439, USA
Phone: +1 (630) 252-9011
Email: ROsborn at anl.gov





More information about the NeXus-committee mailing list