A Tuesday 16 March 2010 17:45:36 Maarten Sneep escrigué:
> Hi,
> 
> I'd like to attach a configuration file to the output of some simulation
> software. This helps to improve the traceability of our results. Right now
> I'm using a filenode to attach the file. This results is an EArray with
> unsigned byte values. Very efficient, space conscious, and very hard to
> decipher with hdfview. The configuration file is an ASCII file. I don't
> know how ViTables handles this (not installed the software (yet)).
> 
> In HDF-EOS (5) some metadata is attached as an HDF5 Scalar Dataset. See
> for instance the OMI cloud product [1]. In these files a group is added
> ("HDFEOS INFORMATION") with ArchiveMetadata.0, CoreMetadata.0 and
> StructMetadata.0 scalar datasets. These appear as text 'files' within
> hdfview.
> 
> When read with pytables, the object's str representation gives:
> /HDFEOS INFORMATION/ArchiveMetadata.0 (Array()) ''
>   atom := StringAtom(itemsize=65535, shape=(), dflt='')
>   maindim := 0
>   flavor := 'numpy'
>   byteorder := 'irrelevant'
>   chunkshape := None
> 
> What is the most convenient way of storing a configuration file like this
> in a pytables file?

Well, I'd say the above (scalar Array) is good enough because it is compact 
and can be larger than 64 KB (which is a limitation for HDF5 attributes).

> Due to all the unfortunate spaces in the HDF-EOS format's group names, the
> calling sequence to arrive at the string is somewhat awkward (fname
> contains a path to an OMI file):
> 
> h5file = tables.openFile(fname, 'r')
> ArchiveMetadata = h5file.root._f_getChild('HDFEOS
> INFORMATION')._f_getChild('ArchiveMetadata.0').read()
> lines = ArchiveMetadata.tostring().strip('\x00').splitlines()
> 
> The natural naming scheme is more convenient, and will be employed in my
> files.

Definitely.  But you can also retrieve the above node as:

ArchiveMetadata = h5file.getNode('/HDFEOS INFORMATION/ArchiveMetadata.0')

which is pretty much shorter.

-- 
Francesc Alted

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to