Skip to content

Cleanup tests/test_advection.py fieldset ingestion to use SGRID#2642

Merged
VeckoTheGecko merged 11 commits into
Parcels-code:mainfrom
VeckoTheGecko:cleanup
May 22, 2026
Merged

Cleanup tests/test_advection.py fieldset ingestion to use SGRID#2642
VeckoTheGecko merged 11 commits into
Parcels-code:mainfrom
VeckoTheGecko:cleanup

Conversation

@VeckoTheGecko
Copy link
Copy Markdown
Contributor

Description

To confidently overhaul architecture, I would like a set of integration tests that rely on stable API (i.e., the SGRID convention ingestion) that I can use to make sure I'm not breaking anything. Once we finalise the re-organisation, we can go through the rest of the test suite deleting/updating tests.

This set of integration tests is tests/test_advection.py. At the moment they use old (manual) fieldset creation. This PR updates them to use SGRID instead:

Changes:

  • see commit log

Checklist

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

AI Disclosure

None used

Needed to relax the tolerance here. Is that acceptable? Might need to revisit the original datasets defined in generic.py to assure the spatial extents are acceptable
@VeckoTheGecko
Copy link
Copy Markdown
Contributor Author

Failures due to #2643 - once that merges we'll be green.

Copy link
Copy Markdown
Contributor Author

@VeckoTheGecko VeckoTheGecko left a comment

Choose a reason for hiding this comment

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

Added some comments for context

Comment thread tests/test_advection.py
Comment on lines 7 to 27
@@ -26,7 +23,7 @@
simple_UV_dataset,
stommel_gyre_dataset,
)
from parcels.interpolators import CGrid_Velocity, XLinear, XLinear_Velocity
from parcels._datasets.structured.generic import datasets_sgrid
from parcels.kernels import (
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The removal of these lower level imports (Field, XGrid, and interpolators) is really nice for this high level set of tests.

Comment thread tests/test_advection.py
[(None, None), (-0.02, slice(0, 1)), (0.07, slice(None))],
ids=["no_vertical", "single_w_layer", "full_w"],
)
def test_length1dimensions(u_value, x_slice, v_value, y_slice, w_value, z_slice):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For this test I replaced the dataset entirely using one of the existing sgrid ones in datasets_sgrid.

I did need to adjust the velocities and seeding positions though. See

@VeckoTheGecko
Fix spatial extent for test
fba5867
Needed to relax the tolerance here. Is that acceptable? Might need to revisit the original datasets defined in generic.py to assure the spatial extents are acceptable

Should be fine right?

In the other tests, all other dataset changes are just related to now ingesting from SGRID metadata - keeping things the same in the tests

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.

Yes, I think this is fine



datasets = {
datasets_comodo = {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To be explicit that these datasets use the (now mostly defunct) COMODO conventions.

Given we're relying more on sgrid I think this renaming is good.

Comment thread tests/test_advection.py
indexers = {"node_dimension1": x_slice, "node_dimension2": y_slice}
if w_value:
indexers.update({"vertical_dimensions_dim1": z_slice})
ds = ds.sgrid.isel(indexers)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The new .sgrid functionality 🚀

Comment thread tests/test_advection.py
Copy link
Copy Markdown
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

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

Excellent, looks all very good to me! Happy to merge on green ticks

@VeckoTheGecko VeckoTheGecko merged commit 1731d52 into Parcels-code:main May 22, 2026
15 of 16 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development May 22, 2026
@VeckoTheGecko VeckoTheGecko deleted the cleanup branch May 22, 2026 12:38
@VeckoTheGecko
Copy link
Copy Markdown
Contributor Author

@fluidnumericsJoe would you say that https://github.com/Parcels-code/Parcels/blob/a228c81ec19d1108df731387755d45633eb9dc5d/tests/test_uxadvection.py would be a good set of integration tests for the unstructured side? Are there any other tests that you think would be helpful for me ?

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants