Skip to content

Add tutorial for SCHISM model for lake ontario.#2660

Open
fluidnumericsJoe wants to merge 4 commits into
mainfrom
docs/ux-schism-model-lakeontario-tutorial
Open

Add tutorial for SCHISM model for lake ontario.#2660
fluidnumericsJoe wants to merge 4 commits into
mainfrom
docs/ux-schism-model-lakeontario-tutorial

Conversation

@fluidnumericsJoe

Copy link
Copy Markdown
Contributor

Description

This is a minimum working example that illustrates primarily how to do 2D (lateral) particle advection with SCHISM model output. It walks through handling issues with uxarray, which assumes that the input grid is in units of degrees for latitude and longitude.

The SCHISM output provided here uses x,y in cartesian coordinates in units of meters. Since uxarray automatically wraps longitude to be between [0,360] we have to overwrite the node_lon values stored in the uxgrid object.

We show how to rename the SCHISM velocity field components, lateral node coordinate, and vertical grid names to match what Parcels expects to see. Note that we intentionally create a ficticious vertical grid in this example; Parcels currently does not support the LSC2 vertical grid that is used in SCHISM and this is documented clearly in the tutorial.

Checklist

  • This PR targets the correct branch (main for normal development, v3-support for v3 support)

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
    • Describe how you used it (e.g., by pasting your prompt): Claude code was used to copy edit the SCHISM tutorial to ensure we maintain similar tone and structure with other tutorials in the parcels documentation.

This is a minimum working example that illustrates primarily how to do
2D (lateral) particle advection with SCHISM model output. It walks
through handling issues with uxarray, which assumes that the input grid
is in units of degrees for latitude and longitude.

The SCHISM output provided here uses x,y in cartesian coordinates in
units of meters. Since uxarray automatically wraps longitude to be
between [0,360] we have to overwrite the `node_lon` values stored in the
uxgrid object.

We show how to rename the SCHISM velocity field components, lateral node
coordinate, and vertical grid names to match what Parcels expects to
see. Note that we intentionally create a ficticious vertical grid in
this example; Parcels currently does not support the LSC2 vertical grid
that is used in SCHISM and this is documented clearly in the tutorial.
pre-commit-ci Bot and others added 3 commits June 12, 2026 15:25
A few minor changes to the tutorial
- Change to Australian spelling (metres -> meters) (#2376)
- increase the number of particles to 1500 (and set as a variable)
- Add grid mesh as black lines in plot
- Clarify that Parcels built-in Kernels require U and V (not Parcels itself)
- Change 'drift' to the more general 'end up'
- changed the Delete Kernel to use more intuitive boolean indexing

@erikvansebille erikvansebille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tutorial! I made some minor changes to the text in f1eb2a0

A few questions

  1. Should StatusCodes become part of the public API? So users can import it as parcels.StatusCodes? @VeckoTheGecko, what do you think?
  2. It seems that UXARRAY/uxarray#1525 is close to being fixed. Should we wait for it? Or merge this now and update when a new version of uxarray is released?
  3. I'm getting a warning (below) in the pset.execute(), is this a problemm?
/Users/erik/Codes/parcels/src/parcels/_core/spatialhash.py:592: RuntimeWarning: invalid value encountered in cast
  xq = np.clip((xn * bitwidth).astype(np.uint32), 0, bitwidth)

@VeckoTheGecko

VeckoTheGecko commented Jun 14, 2026

Copy link
Copy Markdown
Contributor
  1. Should StatusCodes become part of the public API? So users can import it as parcels.StatusCodes? @VeckoTheGecko, what do you think?

Given this line

- `particle.delete()` is no longer valid. Instead, use `particle.state = StatusCode.Delete`.

in the migration guide I think it should be part of the public API. Also I think its a good idea given how important states are for Parcels and users.

I just checked, it is already public API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the import from ._core and use parcels.StatusCode :)

@VeckoTheGecko VeckoTheGecko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for name, field in fieldset.fields.items():
    interp = getattr(field, "interp_method", None)
    print(
        f"{name:>4s} -> {type(field).__name__:<11s} interp={interp.__name__ if interp else '-'}"
    )

Just curious: I'm surprised that the interp_method is None sometimes here, is this from the vector fields?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants