Skip to content

Commit 7a77039

Browse files
Conditionally wrap coordinates if mesh is spherical
1 parent 4a01f43 commit 7a77039

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

parcels/spatialhash.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ def _hash_index2d(self, coords):
8686
coordinates (in degrees)
8787
"""
8888
# Wrap longitude to [-180, 180]
89-
lon = coords[:, 1]
89+
if self._source_grid.mesh == "spherical":
90+
lon = (coords[:, 1] + 180.0) % (360.0) - 180.0
91+
else:
92+
lon = coords[:, 1]
9093
i = ((lon - self._xmin) / self._dh).astype(np.int32)
9194
j = ((coords[:, 0] - self._ymin) / self._dh).astype(np.int32)
9295
return j, i

0 commit comments

Comments
 (0)