ogstools.meshlib.mesh_series module#

A class to handle Meshseries data.

class ogstools.meshlib.mesh_series.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

clear()[source]#
Return type:

None

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