ogstools.meshlib.mesh_series module#
- class ogstools.meshlib.mesh_series.MeshSeries[source]#
- Bases: - Sequence[- Mesh]- A wrapper around pyvista and meshio for reading of pvd and xdmf timeseries. - Initialize a MeshSeries object - param filepath:
- Path to the PVD or XDMF file. 
- returns:
- A MeshSeries object 
 - __init__(filepath=None)[source]#
- Initialize a MeshSeries object - param filepath:
- Path to the PVD or XDMF file. 
- returns:
- A MeshSeries object 
 
 - classmethod from_data(meshes, timevalues)[source]#
- Create a MeshSeries from a list of meshes and timevalues. - Return type:
 
 - extend(mesh_series)[source]#
- Extends self with mesh_series. If the last element of the mesh series is within epsilon to the first element of mesh_series to extend, the duplicate element is removed 
 - classmethod resample(original, timevalues)[source]#
- Return a new MeshSeries interpolated to the given timevalues. - Return type:
 
 - classmethod extract_probe(original, points, data_name=None, interp_method='linear')[source]#
- Create a new MeshSeries by probing points on an existing MeshSeries. - Parameters:
- Returns:
- A MeshSeries (Pointcloud) containing the probed data. 
- Return type:
 
 - copy(deep=True)[source]#
- Create a copy of MeshSeries object. Deep copy is the default. - Parameters:
- deep (bool) – switch to choose between deep (default) and shallow (self.copy(deep=False)) copy. 
- Returns:
- Copy of self. 
- Return type:
 
 - __getitem__(index: int) Mesh[source]#
- __getitem__(index: slice | Sequence) MeshSeries
- __getitem__(index: str) ndarray
 - items()[source]#
- Returns zipped tuples of timevalues and meshes. - Return type:
- Sequence[tuple[float, Mesh]] 
 
 - aggregate_over_time(variable, func)[source]#
- Aggregate data over all timesteps using a specified function. 
 - closest_timestep(timevalue)[source]#
- Return the corresponding timestep from a timevalue. - Return type:
- int 
 
 - closest_timevalue(timevalue)[source]#
- Return the closest timevalue to a timevalue. - Return type:
- float 
 
 - rawdata_file()[source]#
- Checks, if working with the raw data is possible. For example, OGS Simulation results with XDMF support efficient raw data access via h5py - Returns:
- The location of the file containing the raw data. If it does not support efficient read (e.g., no efficient slicing), it returns None. 
- Return type:
- Path | None 
 
 - read_interp(timevalue, lazy_eval=True)[source]#
- Return the temporal interpolated mesh for a given timevalue. - Return type:
 
 - property timevalues: ndarray#
- Return the timevalues. 
 - property timesteps: list#
- Return the OGS simulation timesteps of the timeseries data. Not to be confused with timevalues which returns a list of times usually given in time units. 
 - values(variable: str | Variable) ndarray[source]#
- values(variable: list[str | Variable]) list[ndarray]
- Get the data in the MeshSeries for all timesteps. - Adheres to time slicing via __getitem__ and an applied pyvista filter via transform if the applied filter produced ‘vtkOriginalPointIds’ or ‘vtkOriginalCellIds’ (e.g. clip(…, crinkle=True), extract_cells(…), threshold(…).) - Parameters:
- variable – Data to read/process from the MeshSeries. Can also be a list of str or Variable. 
- Returns:
- A numpy array of shape (n_timesteps, n_points/c_cells). If given an argument of type Variable is given, its transform function is applied on the data. If a list of str or Variable is given, a list of the individual values is returned. 
 
 - time_of_min(variable)[source]#
- Returns a Mesh with the time of the variable minimum as data. - Return type:
 
 - time_of_max(variable)[source]#
- Returns a Mesh with the time of the variable maximum as data. - Return type:
 
 - aggregate_over_domain(variable, func)[source]#
- Aggregate data over domain per timestep using a specified function. - Parameters:
- variable (Variable | str) – The mesh variable to be aggregated. 
- func (Callable) – The aggregation function to apply. E.g. np.min, np.max, np.mean, np.median, np.sum, np.std, np.var 
 
- Returns:
- A numpy array with aggregated data. 
- Return type:
- ndarray 
 
 - plot_domain_aggregate(variable, func, ax=None, **kwargs)[source]#
- Plot the transient aggregated data over the domain per timestep. - Parameters:
- variable (Variable | str) – The mesh variable to be aggregated. 
- func (Callable) – The aggregation function to apply. E.g. np.min, np.max, np.mean, np.median, np.sum, np.std, np.var 
- ax (Axes | None) – matplotlib axis to use for plotting 
 
- Returns:
- A matplotlib Figure or None if plotting on existing axis. 
- Return type:
- Figure | None 
 - Keyword arguments get passed to matplotlib.pyplot.plot 
 - probe(points, data_name, interp_method='linear')[source]#
- Probe the MeshSeries at observation points. - Parameters:
- points (ndarray) – The observation points to sample at. 
- data_name (str | Variable | list[str | Variable]) – Data to sample. If provided as a Variable, the output will transformed accordingly. Can also be a list of str or Variable. 
- interp_method (Literal['nearest', 'linear']) – Interpolation method, defaults to linear 
 
- Returns:
- numpy array/s of interpolated data at observation points with the following shape: - multiple points: (n_timesteps, n_points, [n_components]) 
- single points: (n_timesteps, [n_components]) 
 - If data_name is a list, a corresponding list of arrays is returned. 
- Return type:
- ndarray | list[ndarray] 
 
 - plot_probe(points, variable, variable_abscissa=None, labels=None, interp_method='linear', colors=None, linestyles=None, ax=None, fill_between=False, **kwargs)[source]#
- Plot the transient variable on the observation points in the MeshSeries. - Parameters:
- points (ndarray | list) – The points to sample at. 
- variable (Variable | str) – The variable to be sampled. 
- labels (list[str] | None) – The labels for each observation point. 
- interp_method (Literal['nearest', 'linear']) – Choose the interpolation method, defaults to linear for xdmf MeshSeries and probefilter for pvd MeshSeries. 
- interp_backend – Interpolation backend for PVD MeshSeries. 
 
- Return type:
- Figure | None 
 - Keyword Arguments get passed to matplotlib.pyplot.plot 
 - plot_time_slice(x, y, variable, time_logscale=False, fig=None, ax=None, cbar=True, **kwargs)[source]#
- Create a heatmap for a variable over time and space. - Parameters:
- x (Literal['x', 'y', 'z', 'time']) – What to display on the x-axis (x, y, z or time) 
- y (Literal['x', 'y', 'z', 'time']) – What to display on the y-axis (x, y, z or time) 
- variable (str | Variable) – The variable to be visualized. 
- time_logscale (bool) – Should log-scaling be applied to the time-axis? 
- fig (Figure | None) – matplotlib figure to use for plotting. 
- ax (Axes | None) – matplotlib axis to use for plotting. 
- cbar (bool) – If True, adds a colorbar. 
 
- Return type:
- Figure | None 
 - Keyword Arguments:
- cb_labelsize: colorbar labelsize 
- cb_loc: colorbar location (‘left’ or ‘right’) 
- cb_pad: colorbar padding 
- cmap: colormap 
- vmin: minimum value for colorbar 
- vmax: maximum value for colorbar 
- num_levels: number of levels for colorbar 
- figsize: figure size 
- dpi: resolution 
 
 
 - property mesh_func: Callable[[Mesh], Mesh]#
- Returns stored transformation function or identity if not given. 
 - transform(mesh_func=lambda mesh: ...)[source]#
- Apply a transformation function to the underlying mesh. 
 - scale(spatial=1.0, time=1.0)[source]#
- Scale the spatial coordinates and timevalues. - Useful to convert to other units, e.g. “m” to “km” or “s” to “a”. If given as tuple of strings, the latter units will also be set in ot.plot.setup.spatial_unit and ot.plot.setup.time_unit for plotting. - Parameters:
- spatial (float | tuple[str, str]) – Float factor or a tuple of str (from_unit, to_unit). 
- time (float | tuple[str, str]) – Float factor or a tuple of str (from_unit, to_unit). 
 
- Return type:
 
 - extract(index, preference='points')[source]#
- Extract a subset of the domain by point or cell indices. - Parameters:
- index (slice | int | ndarray | list) – Indices of points or cells to extract. 
- preference (Literal['points', 'cells']) – Selected entities. 
 
- Returns:
- A MeshSeries with the selected domain subset. 
- Return type:
 
 - save(filename, deep=True, ascii=False)[source]#
- Save mesh series to disk. - Parameters:
- filename (str) – Filename to save the series to. Extension specifies the file type. Currently only PVD is supported. 
- deep (bool) – Specifies whether VTU/H5 files should be written. 
- ascii (bool) – Specifies if ascii or binary format should be used, defaults to binary (False) - True for ascii. 
 
 
 - remove_array(name, data_type='field', skip_last=False)[source]#
- Removes an array from all time slices of the mesh series. - Parameters:
- name (str) – Array name 
- data_type (str) – Data type of the array. Could be either field, cell or point 
- skip_last (bool) – Skips the last time slice (e.g. for restart purposes). 
 
 
 
 
    