Edge attributes

class anemoi.graphs.edges.attributes.EdgeDirection(norm: str | None = None, luse_rotated_features: bool = True)

Bases: BaseEdgeAttribute

Edge direction feature.

This class calculates the direction of an edge using either: 1. Rotated features: The target nodes are rotated to the north pole to compute the edge direction. 2. Non-rotated features: The direction is computed as the difference in latitude and longitude between the source and target nodes.

The resulting direction is represented as a unit vector starting at (0, 0), with X and Y components.

norm

Normalisation method. Options: None, “l1”, “l2”, “unit-max”, “unit-range”, “unit-std”.

Type:

Optional[str]

luse_rotated_features

Whether to use rotated features.

Type:

bool

compute(graph, source_name, target_name)

Compute direction of all edges.

get_raw_values(graph: HeteroData, source_name: str, target_name: str) ndarray

Compute directional features for edges.

Parameters:
  • graph (HeteroData) – The graph.

  • source_name (str) – The name of the source nodes.

  • target_name (str) – The name of the target nodes.

Returns:

The directional features.

Return type:

np.ndarray

class anemoi.graphs.edges.attributes.EdgeLength(norm: str | None = None, invert: bool = False)

Bases: BaseEdgeAttribute

Edge length feature.

norm

Normalisation method. Options: None, “l1”, “l2”, “unit-max”, “unit-range”, “unit-std”.

Type:

Optional[str]

invert

Whether to invert the edge lengths, i.e. 1 - edge_length. Defaults to False.

Type:

bool

compute(graph, source_name, target_name)

Compute edge lengths attributes.

get_raw_values(graph: HeteroData, source_name: str, target_name: str) ndarray

Compute haversine distance (in kilometers) between nodes connected by edges.

Parameters:
  • graph (HeteroData) – The graph.

  • source_name (str) – The name of the source nodes.

  • target_name (str) – The name of the target nodes.

Returns:

The edge lengths.

Return type:

np.ndarray

post_process(values: ndarray) Tensor

Post-process edge lengths.