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_sort
dataset containing the value of the meshcell_type_sort
propertylayer
: one rank-1 array floatelevation
dataset containing, in order, thetop
property of each mesh layer, and finally thebottom
property of the last (bottom) layernode
: one rank-2 array floatposition
dataset containing thepos
property of each node (horizontal position) in the meshnode
listcolumn
: an rank-2 integernode
dataset containing the index of each node in the column, for each column in the meshcolumn
list (columns with fewer nodes padded out with -1 values) ; and also a rank-1 integernum_layers
dataset containing the number of layers for each column