AFL.double_agent.Boundary module#
Boundary analysis tools for phase diagram and compositional spaces.
This module provides tools for analyzing and comparing boundaries in phase diagrams and compositional spaces. It includes functionality for creating concave hulls around phase regions and computing similarity scores between different boundary sets.
Key features: - Concave hull generation for phase regions - Boundary comparison metrics - Support for 2D compositional spaces - Visualization tools for boundary analysis - Handling of multi-phase systems
- class AFL.double_agent.Boundary.BoundaryScore(gt_hull_variable: str, al_hull_variable: str, output_prefix: str = 'boundary_score', name: str = 'BoundaryScore', plot: bool = False)#
Bases:
PipelineOp
Computes similarity scores between two sets of phase boundaries.
This class calculates metrics comparing the boundaries of phase regions between two different datasets (e.g., ground truth vs. predicted phases). It provides both numerical scores and optional visualization.
- Parameters:
gt_hull_variable (str) – Name of variable containing ground truth hull data
al_hull_variable (str) – Name of variable containing comparison hull data
output_prefix (str, default="boundary_score") – Prefix to use for output variable names
name (str, default="BoundaryScore") – Name to use when added to a Pipeline
plot (bool, default=False) – Whether to create visualizations of the boundary comparisons
- calculate(dataset: Dataset) Self #
Calculate boundary similarity scores between hull sets.
Computes mean and standard deviation of distances between corresponding points on hull boundaries. Optionally creates visualizations of the comparison.
- Parameters:
dataset (xr.Dataset) – Dataset containing both sets of hulls to compare
- Returns:
The BoundaryScore instance with computed scores
- Return type:
Self
- class AFL.double_agent.Boundary.ConcaveHull(input_variable: str, output_prefix: str, hull_tracing_ratio: float = 0.2, drop_phases: List | None = None, component_dim: str = 'components', label_variable: str | None = None, segmentize_length: float = 0.025, allow_holes: bool = False, name: str = 'ConcaveHull')#
Bases:
PipelineOp
Creates concave hulls around points in 2D space.
This class generates concave hulls (alpha shapes) around sets of points, useful for identifying phase boundaries in compositional spaces. It can handle multiple phases and provides options for hull generation parameters.
- Parameters:
input_variable (str) – The name of the variable containing the points to create hulls around
output_prefix (str) – Prefix to use for output variable names
hull_tracing_ratio (float, default=0.2) – Controls the concavity of the hull. Lower values create tighter hulls
drop_phases (Optional[List], default=None) – List of phase labels to exclude from hull generation
component_dim (str, default="components") – Name of the dimension containing component coordinates
label_variable (Optional[str], default=None) – Name of variable containing phase labels. If None, all points are treated as one phase
segmentize_length (float, default=0.025) – Length to use when segmenting hull boundaries for smoother visualization
allow_holes (bool, default=False) – Whether to allow holes in the generated hulls
name (str, default="ConcaveHull") – Name to use when added to a Pipeline
- calculate(dataset: Dataset) Self #
Generate concave hulls for each phase in the dataset.
Creates concave hulls around points grouped by their phase labels. Handles 2D data only and includes options for hull parameters.
- Parameters:
dataset (xr.Dataset) – The input dataset containing points and optional phase labels
- Returns:
The ConcaveHull instance with generated hulls
- Return type:
Self
- Raises:
ValueError – If the input data is not 2D