Skip to content
Merged
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: 0 additions & 2 deletions parcels/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,6 @@ def _reshape(self, data):
# Ensure that field data is the right data type
if not isinstance(data, (np.ndarray)):
data = np.array(data)
if self.grid._lat_flipped:
data = np.flip(data, axis=-2)

if self.grid.xdim == 1 or self.grid.ydim == 1:
data = np.squeeze(data) # First remove all length-1 dimensions in data, so that we can add them below
Expand Down
15 changes: 0 additions & 15 deletions parcels/grid.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import functools
import warnings
from enum import IntEnum

import numpy as np
import numpy.typing as npt

from parcels._typing import Mesh, UpdateStatus, assert_valid_mesh
from parcels.tools.converters import TimeConverter
from parcels.tools.warnings import FieldSetWarning

__all__ = [
"CurvilinearSGrid",
Expand Down Expand Up @@ -68,7 +66,6 @@ def __init__(
assert_valid_mesh(mesh)
self._mesh = mesh
self._zonal_periodic = False
self._lat_flipped = False
self._defer_load = False
self._lonlat_minmax = np.array(
[np.nanmin(lon), np.nanmax(lon), np.nanmin(lat), np.nanmax(lat)], dtype=np.float32
Expand Down Expand Up @@ -251,16 +248,6 @@ def __init__(self, lon, lat, time, time_origin, mesh: Mesh):
super().__init__(lon, lat, time, time_origin, mesh)
self.tdim = self.time.size

if self.ydim > 1 and self.lat[-1] < self.lat[0]:
self._lat = np.flip(self.lat, axis=0)
self._lat_flipped = True
warnings.warn(
"Flipping lat data from North-South to South-North. "
"Note that this may lead to wrong sign for meridional velocity, so tread very carefully",
FieldSetWarning,
stacklevel=2,
)

@property
def xdim(self):
return self.lon.size
Expand Down Expand Up @@ -379,8 +366,6 @@ def __init__(
), "depth dimension has the wrong format. It should be [zdim, ydim, xdim]"
if not self.depth.dtype == np.float32:
self._depth = self.depth.astype(np.float32)
if self._lat_flipped:
self._depth = np.flip(self.depth, axis=-2)

@property
def zdim(self):
Expand Down
8 changes: 2 additions & 6 deletions tests/test_fieldset_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,11 @@ def test_partialslip_nearland_vertical(boundaryslip):
assert np.allclose([p.lat for p in pset], 0.1)


@pytest.mark.parametrize("lat_flip", [False, True])
def test_fieldset_sample_particle(lat_flip):
def test_fieldset_sample_particle():
"""Sample the fieldset using an array of particles."""
npart = 120
lon = np.linspace(-180, 180, 200, dtype=np.float32)
if lat_flip:
lat = np.linspace(90, -90, 100, dtype=np.float32)
else:
lat = np.linspace(-90, 90, 100, dtype=np.float32)
lat = np.linspace(-90, 90, 100, dtype=np.float32)
V, U = np.meshgrid(lon, lat)
data = {"U": U, "V": V}
dimensions = {"lon": lon, "lat": lat}
Expand Down
10 changes: 0 additions & 10 deletions tests/tools/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@
from tests.utils import TEST_DATA


def test_fieldset_warning_latflipped():
# flipping lats warning
lat = [0, 1, 5, -5]
lon = [0, 1, 5, 10]
u = [[1, 1, 1, 1] for _ in range(4)]
v = [[1, 1, 1, 1] for _ in range(4)]
with pytest.warns(FieldSetWarning, match="Flipping lat data from North-South to South-North.*"):
FieldSet.from_data(data={"U": u, "V": v}, dimensions={"lon": lon, "lat": lat})


def test_fieldset_warning_pop():
filenames = str(TEST_DATA / "POPtestdata_time.nc")
variables = {"U": "U", "V": "V", "W": "W", "T": "T"}
Expand Down
Loading