-
Notifications
You must be signed in to change notification settings - Fork 168
Parcels v4 FieldSet design documentation #1850
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bed9c8a
Doc: Update warning to announcement
VeckoTheGecko 9041816
Doc: Add v4 design document
VeckoTheGecko 8663266
Doc: Add link to project board
VeckoTheGecko 9139eb9
Suggest concretization of eval and interpolate api
fluidnumerics-joe f892552
Change spatio-temporal order of arguments. Add applyConversion arg
fluidnumerics-joe 5df13cd
Change order of args in description/notes
fluidnumerics-joe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # API design document | ||
|
|
||
| ## Field data input | ||
|
|
||
| Here is the proposed API for Field data ingestion into Parcels. | ||
|
|
||
| ```{mermaid} | ||
|
|
||
| classDiagram | ||
| class Fieldset{ | ||
| +List[Field] fields | ||
| } | ||
| class Field{ | ||
| +xr.Dataset|xr.DataArray|ux.Dataset|ux.DataArray data | ||
| +parcels.Grid|ux.Grid grid | ||
| +Interpolator interpolator | ||
| +eval(t, z, y, x, particle=None, applyConversion=True) | ||
| } | ||
|
|
||
| class Interpolator{ | ||
| +assert_is_compatible(Field) | ||
| +interpolate(Field, rid, t, z, y, x ) | ||
| } | ||
|
|
||
|
|
||
| <<Protocol>> Interpolator | ||
|
|
||
| Fieldset ..> Field : depends on | ||
| Field ..> Interpolator : depends on | ||
| Interpolator <|.. ScalarInterpolator : Realization of | ||
| Interpolator <|.. VectorInterpolator : Realization of | ||
| Interpolator <|.. etc : Realization of | ||
| ``` | ||
|
|
||
| Here, important things to note are: | ||
|
|
||
| - 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. | ||
|
|
||
| - 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. | ||
|
|
||
| - 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). | ||
|
|
||
| - The `Field.eval` method takes as input the t,z,y,x spatio-temporal position as required arguments; the `particle` is optional and defaults to `None` and the `applyConversion` argument is optional and defaults to `True`. Initially, we will calculate the element index for a particle. As a future optimization, we could pass via the `particle` object a "cached" index value that could be used to bypass an index search. This will effectively provide `(xi,yi,zi,ti)` on a structured grid and `(fi,zi,ti)` on an unstructured grid (where `fi` is the lateral face id); within `eval` these indices will be `ravel`'ed to a single index that can be `unravel`'ed in the `interpolate` method. The `ravel`'ed index is referred to as `rid` in the `Field.Interpolator.interpolate` method. In the `interpolate` method, we envision that a user will benefit from knowing the nearest cell/index from the `ravel`'ed index (which can be `unravel`'ed) in addition the exact coordinate that we want to interpolate onto. This can permit calculation of interpolation weights using points in the neighborhood of `(x,y,z,t)`. | ||
erikvansebille marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # v4 development | ||
|
|
||
| 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. | ||
|
|
||
| You can think of this as a "living" document as we work towards the release of v4. | ||
|
|
||
| Collaboration on v4 development is happening on the [Parcels v4 Project Board](https://github.com/orgs/OceanParcels/projects/5). | ||
|
|
||
| ```{toctree} | ||
|
|
||
| api | ||
| Parcels v4 Project Board <https://github.com/orgs/OceanParcels/projects/5> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,3 +46,4 @@ dependencies: | |
| - pydata-sphinx-theme | ||
| - sphinx-autobuild | ||
| - myst-parser | ||
| - sphinxcontrib-mermaid | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.