Skip to content

Commit af0d6af

Browse files
authored
Merge pull request #141 from AntSimi/check_coordinates
check coordinates in regular grid #138
2 parents 2d982d5 + 334d4c1 commit af0d6af

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Changed
1414
Fixed
1515
^^^^^
1616

17+
- Check strictly increasing coordinates for RegularGridDataset.
18+
1719
Added
1820
^^^^^
1921

src/py_eddy_tracker/dataset/grid.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,10 @@ def setup_coordinates(self):
11931193
raise Exception(
11941194
"Coordinates in RegularGridDataset must be 1D array, or think to use UnRegularGridDataset"
11951195
)
1196+
dx = self.x_bounds[1:] - self.x_bounds[:-1]
1197+
dy = self.y_bounds[1:] - self.y_bounds[:-1]
1198+
if (dx < 0).any() or (dy < 0).any():
1199+
raise Exception("Coordinates in RegularGridDataset must be strictly increasing")
11961200
self._x_step = (self.x_c[1:] - self.x_c[:-1]).mean()
11971201
self._y_step = (self.y_c[1:] - self.y_c[:-1]).mean()
11981202

0 commit comments

Comments
 (0)