Node builder

class anemoi.graphs.nodes.builders.from_file.AnemoiDatasetNodes(dataset: DictConfig, name: str)

Bases: BaseNodeBuilder

Nodes from an anemoi dataset.

dataset

The dataset.

Type:

str | DictConfig

get_coordinates()

Get the lat-lon coordinates of the nodes.

register_nodes(graph, name)

Register the nodes in the graph.

register_attributes(graph, name, config)

Register the attributes in the nodes of the graph specified.

update_graph(graph, name, attrs_config)

Update the graph with new nodes and attributes.

get_coordinates() Tensor

Get the coordinates of the nodes.

Returns:

A 2D tensor with the coordinates, in radians.

Return type:

torch.Tensor of shape (num_nodes, 2)

class anemoi.graphs.nodes.builders.from_file.TextNodes(dataset: str | Path, name: str, idx_lon: int = 0, idx_lat: int = 1)

Bases: BaseNodeBuilder

Nodes from text file.

dataset

The path including filename to txt file containing the coordinates of the nodes.

Type:

str | Path

idx_lon

The index of the longitude in the dataset.

Type:

int

idx_lat

The index of the latitude in the dataset.

Type:

int

get_coordinates() Tensor

Get the coordinates of the nodes.

Returns:

A 2D tensor with the coordinates, in radians.

Return type:

torch.Tensor of shape (num_nodes, 2)

class anemoi.graphs.nodes.builders.from_file.NPZFileNodes(npz_file: str, name: str, lat_key: str = 'latitudes', lon_key: str = 'longitudes')

Bases: BaseNodeBuilder

Nodes from NPZ defined grids.

npz_file

Path to the file.

Type:

str

lat_key

Name of the key of the latitude arrays.

Type:

str

lon_key

Name of the key of the latitude arrays.

Type:

str

get_coordinates()

Get the lat-lon coordinates of the nodes.

register_nodes(graph, name)

Register the nodes in the graph.

register_attributes(graph, name, config)

Register the attributes in the nodes of the graph specified.

update_graph(graph, name, attrs_config)

Update the graph with new nodes and attributes.

get_coordinates() Tensor

Get the coordinates of the nodes.

Returns:

A 2D tensor with the coordinates, in radians.

Return type:

torch.Tensor of shape (num_nodes, 2)

class anemoi.graphs.nodes.builders.from_file.LimitedAreaNPZFileNodes(npz_file: str, reference_node_name: str, name: str, lat_key: str = 'latitudes', lon_key: str = 'longitudes', mask_attr_name: str | None = None, margin_radius_km: float = 100.0)

Bases: NPZFileNodes

Nodes from NPZ defined grids using an area of interest.

register_nodes(graph: HeteroData) None

Register nodes in the graph.

Parameters:

graph (HeteroData) – The graph to register the nodes.

Returns:

The graph with the registered nodes.

Return type:

HeteroData

get_coordinates() ndarray

Get the coordinates of the nodes.

Returns:

A 2D tensor with the coordinates, in radians.

Return type:

torch.Tensor of shape (num_nodes, 2)

class anemoi.graphs.nodes.builders.from_file.XArrayNodes(dataset: str, name: str, lat_key: str = 'lat', lon_key: str = 'lon')

Bases: BaseNodeBuilder

Class for creating graph nodes based on a xarray-compatible file format.

Parameters:
  • dataset (str) – Path to xarray compatible file (e.g., NetCDF or zarr) containing latitude and longitude variables.

  • name (str) – Identifier to use for the nodes within the graph.

  • lat_key (str, optional) – Variable name for latitude in the dataset (default: “lat”).

  • lon_key (str, optional) – Variable name for longitude in the dataset (default: “lon”).

get_coordinates()

Get the lat-lon coordinates of the nodes.

register_nodes(graph, name)

Register the nodes in the graph.

register_attributes(graph, name, config)

Register the attributes in the nodes of the graph specified.

update_graph(graph, name, attrs_config)

Update the graph with new nodes and attributes.

class anemoi.graphs.nodes.builders.from_healpix.HEALPixNodes(resolution: int, name: str)

Bases: BaseNodeBuilder

Nodes from HEALPix grid.

HEALPix is an acronym for Hierarchical Equal Area isoLatitude Pixelization of a sphere.

resolution

The resolution of the grid.

Type:

int

get_coordinates()

Get the lat-lon coordinates of the nodes.

register_nodes(graph, name)

Register the nodes in the graph.

register_attributes(graph, name, config)

Register the attributes in the nodes of the graph specified.

update_graph(graph, name, attrs_config)

Update the graph with new nodes and attributes.

get_coordinates() Tensor

Get the coordinates of the nodes.

Returns:

Coordinates of the nodes, in radians.

Return type:

torch.Tensor of shape (num_nodes, 2)

class anemoi.graphs.nodes.builders.from_healpix.LimitedAreaHEALPixNodes(resolution: str, reference_node_name: str, name: str, mask_attr_name: str | None = None, margin_radius_km: float = 100.0)

Bases: HEALPixNodes

Nodes from HEALPix grid using an area of interest.

register_nodes(graph: HeteroData) None

Register nodes in the graph.

Parameters:

graph (HeteroData) – The graph to register the nodes.

Returns:

The graph with the registered nodes.

Return type:

HeteroData

get_coordinates() ndarray

Get the coordinates of the nodes.

Returns:

Coordinates of the nodes, in radians.

Return type:

torch.Tensor of shape (num_nodes, 2)

class anemoi.graphs.nodes.builders.from_refined_icosahedron.TriNodes(resolution: int | list[int], name: str)

Bases: IcosahedralNodes

Nodes based on iterative refinements of an icosahedron.

It depends on the trimesh Python library.

class anemoi.graphs.nodes.builders.from_refined_icosahedron.HexNodes(resolution: int | list[int], name: str)

Bases: IcosahedralNodes

Nodes based on iterative refinements of an icosahedron.

It depends on the h3 Python library.

class anemoi.graphs.nodes.builders.from_refined_icosahedron.LimitedAreaTriNodes(resolution: int | list[int], reference_node_name: str, name: str, mask_attr_name: str | None = None, margin_radius_km: float = 100.0)

Bases: LimitedAreaIcosahedralNodes

Nodes based on iterative refinements of an icosahedron using an area of interest.

It depends on the trimesh Python library.

Parameters:

area_mask_builder (AreaMaskBuilder) – The area of interest mask builder.

class anemoi.graphs.nodes.builders.from_refined_icosahedron.LimitedAreaHexNodes(resolution: int | list[int], reference_node_name: str, name: str, mask_attr_name: str | None = None, margin_radius_km: float = 100.0)

Bases: LimitedAreaIcosahedralNodes

Nodes based on iterative refinements of an icosahedron using an area of interest.

It depends on the h3 Python library.

Parameters:

area_mask_builder (AreaMaskBuilder) – The area of interest mask builder.

class anemoi.graphs.nodes.builders.from_refined_icosahedron.StretchedTriNodes(global_resolution: int, lam_resolution: int, name: str, reference_node_name: str, mask_attr_name: str | None = None, margin_radius_km: float = 100.0)

Bases: StretchedIcosahedronNodes

Nodes based on iterative refinements of an icosahedron with 2 different resolutions.

It depends on the trimesh Python library.