Skip to content

Commit

Permalink
docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
JPXKQX committed Jul 23, 2024
1 parent db17d5e commit 15d8eb0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/anemoi/graphs/generate/hexagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ def add_edges_to_nx_graph(
x_hops: int = 1,
depth_children: int = 1,
) -> nx.Graph:
"""Creates a global mesh from a refined icosahedron.
"""Adds the edges to the graph.
This method relies on the H3 python library, which covers the earth with hexagons (and 5 pentagons). At each
refinement level, a hexagon cell has 7 child cells (aperture 7).
This method includes multi-scale connections to the existing graph. The different scales
are defined by the resolutions (or refinement levels) specified.
Parameters
----------
graph : networkx.Graph
The graph to add the nodes.
The graph to add the edges.
resolutions : list[int]
Levels of mesh resolution to consider.
x_hops: int
Expand All @@ -125,7 +125,7 @@ def add_edges_to_nx_graph(
Returns
-------
graph : networkx.Graph
The specified graph (nodes & edges).
The graph with the added edges.
"""

graph = add_neighbour_edges(graph, resolutions, x_hops)
Expand Down
15 changes: 13 additions & 2 deletions src/anemoi/graphs/generate/icosahedral.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ def add_edges_to_nx_graph(
graph: nx.DiGraph,
resolutions: list[int],
x_hops: int = 1,
) -> None:
) -> nx.DiGraph:
"""Adds the edges to the graph.
This method includes multi-scale connections to the existing graph. The different scales
are defined by the resolutions (or refinement levels) specified.
Parameters
----------
graph : nx.DiGraph
Expand All @@ -89,6 +92,11 @@ def add_edges_to_nx_graph(
NearestNeighbors with the cloud of points to limit the mesh area, by default None.
margin_radius_km : float, optional
Margin radius in km to consider when creating the processor mesh, by default 0.0.
Returns
-------
graph : nx.DiGraph
The graph with the added edges.
"""
assert x_hops > 0, "x_hops == 0, graph would have no edges ..."

Expand All @@ -101,9 +109,12 @@ def add_edges_to_nx_graph(

tree = BallTree(vertices_rad, metric="haversine")

# Build the multi-scale connections
for resolution in resolutions[:-1]:
# Defined refined sphere
# Define the refined sphere at specified 'resolution' level
r_sphere = trimesh.creation.icosphere(subdivisions=resolution, radius=1.0)

# Get the vertices of the refined sphere
r_vertices_rad = cartesian_to_latlon_rad(r_sphere.vertices)

# TODO AOI mask builder is not used in the current implementation.
Expand Down

0 comments on commit 15d8eb0

Please sign in to comment.