<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cansas.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ron+Ghosh</id>
	<title>canSAS - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cansas.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ron+Ghosh"/>
	<link rel="alternate" type="text/html" href="https://wiki.cansas.org/index.php?title=Special:Contributions/Ron_Ghosh"/>
	<updated>2026-05-06T14:31:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.4</generator>
	<entry>
		<id>https://wiki.cansas.org/index.php?title=HDF5_Notes_Ghosh&amp;diff=868</id>
		<title>HDF5 Notes Ghosh</title>
		<link rel="alternate" type="text/html" href="https://wiki.cansas.org/index.php?title=HDF5_Notes_Ghosh&amp;diff=868"/>
		<updated>2012-07-02T15:59:46Z</updated>

		<summary type="html">&lt;p&gt;Ron Ghosh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;                   canSAS 2D treated data&lt;br /&gt;
&amp;lt;pre&amp;gt;     &lt;br /&gt;
1. The treated data to be stored might include:&lt;br /&gt;
&lt;br /&gt;
a. sequences of 1D data, measured against a scan variable, eg temperature&lt;br /&gt;
b. one or a sequence of 2D maps, again with possibility of scan variables&lt;br /&gt;
   eg shear rate, temperature, tomography scan etc.&lt;br /&gt;
c. For neutron work the data might be recorded as multiple wave-length &lt;br /&gt;
   slices (TOF); for X-rays these might be from an energy dispersive detector&lt;br /&gt;
e. the data may be measured with polarised neutrons &lt;br /&gt;
f. results from multiple detector configurations.&lt;br /&gt;
&lt;br /&gt;
The common characteristic is the intensity, S(Q,v1,v2..), or S(Qx,Qy,v1,v2...),&lt;br /&gt;
the deviation in S, Q, Qx, Qy, v1... etc.&lt;br /&gt;
&lt;br /&gt;
In addition, continuing from the discussions of canSAS 1D XML data, it&lt;br /&gt;
is useful to add titles, short titles, and a history of precursor(s)&lt;br /&gt;
and treatment (SASprocessnote).&lt;br /&gt;
&lt;br /&gt;
Since the contents have been corrected as far as possible to remove&lt;br /&gt;
instrument characteristics there is no need to propagate these items&lt;br /&gt;
in this treated data; they remain fully described in the raw data.  It&lt;br /&gt;
should thus be possible to merge data from different instruments directly&lt;br /&gt;
at this stage (so item c. might even be results from distinct instruments).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Storage Formats&lt;br /&gt;
&lt;br /&gt;
a. The three platforms where data will be treated are PC-Windows, Macintosh-OSX,&lt;br /&gt;
   and Linux.&lt;br /&gt;
&lt;br /&gt;
b. The primary aim of the canSAS-1D format was to provide a data file which&lt;br /&gt;
   could be automatically read by existing well known programs.  The XML&lt;br /&gt;
   design allows the files to be imported easily into Excel and to be&lt;br /&gt;
   displayed clearly by most web browsers.  The stylised ASCII text can&lt;br /&gt;
   also be read easily without any tools on all three systems.  Attribute&lt;br /&gt;
   fields contained vital information, notably units, for stored values.&lt;br /&gt;
&lt;br /&gt;
c. For potentially large data sets the text readability is much less valuable.&lt;br /&gt;
&lt;br /&gt;
  Navigating large tables of numbers is impracticable.  This was recognised&lt;br /&gt;
  early by the initial proponents of NeXus, notably Jon Tischler (APS).&lt;br /&gt;
  The format proposed for NeXus was based on HDF, the Hierachical Data Format&lt;br /&gt;
  (1990-).  This stored data in system independent binary, &lt;br /&gt;
  in a single file.  For the user this was strucured superficially like&lt;br /&gt;
  a unix file structure, with possiblities of creating links (these, for&lt;br /&gt;
  example, allow creating a slab of a selected region of data as a&lt;br /&gt;
  new entity, but without actually copying the data, simply linking the&lt;br /&gt;
  remapping information to the initial data).  The attraction for very&lt;br /&gt;
  large image data with multiple parameters is evident.  Consequently&lt;br /&gt;
  a number of general data visualisation tools have been developed,&lt;br /&gt;
  and are freely available for all three computer platforms.  It was&lt;br /&gt;
  not initially designed to have large volumes of single valued metadata.&lt;br /&gt;
&lt;br /&gt;
d. The NeXus project started in 1995 with the aim of standardising storage&lt;br /&gt;
   of Neutron and Xray scattering data.  The file format chosen was HDF,&lt;br /&gt;
   based on existing tools and generic visualisation software, but only&lt;br /&gt;
   using a very limited subset for simplicity.  A hierachical dictionary of &lt;br /&gt;
   class names was created and these were attached to the hierachical data&lt;br /&gt;
   items as attributes.  The datafile components were hence navigable through these&lt;br /&gt;
   class names (see appendix 1).  The files are however standard HDF files.&lt;br /&gt;
&lt;br /&gt;
e. In 2003 the increasing limitations (complexity, lack of text methods, etc )&lt;br /&gt;
   of the HDF file format (versions 1 to 4) were finally overcome witha complete&lt;br /&gt;
   change of internal structure, creating HDF5.  The existing petabytes of data&lt;br /&gt;
   in HDF4 compatible format requires continued maintenance of the basic toolset,&lt;br /&gt;
   but all new efforts were directed to HDF5.  The NeXus project too had&lt;br /&gt;
   lead to considereable amounts of data being stored in the HDF4 format,&lt;br /&gt;
   and the NeXus programmers have striven to create a library which&lt;br /&gt;
   is transparent to the type of data file involved.  This is done at&lt;br /&gt;
   a cost of some complexity.&lt;br /&gt;
&lt;br /&gt;
f. For canSAS-2D treated data the need to map the metadata between instruments &lt;br /&gt;
   has been removed; there are few reasons to follow the guidelines for writing&lt;br /&gt;
   a NeXus compatible file.  There are problems of installing software which&lt;br /&gt;
   are dependent on other components, which themselves have dependencies &lt;br /&gt;
   (see appendix 2).   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Proposal for HDF5 based data format for canSAS-2D&lt;br /&gt;
&lt;br /&gt;
a. The necessary identifiers for treated data were discussed for canSAS-1D.&lt;br /&gt;
   The majority of items were optional.&lt;br /&gt;
   It is necessary to extend the information concerning the actual mapped&lt;br /&gt;
   data for canSAS-2D.  &lt;br /&gt;
&lt;br /&gt;
b. The prescription should be extensible. Space requirements are less important&lt;br /&gt;
   than ease of access, dumping sections and browsing.&lt;br /&gt;
&lt;br /&gt;
c. The scattering data could be stored as a sequence of data items  or&lt;br /&gt;
   It would be useful for the first data component in a group to be a &lt;br /&gt;
   2-D plottable array of corrected intensity, or simply identify with the NeXus attribute&lt;br /&gt;
   of Signal=1.  Another option option might be &lt;br /&gt;
   to interpolate this (simple bi-linear, or more sophisticated splines) &lt;br /&gt;
   onto a regular grid linear in x and y.  The plots would then be easier &lt;br /&gt;
   to compare and merge.&lt;br /&gt;
   Additional data items could include scan variables, short identifier&lt;br /&gt;
   titles etc. &lt;br /&gt;
   &lt;br /&gt;
d. In addition to the intensities there could be additional similar maps&lt;br /&gt;
   of intensity deviation, x-deviation, y-deviation, etc.  The notion of &lt;br /&gt;
   links allows the other data items from the first map to be included &lt;br /&gt;
   without needing copies, hence each component appears similar in &amp;quot;shape&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
e. The data could be stored additionally as a sequence of tuples of&lt;br /&gt;
    (S, S_dev, x, x_dev, y, y_dev, polarisation, etc..)  This would allow&lt;br /&gt;
    different measurements to be sorted and merged, for example in TOF&lt;br /&gt;
    measurements several wavelength bands could be saved separately.&lt;br /&gt;
    &lt;br /&gt;
    With the data it is also useful to include the component information &lt;br /&gt;
    and treatment information.  An attribute can contain muli-line text easily.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
f. Since a new set of classes would have to be created for NeXus anyway&lt;br /&gt;
   there seems little point in using/maintaining another package to&lt;br /&gt;
   read/write data.  It is easy to decorate the hdf5 file with the&lt;br /&gt;
   few attributes expected in a NeXus file.  &lt;br /&gt;
   &lt;br /&gt;
   a simple structure might have the following layout&lt;br /&gt;
   &lt;br /&gt;
   canSAS-2D&lt;br /&gt;
     Data&lt;br /&gt;
       S(Qx,Qy) (say 128x128,10,2)&lt;br /&gt;
         Attributes X=&amp;quot;Qx_scale&amp;quot;, Y=&amp;quot;Qy_scale&amp;quot;, Units=&amp;quot;1/cm&amp;quot;, Scan1=&amp;quot;Temperature&amp;quot;&lt;br /&gt;
         Scan2=&amp;quot;Polarisation&amp;quot;, Legend=&amp;quot;short_title&amp;quot;, Interpolation=&amp;quot;None&amp;quot;      &lt;br /&gt;
         Process=&amp;quot;multi-line analysis summary&amp;quot;, Signal=1&lt;br /&gt;
       Sdev(Qx,Qy) (128,128,10,2)&lt;br /&gt;
       Qx_scale (128)&lt;br /&gt;
       Qx_scale_dev (128)&lt;br /&gt;
       Qy_scale (128)&lt;br /&gt;
       Qy_scale_dev(128)&lt;br /&gt;
       Temperature(10)&lt;br /&gt;
       Polarisation(2)&lt;br /&gt;
     &lt;br /&gt;
     Sample&lt;br /&gt;
       Main_Title&lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Data browsing for HDF files&lt;br /&gt;
&lt;br /&gt;
Browsers can open files and restructure internal components; most importantly&lt;br /&gt;
they can not only list the contents of data fields, but usually have several&lt;br /&gt;
plotting options for 1D cuts, 2D maps etc.&lt;br /&gt;
&lt;br /&gt;
They include:&lt;br /&gt;
HDFView http://www.hdfgroup.org/hdf-java-html/hdfview/&lt;br /&gt;
HDFExplorer (semi-commercial product $39)&lt;br /&gt;
ISAW (?)&lt;br /&gt;
PyMca   http://pymca.sourceforge.net&lt;br /&gt;
&lt;br /&gt;
HDF5 Data manipulation&lt;br /&gt;
h5py http://code.google.com/p/h5py&lt;br /&gt;
The HDF5 library includes working interfaces and examples for C, C++,&lt;br /&gt;
F77, F90 and java&lt;br /&gt;
The HDF5 library is incorporated into Mathlab, IDL etc.&lt;br /&gt;
&lt;br /&gt;
The NeXus library is built on top of HDF5 and has support for python&lt;br /&gt;
and C.  The fortran90 works only on Windows.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&lt;br /&gt;
(One weakness of the NeXus project was the paucity of examples, hence&lt;br /&gt;
the divergence in local implementations.)&lt;br /&gt;
&lt;br /&gt;
Typical example files might include &lt;br /&gt;
 - simple SAS from radially symmetric data to check interpolation procedures&lt;br /&gt;
    etc.&lt;br /&gt;
 - GSAS having a pattern offset from nominal detector centre&lt;br /&gt;
 &lt;br /&gt;
 etc. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Appendix 1  Annotated summary of NeXus raw data file&lt;br /&gt;
&lt;br /&gt;
Structure of Nexus HDF5 file from HDFView&lt;br /&gt;
&lt;br /&gt;
top level 054289.nxs&lt;br /&gt;
   group size 1&lt;br /&gt;
   4 attributes&lt;br /&gt;
   HDF5_Version = 1.8.3&lt;br /&gt;
   NeXus_Version = 4.2.0&lt;br /&gt;
   file_name = /users/data/054289.nxs&lt;br /&gt;
   file_time = 2012-04-19T11:12:34+01:00&lt;br /&gt;
   &lt;br /&gt;
   entry0&lt;br /&gt;
    Group size = 14&lt;br /&gt;
    Number of attributes = 1&lt;br /&gt;
      NX_class = NXentry			! standard starting point for&lt;br /&gt;
      						! NeXus files&lt;br /&gt;
      &lt;br /&gt;
      D22                                  	! instrument name&lt;br /&gt;
      Group size = 14&lt;br /&gt;
      Number of attributes = 1&lt;br /&gt;
        NX_class = NXinstrument			!instrument components &amp;amp; values &lt;br /&gt;
	&lt;br /&gt;
	BS&lt;br /&gt;
	Group size = 12&lt;br /&gt;
	Number of attributes = 1&lt;br /&gt;
	NX_class = NXbeamstop&lt;br /&gt;
	  bx_actual&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number of attributes = 0&lt;br /&gt;
	    Value = 1.81               ! (no units!)&lt;br /&gt;
	    &lt;br /&gt;
	  bx_offset  etc&lt;br /&gt;
	Detector&lt;br /&gt;
	Group size = .....  &lt;br /&gt;
	&lt;br /&gt;
	etc. for each attenuator, collimation, selector ...  &lt;br /&gt;
     data&lt;br /&gt;
     Group size = 1&lt;br /&gt;
     Number of attributes = 1&lt;br /&gt;
       NX_class = NXdata&lt;br /&gt;
       data&lt;br /&gt;
       32-bit integer, 128 x 128 x 1&lt;br /&gt;
       Number of attributes = 1&lt;br /&gt;
         signal = 1				! shows plottable data entity&lt;br /&gt;
	   value	   table[,,]&lt;br /&gt;
	   &lt;br /&gt;
     sample&lt;br /&gt;
     Group size = 20&lt;br /&gt;
     Number of attributes = 1&lt;br /&gt;
        NX_class = NXsample&lt;br /&gt;
	  temperature			&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number or attributes = 0&lt;br /&gt;
	  san_actual 				! sample rotation angle&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number or attributes = 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Appendix 2 installing and running programs on different systems using gcc&lt;br /&gt;
&lt;br /&gt;
The dependencies for hdf based software are illustrated below.&lt;br /&gt;
 &lt;br /&gt;
Macintosh OSX, Leopard 10.5.8 (2008) with Xcode, gfortran, gcc 4.2.3&lt;br /&gt;
Linux: Fedora Core-11 (2009) gfortran, gcc 4.4&lt;br /&gt;
&lt;br /&gt;
HDFView 2.7   for pre-2010 systems, v2.8 current&lt;br /&gt;
HDF5 version 1.8.5 for pre-2010 systems..currently 1.8.9&lt;br /&gt;
     h5py 1.3.1.tar.gz  (requires python 2.5-2.6, HDF5 1.6.5 to 1.8.5)&lt;br /&gt;
      requires HDF5 built without Fortran support (needs shared libraries)&lt;br /&gt;
     NeXus-4.2.1 &lt;br /&gt;
        Notes:   requires mxml package, mxml-2.7.tar.gz&lt;br /&gt;
	&lt;br /&gt;
Several binary packages for NeXus (.dmg, .rpm failed dependencies ) all&lt;br /&gt;
finally rebuilt from source.&lt;br /&gt;
&lt;br /&gt;
To build each component requires inspecting the INSTALL information&lt;br /&gt;
to create a suitable set of libraries.  The HDF5 package built&lt;br /&gt;
easily though one of the checks in the x86_64 linux package stopped&lt;br /&gt;
the system (large number test).&lt;br /&gt;
     &lt;br /&gt;
&lt;br /&gt;
Windows - installation binaries Windows-XP for MinGW&lt;br /&gt;
    zlib-      built by MSYS&lt;br /&gt;
    hdf5-1.8.5 built by MSYS -- manually: -lws2_32 added to link library list &lt;br /&gt;
    (a binary distribution exists for Intel compilers)&lt;br /&gt;
    python-2.7.3.msi&lt;br /&gt;
    numpy-1.6.2.win32-py2.7.exe&lt;br /&gt;
    h5py-2.0.1.win32-py2.7.msi&lt;br /&gt;
    NeXus-4.2.0.zip requires mxml&lt;br /&gt;
        mxml mxml-2.7.tar.gz  hand-built libmxml.a (without MSYS)&lt;br /&gt;
&lt;br /&gt;
There are severe problems in using the most recent versions perhaps&lt;br /&gt;
linked to the changes for the x86_64 architecture.  The pre-built&lt;br /&gt;
NeXus packages all depend on the hdf4 and hdf5 and mxml libraries.&lt;br /&gt;
The last would require installing the MSYS package, or hand-building.&lt;br /&gt;
&lt;br /&gt;
Appendix 3       Summary of test file cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
Data are from mondisperse spheres (A. Rennie) D22, run 50506+&lt;br /&gt;
&lt;br /&gt;
h5dump -n cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
HDF5 &amp;quot;cd2_050506_001.h5&amp;quot; {&lt;br /&gt;
FILE_CONTENTS {&lt;br /&gt;
 group      /&lt;br /&gt;
 group      /canSAS2D&lt;br /&gt;
 group      /canSAS2D/ASample&lt;br /&gt;
 dataset    /canSAS2D/ASample/Title&lt;br /&gt;
 group      /canSAS2D/Data&lt;br /&gt;
 dataset    /canSAS2D/Data/Qx&lt;br /&gt;
 dataset    /canSAS2D/Data/Qy&lt;br /&gt;
 dataset    /canSAS2D/Data/S&lt;br /&gt;
 dataset    /canSAS2D/Data/Sdev&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
showing the structure in more detail with NeXus decorations:&lt;br /&gt;
&lt;br /&gt;
h5dump -A cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
HDF5 &amp;quot;cd2_050506_001.h5&amp;quot; {&lt;br /&gt;
GROUP &amp;quot;/&amp;quot; {&lt;br /&gt;
   GROUP &amp;quot;canSAS2D&amp;quot; {&lt;br /&gt;
      GROUP &amp;quot;ASample&amp;quot; {&lt;br /&gt;
         ATTRIBUTE &amp;quot;NXclass&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_STRING {&lt;br /&gt;
                  STRSIZE 8;&lt;br /&gt;
                  STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                  CSET H5T_CSET_ASCII;&lt;br /&gt;
                  CTYPE H5T_C_S1;&lt;br /&gt;
               }&lt;br /&gt;
            DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
            DATA {&lt;br /&gt;
            (0): &amp;quot;NXsample&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Title&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_STRING {&lt;br /&gt;
                  STRSIZE 50;&lt;br /&gt;
                  STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                  CSET H5T_CSET_ASCII;&lt;br /&gt;
                  CTYPE H5T_C_S1;&lt;br /&gt;
               }&lt;br /&gt;
            DATASPACE  SCALAR&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
      GROUP &amp;quot;Data&amp;quot; {&lt;br /&gt;
         DATASET &amp;quot;Qx&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128 ) / ( 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 3;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/A&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Qy&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128 ) / ( 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 3;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/A&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;S&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128, 128 ) / ( 128, 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Interpolation&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 4;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;None&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;NXclass&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 6;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;NXdata&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Process&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 80;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 5 ) / ( 5 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Created by apl8  27-Jun-2012 22:01:09    MASK: m12a.msk                         &amp;quot;,&lt;br /&gt;
               (1): &amp;quot; AvA1 0.0000E+00 AsA2 8.2300E-01 XvA3 0.0000E+00 XsA4 8.2300E-02 XfA5 0.0000E+00&amp;quot;,&lt;br /&gt;
               (2): &amp;quot;S... 50506  0  6.80E+02 sple A 0.4%     Sbak 50505  0  6.79E+02 MT cell         &amp;quot;,&lt;br /&gt;
               (3): &amp;quot;Cd/E 50510  0  3.40E+02 blocked beam                                            &amp;quot;,&lt;br /&gt;
               (4): &amp;quot;                                                                                &amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Signal&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STD_I32LE&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): 1&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 4;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/cm&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;x_scale&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 2;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Qx&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;y_scale&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 2;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Qy&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Sdev&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128, 128 ) / ( 128, 128 ) }&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
python h5toText.py cd2_050506_001.h5 &lt;br /&gt;
cd2_050506_001.h5&lt;br /&gt;
  canSAS2D&lt;br /&gt;
    ASample&lt;br /&gt;
      @NXclass = [&#039;NXsample&#039;]&lt;br /&gt;
      Title:char[50][] = __array&lt;br /&gt;
        __array = &lt;br /&gt;
    Data&lt;br /&gt;
      Qx:float32[128] = __array&lt;br /&gt;
        @Units = [&#039;1/A&#039;]&lt;br /&gt;
        __array = [-0.0093729430809617043, -0.0091350506991147995, -0.0088971592485904694, &#039;...&#039;, 0.020839333534240723]&lt;br /&gt;
      Qy:float32[128] = __array&lt;br /&gt;
        @Units = [&#039;1/A&#039;]&lt;br /&gt;
        __array = [-0.015177506022155285, -0.01493961364030838, -0.01470172218978405, &#039;...&#039;, 0.015034771524369717]&lt;br /&gt;
      S:float32[128,128] = __array&lt;br /&gt;
        @NXclass = [&#039;NXdata&#039;]&lt;br /&gt;
        @x_scale = [&#039;Qx&#039;]&lt;br /&gt;
        @y_scale = [&#039;Qy&#039;]&lt;br /&gt;
        @Interpolation = [&#039;None&#039;]&lt;br /&gt;
        @Units = [&#039;1/cm&#039;]&lt;br /&gt;
        @Signal = [1]&lt;br /&gt;
        @Process = [&#039;Created by apl8  27-Jun-2012 22:01:09    MASK: m12a.msk&#039;&lt;br /&gt;
 &#039; AvA1 0.0000E+00 AsA2 8.2300E-01 XvA3 0.0000E+00 XsA4 8.2300E-02 XfA5 0.0000E+00&#039;&lt;br /&gt;
 &#039;S... 50506  0  6.80E+02 sple A 0.4%     Sbak 50505  0  6.79E+02 MT cell&#039;&lt;br /&gt;
 &#039;Cd/E 50510  0  3.40E+02 blocked beam&#039; &#039;&#039;]&lt;br /&gt;
        __array = [&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0651400014758, &#039;...&#039;, 0.0]&lt;br /&gt;
            ...&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
          ]&lt;br /&gt;
      Sdev:float32[128,128] = __array&lt;br /&gt;
        __array = [&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0420599989593, &#039;...&#039;, 0.0]&lt;br /&gt;
            ...&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
          ]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The file is easily read and dumped by h5dump,&lt;br /&gt;
and may be plotted with HDFView, and PyMCA.&lt;br /&gt;
&lt;br /&gt;
The file size is 140768 bytes for 128x128 data and errors&lt;br /&gt;
The ASCII orginal data are 370694 bytes &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example data file may be obtained from&lt;br /&gt;
&lt;br /&gt;
ftp://ftp.ill.fr/pub/cs/reg/canSAS2D/cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:[[User:Ron Ghosh|Ron Ghosh]] 10:51, 2 July 2012 (CDT)&lt;/div&gt;</summary>
		<author><name>Ron Ghosh</name></author>
	</entry>
	<entry>
		<id>https://wiki.cansas.org/index.php?title=HDF5_Notes_Ghosh&amp;diff=867</id>
		<title>HDF5 Notes Ghosh</title>
		<link rel="alternate" type="text/html" href="https://wiki.cansas.org/index.php?title=HDF5_Notes_Ghosh&amp;diff=867"/>
		<updated>2012-07-02T15:51:28Z</updated>

		<summary type="html">&lt;p&gt;Ron Ghosh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;                   canSAS 2D treated data&lt;br /&gt;
&amp;lt;pre&amp;gt;     &lt;br /&gt;
1. The treated data to be stored might include:&lt;br /&gt;
&lt;br /&gt;
a. sequences of 1D data, measured against a scan variable, eg temperature&lt;br /&gt;
b. one or a sequence of 2D maps, again with possibility of scan variables&lt;br /&gt;
   eg shear rate, temperature, tomography scan etc.&lt;br /&gt;
c. For neutron work the data might be recorded as multiple wave-length &lt;br /&gt;
   slices (TOF); for X-rays these might be from an energy dispersive detector&lt;br /&gt;
e. the data may be measured with polarised neutrons &lt;br /&gt;
f. results from multiple detector configurations.&lt;br /&gt;
&lt;br /&gt;
The common characteristic is the intensity, S(Q,v1,v2..), or S(Qx,Qy,v1,v2...),&lt;br /&gt;
the deviation in S, Q, Qx, Qy, v1... etc.&lt;br /&gt;
&lt;br /&gt;
In addition, continuing from the discussions of canSAS 1D XML data, it&lt;br /&gt;
is useful to add titles, short titles, and a history of precursor(s)&lt;br /&gt;
and treatment (SASprocessnote).&lt;br /&gt;
&lt;br /&gt;
Since the contents have been corrected as far as possible to remove&lt;br /&gt;
instrument characteristics there is no need to propagate these items&lt;br /&gt;
in this treated data; they remain fully described in the raw data.  It&lt;br /&gt;
should thus be possible to merge data from different instruments directly&lt;br /&gt;
at this stage (so item c. might even be results from distinct instruments).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Storage Formats&lt;br /&gt;
&lt;br /&gt;
a. The three platforms where data will be treated are PC-Windows, Macintosh-OSX,&lt;br /&gt;
   and Linux.&lt;br /&gt;
&lt;br /&gt;
b. The primary aim of the canSAS-1D format was to provide a data file which&lt;br /&gt;
   could be automatically read by existing well known programs.  The XML&lt;br /&gt;
   design allows the files to be imported easily into Excel and to be&lt;br /&gt;
   displayed clearly by most web browsers.  The stylised ASCII text can&lt;br /&gt;
   also be read easily without any tools on all three systems.  Attribute&lt;br /&gt;
   fields contained vital information, notably units, for stored values.&lt;br /&gt;
&lt;br /&gt;
c. For potentially large data sets the text readability is much less valuable.&lt;br /&gt;
&lt;br /&gt;
  Navigating large tables of numbers is impracticable.  This was recognised&lt;br /&gt;
  early by the initial proponents of NeXus, notably Jon Tischler (APS).&lt;br /&gt;
  The format proposed for NeXus was based on HDF, the Hierachical Data Format&lt;br /&gt;
  (1990-).  This stored data in system independent binary, &lt;br /&gt;
  in a single file.  For the user this was strucured superficially like&lt;br /&gt;
  a unix file structure, with possiblities of creating links (these, for&lt;br /&gt;
  example, allow creating a slab of a selected region of data as a&lt;br /&gt;
  new entity, but without actually copying the data, simply linking the&lt;br /&gt;
  remapping information to the initial data).  The attraction for very&lt;br /&gt;
  large image data with multiple parameters is evident.  Consequently&lt;br /&gt;
  a number of general data visualisation tools have been developed,&lt;br /&gt;
  and are freely available for all three computer platforms.  It was&lt;br /&gt;
  not initially designed to have large volumes of single valued metadata.&lt;br /&gt;
&lt;br /&gt;
d. The NeXus project started in 1995 with the aim of standardising storage&lt;br /&gt;
   of Neutron and Xray scattering data.  The file format chosen was HDF,&lt;br /&gt;
   based on existing tools and generic visualisation software, but only&lt;br /&gt;
   using a very limited subset for simplicity.  A hierachical dictionary of &lt;br /&gt;
   class names was created and these were attached to the hierachical data&lt;br /&gt;
   items as attributes.  The datafile components were hence navigable through these&lt;br /&gt;
   class names (see appendix 1).  The files are however standard HDF files.&lt;br /&gt;
&lt;br /&gt;
e. In 2003 the increasing limitations (complexity, lack of text methods, etc )&lt;br /&gt;
   of the HDF file format (versions 1 to 4) were finally overcome witha complete&lt;br /&gt;
   change of internal structure, creating HDF5.  The existing petabytes of data&lt;br /&gt;
   in HDF4 compatible format requires continued maintenance of the basic toolset,&lt;br /&gt;
   but all new efforts were directed to HDF5.  The NeXus project too had&lt;br /&gt;
   lead to considereable amounts of data being stored in the HDF4 format,&lt;br /&gt;
   and the NeXus programmers have striven to create a library which&lt;br /&gt;
   is transparent to the type of data file involved.  This is done at&lt;br /&gt;
   a cost of some complexity.&lt;br /&gt;
&lt;br /&gt;
f. For canSAS-2D treated data the need to map the metadata between instruments &lt;br /&gt;
   has been removed; there are few reasons to follow the guidelines for writing&lt;br /&gt;
   a NeXus compatible file.  There are problems of installing software which&lt;br /&gt;
   are dependent on other components, which themselves have dependencies &lt;br /&gt;
   (see appendix 2).   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Proposal for HDF5 based data format for canSAS-2D&lt;br /&gt;
&lt;br /&gt;
a. The necessary identifiers for treated data were discussed for canSAS-1D.&lt;br /&gt;
   The majority of items were optional.&lt;br /&gt;
   It is necessary to extend the information concerning the actual mapped&lt;br /&gt;
   data for canSAS-2D.  &lt;br /&gt;
&lt;br /&gt;
b. The prescription should be extensible. Space requirements are less important&lt;br /&gt;
   than ease of access, dumping sections and browsing.&lt;br /&gt;
&lt;br /&gt;
c. The scattering data could be stored as a sequence of data items  or&lt;br /&gt;
   It would be useful for the first data component in a group to be a &lt;br /&gt;
   2-D plottable array of corrected intensity, or simply identify with the NeXus attribute&lt;br /&gt;
   of Signal=1.  Another option option might be &lt;br /&gt;
   to interpolate this (simple bi-linear, or more sophisticated splines) &lt;br /&gt;
   onto a regular grid linear in x and y.  The plots would then be easier &lt;br /&gt;
   to compare and merge.&lt;br /&gt;
   Additional data items could include scan variables, short identifier&lt;br /&gt;
   titles etc. &lt;br /&gt;
   &lt;br /&gt;
d. In addition to the intensities there could be additional similar maps&lt;br /&gt;
   of intensity deviation, x-deviation, y-deviation, etc.  The notion of &lt;br /&gt;
   links allows the other data items from the first map to be included &lt;br /&gt;
   without needing copies, hence each component appears similar in &amp;quot;shape&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
e. The data could be stored additionally as a sequence of tuples of&lt;br /&gt;
    (S, S_dev, x, x_dev, y, y_dev, polarisation, etc..)  This would allow&lt;br /&gt;
    different measurements to be sorted and merged, for example in TOF&lt;br /&gt;
    measurements several wavelength bands could be saved separately.&lt;br /&gt;
    &lt;br /&gt;
    With the data it is also useful to include the component information &lt;br /&gt;
    and treatment information.  An attribute can contain muli-line text easily.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
f. Since a new set of classes would have to be created for NeXus anyway&lt;br /&gt;
   there seems little point in using/maintaining another package to&lt;br /&gt;
   read/write data.  It is easy to decorate the hdf5 file with the&lt;br /&gt;
   few attributes expected in a NeXus file.  &lt;br /&gt;
   &lt;br /&gt;
   a simple structure might have the following layout&lt;br /&gt;
   &lt;br /&gt;
   canSAS-2D&lt;br /&gt;
     Data&lt;br /&gt;
       S(Qx,Qy) (say 128x128,10,2)&lt;br /&gt;
         Attributes X=&amp;quot;Qx_scale&amp;quot;, Y=&amp;quot;Qy_scale&amp;quot;, Units=&amp;quot;1/cm&amp;quot;, Scan1=&amp;quot;Temperature&amp;quot;&lt;br /&gt;
         Scan2=&amp;quot;Polarisation&amp;quot;, Legend=&amp;quot;short_title&amp;quot;, Interpolation=&amp;quot;None&amp;quot;      &lt;br /&gt;
         Process=&amp;quot;multi-line analysis summary&amp;quot;, Signal=1&lt;br /&gt;
       Sdev(Qx,Qy) (128,128,10,2)&lt;br /&gt;
       Qx_scale (128)&lt;br /&gt;
       Qx_scale_dev (128)&lt;br /&gt;
       Qy_scale (128)&lt;br /&gt;
       Qy_scale_dev(128)&lt;br /&gt;
       Temperature(10)&lt;br /&gt;
       Polarisation(2)&lt;br /&gt;
     &lt;br /&gt;
     Sample&lt;br /&gt;
       Main_Title&lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Data browsing for HDF files&lt;br /&gt;
&lt;br /&gt;
Browsers can open files and restructure internal components; most importantly&lt;br /&gt;
they can not only list the contents of data fields, but usually have several&lt;br /&gt;
plotting options for 1D cuts, 2D maps etc.&lt;br /&gt;
&lt;br /&gt;
They include:&lt;br /&gt;
HDFView http://www.hdfgroup.org/hdf-java-html/hdfview/&lt;br /&gt;
HDFExplorer (semi-commercial product $39)&lt;br /&gt;
ISAW (?)&lt;br /&gt;
PyMca   http://pymca.sourceforge.net&lt;br /&gt;
&lt;br /&gt;
HDF5 Data manipulation&lt;br /&gt;
h5py http://code.google.com/p/h5py&lt;br /&gt;
The HDF5 library includes working interfaces and examples for C, C++,&lt;br /&gt;
F77, F90 and java&lt;br /&gt;
The HDF5 library is incorporated into Mathlab, IDL etc.&lt;br /&gt;
&lt;br /&gt;
The NeXus library is built on top of HDF5 and has support for python&lt;br /&gt;
and C.  The fortran90 works only on Windows.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&lt;br /&gt;
(One weakness of the NeXus project was the paucity of examples, hence&lt;br /&gt;
the divergence in local implementations.)&lt;br /&gt;
&lt;br /&gt;
Typical example files might include &lt;br /&gt;
 - simple SAS from radially symmetric data to check interpolation procedures&lt;br /&gt;
    etc.&lt;br /&gt;
 - GSAS having a pattern offset from nominal detector centre&lt;br /&gt;
 &lt;br /&gt;
 etc. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Appendix 1  Annotated summary of NeXus raw data file&lt;br /&gt;
&lt;br /&gt;
Structure of Nexus HDF5 file from HDFView&lt;br /&gt;
&lt;br /&gt;
top level 054289.nxs&lt;br /&gt;
   group size 1&lt;br /&gt;
   4 attributes&lt;br /&gt;
   HDF5_Version = 1.8.3&lt;br /&gt;
   NeXus_Version = 4.2.0&lt;br /&gt;
   file_name = /users/data/054289.nxs&lt;br /&gt;
   file_time = 2012-04-19T11:12:34+01:00&lt;br /&gt;
   &lt;br /&gt;
   entry0&lt;br /&gt;
    Group size = 14&lt;br /&gt;
    Number of attributes = 1&lt;br /&gt;
      NX_class = NXentry			! standard starting point for&lt;br /&gt;
      						! NeXus files&lt;br /&gt;
      &lt;br /&gt;
      D22                                  	! instrument name&lt;br /&gt;
      Group size = 14&lt;br /&gt;
      Number of attributes = 1&lt;br /&gt;
        NX_class = NXinstrument			!instrument components &amp;amp; values &lt;br /&gt;
	&lt;br /&gt;
	BS&lt;br /&gt;
	Group size = 12&lt;br /&gt;
	Number of attributes = 1&lt;br /&gt;
	NX_class = NXbeamstop&lt;br /&gt;
	  bx_actual&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number of attributes = 0&lt;br /&gt;
	    Value = 1.81               ! (no units!)&lt;br /&gt;
	    &lt;br /&gt;
	  bx_offset  etc&lt;br /&gt;
	Detector&lt;br /&gt;
	Group size = .....  &lt;br /&gt;
	&lt;br /&gt;
	etc. for each attenuator, collimation, selector ...  &lt;br /&gt;
     data&lt;br /&gt;
     Group size = 1&lt;br /&gt;
     Number of attributes = 1&lt;br /&gt;
       NX_class = NXdata&lt;br /&gt;
       data&lt;br /&gt;
       32-bit integer, 128 x 128 x 1&lt;br /&gt;
       Number of attributes = 1&lt;br /&gt;
         signal = 1				! shows plottable data entity&lt;br /&gt;
	   value	   table[,,]&lt;br /&gt;
	   &lt;br /&gt;
     sample&lt;br /&gt;
     Group size = 20&lt;br /&gt;
     Number of attributes = 1&lt;br /&gt;
        NX_class = NXsample&lt;br /&gt;
	  temperature			&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number or attributes = 0&lt;br /&gt;
	  san_actual 				! sample rotation angle&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number or attributes = 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Appendix 2 installing and running programs on different systems using gcc&lt;br /&gt;
&lt;br /&gt;
The dependencies for hdf based software are illustrated below.&lt;br /&gt;
 &lt;br /&gt;
Macintosh OSX, Leopard 10.5.8 (2008) with Xcode, gfortran, gcc 4.2.3&lt;br /&gt;
Linux: Fedora Core-11 (2009) gfortran, gcc 4.4&lt;br /&gt;
&lt;br /&gt;
HDFView 2.7   for pre-2010 systems, v2.8 current&lt;br /&gt;
HDF5 version 1.8.5 for pre-2010 systems..currently 1.8.9&lt;br /&gt;
     h5py 1.3.1.tar.gz  (requires python 2.5-2.6, HDF5 1.6.5 to 1.8.5)&lt;br /&gt;
      requires HDF5 built without Fortran support (needs shared libraries)&lt;br /&gt;
     NeXus-4.2.1 &lt;br /&gt;
        Notes:   requires mxml package, mxml-2.7.tar.gz&lt;br /&gt;
	&lt;br /&gt;
Several binary packages for NeXus (.dmg, .rpm failed dependencies ) all&lt;br /&gt;
finally rebuilt from source.&lt;br /&gt;
&lt;br /&gt;
To build each component requires inspecting the INSTALL information&lt;br /&gt;
to create a suitable set of libraries.  The HDF5 package built&lt;br /&gt;
easily though one of the checks in the x86_64 linux package stopped&lt;br /&gt;
the system (large number test).&lt;br /&gt;
     &lt;br /&gt;
&lt;br /&gt;
Windows - installation binaries Windows-XP for MinGW&lt;br /&gt;
    zlib-      built by MSYS&lt;br /&gt;
    hdf5-1.8.5 built by MSYS -- manually: -lws2_32 added to link library list &lt;br /&gt;
    (a binary distribution exists for Intel compilers)&lt;br /&gt;
    python-2.7.3.msi&lt;br /&gt;
    numpy-1.6.2.win32-py2.7.exe&lt;br /&gt;
    h5py-2.0.1.win32-py2.7.msi&lt;br /&gt;
    NeXus-4.2.0.zip requires mxml&lt;br /&gt;
        mxml mxml-2.7.tar.gz  hand-built libmxml.a (without MSYS)&lt;br /&gt;
&lt;br /&gt;
There are severe problems in using the most recent versions perhaps&lt;br /&gt;
linked to the changes for the x86_64 architecture.  The pre-built&lt;br /&gt;
NeXus packages all depend on the hdf4 and hdf5 and mxml libraries.&lt;br /&gt;
The last would require installing the MSYS package, or hand-building.&lt;br /&gt;
&lt;br /&gt;
Appendix 3       Summary of test file cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
Data are from mondisperse spheres (A. Rennie) D22, run 50506+&lt;br /&gt;
&lt;br /&gt;
h5dump -n cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
HDF5 &amp;quot;cd2_050506_001.h5&amp;quot; {&lt;br /&gt;
FILE_CONTENTS {&lt;br /&gt;
 group      /&lt;br /&gt;
 group      /canSAS2D&lt;br /&gt;
 group      /canSAS2D/ASample&lt;br /&gt;
 dataset    /canSAS2D/ASample/Title&lt;br /&gt;
 group      /canSAS2D/Data&lt;br /&gt;
 dataset    /canSAS2D/Data/Qx&lt;br /&gt;
 dataset    /canSAS2D/Data/Qy&lt;br /&gt;
 dataset    /canSAS2D/Data/S&lt;br /&gt;
 dataset    /canSAS2D/Data/Sdev&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
showing the structure in more detail with NeXus decorations:&lt;br /&gt;
&lt;br /&gt;
h5dump -A cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
HDF5 &amp;quot;cd2_050506_001.h5&amp;quot; {&lt;br /&gt;
GROUP &amp;quot;/&amp;quot; {&lt;br /&gt;
   GROUP &amp;quot;canSAS2D&amp;quot; {&lt;br /&gt;
      GROUP &amp;quot;ASample&amp;quot; {&lt;br /&gt;
         ATTRIBUTE &amp;quot;NXclass&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_STRING {&lt;br /&gt;
                  STRSIZE 8;&lt;br /&gt;
                  STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                  CSET H5T_CSET_ASCII;&lt;br /&gt;
                  CTYPE H5T_C_S1;&lt;br /&gt;
               }&lt;br /&gt;
            DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
            DATA {&lt;br /&gt;
            (0): &amp;quot;NXsample&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Title&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_STRING {&lt;br /&gt;
                  STRSIZE 50;&lt;br /&gt;
                  STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                  CSET H5T_CSET_ASCII;&lt;br /&gt;
                  CTYPE H5T_C_S1;&lt;br /&gt;
               }&lt;br /&gt;
            DATASPACE  SCALAR&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
      GROUP &amp;quot;Data&amp;quot; {&lt;br /&gt;
         DATASET &amp;quot;Qx&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128 ) / ( 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 3;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/A&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Qy&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128 ) / ( 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 3;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/A&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;S&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128, 128 ) / ( 128, 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Interpolation&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 4;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;None&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;NXclass&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 6;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;NXdata&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Process&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 80;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 5 ) / ( 5 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Created by apl8  27-Jun-2012 22:01:09    MASK: m12a.msk                         &amp;quot;,&lt;br /&gt;
               (1): &amp;quot; AvA1 0.0000E+00 AsA2 8.2300E-01 XvA3 0.0000E+00 XsA4 8.2300E-02 XfA5 0.0000E+00&amp;quot;,&lt;br /&gt;
               (2): &amp;quot;S... 50506  0  6.80E+02 sple A 0.4%     Sbak 50505  0  6.79E+02 MT cell         &amp;quot;,&lt;br /&gt;
               (3): &amp;quot;Cd/E 50510  0  3.40E+02 blocked beam                                            &amp;quot;,&lt;br /&gt;
               (4): &amp;quot;                                                                                &amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Signal&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STD_I32LE&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): 1&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 4;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/cm&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;x_scale&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 2;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Qx&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;y_scale&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 2;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Qy&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Sdev&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128, 128 ) / ( 128, 128 ) }&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
python h5toText.py cd2_050506_001.h5 &lt;br /&gt;
cd2_050506_001.h5&lt;br /&gt;
  canSAS2D&lt;br /&gt;
    ASample&lt;br /&gt;
      @NXclass = [&#039;NXsample&#039;]&lt;br /&gt;
      Title:char[50][] = __array&lt;br /&gt;
        __array = &lt;br /&gt;
    Data&lt;br /&gt;
      Qx:float32[128] = __array&lt;br /&gt;
        @Units = [&#039;1/A&#039;]&lt;br /&gt;
        __array = [-0.0093729430809617043, -0.0091350506991147995, -0.0088971592485904694, &#039;...&#039;, 0.020839333534240723]&lt;br /&gt;
      Qy:float32[128] = __array&lt;br /&gt;
        @Units = [&#039;1/A&#039;]&lt;br /&gt;
        __array = [-0.015177506022155285, -0.01493961364030838, -0.01470172218978405, &#039;...&#039;, 0.015034771524369717]&lt;br /&gt;
      S:float32[128,128] = __array&lt;br /&gt;
        @NXclass = [&#039;NXdata&#039;]&lt;br /&gt;
        @x_scale = [&#039;Qx&#039;]&lt;br /&gt;
        @y_scale = [&#039;Qy&#039;]&lt;br /&gt;
        @Interpolation = [&#039;None&#039;]&lt;br /&gt;
        @Units = [&#039;1/cm&#039;]&lt;br /&gt;
        @Signal = [1]&lt;br /&gt;
        @Process = [&#039;Created by apl8  27-Jun-2012 22:01:09    MASK: m12a.msk&#039;&lt;br /&gt;
 &#039; AvA1 0.0000E+00 AsA2 8.2300E-01 XvA3 0.0000E+00 XsA4 8.2300E-02 XfA5 0.0000E+00&#039;&lt;br /&gt;
 &#039;S... 50506  0  6.80E+02 sple A 0.4%     Sbak 50505  0  6.79E+02 MT cell&#039;&lt;br /&gt;
 &#039;Cd/E 50510  0  3.40E+02 blocked beam&#039; &#039;&#039;]&lt;br /&gt;
        __array = [&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0651400014758, &#039;...&#039;, 0.0]&lt;br /&gt;
            ...&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
          ]&lt;br /&gt;
      Sdev:float32[128,128] = __array&lt;br /&gt;
        __array = [&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0420599989593, &#039;...&#039;, 0.0]&lt;br /&gt;
            ...&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
          ]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The file is easily read and dumped by h5dump,&lt;br /&gt;
and may be plotted with HDFView, and PyMCA.&lt;br /&gt;
&lt;br /&gt;
The file size is 140768 bytes for 128x128 data and errors&lt;br /&gt;
The ASCII orginal data are 370694 bytes &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
:[[User:Ron Ghosh|Ron Ghosh]] 10:51, 2 July 2012 (CDT)&lt;/div&gt;</summary>
		<author><name>Ron Ghosh</name></author>
	</entry>
	<entry>
		<id>https://wiki.cansas.org/index.php?title=HDF5_Notes_Ghosh&amp;diff=866</id>
		<title>HDF5 Notes Ghosh</title>
		<link rel="alternate" type="text/html" href="https://wiki.cansas.org/index.php?title=HDF5_Notes_Ghosh&amp;diff=866"/>
		<updated>2012-07-02T15:46:44Z</updated>

		<summary type="html">&lt;p&gt;Ron Ghosh: Proposal for canSAS-2D data using the HDF5 File Format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;                   canSAS 2D treated data&lt;br /&gt;
&amp;lt;pre&amp;gt;     &lt;br /&gt;
1. The treated data to be stored might include:&lt;br /&gt;
&lt;br /&gt;
a. sequences of 1D data, measured against a scan variable, eg temperature&lt;br /&gt;
b. one or a sequence of 2D maps, again with possibility of scan variables&lt;br /&gt;
   eg shear rate, temperature, tomography scan etc.&lt;br /&gt;
c. For neutron work the data might be recorded as multiple wave-length &lt;br /&gt;
   slices (TOF); for X-rays these might be from an energy dispersive detector&lt;br /&gt;
e. the data may be measured with polarised neutrons &lt;br /&gt;
f. results from multiple detector configurations.&lt;br /&gt;
&lt;br /&gt;
The common characteristic is the intensity, S(Q,v1,v2..), or S(Qx,Qy,v1,v2...),&lt;br /&gt;
the deviation in S, Q, Qx, Qy, v1... etc.&lt;br /&gt;
&lt;br /&gt;
In addition, continuing from the discussions of canSAS 1D XML data, it&lt;br /&gt;
is useful to add titles, short titles, and a history of precursor(s)&lt;br /&gt;
and treatment (SASprocessnote).&lt;br /&gt;
&lt;br /&gt;
Since the contents have been corrected as far as possible to remove&lt;br /&gt;
instrument characteristics there is no need to propagate these items&lt;br /&gt;
in this treated data; they remain fully described in the raw data.  It&lt;br /&gt;
should thus be possible to merge data from different instruments directly&lt;br /&gt;
at this stage (so item c. might even be results from distinct instruments).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Storage Formats&lt;br /&gt;
&lt;br /&gt;
a. The three platforms where data will be treated are PC-Windows, Macintosh-OSX,&lt;br /&gt;
   and Linux.&lt;br /&gt;
&lt;br /&gt;
b. The primary aim of the canSAS-1D format was to provide a data file which&lt;br /&gt;
   could be automatically read by existing well known programs.  The XML&lt;br /&gt;
   design allows the files to be imported easily into Excel and to be&lt;br /&gt;
   displayed clearly by most web browsers.  The stylised ASCII text can&lt;br /&gt;
   also be read easily without any tools on all three systems.  Attribute&lt;br /&gt;
   fields contained vital information, notably units, for stored values.&lt;br /&gt;
&lt;br /&gt;
c. For potentially large data sets the text readability is much less valuable.&lt;br /&gt;
&lt;br /&gt;
  Navigating large tables of numbers is impracticable.  This was recognised&lt;br /&gt;
  early by the initial proponents of NeXus, notably Jon Tischler (APS).&lt;br /&gt;
  The format proposed for NeXus was based on HDF, the Hierachical Data Format&lt;br /&gt;
  (1990-).  This stored data in system independent binary, &lt;br /&gt;
  in a single file.  For the user this was strucured superficially like&lt;br /&gt;
  a unix file structure, with possiblities of creating links (these, for&lt;br /&gt;
  example, allow creating a slab of a selected region of data as a&lt;br /&gt;
  new entity, but without actually copying the data, simply linking the&lt;br /&gt;
  remapping information to the initial data).  The attraction for very&lt;br /&gt;
  large image data with multiple parameters is evident.  Consequently&lt;br /&gt;
  a number of general data visualisation tools have been developed,&lt;br /&gt;
  and are freely available for all three computer platforms.  It was&lt;br /&gt;
  not initially designed to have large volumes of single valued metadata.&lt;br /&gt;
&lt;br /&gt;
d. The NeXus project started in 1995 with the aim of standardising storage&lt;br /&gt;
   of Neutron and Xray scattering data.  The file format chosen was HDF,&lt;br /&gt;
   based on existing tools and generic visualisation software, but only&lt;br /&gt;
   using a very limited subset for simplicity.  A hierachical dictionary of &lt;br /&gt;
   class names was created and these were attached to the hierachical data&lt;br /&gt;
   items as attributes.  The datafile components were hence navigable through these&lt;br /&gt;
   class names (see appendix 1).  The files are however standard HDF files.&lt;br /&gt;
&lt;br /&gt;
e. In 2003 the increasing limitations (complexity, lack of text methods, etc )&lt;br /&gt;
   of the HDF file format (versions 1 to 4) were finally overcome witha complete&lt;br /&gt;
   change of internal structure, creating HDF5.  The existing petabytes of data&lt;br /&gt;
   in HDF4 compatible format requires continued maintenance of the basic toolset,&lt;br /&gt;
   but all new efforts were directed to HDF5.  The NeXus project too had&lt;br /&gt;
   lead to considereable amounts of data being stored in the HDF4 format,&lt;br /&gt;
   and the NeXus programmers have striven to create a library which&lt;br /&gt;
   is transparent to the type of data file involved.  This is done at&lt;br /&gt;
   a cost of some complexity.&lt;br /&gt;
&lt;br /&gt;
f. For canSAS-2D treated data the need to map the metadata between instruments &lt;br /&gt;
   has been removed; there are few reasons to follow the guidelines for writing&lt;br /&gt;
   a NeXus compatible file.  There are problems of installing software which&lt;br /&gt;
   are dependent on other components, which themselves have dependencies &lt;br /&gt;
   (see appendix 2).   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Proposal for HDF5 based data format for canSAS-2D&lt;br /&gt;
&lt;br /&gt;
a. The necessary identifiers for treated data were discussed for canSAS-1D.&lt;br /&gt;
   The majority of items were optional.&lt;br /&gt;
   It is necessary to extend the information concerning the actual mapped&lt;br /&gt;
   data for canSAS-2D.  &lt;br /&gt;
&lt;br /&gt;
b. The prescription should be extensible. Space requirements are less important&lt;br /&gt;
   than ease of access, dumping sections and browsing.&lt;br /&gt;
&lt;br /&gt;
c. The scattering data could be stored as a sequence of data items  or&lt;br /&gt;
   It would be useful for the first data component in a group to be a &lt;br /&gt;
   2-D plottable array of corrected intensity, or simply identify with the NeXus attribute&lt;br /&gt;
   of Signal=1.  Another option option might be &lt;br /&gt;
   to interpolate this (simple bi-linear, or more sophisticated splines) &lt;br /&gt;
   onto a regular grid linear in x and y.  The plots would then be easier &lt;br /&gt;
   to compare and merge.&lt;br /&gt;
   Additional data items could include scan variables, short identifier&lt;br /&gt;
   titles etc. &lt;br /&gt;
   &lt;br /&gt;
d. In addition to the intensities there could be additional similar maps&lt;br /&gt;
   of intensity deviation, x-deviation, y-deviation, etc.  The notion of &lt;br /&gt;
   links allows the other data items from the first map to be included &lt;br /&gt;
   without needing copies, hence each component appears similar in &amp;quot;shape&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
e. The data could be stored additionally as a sequence of tuples of&lt;br /&gt;
    (S, S_dev, x, x_dev, y, y_dev, polarisation, etc..)  This would allow&lt;br /&gt;
    different measurements to be sorted and merged, for example in TOF&lt;br /&gt;
    measurements several wavelength bands could be saved separately.&lt;br /&gt;
    &lt;br /&gt;
    With the data it is also useful to include the component information &lt;br /&gt;
    and treatment information.  An attribute can contain muli-line text easily.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
f. Since a new set of classes would have to be created for NeXus anyway&lt;br /&gt;
   there seems little point in using/maintaining another package to&lt;br /&gt;
   read/write data.  It is easy to decorate the hdf5 file with the&lt;br /&gt;
   few attributes expected in a NeXus file.  &lt;br /&gt;
   &lt;br /&gt;
   a simple structure might have the following layout&lt;br /&gt;
   &lt;br /&gt;
   canSAS-2D&lt;br /&gt;
     Data&lt;br /&gt;
       S(Qx,Qy) (say 128x128,10,2)&lt;br /&gt;
         Attributes X=&amp;quot;Qx_scale&amp;quot;, Y=&amp;quot;Qy_scale&amp;quot;, Units=&amp;quot;1/cm&amp;quot;, Scan1=&amp;quot;Temperature&amp;quot;&lt;br /&gt;
         Scan2=&amp;quot;Polarisation&amp;quot;, Legend=&amp;quot;short_title&amp;quot;, Interpolation=&amp;quot;None&amp;quot;      &lt;br /&gt;
         Process=&amp;quot;multi-line analysis summary&amp;quot;, Signal=1&lt;br /&gt;
       Sdev(Qx,Qy) (128,128,10,2)&lt;br /&gt;
       Qx_scale (128)&lt;br /&gt;
       Qx_scale_dev (128)&lt;br /&gt;
       Qy_scale (128)&lt;br /&gt;
       Qy_scale_dev(128)&lt;br /&gt;
       Temperature(10)&lt;br /&gt;
       Polarisation(2)&lt;br /&gt;
     &lt;br /&gt;
     Sample&lt;br /&gt;
       Main_Title&lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Data browsing for HDF files&lt;br /&gt;
&lt;br /&gt;
Browsers can open files and restructure internal components; most importantly&lt;br /&gt;
they can not only list the contents of data fields, but usually have several&lt;br /&gt;
plotting options for 1D cuts, 2D maps etc.&lt;br /&gt;
&lt;br /&gt;
They include:&lt;br /&gt;
HDFView http://www.hdfgroup.org/hdf-java-html/hdfview/&lt;br /&gt;
HDFExplorer (semi-commercial product $39)&lt;br /&gt;
ISAW (?)&lt;br /&gt;
PyMca   http://pymca.sourceforge.net&lt;br /&gt;
&lt;br /&gt;
HDF5 Data manipulation&lt;br /&gt;
h5py http://code.google.com/p/h5py&lt;br /&gt;
The HDF5 library includes working interfaces and examples for C, C++,&lt;br /&gt;
F77, F90 and java&lt;br /&gt;
The HDF5 library is incorporated into Mathlab, IDL etc.&lt;br /&gt;
&lt;br /&gt;
The NeXus library is built on top of HDF5 and has support for python&lt;br /&gt;
and C.  The fortran90 works only on Windows.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&lt;br /&gt;
(One weakness of the NeXus project was the paucity of examples, hence&lt;br /&gt;
the divergence in local implementations.)&lt;br /&gt;
&lt;br /&gt;
Typical example files might include &lt;br /&gt;
 - simple SAS from radially symmetric data to check interpolation procedures&lt;br /&gt;
    etc.&lt;br /&gt;
 - GSAS having a pattern offset from nominal detector centre&lt;br /&gt;
 &lt;br /&gt;
 etc. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Appendix 1  Annotated summary of NeXus raw data file&lt;br /&gt;
&lt;br /&gt;
Structure of Nexus HDF5 file from HDFView&lt;br /&gt;
&lt;br /&gt;
top level 054289.nxs&lt;br /&gt;
   group size 1&lt;br /&gt;
   4 attributes&lt;br /&gt;
   HDF5_Version = 1.8.3&lt;br /&gt;
   NeXus_Version = 4.2.0&lt;br /&gt;
   file_name = /users/data/054289.nxs&lt;br /&gt;
   file_time = 2012-04-19T11:12:34+01:00&lt;br /&gt;
   &lt;br /&gt;
   entry0&lt;br /&gt;
    Group size = 14&lt;br /&gt;
    Number of attributes = 1&lt;br /&gt;
      NX_class = NXentry			! standard starting point for&lt;br /&gt;
      						! NeXus files&lt;br /&gt;
      &lt;br /&gt;
      D22                                  	! instrument name&lt;br /&gt;
      Group size = 14&lt;br /&gt;
      Number of attributes = 1&lt;br /&gt;
        NX_class = NXinstrument			!instrument components &amp;amp; values &lt;br /&gt;
	&lt;br /&gt;
	BS&lt;br /&gt;
	Group size = 12&lt;br /&gt;
	Number of attributes = 1&lt;br /&gt;
	NX_class = NXbeamstop&lt;br /&gt;
	  bx_actual&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number of attributes = 0&lt;br /&gt;
	    Value = 1.81               ! (no units!)&lt;br /&gt;
	    &lt;br /&gt;
	  bx_offset  etc&lt;br /&gt;
	Detector&lt;br /&gt;
	Group size = .....  &lt;br /&gt;
	&lt;br /&gt;
	etc. for each attenuator, collimation, selector ...  &lt;br /&gt;
     data&lt;br /&gt;
     Group size = 1&lt;br /&gt;
     Number of attributes = 1&lt;br /&gt;
       NX_class = NXdata&lt;br /&gt;
       data&lt;br /&gt;
       32-bit integer, 128 x 128 x 1&lt;br /&gt;
       Number of attributes = 1&lt;br /&gt;
         signal = 1				! shows plottable data entity&lt;br /&gt;
	   value	   table[,,]&lt;br /&gt;
	   &lt;br /&gt;
     sample&lt;br /&gt;
     Group size = 20&lt;br /&gt;
     Number of attributes = 1&lt;br /&gt;
        NX_class = NXsample&lt;br /&gt;
	  temperature			&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number or attributes = 0&lt;br /&gt;
	  san_actual 				! sample rotation angle&lt;br /&gt;
	  32-bit floating-point&lt;br /&gt;
	  Number or attributes = 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Appendix 2 installing and running programs on different systems using gcc&lt;br /&gt;
&lt;br /&gt;
The dependencies for hdf based software are illustrated below.&lt;br /&gt;
 &lt;br /&gt;
Macintosh OSX, Leopard 10.5.8 (2008) with Xcode, gfortran, gcc 4.2.3&lt;br /&gt;
Linux: Fedora Core-11 (2009) gfortran, gcc 4.4&lt;br /&gt;
&lt;br /&gt;
HDFView 2.7   for pre-2010 systems, v2.8 current&lt;br /&gt;
HDF5 version 1.8.5 for pre-2010 systems..currently 1.8.9&lt;br /&gt;
     h5py 1.3.1.tar.gz  (requires python 2.5-2.6, HDF5 1.6.5 to 1.8.5)&lt;br /&gt;
      requires HDF5 built without Fortran support (needs shared libraries)&lt;br /&gt;
     NeXus-4.2.1 &lt;br /&gt;
        Notes:   requires mxml package, mxml-2.7.tar.gz&lt;br /&gt;
	&lt;br /&gt;
Several binary packages for NeXus (.dmg, .rpm failed dependencies ) all&lt;br /&gt;
finally rebuilt from source.&lt;br /&gt;
&lt;br /&gt;
To build each component requires inspecting the INSTALL information&lt;br /&gt;
to create a suitable set of libraries.  The HDF5 package built&lt;br /&gt;
easily though one of the checks in the x86_64 linux package stopped&lt;br /&gt;
the system (large number test).&lt;br /&gt;
     &lt;br /&gt;
&lt;br /&gt;
Windows - installation binaries Windows-XP for MinGW&lt;br /&gt;
    zlib-      built by MSYS&lt;br /&gt;
    hdf5-1.8.5 built by MSYS -- manually: -lws2_32 added to link library list &lt;br /&gt;
    (a binary distribution exists for Intel compilers)&lt;br /&gt;
    python-2.7.3.msi&lt;br /&gt;
    numpy-1.6.2.win32-py2.7.exe&lt;br /&gt;
    h5py-2.0.1.win32-py2.7.msi&lt;br /&gt;
    NeXus-4.2.0.zip requires mxml&lt;br /&gt;
        mxml mxml-2.7.tar.gz  hand-built libmxml.a (without MSYS)&lt;br /&gt;
&lt;br /&gt;
There are severe problems in using the most recent versions perhaps&lt;br /&gt;
linked to the changes for the x86_64 architecture.  The pre-built&lt;br /&gt;
NeXus packages all depend on the hdf4 and hdf5 and mxml libraries.&lt;br /&gt;
The last would require installing the MSYS package, or hand-building.&lt;br /&gt;
&lt;br /&gt;
Appendix 3       Summary of test file cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
Data are from mondisperse spheres (A. Rennie) D22, run 50506+&lt;br /&gt;
&lt;br /&gt;
h5dump -n cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
HDF5 &amp;quot;cd2_050506_001.h5&amp;quot; {&lt;br /&gt;
FILE_CONTENTS {&lt;br /&gt;
 group      /&lt;br /&gt;
 group      /canSAS2D&lt;br /&gt;
 group      /canSAS2D/ASample&lt;br /&gt;
 dataset    /canSAS2D/ASample/Title&lt;br /&gt;
 group      /canSAS2D/Data&lt;br /&gt;
 dataset    /canSAS2D/Data/Qx&lt;br /&gt;
 dataset    /canSAS2D/Data/Qy&lt;br /&gt;
 dataset    /canSAS2D/Data/S&lt;br /&gt;
 dataset    /canSAS2D/Data/Sdev&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
showing the structure in more detail with NeXus decorations:&lt;br /&gt;
&lt;br /&gt;
h5dump -A cd2_050506_001.h5&lt;br /&gt;
&lt;br /&gt;
HDF5 &amp;quot;cd2_050506_001.h5&amp;quot; {&lt;br /&gt;
GROUP &amp;quot;/&amp;quot; {&lt;br /&gt;
   GROUP &amp;quot;canSAS2D&amp;quot; {&lt;br /&gt;
      GROUP &amp;quot;ASample&amp;quot; {&lt;br /&gt;
         ATTRIBUTE &amp;quot;NXclass&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_STRING {&lt;br /&gt;
                  STRSIZE 8;&lt;br /&gt;
                  STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                  CSET H5T_CSET_ASCII;&lt;br /&gt;
                  CTYPE H5T_C_S1;&lt;br /&gt;
               }&lt;br /&gt;
            DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
            DATA {&lt;br /&gt;
            (0): &amp;quot;NXsample&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Title&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_STRING {&lt;br /&gt;
                  STRSIZE 50;&lt;br /&gt;
                  STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                  CSET H5T_CSET_ASCII;&lt;br /&gt;
                  CTYPE H5T_C_S1;&lt;br /&gt;
               }&lt;br /&gt;
            DATASPACE  SCALAR&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
      GROUP &amp;quot;Data&amp;quot; {&lt;br /&gt;
         DATASET &amp;quot;Qx&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128 ) / ( 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 3;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/A&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Qy&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128 ) / ( 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 3;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/A&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;S&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128, 128 ) / ( 128, 128 ) }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Interpolation&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 4;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;None&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;NXclass&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 6;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;NXdata&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Process&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 80;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 5 ) / ( 5 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Created by apl8  27-Jun-2012 22:01:09    MASK: m12a.msk                         &amp;quot;,&lt;br /&gt;
               (1): &amp;quot; AvA1 0.0000E+00 AsA2 8.2300E-01 XvA3 0.0000E+00 XsA4 8.2300E-02 XfA5 0.0000E+00&amp;quot;,&lt;br /&gt;
               (2): &amp;quot;S... 50506  0  6.80E+02 sple A 0.4%     Sbak 50505  0  6.79E+02 MT cell         &amp;quot;,&lt;br /&gt;
               (3): &amp;quot;Cd/E 50510  0  3.40E+02 blocked beam                                            &amp;quot;,&lt;br /&gt;
               (4): &amp;quot;                                                                                &amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Signal&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STD_I32LE&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): 1&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;Units&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 4;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;1/cm&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;x_scale&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 2;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Qx&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
            ATTRIBUTE &amp;quot;y_scale&amp;quot; {&lt;br /&gt;
               DATATYPE  H5T_STRING {&lt;br /&gt;
                     STRSIZE 2;&lt;br /&gt;
                     STRPAD H5T_STR_SPACEPAD;&lt;br /&gt;
                     CSET H5T_CSET_ASCII;&lt;br /&gt;
                     CTYPE H5T_C_S1;&lt;br /&gt;
                  }&lt;br /&gt;
               DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }&lt;br /&gt;
               DATA {&lt;br /&gt;
               (0): &amp;quot;Qy&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         DATASET &amp;quot;Sdev&amp;quot; {&lt;br /&gt;
            DATATYPE  H5T_IEEE_F32LE&lt;br /&gt;
            DATASPACE  SIMPLE { ( 128, 128 ) / ( 128, 128 ) }&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
python h5toText.py cd2_050506_001.h5 &lt;br /&gt;
cd2_050506_001.h5&lt;br /&gt;
  canSAS2D&lt;br /&gt;
    ASample&lt;br /&gt;
      @NXclass = [&#039;NXsample&#039;]&lt;br /&gt;
      Title:char[50][] = __array&lt;br /&gt;
        __array = &lt;br /&gt;
    Data&lt;br /&gt;
      Qx:float32[128] = __array&lt;br /&gt;
        @Units = [&#039;1/A&#039;]&lt;br /&gt;
        __array = [-0.0093729430809617043, -0.0091350506991147995, -0.0088971592485904694, &#039;...&#039;, 0.020839333534240723]&lt;br /&gt;
      Qy:float32[128] = __array&lt;br /&gt;
        @Units = [&#039;1/A&#039;]&lt;br /&gt;
        __array = [-0.015177506022155285, -0.01493961364030838, -0.01470172218978405, &#039;...&#039;, 0.015034771524369717]&lt;br /&gt;
      S:float32[128,128] = __array&lt;br /&gt;
        @NXclass = [&#039;NXdata&#039;]&lt;br /&gt;
        @x_scale = [&#039;Qx&#039;]&lt;br /&gt;
        @y_scale = [&#039;Qy&#039;]&lt;br /&gt;
        @Interpolation = [&#039;None&#039;]&lt;br /&gt;
        @Units = [&#039;1/cm&#039;]&lt;br /&gt;
        @Signal = [1]&lt;br /&gt;
        @Process = [&#039;Created by apl8  27-Jun-2012 22:01:09    MASK: m12a.msk&#039;&lt;br /&gt;
 &#039; AvA1 0.0000E+00 AsA2 8.2300E-01 XvA3 0.0000E+00 XsA4 8.2300E-02 XfA5 0.0000E+00&#039;&lt;br /&gt;
 &#039;S... 50506  0  6.80E+02 sple A 0.4%     Sbak 50505  0  6.79E+02 MT cell&#039;&lt;br /&gt;
 &#039;Cd/E 50510  0  3.40E+02 blocked beam&#039; &#039;&#039;]&lt;br /&gt;
        __array = [&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0651400014758, &#039;...&#039;, 0.0]&lt;br /&gt;
            ...&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
          ]&lt;br /&gt;
      Sdev:float32[128,128] = __array&lt;br /&gt;
        __array = [&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
            [0.0, 0.0, 0.0420599989593, &#039;...&#039;, 0.0]&lt;br /&gt;
            ...&lt;br /&gt;
            [0.0, 0.0, 0.0, &#039;...&#039;, 0.0]&lt;br /&gt;
          ]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The file is easily read and dumped by h5dump,&lt;br /&gt;
and may be plotted with HDFView, and PyMCA.&lt;br /&gt;
&lt;br /&gt;
The file size is 140768 bytes for 128x128 data and errors&lt;br /&gt;
The ASCII orginal data are 370694 bytes &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ron Ghosh</name></author>
	</entry>
</feed>