Modules.ProbabilisticMarchingSquares package
Submodules
Modules.ProbabilisticMarchingSquares.plot module
Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares module
- Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares.probabilistic_marching_squares(ensemble_images, isovalue, ax=None, colormap='viridis', x_coords=None, y_coords=None)[source]
Compute and visualize probabilistic marching squares.
This function implements the complete stats->mesh->vis pipeline for probabilistic marching squares visualization. It calculates the probability of isocontour presence in each cell and creates a matplotlib visualization.
Parameters:
- ensemble_imagesnp.ndarray
3D array of shape (y_dim, x_dim, n_ensemble) representing the scalar field with ensemble members.
- isovaluefloat
The isovalue for which to compute the isocontour.
- axmatplotlib.axes.Axes, optional
The axis to draw on. If None, a new figure and axis will be created.
- colormapstr, optional
Colormap for the visualization. Default is ‘viridis’.
- x_coordsnp.ndarray, optional
1D array of x-axis coordinates defining the spatial domain. Length must match x_dim. If None, pixel indices are used.
- y_coordsnp.ndarray, optional
1D array of y-axis coordinates defining the spatial domain. Length must match y_dim. If None, pixel indices are used.
Returns:
- axmatplotlib.axes.Axes
The axis with the visualized probabilistic isocontour.
Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares_stats module
- Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares_stats.probabilistic_marching_squares_summary_statistics(ensemble_images, isovalue)[source]
Compute level crossing probability for probabilistic marching squares.
This function calculates the probability of an isocontour crossing through each cell in a 2D grid based on an ensemble of scalar fields.
Parameters:
- ensemble_imagesnp.ndarray
3D array of shape (y_dim, x_dim, n_ensemble) representing the scalar field with ensemble members.
- isovaluefloat
The isovalue for which to compute the contour crossing probability.
Returns:
- dict
Dictionary containing: - ‘level_crossing_probability’: np.ndarray
2D array of shape (y_dim-1, x_dim-1) with probabilities of contour presence in each cell. Values range from 0 to 1.
Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares_vis module
- Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares_vis.visualize_probabilistic_marching_squares(mesh_data, ax=None, colormap='viridis')[source]
Visualize the probability map of isocontour presence using matplotlib.
Parameters:
- mesh_datadict
Dictionary from probabilistic_marching_squares_mesh containing: - ‘level_crossing_probability’: np.ndarray
2D array of shape (y_dim-1, x_dim-1) with probabilities of contour presence in each cell.
‘extent’: tuple (x_min, x_max, y_min, y_max) or None
- axmatplotlib.axes.Axes, optional
The axis to draw on. If None, a new figure and axis will be created.
- colormapstr, optional
Colormap for the probability map. Default is ‘viridis’.
Returns:
- axmatplotlib.axes.Axes
The axis with the visualized probabilistic isocontour.
Module contents
ProbabilisticMarchingSquares Module
This module provides functionality for performing probabilistic marching squares on 2D datasets with uncertainty. It includes methods for calculating cell crossing probabilities and visualizing the results using matplotlib.
- Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares(ensemble_images, isovalue, ax=None, colormap='viridis', x_coords=None, y_coords=None)[source]
Compute and visualize probabilistic marching squares.
This function implements the complete stats->mesh->vis pipeline for probabilistic marching squares visualization. It calculates the probability of isocontour presence in each cell and creates a matplotlib visualization.
Parameters:
- ensemble_imagesnp.ndarray
3D array of shape (y_dim, x_dim, n_ensemble) representing the scalar field with ensemble members.
- isovaluefloat
The isovalue for which to compute the isocontour.
- axmatplotlib.axes.Axes, optional
The axis to draw on. If None, a new figure and axis will be created.
- colormapstr, optional
Colormap for the visualization. Default is ‘viridis’.
- x_coordsnp.ndarray, optional
1D array of x-axis coordinates defining the spatial domain. Length must match x_dim. If None, pixel indices are used.
- y_coordsnp.ndarray, optional
1D array of y-axis coordinates defining the spatial domain. Length must match y_dim. If None, pixel indices are used.
Returns:
- axmatplotlib.axes.Axes
The axis with the visualized probabilistic isocontour.
- Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares_mesh(summary_statistics, x_coords=None, y_coords=None)[source]
Process summary statistics and spatial coordinates for visualization.
This function exists to maintain consistency with the stats->mesh->vis pipeline architecture used in other modules, even though no mesh transformation is needed for probabilistic marching squares.
Parameters:
- summary_statisticsdict
Dictionary containing: - ‘level_crossing_probability’: np.ndarray
2D array of shape (y_dim-1, x_dim-1) representing the probability of contour presence in each cell.
- x_coordsnp.ndarray, optional
1D array of x-axis coordinates defining the spatial domain. Length must match x_dim (the number of grid vertices, which is one more than the probability image width). If None, pixel indices are used.
- y_coordsnp.ndarray, optional
1D array of y-axis coordinates defining the spatial domain. Length must match y_dim (the number of grid vertices, which is one more than the probability image height). If None, pixel indices are used.
Returns:
- dict
Dictionary containing: - ‘level_crossing_probability’: np.ndarray - ‘extent’: tuple (x_min, x_max, y_min, y_max) or None - ‘x_coords’: np.ndarray or None - ‘y_coords’: np.ndarray or None
- Modules.ProbabilisticMarchingSquares.probabilistic_marching_squares_summary_statistics(ensemble_images, isovalue)[source]
Compute level crossing probability for probabilistic marching squares.
This function calculates the probability of an isocontour crossing through each cell in a 2D grid based on an ensemble of scalar fields.
Parameters:
- ensemble_imagesnp.ndarray
3D array of shape (y_dim, x_dim, n_ensemble) representing the scalar field with ensemble members.
- isovaluefloat
The isovalue for which to compute the contour crossing probability.
Returns:
- dict
Dictionary containing: - ‘level_crossing_probability’: np.ndarray
2D array of shape (y_dim-1, x_dim-1) with probabilities of contour presence in each cell. Values range from 0 to 1.
- Modules.ProbabilisticMarchingSquares.visualize_probabilistic_marching_squares(mesh_data, ax=None, colormap='viridis')[source]
Visualize the probability map of isocontour presence using matplotlib.
Parameters:
- mesh_datadict
Dictionary from probabilistic_marching_squares_mesh containing: - ‘level_crossing_probability’: np.ndarray
2D array of shape (y_dim-1, x_dim-1) with probabilities of contour presence in each cell.
‘extent’: tuple (x_min, x_max, y_min, y_max) or None
- axmatplotlib.axes.Axes, optional
The axis to draw on. If None, a new figure and axis will be created.
- colormapstr, optional
Colormap for the probability map. Default is ‘viridis’.
Returns:
- axmatplotlib.axes.Axes
The axis with the visualized probabilistic isocontour.