From fd48effebd43baa848a5f7ca41c1ae0f56c059f3 Mon Sep 17 00:00:00 2001 From: BLANCO-GARCIA <oscar-roberto.blanco-garcia@synchrotron-soleil.fr> Date: Tue, 13 Jun 2023 14:23:31 +0200 Subject: [PATCH] add hdf5 reading function --- pyatsoleiloutils/readhdf5file.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pyatsoleiloutils/readhdf5file.py diff --git a/pyatsoleiloutils/readhdf5file.py b/pyatsoleiloutils/readhdf5file.py new file mode 100644 index 0000000..8f3ab7d --- /dev/null +++ b/pyatsoleiloutils/readhdf5file.py @@ -0,0 +1,34 @@ +""" +This file contains functions to read preformated data from +hdf5 files +""" + +import h5py +import numpy + +__all__ = ['readmomaphdf5'] + +def readmomaphdf5( + fname + ): + """ + This functions reads a given hdf5 with momentum aperture data + saved with the function savemomaphdf5. + + Args: + fname: name of the input hdf5 file + Returns: + + """ + f = h5py.File('momap_'+listofringnames[i]+'.hdf5', 'r') + + # set momap input format for get_lifetime + momap_pn = numpy.array((f['momap']['dppP'][:], + f['momap']['dppN'][:])) + momap_pn = numpy.copy(momap_pn.T) + s_indexes=f['momap']['s_indexes'][:] + s_array=f['momap']['s_array'][:] + f.close() + + return momap_pn, s_indexes, s_array + -- GitLab