Edge builder
- class anemoi.graphs.edges.builder.KNNEdges(source_name: str, target_name: str, num_nearest_neighbours: int, source_mask_attr_name: str | None = None, target_mask_attr_name: str | None = None)
Bases:
BaseEdgeBuilder,NodeMaskingMixinComputes KNN based edges and adds them to the graph.
- source_mask_attr_name
The name of the source mask attribute to filter edge connections.
- Type:
str | None
- target_mask_attr_name
The name of the target mask attribute to filter edge connections.
- Type:
str | None
- register_edges(graph)
Register the edges in the graph.
- register_attributes(graph, config)
Register attributes in the edges of the graph.
- update_graph(graph, attrs_config)
Update the graph with the edges.
- get_adjacency_matrix(source_nodes: NodeStorage, target_nodes: NodeStorage) ndarray
Compute the adjacency matrix for the KNN method.
- Parameters:
source_nodes (NodeStorage) – The source nodes.
target_nodes (NodeStorage) – The target nodes.
- Returns:
The adjacency matrix.
- Return type:
np.ndarray
- class anemoi.graphs.edges.builder.CutOffEdges(source_name: str, target_name: str, cutoff_factor: float, source_mask_attr_name: str | None = None, target_mask_attr_name: str | None = None)
Bases:
BaseEdgeBuilder,NodeMaskingMixinComputes cut-off based edges and adds them to the graph.
- cutoff_factor
Factor to multiply the grid reference distance to get the cut-off radius.
- Type:
- source_mask_attr_name
The name of the source mask attribute to filter edge connections.
- Type:
str | None
- target_mask_attr_name
The name of the target mask attribute to filter edge connections.
- Type:
str | None
- register_edges(graph)
Register the edges in the graph.
- register_attributes(graph, config)
Register attributes in the edges of the graph.
- update_graph(graph, attrs_config)
Update the graph with the edges.
- get_cutoff_radius(graph: HeteroData, mask_attr: Tensor | None = None) float
Compute the cut-off radius.
The cut-off radius is computed as the product of the target nodes reference distance and the cut-off factor.
- Parameters:
graph (HeteroData) – The graph.
mask_attr (torch.Tensor) – The mask attribute.
- Returns:
The cut-off radius.
- Return type:
- prepare_node_data(graph: HeteroData) tuple[NodeStorage, NodeStorage]
Prepare node information and get source and target nodes.
- get_adjacency_matrix(source_nodes: NodeStorage, target_nodes: NodeStorage) ndarray
Get the adjacency matrix for the cut-off method.
- Parameters:
source_nodes (NodeStorage) – The source nodes.
target_nodes (NodeStorage) – The target nodes.
- Returns:
The adjacency matrix.
- Return type:
np.ndarray
- class anemoi.graphs.edges.builder.MultiScaleEdges(source_name: str, target_name: str, x_hops: int, **kwargs)
Bases:
BaseEdgeBuilderBase class for multi-scale edges in the nodes of a graph.
- x_hops
Number of hops (in the refined icosahedron) between two nodes to connect them with an edge.
- Type:
- register_edges(graph)
Register the edges in the graph.
- register_attributes(graph, config)
Register attributes in the edges of the graph.
- update_graph(graph, attrs_config)
Update the graph with the edges.
- class anemoi.graphs.edges.builder.ICONTopologicalBaseEdgeBuilder(source_name: str, target_name: str, icon_mesh: str, source_mask_attr_name: str | None = None, target_mask_attr_name: str | None = None)
Bases:
BaseEdgeBuilderBase class for computing edges based on ICON grid topology.
- update_graph(graph: HeteroData, attrs_config: DotDict = None) HeteroData
Update the graph with the edges.
- get_adjacency_matrix(source_nodes: NodeStorage, target_nodes: NodeStorage)
- Parameters:
source_nodes (NodeStorage) – The source nodes.
target_nodes (NodeStorage) – The target nodes.
- class anemoi.graphs.edges.builder.ICONTopologicalProcessorEdges(source_name: str, target_name: str, icon_mesh: str, source_mask_attr_name: str | None = None, target_mask_attr_name: str | None = None)
Bases:
ICONTopologicalBaseEdgeBuilderComputes edges based on ICON grid topology: processor grid built from ICON grid vertices.
- class anemoi.graphs.edges.builder.ICONTopologicalEncoderEdges(source_name: str, target_name: str, icon_mesh: str, source_mask_attr_name: str | None = None, target_mask_attr_name: str | None = None)
Bases:
ICONTopologicalBaseEdgeBuilderComputes encoder edges based on ICON grid topology: ICON cell circumcenters for mapped onto processor grid built from ICON grid vertices.
- class anemoi.graphs.edges.builder.ICONTopologicalDecoderEdges(source_name: str, target_name: str, icon_mesh: str, source_mask_attr_name: str | None = None, target_mask_attr_name: str | None = None)
Bases:
ICONTopologicalBaseEdgeBuilderComputes encoder edges based on ICON grid topology: mapping from processor grid built from ICON grid vertices onto ICON cell circumcenters.