ogstools.meshlib.data_processing module#
- ogstools.meshlib.data_processing.difference(base_mesh, subtract_mesh, variable=None)[source]#
Compute the difference of variables between two meshes.
- Parameters:
base_mesh (Mesh) – The mesh to subtract from.
subtract_mesh (Mesh) – The mesh whose data is to be subtracted.
variable (Variable | str | None) – The variable of interest. If not given, all point and cell_data will be processed raw.
- Returns:
A new mesh containing the difference of variable or of all datasets between both meshes.
- Return type:
Mesh
- ogstools.meshlib.data_processing.difference_pairwise(meshes_1, meshes_2, variable=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.
variable (Variable | str | None) – The variable of interest. If not given, all point and cell_data will be processed raw.
- Returns:
An array of meshes containing the differences of variable or all datasets between meshes_1 and meshes_2.
- Return type:
ndarray
- ogstools.meshlib.data_processing.difference_matrix(meshes_1, meshes_2=None, variable=None)[source]#
Compute the difference between all combinations of two meshes from one or two arrays based on a specified variable.
- 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).
variable (Variable | str | None) – The variable of interest. If not given, all point and cell_data will be processed raw.
- Returns:
An array of meshes containing the differences of variable or all datasets between meshes_1 and meshes_2 for all possible combinations.
- Return type:
ndarray
- ogstools.meshlib.data_processing.interp_points(points, resolution=100)[source]#
Provides lists of points on every segment at a line profile between arbitrary number of points pairs.
- Parameters:
points (ndarray) – Numpy array of N points to sample between. Has to be of shape (N, 3).
resolution (int) – Resolution of the sampled profile. Total number of points within all profile segments.
- Returns:
Numpy array of shape (N, 3), without duplicated nodal points.
- Return type:
ndarray
- ogstools.meshlib.data_processing.distance_in_segments(profile_nodes, profile)[source]#
Calculate the distance within segments of a polyline profile.
- Parameters:
profile_nodes (ndarray) – 2D array of N points (profile nodes) of shape (N, 3)
profile (ndarray) – output from interp_points function. 2D array of N points (profile nodes) of shape (N, 3)
- Returns:
1D array of distances in each segment to its starting point of shape (N, 3), where N is the number of points in profile
- Return type:
ndarray
- ogstools.meshlib.data_processing.distance_in_profile(points)[source]#
- Parameters:
points (ndarray) – 2D array of N points (profile nodes) of shape (N, 3)
- Returns:
1D array of distances of each point to the beginning of the profile (first row in points), shape of (N,)
- Return type:
ndarray
- ogstools.meshlib.data_processing.sample_polyline(mesh, variables, profile_nodes, resolution=100)[source]#
Sample one or more variables along a polyline. Profiles created by user can be passed as profile_nodes parameter. In this case user should also set resolution to None in order to avoid further interpolation between the points.
- Parameters:
mesh (UnstructuredGrid) – Mesh from which variables will be sampled.
variables (str | Variable | list[str] | list[Variable]) – Name or list of names of variables to sample.
profile_nodes (ndarray) – 2D array of N points (profile nodes) of shape (N, 3)
resolution (int | None) – Total number of sampling points.
- Returns:
tuple containing DataFrame with results of the profile sampling and Numpy array of distances from the beginning of the profile at points defined in profile_points.
- Return type:
tuple[DataFrame, ndarray]