Saving HDF5 FilesΒΆ

an example of saving nddata to hdf5 files, which preserves all of the nddata information flawlessly

file already exists, not creating again -- delete the file or node if wanted
found data: array([0.        , 0.55555556, 1.11111111, 1.66666667, 2.22222222,
       2.77777778, 3.33333333, 3.88888889, 4.44444444, 5.        ])
                +/-None
        dimlabels=['x']
        axes={`x':array([0.        , 0.55555556, 1.11111111, 1.66666667, 2.22222222,
       2.77777778, 3.33333333, 3.88888889, 4.44444444, 5.        ])
                        +/-None}

found data: array([0.        , 0.55555556, 1.11111111, 1.66666667, 2.22222222,
       2.77777778, 3.33333333, 3.88888889, 4.44444444, 5.        ])
                +/-None
        dimlabels=['x']
        axes={`x':array([0.        , 0.55555556, 1.11111111, 1.66666667, 2.22222222,
       2.77777778, 3.33333333, 3.88888889, 4.44444444, 5.        ])
                        +/-None}

from pyspecdata import *
a = nddata(r_[0:5:10j], 'x')
a.name('test_data')
try:
    a.hdf5_write('example.h5',getDATADIR(exp_type='francklab_esr/Sam'))
except:
    print("file already exists, not creating again -- delete the file or node if wanted")
# read the file by the "raw method"
b = nddata_hdf5('example.h5/test_data',
        getDATADIR(exp_type='francklab_esr/Sam'))
print("found data:",b)
# or use the find file method
c = find_file('example.h5', exp_type='francklab_esr/Sam',
        expno='test_data')
print("found data:",c)

Total running time of the script: ( 0 minutes 0.104 seconds)

Gallery generated by Sphinx-Gallery