resqpy.surface.Mesh

class resqpy.surface.Mesh(parent_model, uuid=None, mesh_file=None, mesh_format=None, mesh_flavour='explicit', xyz_values=None, nj=None, ni=None, origin=None, dxyz_dij=None, z_values=None, z_supporting_mesh_uuid=None, surface_role='map', crs_uuid=None, title=None, originator=None, extra_metadata=None)

Bases: BaseSurface

Class covering meshes (lattices: surfaces where points form a 2D grid; RESQML obj_Grid2dRepresentation).

Public Data Attributes:

resqml_type

Inherited from BaseResqpy

resqml_type

part

Standard part name corresponding to self.uuid.

root

XML node corresponding to self.uuid.

citation_title

Citation block title equivalent to self.title.

Methods:

__init__(parent_model[, uuid, mesh_file, ...])

Initialises a Mesh object from xml, or a regular mesh from arguments.

from_regular_grid_column_property(...)

Creates a reg&z flavoured Mesh from an aligned regular grid column property.

set_represented_interpretation_root(interp_root)

Makes a note of the xml root of the represented interpretation.

full_array_ref()

Populates a full 2D(+1) numpy array of shape (nj, ni, 3) with xyz values, caches and returns.

surface([quad_triangles])

Returns a surface object generated from this mesh.

write_hdf5([file_name, mode, use_xy_only])

Create or append to an hdf5 file, writing datasets for the mesh depending on flavour.

create_xml([ext_uuid, use_xy_only, ...])

Creates a grid 2d representation xml node from this mesh object and optionally adds as part of model.

Inherited from BaseSurface

create_interpretation_and_feature([kind, ...])

Creates xml and objects for a represented interpretaion and interpreted feature, if not already present.

Inherited from BaseResqpy

__init__(parent_model[, uuid, mesh_file, ...])

Initialises a Mesh object from xml, or a regular mesh from arguments.

try_reuse()

Look for an equivalent existing RESQML object and modify the uuid of this object if found.

create_xml([ext_uuid, use_xy_only, ...])

Creates a grid 2d representation xml node from this mesh object and optionally adds as part of model.

append_extra_metadata(meta_dict)

Append a given dictionary of metadata to the existing metadata.

__eq__(other)

Implements equals operator; uses is_equivalent() otherwise compares class type and uuid.

__ne__(other)

Implements not equal operator.

__repr__()

String representation.


__init__(parent_model, uuid=None, mesh_file=None, mesh_format=None, mesh_flavour='explicit', xyz_values=None, nj=None, ni=None, origin=None, dxyz_dij=None, z_values=None, z_supporting_mesh_uuid=None, surface_role='map', crs_uuid=None, title=None, originator=None, extra_metadata=None)[source]

Initialises a Mesh object from xml, or a regular mesh from arguments.

Parameters
  • parent_model (model.Model object) – the model to which this Mesh object will be associated

  • uuid (uuid.UUID, optional) – the uuid of an existing RESQML obj_Grid2dRepresentation object from which this resqpy Mesh object is populated

  • mesh_file (string, optional) – file name, required if initialising from an RMS text or zmap+ ascii file

  • mesh_format (string, optional) – ‘rms’ or ‘zmap’, required if initialising from an ascii file

  • mesh_flavour (string, default 'explicit') – required flavour when reading from a mesh file; one of: ‘explicit’, ‘regular’ (z values discarded), ‘reg&z’, ‘ref&z’

  • xyz_values (numpy int array of shape (nj, ni, 3), optional) – can be used to create an explicit mesh directly from the full array of points

  • nj (int, optional) – when generating a regular or ‘ref&z’ mesh, the number of nodes (NB. not ‘cells’) in the j axis of the regular mesh

  • ni (int, optional) – the number of nodes in the i axis of the regular or ref&z mesh

  • origin (triple float, optional) – the xyz origin of the regular mesh; use z value of zero if irrelevant

  • dxyz_dij (numpy float array of shape (2, 3), optional) – the xyz increment for each step in i and j axes; use z increments of zero if not applicable; eg. [[50.0, 0.0, 0.0], [0.0, 50.0, 0.0]] for mesh with 50 (m or ft) spacing where the I axis aligns with x axis and the J axis aligns with y axis; first of the two triplets relates to the I axis

  • z_values (numpy int array of shape (nj, ni), optional) – z values used when creating a ref&z flavour mesh; z_supporting_mesh_uuid must also be supplied

  • z_supporting_mesh_uuid (uuid.UUID, optional) – used to specify the supporting mesh when creating a ref&z or reg&z flavour mesh; z_values must also be supplied

  • surface_role (string, default 'map') – ‘map’ or ‘pick’; ignored if uuid is not None

  • crs_uuid (uuid.Uuid or string, optional) – required if generating a regular mesh, the uuid of the crs

  • title (str, optional) – the citation title to use for a new mesh; ignored if uuid is not None

  • originator (str, optional) – the name of the person creating the mesh, defaults to login id; ignored if uuid is not None

  • extra_metadata (dict, optional) – string key, value pairs to add as extra metadata for the mesh; ignored if uuid is not None

Returns

the newly created Mesh object

Notes

a mesh is a set of x,y,z (or x,y) points organised into a 2D lattice indexed by j,i; the z values are sometimes not applicable and then can be set to zero; 3 flavours of mesh are supported (the RESQML standard might allow for others): regular, where a constant xyz delta is applied with each step in i and j, starting from an origin, to yield a planar surface; explicit, where the full xyz (or xy) data is held as an array; ‘ref & z’, where another mesh is referred to for xy data, and z values are held in an array; there are 5 ways to initialise a Mesh object, in order of precedence: 1. pass uuid to initialise from xml 2. pass mesh_file, mesh_format and crs_uuid to load an explicit mesh from an ascii file 3. pass xyz_values and crs_uuid to create an explicit mesh from a numpy array 4. pass nj, ni, origin, dxyz_dij and crs_uuid to initialise a regular mesh directly 5. pass z_values, z_supporting_mesh_uuid and crs_uuid to initialise a ‘ref & z’ mesh 6. leave all optional arguments as None for an empty Mesh object

append_extra_metadata(meta_dict)

Append a given dictionary of metadata to the existing metadata.

property citation_title

Citation block title equivalent to self.title.

create_interpretation_and_feature(kind='horizon', name=None, interp_title_suffix=None, is_normal=True)

Creates xml and objects for a represented interpretaion and interpreted feature, if not already present.

create_xml(ext_uuid=None, use_xy_only=False, add_as_part=True, add_relationships=True, title=None, originator=None)[source]

Creates a grid 2d representation xml node from this mesh object and optionally adds as part of model.

Parameters
  • ext_uuid (uuid.UUID, optional) – the uuid of the hdf5 external part holding the mesh array

  • use_xy_only (boolean, default False) – if True and the flavour of this mesh is explicit, only the xy coordinates are stored in the hdf5 dataset, otherwise xyz are stored

  • add_as_part (boolean, default True) – if True, the newly created xml node is added as a part in the model

  • add_relationships (boolean, default True) – if True, a relationship xml part is created relating the new grid 2d part to the crs part (and optional interpretation part), and to the represented interpretation if present

  • title (string, optional) – used as the citation Title text; should be meaningful to a human

  • originator (string, optional) – the name of the human being who created the grid 2d representation part; default is to use the login name

Returns

the newly created grid 2d representation (mesh) xml node

classmethod from_regular_grid_column_property(parent_model, grid_uuid, property_uuid)[source]

Creates a reg&z flavoured Mesh from an aligned regular grid column property.

Parameters
  • parent_model (Model) – the model that the property is part of and the new Mesh will be part of

  • grid_uuid (UUID) – the uuid of the RegularGrid object

  • property_uuid (UUID) – the uuid of a property whose supporting representation is a RegularGrid and where the indexable elements are columns

Returns

a new Mesh object with flavour reg&z, the xy regular points are the column centres and the z values are the property values

Notes

the grid’s (constant) dx, dy & dz properties must be avaiable in the model; the property must not be a points property and must have a count of 1; discrete property data will be converted to continuous (float) data; if the property uom is of quantity class length, a suitable crs will be used for the mesh, otherwise the grid’s crs will be used and a uom extra metadata item will be added; calling code will need to call the write_hdf5() and create_xml() methods for the mesh

full_array_ref()[source]

Populates a full 2D(+1) numpy array of shape (nj, ni, 3) with xyz values, caches and returns.

Note

z values may be zero or not applicable when using the mesh as support for properties.

property part

Standard part name corresponding to self.uuid.

property root

XML node corresponding to self.uuid.

set_represented_interpretation_root(interp_root)[source]

Makes a note of the xml root of the represented interpretation.

surface(quad_triangles=False)[source]

Returns a surface object generated from this mesh.

try_reuse()

Look for an equivalent existing RESQML object and modify the uuid of this object if found.

Returns

boolean – True if an equivalent object was found, False if not

Note

by design this method may change this object’s uuid as a side effect

write_hdf5(file_name=None, mode='a', use_xy_only=False)[source]

Create or append to an hdf5 file, writing datasets for the mesh depending on flavour.

title

Citation title

originator

Creator of object. By default, user id.

uuid

Unique identifier