Skip to content

Commit

Permalink
documentation (for NIAC2014 attributes)
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Feb 11, 2016
1 parent ae193c0 commit 01ff715
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
18 changes: 12 additions & 6 deletions docs/source/eznx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ Here is a simple example to write a NeXus data file using eznx:
The output of this code is an HDF5 file (binary).
It has this structure:

.. code-block:: guess
.. code-block:: text
:linenos:
eznx_example.hdf5:NeXus data file
@default = entry
entry:NXentry
@NX_class = NXentry
@default = data
data:NXdata
@NX_class = NXdata
@signal = counts
@axes = two_theta
@two_theta_indices = 0
counts --> /entry/instrument/detector/counts
two_theta --> /entry/instrument/detector/two_theta
instrument:NXinstrument
Expand All @@ -36,8 +41,6 @@ It has this structure:
@NX_class = NXdetector
counts:NX_FLOAT64[11] = __array
@units = counts
@signal = 1
@axes = two_theta
@target = /entry/instrument/detector/counts
__array = [1037.0, 2857.0, 23819.0, '...', 1321.0]
two_theta:NX_FLOAT64[11] = __array
Expand All @@ -52,11 +55,13 @@ The output of this code is an HDF5 file (binary).
It has this general structure (indentation shows HDF5 groups,
@ signs describe attributes of the preceding item):

.. code-block:: guess
.. code-block:: text
:linenos:
hdf5_file:NeXus data file
@default = S1
S1:NXentry (one NXentry for each scan)
@default = data
title = #S
T or M: #T or #M
comments: #C for entire scan
Expand All @@ -69,11 +74,12 @@ It has this general structure (indentation shows HDF5 groups,
...
data:NXdata
@description = SPEC scan data (content from #L and data lines)
@signal = I0
@axes = mr
@mr_indices = 0
Epoch:NX_FLOAT64[]
I0:NX_FLOAT64[] (last data column)
@spec_name = I0
@signal = 1
@axes = mr
mr:NX_FLOAT64[] (first data column)
...
metadata:NXcollection
Expand Down
9 changes: 6 additions & 3 deletions docs/source/h5toText.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,23 @@ Here's an example from a test data file
(**writer_1_3.h5** from the NeXus documentation [#]_):


.. code-block:: guess
.. code-block:: text
:linenos:
[linux,512]$ h5toText data/writer_1_3.h5
data/writer_1_3.h5 : NeXus data file
@default = Scan
Scan:NXentry
@NX_class = NXentry
@default = data
data:NXdata
@NX_class = NXdata
@signal = counts
@axes = two_theta
@two_theta_indices = 0
counts:NX_INT32[31] = __array
__array = [1037, 1318, 1704, '...', 1321]
@units = counts
@signal = 1
@axes = two_theta
two_theta:NX_FLOAT64[31] = __array
__array = [17.926079999999999, 17.925909999999998, 17.925750000000001, '...', 17.92108]
@units = degrees
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec2nexus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Verify the version of the installed spec2nexus::
command-line options
********************

.. code-block:: guess
.. code-block:: text
:linenos:
$ spec2nexus.py -h
Expand Down
4 changes: 2 additions & 2 deletions src/spec2nexus/eznx.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
In [3]: nxentry = eznx.makeGroup(root, 'entry', 'NXentry')
In [4]: eznx.write_dataset(nxentry, 'title', 'simple test data', default='data')
Out[4]: <HDF5 dataset "title": shape (), type "|O8">
In [5]: nxdata = eznx.makeGroup(nxentry, 'data', 'NXdata', signal='counts', axes='tth', tth_indices=[0,])
In [5]: nxdata = eznx.makeGroup(nxentry, 'data', 'NXdata', signal='counts', axes='tth', tth_indices=0)
In [6]: eznx.write_dataset(nxdata, 'tth', [10.0, 10.1, 10.2, 10.3], units='degrees')
Out[6]: <HDF5 dataset "tth": shape (4,), type "<f8">
In [7]: eznx.write_dataset(nxdata, 'counts', [1, 50, 1000, 5], units='counts')
Expand All @@ -61,7 +61,7 @@
@NX_class = NXdata
@signal = 'counts'
@axes = 'tth'
@axes_indices = [0,]
@axes_indices = 0
counts:NX_INT64[4] = [1, 50, 1000, 5]
@units = counts
@axes = tth
Expand Down
9 changes: 5 additions & 4 deletions src/spec2nexus/eznx_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@
tthData, countsData = zip(*[map(float,_.split()) for _ in I_v_TTH_DATA.strip().splitlines()])

f = eznx.makeFile(HDF5_FILE) # create the HDF5 NeXus file
f.attrs['default'] = 'entry'

nxentry = eznx.makeGroup(f, 'entry', 'NXentry')
nxentry = eznx.makeGroup(f, 'entry', 'NXentry', default='data')
nxinstrument = eznx.makeGroup(nxentry, 'instrument', 'NXinstrument')
nxdetector = eznx.makeGroup(nxinstrument, 'detector', 'NXdetector')

tth = eznx.makeDataset(nxdetector, "two_theta", tthData, units='degrees')
counts = eznx.makeDataset(nxdetector, "counts", countsData,
units='counts', signal=1, axes='two_theta')
counts = eznx.makeDataset(nxdetector, "counts", countsData, units='counts')

nxdata = eznx.makeGroup(nxentry, 'data', 'NXdata')
nxdata = eznx.makeGroup(nxentry, 'data', 'NXdata',
signal=1, axes='two_theta', two_theta_indices=0)
eznx.makeLink(nxdetector, tth, nxdata.name+'/two_theta')
eznx.makeLink(nxdetector, counts, nxdata.name+'/counts')

Expand Down

0 comments on commit 01ff715

Please sign in to comment.