Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/fesom2.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def pset_execute(self, npart, integrator):
lat = np.linspace(32.0, 19.0, npart)

pset = ParticleSet(fieldset=fieldset, pclass=Particle, lon=lon, lat=lat)
pset.execute(runtime=runtime, dt=dt, pyfunc=integrator)
pset.execute(kernels=integrator, runtime=runtime, dt=dt)

def time_pset_execute(self, npart, integrator):
self.pset_execute(npart, integrator)
Expand Down
51 changes: 10 additions & 41 deletions benchmarks/moi_curvilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np
import parcels
import xarray as xr
import xgcm
from parcels.interpolators import XLinear

from parcels_benchmarks.benchmark_setup import PARCELS_DATADIR, download_example_dataset
Expand All @@ -14,7 +13,6 @@

def _load_ds(datapath, chunk):
"""Helper function to load xarray dataset from datapath with or without chunking"""

fileU = f"{datapath}/psy4v3r1-daily_U_2025-01-0[1-3].nc"
filenames = {
"U": glob(fileU),
Expand All @@ -32,27 +30,16 @@ def _load_ds(datapath, chunk):
if chunk:
fileargs["chunks"] = {"time_counter": 1, "depth": 2, "y": chunk, "x": chunk}

ds_u = xr.open_mfdataset(filenames["U"], **fileargs)[["vozocrtx"]].drop_vars(
["nav_lon", "nav_lat"]
ds_u = xr.open_mfdataset(filenames["U"], **fileargs)[["vozocrtx"]].rename_vars(
{"vozocrtx": "U"}
)
ds_v = xr.open_mfdataset(filenames["V"], **fileargs)[["vomecrty"]].drop_vars(
["nav_lon", "nav_lat"]
ds_v = xr.open_mfdataset(filenames["V"], **fileargs)[["vomecrty"]].rename_vars(
{"vomecrty": "V"}
)
ds_depth = xr.open_mfdataset(filenames["W"], **fileargs)[["depthw"]]
da_depth = xr.open_mfdataset(filenames["W"], **fileargs)["depthw"]
ds_mesh = xr.open_dataset(mesh_mask)[["glamf", "gphif"]].isel(t=0)

ds = xr.merge([ds_u, ds_v, ds_depth, ds_mesh], compat="identical")
ds = ds.rename(
{
"vozocrtx": "U",
"vomecrty": "V",
"glamf": "lon",
"gphif": "lat",
"time_counter": "time",
"depthw": "depth",
}
)
ds.deptht.attrs["c_grid_axis_shift"] = -0.5
ds_mesh["depthw"] = da_depth
ds = parcels.convert.nemo_to_sgrid(fields=dict(U=ds_u, V=ds_v), coords=ds_mesh)

return ds

Expand Down Expand Up @@ -89,31 +76,13 @@ def time_load_data_3d(self, interpolator, chunk, npart):

def pset_execute_3d(self, interpolator, chunk, npart):
ds = _load_ds(self.datapath, chunk)
coords = {
"X": {"left": "x"},
"Y": {"left": "y"},
"Z": {"center": "deptht", "left": "depth"},
"T": {"center": "time"},
}

grid = parcels._core.xgrid.XGrid(
xgcm.Grid(ds, coords=coords, autoparse_metadata=False, periodic=False),
mesh="spherical",
)

fieldset = parcels.FieldSet.from_sgrid_conventions(ds)
if interpolator == "XLinear":
interp_method = XLinear
fieldset.U.interp_method = XLinear
fieldset.V.interp_method = XLinear
else:
raise ValueError(f"Unknown interpolator: {interpolator}")

U = parcels.Field("U", ds["U"], grid, interp_method=interp_method)
V = parcels.Field("V", ds["V"], grid, interp_method=interp_method)
U.units = parcels.GeographicPolar()
V.units = parcels.Geographic()
UV = parcels.VectorField("UV", U, V)

fieldset = parcels.FieldSet([U, V, UV])

pclass = parcels.Particle

lon = np.linspace(-10, 10, npart)
Expand Down
6 changes: 3 additions & 3 deletions results/benchmarks.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"10000"
],
[
"<function AdvectionEE>"
"<function AdvectionRK2_3D>"
]
],
"type": "peakmemory",
Expand All @@ -32,7 +32,7 @@
"10000"
],
[
"<function AdvectionEE>"
"<function AdvectionRK2_3D>"
]
],
"repeat": 0,
Expand All @@ -57,7 +57,7 @@
"10000"
],
[
"<function AdvectionEE>"
"<function AdvectionRK2_3D>"
]
],
"repeat": 0,
Expand Down