Skip to content

Update NEMO ingestion code#2549

Open
VeckoTheGecko wants to merge 4 commits intoParcels-code:mainfrom
VeckoTheGecko:update-convert
Open

Update NEMO ingestion code#2549
VeckoTheGecko wants to merge 4 commits intoParcels-code:mainfrom
VeckoTheGecko:update-convert

Conversation

@VeckoTheGecko
Copy link
Contributor

@VeckoTheGecko VeckoTheGecko commented Mar 18, 2026

Upon further testing, our convert.nemo_to_sgrid function needed some changes. This PR:

  • Updates NEMO fieldset ingestion so that it expects depthw to be provided (and distinguishes from depths that are on the cell centers vs the cell edges)
  • warns the user if they don't provide the depth

Still to add tests... Wondering what the best way to do that is for the convert.py module


Now....I think this means that we run into a problem. Trying to advect particles on the ocean surface with U and V velocities gives (I think) some being out of bound errors

parcels._core.statuscodes.FieldInterpolationError: Field interpolation returned NaN at (z=array([0., 0.], dtype=float32), lat=array([-25.004845, -24.99483 ], dtype=float32), lon=array([-0.01091189,  0.00910761], dtype=float32))

since now the U and V velocities are defined at -0.5 cell height. Is this something that we have resolved in our internal model of Parcels? cc @erikvansebille

(debugging within parcels_benchmarks was a bit of a nightmare - I'm hope we can get a better loop working. #2546 should help somewhat. @fluidnumerics-joe what's your experience working within parcels_benchmarks?)

xref Parcels-code/parcels-benchmarks#40

@VeckoTheGecko
Copy link
Contributor Author

Also, another question about API:

Is the following the API we're going for?

    U = xr.open_mfdataset(data_folder.glob("*U.nc4"))
    V = xr.open_mfdataset(data_folder.glob("*V.nc4"))
    depth_da = xr.open_mfdataset(data_folder.glob("*W.nc4"))['depthw']
    coords = xr.open_dataset(data_folder / "mesh_mask.nc4")
    coords['depthw'] = depth_da
    ds = convert.nemo_to_sgrid(fields=dict(U=U, V=V), coords=coords)

and then if they want to do 2D advection (no depth)

    U = xr.open_mfdataset(data_folder.glob("*U.nc4"))
    V = xr.open_mfdataset(data_folder.glob("*V.nc4"))
    coords = xr.open_dataset(data_folder / "mesh_mask.nc4")
    ds = convert.nemo_to_sgrid(fields=dict(U=U, V=V), coords=coords)

(currently the test cases are failing since it expects depthw to be provided regardless - so explicitly providing [0] for 2D advection)

@erikvansebille
Copy link
Member

Yep, I think that's a good API. Mirrors also what's now in Parcels v3, where 2D advection at the surface does not require a depth field (depth is then assumed zero throughout)

@fluidnumerics-joe
Copy link
Contributor

@fluidnumerics-joe what's your experience working within parcels_benchmarks?

The MOI Curvilinear benchmark has been broken for some time. After getting the time ordering sorted out on my system, it's been a bit of whack-a-mole to get that benchmark running.

@VeckoTheGecko
Copy link
Contributor Author

VeckoTheGecko commented Mar 19, 2026

I'm going to park this PR for the timebeing to focus on other profiling stuff

The MOI Curvilinear benchmark has been broken for some time. After getting the time ordering sorted out on my system, it's been a bit of whack-a-mole to get that benchmark running.

Good to know - let me know when you'd like to hop back on that line, happy to work on it together

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