ecmwf/anemoi-graphs
Graph generation library for weather forecasting neural networks
Configuration drives instantiation of node builders and edge builders, which populate a PyTorch Geometric HeteroData graph structure
Under the hood, the system uses 2 data pools, 4 control points to manage its runtime behavior.
Structural Verdict
A 10-component weather climate with 3 connections. 57 files analyzed. Loosely coupled — components are relatively independent.
How Data Flows Through the System
Configuration drives instantiation of node builders and edge builders, which populate a PyTorch Geometric HeteroData graph structure
- Config Loading — Parse YAML configuration using Hydra and DotDict
- Node Generation — Instantiate node builders to create spherical tessellation points (config: nodes)
- Edge Generation — Instantiate edge builders to create connectivity patterns (config: edges)
- Graph Assembly — Combine nodes and edges into HeteroData structure
- Serialization — Save graph as PyTorch .pt file
System Behavior
How the system actually operates at runtime — where data accumulates, what loops, what waits, and what controls what.
Data Pools
PyTorch Geometric heterogeneous graph with nodes and edges
Saved .pt files containing complete graph structures
Control Points
- Resolution Level (env-var) — Controls: Icosahedral refinement depth affecting node density
- K Value (env-var) — Controls: Number of nearest neighbors in KNN edge builders
- Area Mask Radius (threshold) — Controls: Geographic extent of limited area meshes. Default: 100 km
- Earth Radius (runtime-toggle) — Controls: Distance calculations and spherical geometry. Default: 6371.0 km
Technology Stack
Graph neural network data structures
Hexagonal tessellation of the sphere
Triangular mesh processing
Graph data structures and algorithms
KNN and spatial algorithms
Configuration management and dependency injection
Spherical harmonics and HEALPix pixelization
Reading ICON mesh files
Key Components
- GraphCreator (class) — Main orchestrator that builds graphs from YAML configuration using Hydra
src/anemoi/graphs/create.py - KNNEdges (class) — Builds edges between nodes using k-nearest neighbor connectivity
src/anemoi/graphs/edges/builder.py - HexNodes (class) — Creates hexagonal tessellation nodes using H3 library on icosahedron
src/anemoi/graphs/nodes/builders/from_refined_icosahedron.py - create_hex_nodes (function) — Generates hexagonal mesh nodes at specified resolution using H3 library
src/anemoi/graphs/generate/hex_icosahedron.py - create_tri_nodes (function) — Generates triangular mesh nodes from refined icosahedron using trimesh
src/anemoi/graphs/generate/tri_icosahedron.py - KNNAreaMaskBuilder (class) — Creates spatial masks for limiting graph area using k-nearest neighbors
src/anemoi/graphs/generate/masks.py - GraphDescriptor (class) — Analyzes and describes graph structure, sizes, and properties
src/anemoi/graphs/describe.py - directional_edge_features (function) — Computes directional features for edges on spherical surfaces
src/anemoi/graphs/edges/directional.py - ICONTopologicalProcessorEdges (class) — Builds edges using ICON mesh topology for processor-to-processor connections
src/anemoi/graphs/edges/builder.py - BaseEdgeAttribute (class) — Abstract base for computing edge attributes with normalization support
src/anemoi/graphs/edges/attributes.py
Science Pipeline
- Coordinate Generation — Generate lat-lon coordinates from icosahedral tessellation
src/anemoi/graphs/generate/hex_icosahedron.py - Coordinate Transformation — Convert between Cartesian and spherical coordinates [(N, 3) or (N, 2) → (N, 2) or (N, 3)]
src/anemoi/graphs/generate/transforms.py - Spatial Indexing — Build KNN index for nearest neighbor searches [(N, 3) → (N, K)]
src/anemoi/graphs/edges/builder.py - Edge Attribute Computation — Calculate distances and directional features between connected nodes [(E, 2) → (E, F)]
src/anemoi/graphs/edges/attributes.py - Graph Assembly — Combine nodes and edges into HeteroData structure [various tensors → HeteroData]
src/anemoi/graphs/create.py
Assumptions & Constraints
- [warning] Assumes input coordinates are in radians with shape (N, 2) for lat-lon pairs (shape)
- [info] Assumes points have shape (num_points, 3) but assertion only checks second dimension (shape)
- [info] Fixed Earth radius of 6371 km may not be accurate for all use cases or coordinate systems (value-range)
- [warning] Assumes spherical distance calculations are appropriate for all geographic projections (dependency)
Explore the interactive analysis
See the full architecture map, data flow, and code patterns visualization.
Analyze on CodeSeaRelated Weather Climate Repositories
Frequently Asked Questions
What is anemoi-graphs used for?
Graph generation library for weather forecasting neural networks ecmwf/anemoi-graphs is a 10-component weather climate written in Python. Loosely coupled — components are relatively independent. The codebase contains 57 files.
How is anemoi-graphs architected?
anemoi-graphs is organized into 5 architecture layers: CLI Interface, Graph Creation, Node Builders, Edge Builders, and 1 more. Loosely coupled — components are relatively independent. This layered structure keeps concerns separated and modules independent.
How does data flow through anemoi-graphs?
Data moves through 5 stages: Config Loading → Node Generation → Edge Generation → Graph Assembly → Serialization. Configuration drives instantiation of node builders and edge builders, which populate a PyTorch Geometric HeteroData graph structure This pipeline design reflects a complex multi-stage processing system.
What technologies does anemoi-graphs use?
The core stack includes PyTorch Geometric (Graph neural network data structures), H3 (Hexagonal tessellation of the sphere), trimesh (Triangular mesh processing), networkx (Graph data structures and algorithms), scikit-learn (KNN and spatial algorithms), Hydra (Configuration management and dependency injection), and 2 more. A focused set of dependencies that keeps the build manageable.
What system dynamics does anemoi-graphs have?
anemoi-graphs exhibits 2 data pools (HeteroData Graph, Serialized Graph), 4 control points. These runtime behaviors shape how the system responds to load, failures, and configuration changes.
What design patterns does anemoi-graphs use?
4 design patterns detected: Builder Pattern, Plugin Architecture, Template Method, Command Pattern.
Analyzed on March 31, 2026 by CodeSea. Written by Karolina Sarna.