:py:mod:`python.odpy.hdf5` ========================== .. py:module:: python.odpy.hdf5 .. autoapi-nested-parse:: Copyright (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt * AUTHOR : A. Huck * DATE : Nov 2018 Module Summary ############### Tools for reading hdf5 files created by OpendTect. Ensures standard access to hdf5 for independent workflow KEY methods ------------- * openFile() * opens any h5 or hdf5 files, ensures and optimize access to the file Example -------- >>> import odpy.hdf5 as odhdf >>> file =odhdf.openFile(filenm='DTECT_DATA/F3_Demo_2020/NLAs/3D_seismic_energy.h5', mode='r') >>> file >>> info = odhdf.getInfoDataSet(h5file_or_grp=file) >>> info Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: python.odpy.hdf5.openFile python.odpy.hdf5.getInfoDataSet python.odpy.hdf5.ensureHasDataset python.odpy.hdf5.getAttr python.odpy.hdf5.setAttr python.odpy.hdf5.hasAttr python.odpy.hdf5.getAttrs python.odpy.hdf5.getText python.odpy.hdf5.setArray python.odpy.hdf5.getBoolValue python.odpy.hdf5.getIArray_ python.odpy.hdf5.getIntValue python.odpy.hdf5.getIInterval python.odpy.hdf5.getIStepInterval python.odpy.hdf5.getIArray python.odpy.hdf5.getDArray_ python.odpy.hdf5.getDValue python.odpy.hdf5.getDInterval python.odpy.hdf5.getDStepInterval python.odpy.hdf5.getDArray python.odpy.hdf5.getAttribInfo python.odpy.hdf5.getTransform python.odpy.hdf5.getSurveyInfo Attributes ~~~~~~~~~~ .. autoapisummary:: python.odpy.hdf5.dGBInfoDSName .. py:data:: dGBInfoDSName :annotation: = ++info++ .. py:function:: openFile(filenm, mode) Opens and ensures and optimize access to the hdf5 file Parameters: * filenm (str): HDF5 file name * mode (str): options to read, write or edit to the file (r, r+, w, w-, x, a) Returns: * obj: A HDF5 file object (in mode selected) .. py:function:: getInfoDataSet(h5file_or_grp) Gets info on HDF5 object Parameters: * h5file_or_grp (object): hdf5 file object Returns: * obj: A h5 dataset object created by OpendTect, Input error is generated if HDF5 file is not created by OpendTect Notes: * KeyError (HDF5 key not found) is returned if dataset has no attribute passed .. py:function:: ensureHasDataset(h5file_or_grp) Ensures HDF5 object has info file (++info++) created by OpendTect Parameters: * h5file_or_grp (obj): HDF5 file object Returns: * obj: A h5 dataset object created by OpendTect .. py:function:: getAttr(dataset, ky) Gets attribute value from HDF5 Dataset Parameters: * dataset (obj): HDF5 file object * ky (str): HDF5 attribute name Returns: bytes: Attribute value Notes: * KeyError (HDF5 key not found) is returned if dataset has no attribute passed .. py:function:: setAttr(dataset, ky, str) Sets HDF5 dataset attribute Parameters: * dataset (obj): HDF5 file object * ky (str): attribute name * str (str): attribute value Returns: * Nothing (sets dataset attribute) .. py:function:: hasAttr(dataset, ky) Checks if HDF5 object has attribute Parameters: * dataset (obj): HDF5 file object * ky (str): attribute name Returns: * bool: True if attribute is present, False if otherwise .. py:function:: getAttrs(dataset, ky) Gets attribute value(s) from HDF5 dataset Parameters: * dataset (obj): HDF5 file object * ky (str): attribute name Returns: * list: of atrribute value(s) Notes: * KeyError (HDF5 key not found) is returned if dataset has no attribute passed List of available attributes is displayed .. py:function:: getText(infos, ky) Gets attribute text value from HDF5 dataset Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * str: attribute value .. py:function:: setArray(infos, ky, arr) Sets array values for dataset attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name * arr (list, tup, int, float, str): attribute value(s) Returns: * Nothing (sets dataset attribute value(s)) .. py:function:: getBoolValue(infos, ky) Gets boolean value Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: bool: True if attribute key evaluates to 'Yes', False if otherwise .. py:function:: getIArray_(valsstr) Provides integer equivalence of input. Converts input or element of input into integers Parameters: * valsstr (int, float, list of int/float) Returns: * int, list of int .. py:function:: getIntValue(infos, ky) Gets integer value of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * int: attribute value Notes: * Returns ValueError if attribute value is text .. py:function:: getIInterval(infos, ky) Gets interval int values of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * list: interval int values Notes: * Returns ValueError if attribute value is text .. py:function:: getIStepInterval(infos, ky) Gets interval step int values of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * tuple: interval step int values Notes: * Returns ValueError if attribute value is text .. py:function:: getIArray(infos, ky) Gets array int values of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * list: attribute int values Notes: * Returns ValueError if attribute value is text .. py:function:: getDArray_(valsstr) Provides float equivalence of input. Converts input or element of input into floats Parameters: * valsstr (int, float, list of int/float) Returns: * float, list of float .. py:function:: getDValue(infos, ky) Gets float value of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * float: attribute value Notes: * Returns ValueError if attribute value is text .. py:function:: getDInterval(infos, ky) Gets interval float values of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * list: interval float values Notes: * Returns ValueError if attribute value is text .. py:function:: getDStepInterval(infos, ky) Gets float interval step values of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * tuple: interval step float values Notes: * Returns ValueError if attribute value is text .. py:function:: getDArray(infos, ky) Gets array float values of attribute Parameters: * infos (obj): HDF5 file object * ky (str): attribute name Returns: * list: attribute float values Notes: * Returns ValueError if attribute value is text .. py:function:: getAttribInfo(filenm) .. py:function:: getTransform(info) .. py:function:: getSurveyInfo(filenm) Gets survey information Parameters: * filenm (str): file name Returns: * orderedDict: containing information on survey name, survey ranges (inline, crossline, x, y), transform