Repository navigation
DOCS: Add tutorial for writing converter functions - #2939
VeckoTheGecko wants to merge 11 commits into
Conversation
|
I merged #2938 (which was quite cut and dry) so that we could focus on this |
|
keen to hear your thoughts here @erikvansebille . I think there are some items in |
erikvansebille
left a comment
There was a problem hiding this comment.
Very useful manual! See below some comments/thoughts/questions
| Parcels reads structured-grid model data through {py:func}`parcels.FieldSet.from_sgrid_conventions`. This function | ||
| does not guess how your model grid is laid out. Instead, it reads [SGRID](https://sgrid.github.io/sgrid/) metadata |
There was a problem hiding this comment.
I find the "does not ... instead" wording a bit confusing. Why not the simpler
| Parcels reads structured-grid model data through {py:func}`parcels.FieldSet.from_sgrid_conventions`. This function | |
| does not guess how your model grid is laid out. Instead, it reads [SGRID](https://sgrid.github.io/sgrid/) metadata | |
| Parcels reads structured-grid model data through {py:func}`parcels.FieldSet.from_sgrid_conventions`. This function reads [SGRID](https://sgrid.github.io/sgrid/) metadata |
| walks through writing a converter for a made-up model, and shows how to check the result with `describe()`. | ||
|
|
||
| ```{note} | ||
| This guide covers structured grids only (SGRID). Unstructured grids use the UGRID conventions and are not covered here. |
There was a problem hiding this comment.
@wyatt-fluidnumerics and @fluidnumericsJoe do you want to extend this manual to UGRID too? In a next PR?
| {py:func}`parcels.FieldSet.describe` to check that the vector fields were found and that the mesh is what you expect: | ||
|
|
||
| ```{code-cell} | ||
| fieldset = parcels.FieldSet.from_sgrid_conventions(ds) |
| print(f"x: {pset.x[0]:.4f} (expected ~{expected_x:.4f})") | ||
| print(f"y: {pset.y[0]:.4f} (expected ~{expected_y:.4f})") | ||
| print(f"z: {pset.z[0]:.4f} (expected ~{expected_z:.4f})") |
There was a problem hiding this comment.
Should we also do these as asserts, so that the RTD fails if for any reason they don't agree?
| | `No variable found in dataset with 'cf_role' attribute set to 'grid_topology'` | No SGRID metadata has been attached. | Add the `grid` variable (Step 2, part 5). | | ||
| | `DataArray 'U' with dims (...) has dimensions {'kt'} that are not associated with a direction` | A field dimension is not listed in the SGRID metadata. | Add it to `face_dimensions` or `vertical_dimensions`, or drop the extra dimension (e.g. with `.isel`). | | ||
| | `No variable named 'lat'` | The node coordinates have not been renamed. | Rename them to `lon` and `lat`, and make sure `node_coordinates` is `"lon lat"`. | | ||
| | `Coordinate 'lon' of your dataset has no 'units' attribute` | Parcels cannot tell whether the mesh is spherical or flat. | Set `units` (e.g. `"degrees_east"` or `"m"`), or pass `mesh=` to `from_sgrid_conventions`. | |
There was a problem hiding this comment.
Do we need to be even more explicit how to set units?
| | _No error, but particles don't move vertically, or move the wrong way_ | `W` is not named `W`, or its sign convention is positive upward. | Rename it to `W`, and negate it if the model uses positive upward. | | ||
|
|
||
| ## A template to start from | ||
|
|
There was a problem hiding this comment.
Add one sentence what to do with the template below? (although the title is relatively self-explanatory)
There was a problem hiding this comment.
I'm happy leaving it as is. Adding "copy paste the following into where you're writing your code" doesn't really add much value I think
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
for more information, see https://pre-commit.ci
46ee402 to
ede7880
Compare
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
for more information, see https://pre-commit.ci

Description
(Will populate PR template later - submitting now for review discussion)
Checklist
mainfor normal development,v3-supportfor v3 support)AI Disclosure