Skip to content

Commit fdc45ba

Browse files
Merge pull request #1811 from OceanParcels/deprecating_curvilnear_halo_support
Deprecating curvilnear halo support
2 parents c3b17ca + 2522cb9 commit fdc45ba

File tree

3 files changed

+6
-49
lines changed

3 files changed

+6
-49
lines changed

docs/examples/tutorial_periodic_boundaries.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"cell_type": "markdown",
4343
"metadata": {},
4444
"source": [
45-
"In case of 'simple' models on an A-grid, the idea in Parcels is to do two things:\n",
45+
"If you have a 'simple' `Rectilinear` A-grid, you can create periodic boundaries in Parcels in two steps:\n",
4646
"\n",
4747
"1. Extend the fieldset with a small 'halo'\n",
4848
"2. Add a periodic boundary kernel to the `.execute`\n"

parcels/grid.py

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -694,53 +694,9 @@ def add_periodic_halo(self, zonal, meridional, halosize=5):
694694
halosize : int
695695
size of the halo (in grid points). Default is 5 grid points
696696
"""
697-
if zonal:
698-
lonshift = self.lon[:, -1] - 2 * self.lon[:, 0] + self.lon[:, 1]
699-
if not np.allclose(self.lon[:, 1] - self.lon[:, 0], self.lon[:, -1] - self.lon[:, -2]):
700-
warnings.warn(
701-
"The zonal halo is located at the east and west of current grid, "
702-
"with a dx = lon[1]-lon[0] between the last nodes of the original grid and the first ones of the halo. "
703-
"In your grid, lon[1]-lon[0] != lon[-1]-lon[-2]. Is the halo computed as you expect?",
704-
FieldSetWarning,
705-
stacklevel=2,
706-
)
707-
self._lon = np.concatenate(
708-
(
709-
self.lon[:, -halosize:] - lonshift[:, np.newaxis],
710-
self.lon,
711-
self.lon[:, 0:halosize] + lonshift[:, np.newaxis],
712-
),
713-
axis=len(self.lon.shape) - 1,
714-
)
715-
self._lat = np.concatenate(
716-
(self.lat[:, -halosize:], self.lat, self.lat[:, 0:halosize]), axis=len(self.lat.shape) - 1
717-
)
718-
self._zonal_periodic = True
719-
self._zonal_halo = halosize
720-
if meridional:
721-
if not np.allclose(self.lat[1, :] - self.lat[0, :], self.lat[-1, :] - self.lat[-2, :]):
722-
warnings.warn(
723-
"The meridional halo is located at the north and south of current grid, "
724-
"with a dy = lat[1]-lat[0] between the last nodes of the original grid and the first ones of the halo. "
725-
"In your grid, lat[1]-lat[0] != lat[-1]-lat[-2]. Is the halo computed as you expect?",
726-
FieldSetWarning,
727-
stacklevel=2,
728-
)
729-
latshift = self.lat[-1, :] - 2 * self.lat[0, :] + self.lat[1, :]
730-
self._lat = np.concatenate(
731-
(
732-
self.lat[-halosize:, :] - latshift[np.newaxis, :],
733-
self.lat,
734-
self.lat[0:halosize, :] + latshift[np.newaxis, :],
735-
),
736-
axis=len(self.lat.shape) - 2,
737-
)
738-
self._lon = np.concatenate(
739-
(self.lon[-halosize:, :], self.lon, self.lon[0:halosize, :]), axis=len(self.lon.shape) - 2
740-
)
741-
self._meridional_halo = halosize
742-
if isinstance(self, CurvilinearSGrid):
743-
self._add_Sdepth_periodic_halo(zonal, meridional, halosize)
697+
raise NotImplementedError(
698+
"CurvilinearGrid does not support add_periodic_halo. See https://github.com/OceanParcels/Parcels/pull/1811"
699+
)
744700

745701

746702
class CurvilinearZGrid(CurvilinearGrid):

tests/test_fieldset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ def test_curv_fieldset_add_periodic_halo():
565565
dimensions = {"dx": {"lon": "glamu", "lat": "gphiu"}, "dy": {"lon": "glamu", "lat": "gphiu"}}
566566
fieldset = FieldSet.from_nemo(filenames, variables, dimensions)
567567

568-
fieldset.add_periodic_halo(zonal=3, meridional=2)
568+
with pytest.raises(NotImplementedError):
569+
fieldset.add_periodic_halo(zonal=3, meridional=2)
569570

570571

571572
@pytest.mark.parametrize("mesh", ["flat", "spherical"])

0 commit comments

Comments
 (0)