pmmoto.analysis package
Initialize the analysis subpackage for PMMoTo.
Provides statistical, Minkowski, averaging, and binning analysis utilities.
Submodules
pmmoto.analysis.average module
average.py
Functions for calculating averages of 3D images.
- pmmoto.analysis.average.average_image_along_axis(subdomain: Subdomain, img: NDArray[T], dimension: Literal[0, 1, 2] | Tuple[Literal[0, 1, 2], Literal[0, 1, 2]]) NDArray[np.float64]
Calculate the average of a 3D image along one or two dimensions.
- Parameters:
subdomain – The subdomain object containing domain information
img – 3D numpy array representing the image
dimension – One or two dimensions along which to average (0=x, 1=y, 2=z)
- Returns:
Reduced array (2D or 1D) of averaged values.
- Return type:
np.ndarray
pmmoto.analysis.bins module
bins.py
Bin utilities for PMMoTo, including 1D and radial bins, and distributed bin counting.
This module provides classes and functions for binning data, such as atom locations, and for computing radial distribution functions (RDFs) and distributed bin statistics.
- pmmoto.analysis.bins.count_locations(coordinates: ndarray[Any, dtype[floating[Any]]], dimension: int, bin: Bin, parallel: bool = True) None
Count the number of atoms or objects in each bin.
This function increments the bin values by counting the number of coordinates that fall into each bin along the specified dimension. If a subdomain is provided, the counts are summed across all processes.
- Parameters:
coordinates (np.ndarray) – Atom or object coordinates.
dimension (int) – Dimension along which to bin.
bin (Bin) – Bin object. Results are stored in bin.values.
parallel (bool) – If the bins need to be summed in parallel
Note
Repeated calls to this function increment bin.values!
pmmoto.analysis.minkowski module
minkowski.py
Minkowski functionals analysis for PMMoTo.
This module provides routines to compute the four Minkowski functionals (volume, surface area, mean curvature, Euler characteristic) for a given binary image and a PMMoTo subdomain.
- pmmoto.analysis.minkowski.functionals(subdomain: Subdomain, img: NDArray[np.bool_]) Tuple[float, float, float, float]
Calculate the Minkowski functionals for a subdomain.
The algorithm skips the last index for boundary conditions.
- Parameters:
subdomain – Subdomain object.
img (np.ndarray) – Input binary image.
- Returns:
- (volume, surface_area, mean_curvature, euler_characteristic)
volume (float): Total volume of the pore space.
surface_area (float): Total surface area of the pore space.
mean_curvature (float): Integrated mean curvature of the pore space.
euler_characteristic (float): Euler characteristic of the pore space.
- Return type:
tuple
Notes
The Minkowski functionals are defined as:
\[\begin{split}M_{0} (X) = \int_{X} d v, \\ M_{1} (X) = \frac{1}{8} \int_{\delta X} d s, \\ M_{2} (X) = \frac{1}{2 \pi^{2}} \int_{\delta X} \frac{1}{2} \left[\frac{1}{R_{1}} + \frac{1}{R_{2}}\right] d s, \\ M_{3} (X) = \frac{3}{(4 \pi)^{2}} \int_{\delta X} \left[\frac{1}{R_{1} R_{2}}\right] d s,\end{split}\]The returned values are computed for the “own” region of the subdomain, excluding padding and ghost regions, and are normalized by the voxel size.
pmmoto.analysis.stats module
Statistical analysis utilities for PMMoTo.
Provides functions to compute global minimum and maximum values across subdomains.
- pmmoto.analysis.stats.get_maximum(subdomain: Subdomain, img: NDArray[np.floating[Any] | np.integer[Any]], own: bool = True) Any
Compute the global maximum value from a distributed image array.
Depending on the own flag, the function either restricts the computation to the local portion of the image owned by the subdomain or uses the full image. If the domain is distributed across multiple subdomains, a parallel reduction is performed to obtain the global maximum.
- Parameters:
subdomain (Subdomain) – The subdomain defining ownership within the domain.
img (NDArray) – The full image array containing data across all subdomains.
own (bool, optional) – If True, compute the maximum over the owned portion of the image only; otherwise, use the full image. Defaults to True.
- Returns:
The global maximum value of the image, reduced across all processes if the domain is distributed.
- Return type:
Any
- pmmoto.analysis.stats.get_minimum(subdomain: Subdomain, img: NDArray[np.floating[Any] | np.integer[Any]], own: bool = True) Any
Compute the global minimum value from a distributed image array.
Depending on the own flag, the function either restricts the computation to the local portion of the image owned by the subdomain or uses the full image. If the domain is distributed across multiple subdomains, a parallel reduction is performed to obtain the global minimum.
- Parameters:
subdomain (Subdomain) – The subdomain defining ownership within the domain.
img (NDArray) – The full image array containing data across all subdomains.
own (bool, optional) – If True, compute the minimum over the owned portion of the image only; otherwise, use the full image. Defaults to True.
- Returns:
The global minimum value of the image, reduced across all processes if the domain is distributed.
- Return type:
Any