Skip to content

Commit 72b7e45

Browse files
committed
remove latitude flipping
1 parent b5daffb commit 72b7e45

File tree

3 files changed

+0
-27
lines changed

3 files changed

+0
-27
lines changed

parcels/field.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,6 @@ def _reshape(self, data):
691691
# Ensure that field data is the right data type
692692
if not isinstance(data, (np.ndarray)):
693693
data = np.array(data)
694-
if self.grid._lat_flipped:
695-
data = np.flip(data, axis=-2)
696694

697695
if self.grid.xdim == 1 or self.grid.ydim == 1:
698696
data = np.squeeze(data) # First remove all length-1 dimensions in data, so that we can add them below

parcels/grid.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import functools
2-
import warnings
32
from enum import IntEnum
43

54
import numpy as np
65
import numpy.typing as npt
76

87
from parcels._typing import Mesh, UpdateStatus, assert_valid_mesh
98
from parcels.tools.converters import TimeConverter
10-
from parcels.tools.warnings import FieldSetWarning
119

1210
__all__ = [
1311
"CurvilinearSGrid",
@@ -68,7 +66,6 @@ def __init__(
6866
assert_valid_mesh(mesh)
6967
self._mesh = mesh
7068
self._zonal_periodic = False
71-
self._lat_flipped = False
7269
self._defer_load = False
7370
self._lonlat_minmax = np.array(
7471
[np.nanmin(lon), np.nanmax(lon), np.nanmin(lat), np.nanmax(lat)], dtype=np.float32
@@ -251,16 +248,6 @@ def __init__(self, lon, lat, time, time_origin, mesh: Mesh):
251248
super().__init__(lon, lat, time, time_origin, mesh)
252249
self.tdim = self.time.size
253250

254-
if self.ydim > 1 and self.lat[-1] < self.lat[0]:
255-
self._lat = np.flip(self.lat, axis=0)
256-
self._lat_flipped = True
257-
warnings.warn(
258-
"Flipping lat data from North-South to South-North. "
259-
"Note that this may lead to wrong sign for meridional velocity, so tread very carefully",
260-
FieldSetWarning,
261-
stacklevel=2,
262-
)
263-
264251
@property
265252
def xdim(self):
266253
return self.lon.size
@@ -379,8 +366,6 @@ def __init__(
379366
), "depth dimension has the wrong format. It should be [zdim, ydim, xdim]"
380367
if not self.depth.dtype == np.float32:
381368
self._depth = self.depth.astype(np.float32)
382-
if self._lat_flipped:
383-
self._depth = np.flip(self.depth, axis=-2)
384369

385370
@property
386371
def zdim(self):

tests/tools/test_warnings.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@
1717
from tests.utils import TEST_DATA
1818

1919

20-
def test_fieldset_warning_latflipped():
21-
# flipping lats warning
22-
lat = [0, 1, 5, -5]
23-
lon = [0, 1, 5, 10]
24-
u = [[1, 1, 1, 1] for _ in range(4)]
25-
v = [[1, 1, 1, 1] for _ in range(4)]
26-
with pytest.warns(FieldSetWarning, match="Flipping lat data from North-South to South-North.*"):
27-
FieldSet.from_data(data={"U": u, "V": v}, dimensions={"lon": lon, "lat": lat})
28-
29-
3020
def test_fieldset_warning_pop():
3121
filenames = str(TEST_DATA / "POPtestdata_time.nc")
3222
variables = {"U": "U", "V": "V", "W": "W", "T": "T"}

0 commit comments

Comments
 (0)