Package pylal :: Module hdf5utils
[hide private]
[frames] | no frames]

Module hdf5utils

source code

This module provides a bunch of user-friendly wrappers to the HDF5 data format, for reading and writing SWIG-bound TimeSeries and FrequencySeries objects from LAL. Issues should be raised on redmine: https://bugs.ligo.org/redmine/projects/lalsuite


Version: 8cbd1b7187ce3ed9a825d6ed11cc432f3cfde9a5

Date: 2017-12-05 15:29:36 +0000

Author: Duncan M. Macleod <duncan.macleod@ligo.org>

Functions [hide private]
 
readTimeSeries(h5file, name, group="", start=None, duration=None, datatype=None)
Read a 1-D array from an HDF5 file into a LAL TimeSeries.
source code
 
readFrequencySeries(h5file, name, group=None, fmin=None, fmax=None, datatype=None)
Read FrequencySeries object from HDF5 file.
source code
 
readVectorSequence(h5file, name, group=None, start=None, duration=None, fmin=None, fmax=None, datatype=None)
Read VectorSequence object from HDF5 file.
source code
 
readArray(h5file, name, group=None)
Read numpy.ndarray from h5py.File object h5file.
source code
 
writeTimeSeries(h5file, series, group=None, **kwargs)
Write TimeSeries object to the given h5py.File object h5file.
source code
 
writeFrequencySeries(h5file, series, group=None, **kwargs)
Write FrequencySeries object to the given h5py.File object h5file.
source code
 
seriesToDataset(h5group, series, **kwargs)
Write {Time,Frequency}Series object to a new data set in the given h5py.Group object h5group.
source code
 
arrayToDataset(h5group, name, array, metadata={}, **kwargs)
Write the given numpy array object to a new data set in the given h5py.highlevel.Group object h5group, including each element in the metadata dict.
source code
 
_create_groups(h5file, group)
Helper to return a group from an h5py.File object, creating all parents and the group itself if needed.
source code
Variables [hide private]
  _numpy_lal_typemap = {numpy.int16: lal.LAL_I2_TYPE_CODE, numpy...
  _lal_numpy_typemap = dict((v, k) for k, v in _numpy_lal_typema...
Function Details [hide private]

readTimeSeries(h5file, name, group="", start=None, duration=None, datatype=None)

source code 

Read a 1-D array from an HDF5 file into a LAL TimeSeries.

Returns SWIG-bound LAL TimeSeries.

Arguments:

    h5file : [ h5py.File | str ]
        open HDF5 file object, or path to HDF5 file on disk.
    name : str
        name of data object in HDF5 file relative in it's group.

Keyword arguments:

    group : str
        name of HDF5 Group containing data object required.
    start : LIGOTimeGPS
        GPS start time of data requested, defaults to first data point.
    duration : float
        length of data (seconds) requested, default to all data.
    datatype : int
        LAL typecode for output datatype, defaults to type of data found.

readFrequencySeries(h5file, name, group=None, fmin=None, fmax=None, datatype=None)

source code 

Read FrequencySeries object from HDF5 file.

Returns SWIG-bound LAL FrequencySeries.

Arguments:

    h5file : [ h5py.File | str ]
        open HDF5 file object, or path to HDF5 file on disk.
    name : str
        name of data object in HDF5 file relative in it's group.

Keyword arguments:

    group : str
        name of HDF5 Group containing data object required.
    fmin : float
        lower frequency bound on data returned
    fmax : float
        upper frequency bound on data returned
    datatype : int
        LAL typecode for output datatype, defaults to type of data found.

readVectorSequence(h5file, name, group=None, start=None, duration=None, fmin=None, fmax=None, datatype=None)

source code 

Read VectorSequence object from HDF5 file.

Returns SWIG-bound LAL VectorSequence, LIGOTimeGPS epoch, float deltaT,
float f0, float deltaF.

Arguments:

    h5file : [ h5py.File | str ]
        open HDF5 file object, or path to HDF5 file on disk.
    name : str
        name of data object in HDF5 file relative in it's group.

Keyword arguments:

    group : str
        name of HDF5 Group containing data object required.
    start : LIGOTimeGPS
        GPS start time of data requested, defaults to first data point.
    duration : float
        length of data (seconds) requested, default to all data.
    fmin : float
        lower frequency bound on data returned
    fmax : float
        upper frequency bound on data returned
    datatype : int
        LAL typecode for output datatype, defaults to type of data found.

readArray(h5file, name, group=None)

source code 

Read numpy.ndarray from h5py.File object h5file.

Returns numpy.ndarray and metadata dict. 

Arguments:

    h5file : [ h5py.File | str ]
        open HDF5 file object, or path to HDF5 file on disk.
    name : str
        name of data object in HDF5 file relative in it's group.

Keyword arguments:

    group : str
        name of HDF5 Group containing data object required.

writeTimeSeries(h5file, series, group=None, **kwargs)

source code 

Write TimeSeries object to the given h5py.File object h5file.

No return.

Arguments:

    h5file : h5py.File
        open HDF5 file object
    series : TimeSeries
        SWIG-bound LAL TimeSeries object

Keyword arguments:

    group : str
        name of HDF5 Group to write to, group is generated if required.

All other keyword arguments are passed to
h5py.highlevel.Group.create_dataset.

writeFrequencySeries(h5file, series, group=None, **kwargs)

source code 

Write FrequencySeries object to the given h5py.File object h5file.

No return.

Arguments:

    h5file : h5py.File
        open HDF5 file object
    series : FrequencySeries
        SWIG-bound LAL FrequencySeries object

Keyword arguments:

    group : str
        name of HDF5 Group to write to, group is generated if required.

All other keyword arguments are passed to
h5py.highlevel.Group.create_dataset.

seriesToDataset(h5group, series, **kwargs)

source code 

Write {Time,Frequency}Series object to a new data set in the
given h5py.Group object h5group.

Returns h5py.highlevel.Dataset.

Arguments:

    h5group : h5py.highlevel.Group
        Group object inside an HDF5 file
    series : [ TimeSeries | FrequencySeries ]
        LAL Time or FrequencySeries object

All kwargs are passed to h5py.highlevel.Group.create_dataset.

arrayToDataset(h5group, name, array, metadata={}, **kwargs)

source code 

Write the given numpy array object to a new data set in the given
h5py.highlevel.Group object h5group, including each element in the
metadata dict.

Returns h5py.highlevel.Dataset.

Arguments:

    h5group : h5py.highlevel.Group
        Group object inside an HDF5 file
    name : str
        descriptive name for the new dataset.
    array: numpy.ndarray
        data object to write to dataset
    
Keyword arguments:

    metadata: dict 
        dict containing metadata to write as attributes in the
        dataset, default={} (empty)

All kwargs are passed to h5py.highlevel.Group.create_dataset.

_create_groups(h5file, group)

source code 

Helper to return a group from an h5py.File object, creating all parents
and the group itself if needed.

Returns a new h5py.highlevel.Group, except in the special case of
group=None, in which case the original h5py.File is returned.

Argument:

    h5file : [ h5py.File | str ]
        open HDF5 file object, or path to HDF5 file on disk.
    group : str
        name of Group to create. If a composite group is given
        (e.g. "/data/spectra") the full tree will be generated
        as appropriate.


Variables Details [hide private]

_numpy_lal_typemap

Value:
{numpy.int16: lal.LAL_I2_TYPE_CODE, numpy.int32: lal.LAL_I4_TYPE_CODE,\
 numpy.int64: lal.LAL_I8_TYPE_CODE, numpy.uint16: lal.LAL_U2_TYPE_CODE\
, numpy.uint32: lal.LAL_U4_TYPE_CODE, numpy.uint64: lal.LAL_U8_TYPE_CO\
DE, numpy.float32: lal.LAL_S_TYPE_CODE, numpy.float64: lal.LAL_D_TYPE_\
CODE, numpy.complex64: lal.LAL_C_TYPE_CODE, numpy.complex128: lal.LAL_\
Z_TYPE_CODE}

_lal_numpy_typemap

Value:
dict((v, k) for k, v in _numpy_lal_typemap.items())