Reading and writing HDF5 mesh files¶
A Layermesh mesh object can be written to an
HDF5 file using its
write() method, which takes a filename as its parameter, e.g.:
msh.write('mymesh.h5')
writes the mesh object msh to the file “mymesh.h5”.
Similarly, a mesh object can be read in from file by passing in a
filename when creating it:
import layermesh.mesh as lm
msh = lm.mesh('mymesh.h5')
creates a new mesh object called msh and reads its contents
from the file “mymesh.h5”.
Layermesh HDF5 files have a simple structure with four groups:
cell: one integer scalartype_sortdataset containing the value of the meshcell_type_sortpropertylayer: one rank-1 array floatelevationdataset containing, in order, thetopproperty of each mesh layer, and finally thebottomproperty of the last (bottom) layernode: one rank-2 array floatpositiondataset containing theposproperty of each node (horizontal position) in the meshnodelistcolumn: an rank-2 integernodedataset containing the index of each node in the column, for each column in the meshcolumnlist (columns with fewer nodes padded out with -1 values) ; a rank-1 integernum_layersdataset containing the number of layers for each column; and also an optional rank-1 integerbottom_layerdataset containing the index of the bottom layer for each column (assumed -1 if not present)