ogstools.meshplotlib.core module#

Meshplotlib core utilitites.

ogstools.meshplotlib.core.get_data(mesh, property)[source]#

Get the data associated with a scalar or vector property from a mesh.

Parameters:
  • mesh (UnstructuredGrid) –

  • property (Property) –

Return type:

ndarray

ogstools.meshplotlib.core.get_level_boundaries(levels)[source]#
Parameters:

levels (ndarray) –

ogstools.meshplotlib.core.get_cmap_norm(levels, property)[source]#

Construct a discrete colormap and norm for the property field.

Parameters:
  • levels (ndarray) –

  • property (Property) –

Return type:

tuple[Colormap, Normalize]

ogstools.meshplotlib.core.fix_scientific_offset_position(axis, func)[source]#
ogstools.meshplotlib.core.y_update_offset_text_position(self, bboxes, bboxes2)[source]#
ogstools.meshplotlib.core.add_colorbars(fig, ax, property, levels, pad=0.05)[source]#

Add a colorbar to the matplotlib figure.

Parameters:
  • fig (Figure) –

  • ax (Axes | list[Axes]) –

  • property (Property) –

  • levels (ndarray) –

  • pad (float) –

Return type:

None

ogstools.meshplotlib.core.subplot(mesh, property, ax, levels=None)[source]#

Plot the property field of a mesh on a matplotlib.axis.

In 3D the mesh gets sliced according to slice_type and the origin in the PlotSetup in meshplotlib.setup. Custom levels and a colormap string can be provided.

Parameters:
  • mesh (UnstructuredGrid) –

  • property (Property | str) –

  • ax (Axes) –

  • levels (ndarray | None) –

Return type:

None

ogstools.meshplotlib.core.get_combined_levels(meshes, property)[source]#

Calculate well spaced levels for the encompassing property range in meshes.

Parameters:
  • meshes (ndarray) –

  • property (Property | str) –

Return type:

ndarray

ogstools.meshplotlib.core.get_data_aspect(mesh)[source]#

Calculate the data aspect ratio of a 2D mesh.

Parameters:

mesh (DataSet) –

Return type:

float

ogstools.meshplotlib.core.plot(meshes, property)[source]#

Plot the property field of meshes with default settings.

The resulting figure adheres to the configurations in meshplotlib.setup. For 2D, the whole domain, for 3D a set of slices is displayed.

Parameters:
  • meshes (list[UnstructuredGrid] | ndarray | UnstructuredGrid) – Singular mesh of 2D numpy array of meshes

  • property (Property | str) – The property field to be visualized on all meshes

Return type:

Figure