Ejemplo n.º 1
0
#!/usr/bin/env python
'''
Writes the simplest NeXus HDF5 file using 
a simple helper library with h5py and numpy calls
according to the example from Figure 1.3 
in the Introduction chapter
'''

import my_lib

INPUT_FILE = 'input.dat'
HDF5_FILE = 'writer_1_3.hdf5'

#---------------------------

tthData, countsData = my_lib.get2ColumnData(INPUT_FILE)

f = my_lib.makeFile(HDF5_FILE)
# since this is a simple example, no attributes are used at this point

nxentry = my_lib.makeGroup(f, 'Scan', 'NXentry')
nxdata = my_lib.makeGroup(nxentry, 'data', 'NXdata')

my_lib.makeDataset(nxdata, "two_theta", tthData, units='degrees')
my_lib.makeDataset(nxdata, "counts", countsData, 
                   units='counts', signal=1, axes='two_theta')

f.close()	# be CERTAIN to close the file
Ejemplo n.º 2
0
'''

import my_lib

INPUT_FILE = 'input.dat'
HDF5_FILE = 'writer_2_1.hdf5'

#---------------------------

tthData, countsData = my_lib.get2ColumnData(INPUT_FILE)

f = my_lib.makeFile(HDF5_FILE)  # create the HDF5 NeXus file

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

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

nxdata = my_lib.makeGroup(nxentry, 'data', 'NXdata')
my_lib.makeLink(nxdetector, tth, nxdata.name + '/two_theta')
my_lib.makeLink(nxdetector, counts, nxdata.name + '/counts')

f.close()  # be CERTAIN to close the file
Ejemplo n.º 3
0
#!/usr/bin/env python
"""
Writes a simple NeXus HDF5 file using h5py with links
according to the example from Figure 2.1 in the Design chapter
"""

import my_lib

INPUT_FILE = "input.dat"
HDF5_FILE = "writer_2_1.hdf5"

# ---------------------------

tthData, countsData = my_lib.get2ColumnData(INPUT_FILE)

f = my_lib.makeFile(HDF5_FILE)  # create the HDF5 NeXus file

nxentry = my_lib.makeGroup(f, "entry", "NXentry")
nxinstrument = my_lib.makeGroup(nxentry, "instrument", "NXinstrument")
nxdetector = my_lib.makeGroup(nxinstrument, "detector", "NXdetector")

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

nxdata = my_lib.makeGroup(nxentry, "data", "NXdata")
my_lib.makeLink(nxdetector, tth, nxdata.name + "/two_theta")
my_lib.makeLink(nxdetector, counts, nxdata.name + "/counts")

f.close()  # be CERTAIN to close the file
Ejemplo n.º 4
0
data = numpy.loadtxt('input.dat').T
mr_arr = data[0]
i00_arr = numpy.asarray(data[1], 'int32')

# create the HDF5 NeXus file
f = my_lib.makeFile(fileName,
                    file_name=fileName,
                    file_time=timestamp,
                    instrument="APS USAXS at 32ID-B",
                    creator="BasicWriter.py",
                    NeXus_version="4.3.0",
                    HDF5_Version=h5py.version.hdf5_version,
                    h5py_version=h5py.version.version)

nxentry = my_lib.makeGroup(f, "entry", "NXentry")
my_lib.makeDataset(nxentry, 'title', data='1-D scan of I00 v. mr')

nxdata = my_lib.makeGroup(nxentry, "mr_scan", "NXdata")

my_lib.makeDataset(nxdata,
                   "mr",
                   mr_arr,
                   units='degrees',
                   long_name='USAXS mr (degrees)')

my_lib.makeDataset(
    nxdata,
    "I00",
    i00_arr,
    units='counts',
    signal=1,  # Y axis of default plot
Ejemplo n.º 5
0
# load data from two column format
data = numpy.loadtxt('input.dat').T
mr_arr = data[0]
i00_arr = numpy.asarray(data[1],'int32')

# create the HDF5 NeXus file
f = my_lib.makeFile(fileName, file_name=fileName,
        file_time=timestamp,
        instrument="APS USAXS at 32ID-B",
        creator="BasicWriter.py",
        NeXus_version="4.3.0",
        HDF5_Version=h5py.version.hdf5_version,
        h5py_version=h5py.version.version)

nxentry = my_lib.makeGroup(f, "entry", "NXentry")
my_lib.makeDataset(nxentry, 'title', data='1-D scan of I00 v. mr')

nxdata = my_lib.makeGroup(nxentry, "mr_scan", "NXdata")

my_lib.makeDataset(nxdata,  "mr",  mr_arr, units='degrees', 
                   long_name='USAXS mr (degrees)')

my_lib.makeDataset(nxdata,  "I00",  i00_arr, units='counts',
      signal=1,          # Y axis of default plot
      axes='mr',	     # name "mr" as X axis
      long_name='USAXS I00 (counts)')

f.close()	# be CERTAIN to close the file

print "wrote file:", fileName