From 5caa326c0c5065c54087ff8f8895b657f43c43be Mon Sep 17 00:00:00 2001 From: hayatexe <145812188+hayatexe@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:04:29 +0300 Subject: [PATCH] Rename _is_agrid to _is_cgrid The check (U and V defined on the same dimensions) also holds for B-grids, so the old name was misleading. Rename to _is_cgrid and negate the logic. No behaviour change. Fixes #2692 --- src/parcels/_core/model.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/parcels/_core/model.py b/src/parcels/_core/model.py index e1c44de30..35eac176f 100644 --- a/src/parcels/_core/model.py +++ b/src/parcels/_core/model.py @@ -216,7 +216,7 @@ def construct_fields(self) -> list[Field | VectorField]: for vfield_name, components in self.vector_field_components.items(): interp_method = ( - XLinear_Velocity() if _is_agrid(self.data, u=components[0], v=components[1]) else CGrid_Velocity() + CGrid_Velocity() if _is_cgrid(self.data, u=components[0], v=components[1]) else XLinear_Velocity() ) component_fields = [single_fields[name] for name in components] @@ -553,10 +553,10 @@ def _select_uxinterpolator(da: ux.UxDataArray): return None -def _is_agrid(ds: xr.Dataset, u: str, v: str) -> bool: - # check if U and V are defined on the same dimensions - # if yes, interpret as A grid - return set(ds[u].dims) == set(ds[v].dims) +def _is_cgrid(ds: xr.Dataset, u: str, v: str) -> bool: + # check if U and V are defined on different dimensions + # if yes, interpret as C grid (if no, it could be an A or B grid) + return set(ds[u].dims) != set(ds[v].dims) def _get_time_interval(data: xr.DataArray | ux.UxDataArray) -> TimeInterval | None: