bp / resqpy

Python API for working with RESQML models
https://resqpy.readthedocs.io/en/latest/
MIT License
52 stars 13 forks source link

Low-level h5 usage #26

Closed jrt54 closed 2 years ago

jrt54 commented 3 years ago

The UUID of various objects seems to correspond to h5 keys. I imagine there may be use-cases for resqpy just being used to get an h5-based representation of a resqml dataset if, for example, I want to use an existing tool/codebase based on h5. Are there attributes of resqml properties or functions to get the underlying h5 file and h5 key-pair for a given property.

andy-beer commented 3 years ago

There are a few methods in the Model class of relevance to the h5 keys:

Model.h5_uuid_and_path_for_node(node, tag = 'Values') returns a (UUID, str) pair:

Model.h5_uuid() returns the UUID of the 'main' hdf5 part for the model (there is usually only 1)

Model.h5_file_name(uuid = None, override = True, file_must_exist = True) returns the path of the hdf5 file:

Model.h5_access(uuid = None, mode = 'r', override = True, file_path = None) notes and returns an open file handle

Model.h5_release() closes the file

Model.h5_array_shape_and_type(h5_key_pair) returns the shape and dtype of the array

Model.h5_array_element(h5_key_pair, index = None, cache_array = False, object = None, array_attribute = None, dtype = 'float', required_shape = None) returns a single element from an hdf5 array and/or caches the array in memory

Model.h5_array_slice(h5_key_pair, slice_tuple) returns a slice of an hdf5 array

Model.h5_overwrite_array_slice(h5_key_pair, slice_tuple, array_slice) overwrites a slice of an hdf5 array