Skip to content

Commit 9041816

Browse files
committed
Doc: Add v4 design document
1 parent bed9c8a commit 9041816

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"myst_parser",
4444
"nbsphinx",
4545
"numpydoc",
46+
"sphinxcontrib.mermaid",
4647
]
4748

4849
# Add any paths that contain templates here, relative to this directory.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ If you need more help with Parcels, try the `Discussions page on GitHub <https:/
1717
:hidden:
1818

1919
Home <self>
20+
v4 <v4/index>
2021
Installation <installation>
2122
Tutorials & Documentation <documentation/index>
2223
API reference <reference>

docs/v4/api.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# API design document
2+
3+
## Field data input
4+
5+
Here is the proposed API for Field data ingestion into Parcels.
6+
7+
```{mermaid}
8+
9+
classDiagram
10+
class Fieldset{
11+
+List[Field] fields
12+
}
13+
class Field{
14+
+xr.Dataset|xr.DataArray|ux.Dataset|ux.DataArray data
15+
+parcels.Grid|ux.Grid grid
16+
+Interpolator interpolator
17+
+eval(...)
18+
}
19+
20+
class Interpolator{
21+
+assert_is_compatible(Field)
22+
+interpolate(Field, ...)
23+
}
24+
25+
26+
<<Protocol>> Interpolator
27+
28+
Fieldset ..> Field : depends on
29+
Field ..> Interpolator : depends on
30+
Interpolator <|.. ScalarInterpolator : Realization of
31+
Interpolator <|.. VectorInterpolator : Realization of
32+
Interpolator <|.. etc : Realization of
33+
```
34+
35+
Here, important things to note are:
36+
37+
- Interpolators (which would implement the `Interpolator` protocol) are responsible for the actual interpolation of the data, and performance considerations. There will be interpolation and indexing utilities that can be made available to the interpolators, allowing for code re-use.
38+
39+
- In the `Field` class, not all combinations of `data`, `grid`, and `interpolator` will logically make sense (e.g., a `xr.DataArray` on a `ux.Grid`, or `ux.DataArray` on a `parcels.Grid`). It's up to the `Interpolator.assert_is_compatible(Field)` to define what is and is not compatible, and raise `ValueError` / `TypeError` on incompatible data types. The `.assert_is_compatible()` method also acts as developer documentation, defining clearly for the `.interpolate()` method what assumptions it is working on. The `.assert_is_compatible()` method should be lightweight as it will be called on `Field` initialisation.
40+
41+
- The `grid` object, in the case of unstructured grids, will be the `Grid` class from UXarray. For structured `Grid`s, it will be an object similar to that of `xgcm.Grid` (note that it will be very different from the v3 `Grid` object hierarchy).

docs/v4/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# v4 development
2+
3+
This is a central hub to discuss the development of v4. As development progresses, some of the pages mentioned here will be incorporated into the main documentation.
4+
5+
You can think of this as a "living" document as we work towards the release of v4.
6+
7+
```{toctree}
8+
9+
api
10+
```

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ dependencies:
4646
- pydata-sphinx-theme
4747
- sphinx-autobuild
4848
- myst-parser
49+
- sphinxcontrib-mermaid

0 commit comments

Comments
 (0)