Skip to content

Conversation

@mx-moth
Copy link
Contributor

@mx-moth mx-moth commented Aug 18, 2025

SCHISM datasets define many variables on the node grid of the dataset, unlike COMPAS datasets with their data on the face grid. emsarray can open SCHISM datasets but didn't know how to plot them till now.

This support is experimental and the API is likely to change. There are no tests yet.

This is preliminary work to add temporary support for SCHISM. A full rework to generically support extended plotting options is coming in the future but is not part of this work.

@mx-moth mx-moth self-assigned this Aug 18, 2025
@mx-moth mx-moth force-pushed the plot-schism-output branch 3 times, most recently from 243ab1b to 9f181b8 Compare August 19, 2025 06:46
SCHISM datasets define many variables on the node grid of the dataset,
unlike COMPAS datasets with their data on the face grid. emsarray can
open SCHISM datasets but didn't know how to plot them till now.

This support is experimental and the API is likely to change. There are
no tests yet.
Now the convention can decide how to plot a variable / tuple of
variables, perhaps by determining which grid they are on. The collection
of new plot functions on the Convention also give more flexibility to
callers.

The animation functions have not been updated to match yet.

This is a partial implementation of the work required for #175
@mx-moth mx-moth force-pushed the plot-schism-output branch from 9f181b8 to 171146f Compare August 19, 2025 06:52
@mx-moth
Copy link
Contributor Author

mx-moth commented Aug 19, 2025

You can now do something like this:

ds = emsarray.open_dataset(...)
ds.ems.plot("face_based_variable")
ds.ems.plot("node_based_variable")
ds.ems.plot(("u", "v"))

and emsarray will pick the right thing to do. You can stack plots by supplying more variables as:

ds = emsarray.open_dataset(...)
ds = ds.isel(time=0, depth=0)
ds.ems.plot("temp", ("u", "v"))

Each convention knows how to plot some kinds of variables, and a particular convention can add support for plotting more kinds of variables. A "variable" here means either a data array, or a tuple of data arrays. The tuple form is useful for plotting vectors, for example, where the individual data arrays form components of the whole variable.

The base Convention knows how to plot scalar variables on the default polygon grid, and face centred vectors from two component variables. The UGrid convention knows how to plot variables defined on nodes as a TriMesh with gouraud shading.

Once more tests have been written this could be merged as is, but this is not the final form. ArakawaC grids also have node based data, for example, and those should be plotable by reusing the code. This would require moving the trimesh code somewhere reusable instead of being in the UGrid convention. My proposed approach is detailed in #121.

The triangulation code also needs some changes. The fix added here is temporary. A better approach is documented in #189.

@mx-moth mx-moth mentioned this pull request Dec 11, 2025
@mx-moth
Copy link
Contributor Author

mx-moth commented Dec 11, 2025

Closing in favour of #205, which does this but more thoroughly.

@mx-moth mx-moth closed this Dec 11, 2025
@mx-moth mx-moth deleted the plot-schism-output branch December 11, 2025 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants