Skip to content

Update NEMO ingestion code#2549

Merged
VeckoTheGecko merged 7 commits intoParcels-code:mainfrom
VeckoTheGecko:update-convert
Apr 7, 2026
Merged

Update NEMO ingestion code#2549
VeckoTheGecko merged 7 commits intoParcels-code:mainfrom
VeckoTheGecko:update-convert

Conversation

@VeckoTheGecko
Copy link
Copy Markdown
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) In fact, I guess they should be able to not provide depth in the 2D case. The convert module should be refactored later
  • 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

xref Parcels-code/parcels-benchmarks#40

EDIT: Updated description to remove out of date test failure info

@VeckoTheGecko
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@VeckoTheGecko
Copy link
Copy Markdown
Contributor Author

I'm going to merge this so that we can also move forward with Parcels-code/parcels-benchmarks#40 (I will then work on this "middle layer" of testing which is described in that PR so that we can better develop the convert module here).

@VeckoTheGecko VeckoTheGecko enabled auto-merge (squash) April 7, 2026 09:57
@VeckoTheGecko VeckoTheGecko merged commit 95eed0a into Parcels-code:main Apr 7, 2026
11 of 12 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Parcels development Apr 7, 2026
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.

3 participants