ogstools.meshlib package#
- class ogstools.meshlib.Surface[source]#
Bases:
object
A surface is a sub group of a polygon mesh (2D). A surface is not closed and therefore does not represent a volume. (Geological) layers (stratigraphic units) can be defined by an upper and lower surface. By convention, properties (material_id and resolution ), actually associated to the stratigraphic unit layer, are given together with the lower boundary (class Surface) of a stratigraphic unit (class Layer).
Initialize a surface mesh. Either from pyvista or from a file.
- property material_id: int#
- class ogstools.meshlib.Layer[source]#
Bases:
Boundary
Layer(top: ogstools.meshlib.boundary_subset.Surface, bottom: ogstools.meshlib.boundary_subset.Surface, material_id: int = 0, num_subdivisions: int = 0)
- material_id: int = 0#
- num_subdivisions: int = 0#
Class representing a geological layer with top and bottom surfaces.
A geological layer is a distinct unit of rock or sediment that has unique properties and characteristics, associated by the material_id. It is often bounded by two surfaces: the top surface and the bottom surface. These surfaces delineate the spatial extent of the layer in the GIS system.
- create_raster(resolution)[source]#
Create raster representations for the layer.
For each surface, including intermediate surfaces (num_of_subdivisions > 0), this method generates .asc files.
- Args:
resolution (float): The resolution for raster creation.
- Returns:
list[Path]: A list of filenames to .asc raster files.
- Parameters:
resolution (float) –
- Return type:
list[Path]
- class ogstools.meshlib.Raster[source]#
Bases:
object
Class representing a raster representation of a location frame.
This class provides methods to create and save a raster representation based on a specified location frame and resolution.
- frame: LocationFrame#
- resolution: float#
- __init__(frame, resolution)#
- Parameters:
frame (LocationFrame) –
resolution (float) –
- Return type:
None
- as_vtu(outfilevtu)[source]#
Create and save a raster representation as a VTK unstructured grid.
- Args:
outfilevtu (Path): The path to save the VTK unstructured grid representation.
- Returns:
Path: The path to the saved VTK unstructured grid representation.
- Parameters:
outfilevtu (Path) –
- Return type:
Path
- class ogstools.meshlib.LocationFrame[source]#
Bases:
object
LocationFrame(xmin: float, xmax: float, ymin: float, ymax: float)
- xmin: float#
- xmax: float#
- ymin: float#
- ymax: float#
- as_gml(filename)[source]#
Generate GML representation of the location frame.
- Args:
filename (Path): The filename to save the GML representation to.
- Returns:
None
- Parameters:
filename (Path) –
- Return type:
None
- __init__(xmin, xmax, ymin, ymax)#
- Parameters:
xmin (float) –
xmax (float) –
ymin (float) –
ymax (float) –
- Return type:
None
- class ogstools.meshlib.Boundary[source]#
Bases:
ABC
Abstract base class representing a boundary within a mesh.
A boundary refers to the set of edges or faces that defines the delineation between the interior region and exterior regions of a mesh. In a 2D mesh, it is formed by a closed collection of line segments (1D). In a 3D mesh, it is formed by a closed collection of faces (2D).
- class ogstools.meshlib.MeshSeries[source]#
Bases:
object
A wrapper around pyvista and meshio for reading of pvd and xdmf timeseries.
Will be replaced by own module in ogstools with similar interface.
Initialize a MeshSeries object
- param filepath:
Path to the PVD or XDMF file.
- param time_unit:
Data unit of the timevalues.
- returns:
A MeshSeries object
- __init__(filepath, time_unit='s')[source]#
Initialize a MeshSeries object
- param filepath:
Path to the PVD or XDMF file.
- param time_unit:
Data unit of the timevalues.
- returns:
A MeshSeries object
- Parameters:
filepath (str | Path) –
time_unit (str | None) –
- Return type:
None
- property hdf5: File#
- read(timestep, lazy_eval=True)[source]#
Lazy read function.
- Parameters:
timestep (int) –
lazy_eval (bool) –
- Return type:
UnstructuredGrid
- property timesteps: range#
Return the timesteps of the timeseries data.
- property timevalues: ndarray#
Return the timevalues of the timeseries data.
- closest_timestep(timevalue)[source]#
Return the corresponding timestep from a timevalue.
- Parameters:
timevalue (float) –
- Return type:
int
- closest_timevalue(timevalue)[source]#
Return the closest timevalue to a timevalue.
- Parameters:
timevalue (float) –
- Return type:
float
- read_closest(timevalue)[source]#
Return the closest timestep in the data for a given timevalue.
- Parameters:
timevalue (float) –
- Return type:
UnstructuredGrid
- read_interp(timevalue, lazy_eval=True)[source]#
Return the temporal interpolated mesh for a given timevalue.
- Parameters:
timevalue (float) –
lazy_eval (bool) –
- Return type:
UnstructuredGrid
- values(data_name)[source]#
Get the data in the MeshSeries for all timesteps.
- Parameters:
data_name (str) – Name of the data in the MeshSeries.
- Returns:
A numpy array of the requested data for all timesteps
- Return type:
ndarray
- aggregate(mesh_property, func)[source]#
Aggregate data over all timesteps using a specified function.
- Parameters:
mesh_property (Property | str) – The mesh property to be aggregated. If given as type Property, the
transform()
function will be applied on each timestep and aggregation afterwards.func (Literal['min', 'max', 'mean', 'median', 'sum', 'std', 'var']) – The aggregation function to apply. It must be one of “min”, “max”, “mean”, “median”, “sum”, “std”, “var”. The equally named numpy function will be used to aggregate over all timesteps.
- Returns:
A mesh with aggregated data according to the given function.
- Return type:
UnstructuredGrid
- probe(points, data_name, interp_method=None, interp_backend_pvd=None)[source]#
Probe the MeshSeries at observation points.
- Parameters:
points (ndarray) – The points to sample at.
data_name (str) – Name of the data to sample.
interp_method (Literal['nearest', 'linear', 'probefilter'] | None) – Choose the interpolation method, defaults to linear for xdmf MeshSeries and probefilter for pvd MeshSeries.
interp_backend – Interpolation backend for PVD MeshSeries.
interp_backend_pvd (Literal['vtk', 'scipy'] | None) –
- Returns:
numpy array of interpolated data at observation points.
- Return type:
ndarray
- class ogstools.meshlib.LayerSet[source]#
Bases:
BoundarySet
Collection of geological layers stacked to represent subsurface arrangements.
In a geological information system, multiple layers can be stacked vertically to represent the subsurface arrangement. This class provides methods to manage and work with layered geological data.
Initializes a LayerSet. It checks if the list of provided layers are given in a top to bottom order. In neighboring layers, layers share the same surface (upper bottom == low top).
- __init__(layers)[source]#
Initializes a LayerSet. It checks if the list of provided layers are given in a top to bottom order. In neighboring layers, layers share the same surface (upper bottom == low top).
- Parameters:
layers (list[Layer]) –
- classmethod from_pandas(df)[source]#
Create a LayerSet from a Pandas DataFrame.
- Parameters:
df (DataFrame) –
- Return type:
- ogstools.meshlib.difference(mesh1, mesh2, mesh_property=None)[source]#
Compute the difference of properties between two meshes.
- Parameters:
mesh1 (UnstructuredGrid) – The first mesh to be subtracted from.
mesh2 (UnstructuredGrid) – The second mesh whose data is subtracted from the first mesh.
mesh_property (Property | str | None) – The property of interest. If not given, all point and cell_data will be processed raw.
- Returns:
A new mesh containing the difference of mesh_property or all datasets between mesh1 and mesh2.
- Return type:
UnstructuredGrid
- ogstools.meshlib.difference_pairwise(meshes_1, meshes_2, mesh_property=None)[source]#
Compute pairwise difference between meshes from two lists/arrays (they have to be of the same length).
- Parameters:
meshes_1 (list | ndarray) – The first list/array of meshes to be subtracted from.
meshes_2 (list | ndarray) – The second list/array of meshes whose data is subtracted from the first list/array of meshes - meshes_1.
mesh_property (Property | str | None) – The property of interest. If not given, all point and cell_data will be processed raw.
- Returns:
An array of meshes containing the differences of mesh_property or all datasets between meshes_1 and meshes_2.
- Return type:
ndarray
- ogstools.meshlib.difference_matrix(meshes_1, meshes_2=None, mesh_property=None)[source]#
Compute the difference between all combinations of two meshes from one or two arrays based on a specified property.
- Parameters:
meshes_1 (list | ndarray) – The first list/array of meshes to be subtracted from.
meshes_2 (list | ndarray | None) – The second list/array of meshes, it is subtracted from the first list/array of meshes - meshes_1 (optional).
mesh_property (Property | str | None) – The property of interest. If not given, all point and cell_data will be processed raw.
- Returns:
An array of meshes containing the differences of mesh_property or all datasets between meshes_1 and meshes_2 for all possible combinations.
- Return type:
ndarray
- ogstools.meshlib.rect(lengths=1.0, n_edge_cells=1, structured_grid=True, order=1, out_name=Path('unit_square.msh'))[source]#
- Parameters:
lengths (float | list[float]) –
n_edge_cells (int | list[int]) –
structured_grid (bool) –
order (int) –
out_name (Path) –
- Return type:
None
- ogstools.meshlib.cuboid(lengths=1.0, n_edge_cells=1, structured_grid=True, order=1, out_name=Path('unit_cube.msh'))[source]#
- Parameters:
lengths (float | list[float]) –
n_edge_cells (int | list[int]) –
structured_grid (bool) –
order (int) –
out_name (Path) –
- Return type:
None
Subpackages#
Submodules#
- ogstools.meshlib.boundary module
- ogstools.meshlib.boundary_set module
- ogstools.meshlib.boundary_subset module
- ogstools.meshlib.data_processing module
- ogstools.meshlib.gmsh_meshing module
- ogstools.meshlib.mesh_series module
- ogstools.meshlib.refine_mesh module
- ogstools.meshlib.xdmf_reader module