Node builder

class anemoi.graphs.nodes.builders.from_file.ZarrDatasetNodes(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 = 'longiutdes', 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_icon.ICONNodes(name: str, grid_filename: str, max_level_multimesh: int, max_level_dataset: int)

Bases: BaseNodeBuilder

ICON grid (cell and vertex locations).

register_attributes(graph: HeteroData, config: DotDict) HeteroData

Register attributes in the nodes of the graph specified.

Parameters:
  • graph (HeteroData) – The graph to register the attributes.

  • config (DotDict) – The configuration of the attributes.

Returns:

The graph with the registered attributes.

Return type:

HeteroData

class anemoi.graphs.nodes.builders.from_icon.ICONTopologicalBaseNodeBuilder(name: str, icon_mesh: str)

Bases: BaseNodeBuilder

Base class for data mesh or processor mesh based on an ICON grid.

Parameters:
  • name (str) – key for the nodes in the HeteroData graph object.

  • icon_mesh (str) – key corresponding to the ICON mesh (cells and vertices).

update_graph(graph: HeteroData, attrs_config: DotDict | None = None) HeteroData

Update the graph with new nodes.

class anemoi.graphs.nodes.builders.from_icon.ICONMultimeshNodes(name: str, icon_mesh: str)

Bases: ICONTopologicalBaseNodeBuilder

Processor mesh based on an ICON grid.

class anemoi.graphs.nodes.builders.from_icon.ICONCellGridNodes(name: str, icon_mesh: str)

Bases: ICONTopologicalBaseNodeBuilder

Data mesh based on an ICON grid.

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 (KNNAreaMaskBuilder) – 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 (KNNAreaMaskBuilder) – 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, 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.