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
check coordinates in regular grid #138
  • Loading branch information
AntSimi committed Feb 27, 2022
commit 334d4c124fd998010757479d527fcd72153dcea8
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Changed
Fixed
^^^^^

- Check strictly increasing coordinates for RegularGridDataset.

Added
^^^^^

Expand Down
4 changes: 4 additions & 0 deletions src/py_eddy_tracker/dataset/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,10 @@ def setup_coordinates(self):
raise Exception(
"Coordinates in RegularGridDataset must be 1D array, or think to use UnRegularGridDataset"
)
dx = self.x_bounds[1:] - self.x_bounds[:-1]
dy = self.y_bounds[1:] - self.y_bounds[:-1]
if (dx < 0).any() or (dy < 0).any():
raise Exception("Coordinates in RegularGridDataset must be strictly increasing")
self._x_step = (self.x_c[1:] - self.x_c[:-1]).mean()
self._y_step = (self.y_c[1:] - self.y_c[:-1]).mean()

Expand Down