Skip to content

Commit eca695d

Browse files
Ensure spatial indices are positive values
In the event that ti=-1, the `ei` attribute will be negative. While we want to capture the negative value for `ti`, all spatial indices ought to be positive.
1 parent 243e8c4 commit eca695d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

parcels/field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ def unravel_index(self, ei):
12971297
"""
12981298
_ei = ei[self.igrid]
12991299
ti = _ei // (self.grid.xdim * self.grid.ydim * self.grid.zdim)
1300-
_ei = _ei % (self.grid.xdim * self.grid.ydim * self.grid.zdim)
1300+
_ei = abs(_ei) % (self.grid.xdim * self.grid.ydim * self.grid.zdim)
13011301
zi = _ei // (self.grid.xdim * self.grid.ydim)
13021302
_ei = _ei % (self.grid.xdim * self.grid.ydim)
13031303
yi = _ei // self.grid.xdim

0 commit comments

Comments
 (0)