pysdic.Mesh.compute_elements_neighborhood_statistics#
- Mesh.compute_elements_neighborhood_statistics(property, statistics)[source]#
Compute the specified statistics for the given property array defined at the elements of a mesh based on the neighborhood information for each element.
Note
The function is a convenience wrapper around the
pysdic.compute_neighborhood_statistics()function, which computes the neighborhood statistics for each vertex of a graph.Important
elements_neighborhoodmust be precomputed before calling this function.
Implemented statistics include:
Statistic
Description
meanCompute the mean of the property values from the neighbors.
medianCompute the median of the property values from the neighbors.
minCompute the minimum of the property values from the neighbors.
maxCompute the maximum of the property values from the neighbors.
stdCompute the standard deviation of the property values from the neighbors.
varCompute the variance of the property values from the neighbors.
Q1Compute the first quartile (25th percentile) of the property values from the neighbors.
Q3Compute the third quartile (75th percentile) of the property values from the neighbors.
IQRCompute the interquartile range (IQR) of the property values from the neighbors, defined as Q3 - Q1.
- Parameters:
property (Union[
str, ArrayLike]) – An array of shape \((N_e, P)\) containing the property values defined at the elements of the mesh. If 1D-array is provided, it will be treated as a single-component property of shape \((N, 1)\). If a string, the property will be retrieved from the properties of the elements using the string as a key.statistics (Union[
str, Sequence[str]]) – A string or a sequence of strings specifying the statistic(s) to compute for each vertex/element based on its neighbors.
- Returns:
A dictionary where the keys are the names of the computed statistics and the values are arrays of shape \((N_e, P)\) containing the computed statistic values for each element and each property.
- Return type:
Dict[
str,numpy.ndarray]- Raises:
TypeError – If the input property array is not 1D or 2D. If the statistic parameter is not a string or a sequence of strings.
ValueError – If the statistic parameter contains an unsupported statistic name.
See also
pysdic.compute_neighborhood_statistics()For more information on the algorithm used to compute the neighborhood statistics and an example of how to use it.