Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Limited Area Modeling #42

Merged
merged 88 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
38f8d15
feat: Initial implementation of global graphs
theissenhelen Jun 24, 2024
9dc2cec
add dependencies
theissenhelen Jun 25, 2024
f1fe18f
add cli command
JPXKQX Jun 25, 2024
b8b558d
Ignore .pt files
JPXKQX Jun 25, 2024
7f6f4bd
run pre-commit
JPXKQX Jun 25, 2024
d5f67fd
docstring + log erros
JPXKQX Jun 26, 2024
b12272d
initial tests
JPXKQX Jun 26, 2024
cce5ea6
feat: initial version of AttributeBuilder
theissenhelen Jun 26, 2024
9ba0391
refactor: separate into node edge attribute builders
theissenhelen Jun 26, 2024
9a47184
feat: edge_length moved to edges/attributes.py
JPXKQX Jun 27, 2024
384adc7
remove __init__
JPXKQX Jun 27, 2024
0bc176c
feat: test edge builders
JPXKQX Jun 27, 2024
d16934b
add blank lines
JPXKQX Jun 27, 2024
0f82ea7
dep: hydra-core
JPXKQX Jun 27, 2024
a9c5ada
bugfix (encoder edge lengths) + refector
JPXKQX Jun 27, 2024
66ef5dc
deps: == to >=
JPXKQX Jun 27, 2024
0d31c56
docs: first documentation WIP
JPXKQX Jun 27, 2024
42e1ad4
update docs
JPXKQX Jul 2, 2024
3609681
Global Encoder-Processor-Decoder graph (#9)
JPXKQX Jul 5, 2024
63c090b
add cli command
JPXKQX Jun 25, 2024
d02be30
run pre-commit
JPXKQX Jun 25, 2024
aa59627
feat: initial version of AttributeBuilder
theissenhelen Jun 26, 2024
428d799
refactor: separate into node edge attribute builders
theissenhelen Jun 26, 2024
c54e491
feat: edge_length moved to edges/attributes.py
JPXKQX Jun 27, 2024
221dc30
remove __init__
JPXKQX Jun 27, 2024
541a6b2
docs: first documentation WIP
JPXKQX Jun 27, 2024
7c4f706
update docs
JPXKQX Jul 2, 2024
12e5950
Merge branch 'develop' into feature/docs
JPXKQX Jul 5, 2024
0f7fce5
Merge branch 'develop' of github.com:ecmwf/anemoi-graphs into feature…
JPXKQX Jul 8, 2024
9836945
udpate documentation
JPXKQX Jul 8, 2024
bcf0f5a
Merge branch 'develop' into feature/docs
theissenhelen Jul 9, 2024
ba69531
refactor: precommit
theissenhelen Jul 9, 2024
5865b35
Merge pull request #14 from ecmwf/hotfix/config_node_name
JPXKQX Jul 9, 2024
bd6b612
Merge remote-tracking branch 'origin/develop' into feature/docs
JPXKQX Jul 9, 2024
be3012c
update docs for global use case (only
JPXKQX Jul 9, 2024
a3872fd
docstrings
JPXKQX Jul 10, 2024
ffdf62a
remove math equations
JPXKQX Jul 10, 2024
09d3290
remove deprecated files
JPXKQX Jul 10, 2024
2e45397
review typos
JPXKQX Jul 10, 2024
983ff0f
fix: typos
JPXKQX Jul 11, 2024
db81caf
data structure section
JPXKQX Jul 11, 2024
c5eaa41
update: docstring
JPXKQX Jul 24, 2024
3f83f90
Merge branch 'develop' into feature/docs
JesperDramsch Jul 31, 2024
cdf5db5
Merge branch 'develop' into feature/docs
JesperDramsch Jul 31, 2024
5b378d2
Merge branch 'develop' into feature/docs
JPXKQX Aug 6, 2024
f533392
Update CHANGELOG.md
JPXKQX Aug 6, 2024
3736756
fix: cli/inspect
JPXKQX Aug 6, 2024
3cf342f
Merge branch 'develop' into feature/docs
JPXKQX Aug 20, 2024
9bcdce6
fix: rename to anemoi.graphs
JPXKQX Aug 20, 2024
3ae861a
fix: rename to anemoi.graphs
JPXKQX Aug 20, 2024
6b37987
docs: docstring for MultiScaleEdges
JPXKQX Aug 20, 2024
e53588b
docs: explain output object
JPXKQX Aug 20, 2024
9cea800
docs: homegenize modules section
JPXKQX Aug 20, 2024
903aebe
docs: fix table
JPXKQX Aug 20, 2024
2888205
docs: refactor modules into a section
JPXKQX Aug 20, 2024
2ab138f
docs: fix layout
JPXKQX Aug 20, 2024
f826e95
docs: bring contributing guidelines from anemoi-training
JPXKQX Aug 20, 2024
ba0fc13
docs: add references to cli pages
JPXKQX Aug 20, 2024
5354407
docs: add anemoi-graphs describe CLI
JPXKQX Aug 20, 2024
bf38fe3
docs: expand docstring
JPXKQX Aug 20, 2024
c6ca217
docs: lam documentation WIP
JPXKQX Aug 20, 2024
d68bbf1
docs: include creator and inspector to modules
JPXKQX Aug 21, 2024
0410996
Merge branch 'feature/docs' into docs/limited_area
JPXKQX Aug 21, 2024
73b8395
docs: update usage
JPXKQX Aug 21, 2024
19a3d16
Merge branch 'develop' into docs/limited_area
JPXKQX Aug 23, 2024
c4a592a
docs: fix typo
JPXKQX Sep 2, 2024
46d5bdf
docs: CutOutZarrDatasetNodes
JPXKQX Sep 2, 2024
83f1c82
fix: typo
JPXKQX Sep 11, 2024
0deac2e
docs: fix typos
JPXKQX Sep 16, 2024
0f5bfb1
docs: adding edges to tables
JPXKQX Sep 16, 2024
aa9c359
docs: update
JPXKQX Sep 20, 2024
3dbf4d2
Merge branch 'develop' into docs/limited_area
JPXKQX Oct 3, 2024
cfc4b18
fix: issue 57
JPXKQX Oct 15, 2024
36c9299
Merge branch 'develop' into docs/limited_area
JPXKQX Oct 21, 2024
b3c3899
docs: update
JPXKQX Oct 21, 2024
2826f4c
docs: include all node builders into modules
JPXKQX Oct 21, 2024
dbb842a
Merge branch 'develop' into docs/limited_area
JPXKQX Oct 23, 2024
6d6d643
Merge branch 'develop' into docs/limited_area
JPXKQX Oct 23, 2024
505d914
Merge branch 'develop' into docs/limited_area
JPXKQX Oct 28, 2024
3afbfe0
Merge branch 'develop' into docs/limited_area
JPXKQX Nov 12, 2024
445896b
Merge branch 'develop' into docs/limited_area
JPXKQX Nov 21, 2024
93e1588
fix: remove "s"
JPXKQX Nov 21, 2024
6b62501
fix: add icon docs to index
JPXKQX Nov 21, 2024
0613d05
Merge branch 'docs/limited_area' of github.com:ecmwf/anemoi-graphs in…
JPXKQX Nov 21, 2024
5f6ed36
Merge branch 'develop' into docs/limited_area
JPXKQX Nov 22, 2024
e3ebcab
docs: post-processors
JPXKQX Nov 22, 2024
5641276
fix: update to new PRs
JPXKQX Nov 22, 2024
3154209
docs: minor fixes
JPXKQX Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Keep it human-readable, your future self will thank you!
- feat: Add CONTRIBUTORS.md file. (#72)
- Fixed issue when computing area weights with scipy.Voronoi. (#79)

- Create package documentation.

### Changed

- ci: small fixes and updates pre-commit, downsteam-ci (#49)
Expand Down
3 changes: 2 additions & 1 deletion docs/cli/inspect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
inspect
========

Use this command to inspect a graph stored in your filesystem.
Use this command to inspect a graph stored in your filesystem. A set of interactive and static visualisations
are generated to allow visual inspection of the graph design.

The syntax of the recipe file is described in :doc:`building graphs <../graphs/introduction>`.

Expand Down
10 changes: 6 additions & 4 deletions docs/graphs/edge_attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ coordinates.
.. code:: yaml

edges:
- ...
edge_builder: ...
- source_name: ...
target_name: ...
edge_builders: ...
attributes:
edge_length:
_target_: anemoi.graphs.edges.attributes.EdgeLength
Expand All @@ -37,8 +38,9 @@ latitude and longitude coordinates of the source and target nodes.
.. code:: yaml

edges:
- ...
edge_builder: ...
- source_name: ...
target_name: ...
edge_builders: ...
attributes:
edge_length:
_target_: anemoi.graphs.edges.attributes.EdgeDirection
20 changes: 18 additions & 2 deletions docs/graphs/edges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ for each (`source name`, `target name`) pair specified.
edges:
- source_name: data
target_name: hidden
edge_builder:
_target_: anemoi.graphs.edges.CutOff
edge_builders:
- _target_: anemoi.graphs.edges.CutOff
cutoff_factor: 0.7

Below are the available methods for defining the edges:
Expand All @@ -26,3 +26,19 @@ Below are the available methods for defining the edges:
edges/cutoff
edges/knn
edges/multi_scale

Additionally, there are 2 extra arguments (``source_mask_attr_name`` and
``target_mask_attr_name``) that can be used in the edge configuration to
mask source and/or target nodes. This can be useful to different use
cases, such as Limited Area Modeling (LAM) where your decoder edges
should only connect to the nodes in the limited area.

.. code:: yaml

edges:
- source_name: hidden
target_name: data
edge_builders:
- _target_: anemoi.graphs.edges.KNNEdges
num_nearest_neighbours: 5
target_mask_attr_name: cutout
6 changes: 3 additions & 3 deletions docs/graphs/edges/cutoff.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ YAML configuration:
edges:
- source_name: source
target_name: destination
edge_builder:
_target_: anemoi.graphs.edges.CutOffEdges
edge_builders:
- _target_: anemoi.graphs.edges.CutOffEdges
cutoff_factor: 0.6

.. note::

The cut-off method is recommended for the encoder edges, to connect
The cut-off method is recommended for the encoder edge, to connect
all data nodes to hidden nodes. The optimal ``cutoff_factor`` value
will be the lowest value without orphan nodes. This optimal value
depends on the node distribution, so it is recommended to tune it for
Expand Down
20 changes: 10 additions & 10 deletions docs/graphs/edges/knn.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#####################
K-Nearest Neighbors
#####################
######################
K-Nearest Neighbours
######################

The knn method is a method for establishing connections between two sets
of nodes. Given two sets of nodes, (`source`, `target`), the knn method
connects all destination nodes, to their ``num_nearest_neighbours``
nearest source nodes.
connects all target nodes, to their ``num_nearest_neighbours`` nearest
source nodes.

To use this method to build your connections, you can use the following
YAML configuration:
Expand All @@ -14,12 +14,12 @@ YAML configuration:

edges:
- source_name: source
target_name: destination
edge_builder:
_target_: anemoi.graphs.edges.KNNEdges
target_name: target
edge_builders:
- _target_: anemoi.graphs.edges.KNNEdges
num_nearest_neighbours: 3

.. note::

The knn method is recommended for the decoder edges, to connect all
data nodes with the surrounding hidden nodes.
The KNNEdges method is recommended for the decoder edges, to connect
all target nodes with the surrounding source nodes.
12 changes: 8 additions & 4 deletions docs/graphs/edges/multi_scale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The multi-scale connections can only be defined with the same source and
target nodes. Edges of different scales are defined based on the
refinement level of an icosahedron. The higher the refinement level, the
shorter the length of the edges. By default, all possible refinements
shorther the length of the edges. By default, all possible refinements
levels are considered.

To use this method to build your connections, you can use the following
Expand All @@ -16,8 +16,8 @@ YAML configuration:
edges:
- source_name: source
target_name: source
edge_builder:
_target_: anemoi.graphs.edges.MultiScaleEdges
edge_builders:
- _target_: anemoi.graphs.edges.MultiScaleEdges
x_hops: 1

where `x_hops` is the number of hops between two nodes of the same
Expand All @@ -28,8 +28,12 @@ refinement level to be considered neighbours, and then connected.
This method is used by data-driven weather models like GraphCast to
process the latent/hidden state.

.. csv-table:: Triangular refinements specifications (x_hops=1)
:file: ./tri_refined_edges.csv
:header-rows: 1

.. warning::

This connection method is only supported for building the connections
This connection method is only support for building the connections
within a set of nodes defined with the ``TriNodes`` or ``HexNodes``
classes.
8 changes: 8 additions & 0 deletions docs/graphs/edges/tri_refined_edges.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Refinement,Num Nodes,Num Edges,Num Multilevel Edges
0,12,60,60
1,42,240,300
2,162,960,1260
3,642,3840,5100
4,2562,15360,20460
5,10242,61440,81900
6,40962,245760,327660
1 change: 1 addition & 0 deletions docs/graphs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ following classes define different behaviour:

- :doc:`node_coordinates/zarr_dataset`
- :doc:`node_coordinates/npz_file`
- :doc:`node_coordinates/icon_mesh`
- :doc:`node_coordinates/tri_refined_icosahedron`
- :doc:`node_coordinates/hex_refined_icosahedron`
- :doc:`node_coordinates/healpix`
Expand Down
9 changes: 9 additions & 0 deletions docs/graphs/node_attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ nodes.
:maxdepth: 1

node_attributes/weights
node_attributes/zarr_attribute

Additionally, different boolean operations have been implemented to
support more complex use cases:

.. toctree::
:maxdepth: 1

node_attributes/boolean_operations
12 changes: 12 additions & 0 deletions docs/graphs/node_attributes/boolean_operations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
####################
Boolean operations
####################

_anemoi-graphs_ package implements a set of boolean opearations to
support these operations when defining node attributes. Below, an
attribute `mask` is computed as the intersection of two other masks,
that are generated as the non-missing values in 2 different variables in
a Zarr dataset.

.. literalinclude:: ../yaml/attributes_boolean_operation.yaml
:language: yaml
2 changes: 1 addition & 1 deletion docs/graphs/node_attributes/weights.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Weights
#########

The `weights` are a node attribute useful for defining the importance of
The `weights` are node attributes useful for defining the importance of
a node in the loss function. You can set the weights to follow an
uniform distribution or to match the area associated with that node.

Expand Down
18 changes: 18 additions & 0 deletions docs/graphs/node_attributes/zarr_attribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
###################
From Zarr dataset
###################

Zarr datasets are the standard format to define data nodes in
_anemoi-graphs_. The user can define node attributes based on a zarr
dataset variable. For example, the following recipe will define an
attribute `land_mask` based on the _lsm_ variable of the dataset.

.. literalinclude:: ../yaml/attributes_nonmissingzarr.yaml
:language: yaml

In addition, if an user is using "cutout" operation to build their
dataset, it may be helpful to create a `cutout_mask` to track the
provenance of the resulting nodes. An example is shown below:

.. literalinclude:: ../yaml/attributes_cutout.yaml
:language: yaml
1 change: 1 addition & 0 deletions docs/graphs/node_coordinates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ a file:

node_coordinates/zarr_dataset
node_coordinates/npz_file
node_coordinates/icon_mesh

or based on other algorithms. A commonn approach is to use an
icosahedron to project the earth's surface, and refine it iteratively to
Expand Down
2 changes: 1 addition & 1 deletion docs/graphs/node_coordinates/healpix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ to the number of refinements of the sphere.
.. code:: yaml

nodes:
data:
data: # name of the nodes
node_builder:
_target_: anemoi.graphs.nodes.HEALPixNodes
resolution: 3
Expand Down
42 changes: 33 additions & 9 deletions docs/graphs/node_coordinates/hex_refined_icosahedron.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,56 @@

This method allows us to define the nodes based on the Hexagonal
Hierarchical Geospatial Indexing System, which uses hexagons to divide
the sphere. Each refinement level divides each hexagon into seven
smaller hexagons.
the sphere. With each refinement, each hexagon into seven smaller
hexagons.

To define the `node coordinates` based on the hexagonal refinements of
an icosahedron, you can use the following YAML configuration:

***************
Global graphs
***************

The class `HexNodes` allows us to define the nodes over the entire
globe.

.. code:: yaml

nodes:
data:
hidden: # name of the nodes
node_builder:
_target_: anemoi.graphs.nodes.HexNodes
resolution: 4
attributes: ...

where resolution is the number of refinements to be applied.
where `resolution` is the number of refinements to be applied.

*********************
Limited Area graphs
*********************

The class `LimitedAreaHexNodes` allows us to define the nodes only for a
specific area of interest.

.. code:: yaml

nodes:
hidden: # name of the nodes
node_builder:
_target_: anemoi.graphs.nodes.LimitedAreaHexNodes
resolution: 4
reference_node_name: nodes_name
mask_attr_name: mask_name # optional
margin_radius_km: 100 # optional
attributes: ...

where `reference_node_name` is the name of the nodes to define the area
of interest.

.. csv-table:: Hexagonal Hierarchical refinements specifications
:file: ./hex_refined.csv
:header-rows: 1

Note that the refinement level is the parameter used to control the
resolution of the nodes, but the resolution also depends on the
refinement method. Then, for the same refinement level, ``HexNodes``
will have a higher resolution than ``TriNodes``.

.. warning::

This class will require the `h3 <https://h3.org>`_ package to be
Expand Down
10 changes: 4 additions & 6 deletions docs/graphs/node_coordinates/icon_mesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ following YAML example:
node_builder:
_target_: anemoi.graphs.nodes.ICONCellGridNodes
icon_mesh: "icon_mesh"
attributes: ${graph.attributes.nodes}
# Hidden nodes
hidden:
node_builder:
Expand All @@ -56,9 +55,8 @@ following YAML example:

edges:
# Processor configuration
- source_name: ${graph.hidden}
target_name: ${graph.hidden}
edge_builder:
_target_: anemoi.graphs.edges.ICONTopologicalProcessorEdges
- source_name: "hidden"
target_name: "hidden"
edge_builders:
- _target_: anemoi.graphs.edges.ICONTopologicalProcessorEdges
icon_mesh: "icon_mesh"
attributes: ${graph.attributes.edges}
6 changes: 3 additions & 3 deletions docs/graphs/node_coordinates/npz_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ following YAML configuration:
.. code:: yaml

nodes:
data:
data: # name of the nodes
node_builder:
_target_: anemoi.graphs.nodes.NPZFileNodes
grids_definition_path: /path/to/folder/with/grids/
grid_definition_path: /path/to/folder/with/grids/
resolution: o48

where `grids_definition_path` is the path to the folder containing the
where `grid_definition_path` is the path to the folder containing the
grid definition files and `resolution` is the resolution of the grid to
be used.

Expand Down
8 changes: 8 additions & 0 deletions docs/graphs/node_coordinates/tri_nodes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Refinement,Num Nodes,Num Faces,Avg. Area (sq km)
0,12,20,25503600
1,42,80,6375900
2,162,320,1593975
3,642,1280,398494
4,2562,5120,99623
5,10242,20480,24905
6,40962,81920,6226
Loading
Loading