Skip to content

Conversation

@cdibble
Copy link
Contributor

@cdibble cdibble commented Dec 31, 2025

Handle discontinuities in X and Y direction for curvilinear grids. (pipeline.py).

Motivation

Visualizing HYCOM ocean model data with a curvilinear grid (see: Real-Time Ocean Forecast System/RTOFS grid) with X,Y dimensions and Latitude (X,Y) / Longitude (X,Y) coordinates for a large domain in the northeast pacific.

Screenshot 2025-12-17 at 12 28 21

Fixing pipeline.py

The issue seems to be that discontinuities can happen in either dimension for 2D grids. At different values of X an antimeridian crossing may or may not occur. At different values of Y, the starting value of Longitude can change. Previously, pipeline.subset_to_bbox was only handling the former. pipeline.subset_to_bbox now corrects for discontinuities in both directions.


Including both of these changes gives me the image I expect.

Screenshot 2025-12-16 at 23 42 44

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.64%. Comparing base (7c61ad6) to head (099e14a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
+ Coverage   75.58%   75.64%   +0.06%     
==========================================
  Files          26       26              
  Lines        3555     3564       +9     
==========================================
+ Hits         2687     2696       +9     
  Misses        868      868              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dcherian
Copy link
Collaborator

dcherian commented Dec 31, 2025

Can we get those unit tests too please?

Good sign that existing snapshots have not changed (as expected)

@cdibble
Copy link
Contributor Author

cdibble commented Jan 5, 2026

@dcherian Ok here are some unit tests- reworked a bit per your direction in #178

@dcherian
Copy link
Collaborator

dcherian commented Jan 6, 2026

Well the good news is that this example surfaced a couple of bugs that I have fixed. (#184 , #183).

The bad news is that this "simple" approach doesn't seem to work too well with the coarsen path.


Is this the "feature" of the real dataset that causes the problem?

ds.longitude.isel(Y=[0, -1]).plot(hue="Y")
image

@cdibble
Copy link
Contributor Author

cdibble commented Jan 6, 2026

Well the good news is that this example surfaced a couple of bugs that I have fixed. (#184 , #183).

That's great to hear.

The bad news is that this "simple" approach doesn't seem to work too well with the coarsen path.

Is this the "feature" of the real dataset that causes the problem?

ds.longitude.isel(Y=[0, -1]).plot(hue="Y")
image

I hadn't visualized it like that, but that sure seems to pinpoint the issue. The fundamental challenge may be that this is a hybrid grid- could that explain the strange behavior at [0, 3297] and [4500, 1]?

Here is an excerpt from the HYCOM docs. A more complete description lies here.

The global hycom grid is rectilinear from j=1 to j=2172, and you can check this by confirming that the minval and maxval of plat(1:4500,j) are identical there. The grid is curvilinear (bi-polar patch) from j=2173 to j=3298. Note that the j=3298 row is a permuted copy of j=3297 (because of the way the tripole grid is implemented in HYCOM), so you can discard j=3298.

@dcherian
Copy link
Collaborator

dcherian commented Jan 7, 2026

Can you merge ScootScience#2

* Tweak

* comment out for now

* Fix size limiter again (earth-mover#183)

* Add test

* Fix in-place transforms for float32 coordinates. (earth-mover#184)

* Update coarsen too

* Update localhost example
@cdibble
Copy link
Contributor Author

cdibble commented Jan 7, 2026

Ok merged those changes into this branch. I'll try and dig into the coarsen problem soon. Thanks for all the assistance.

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