Skip to content

Commit 663beaa

Browse files
Removing the calculation of periods also from _time_index
This PR continues the removal of removing time_periodic in #1880
1 parent 0414f58 commit 663beaa

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

parcels/application_kernels/advection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def AdvectionAnalytical(particle, fieldset, time): # pragma: no cover
177177
direction = 1.0 if particle.dt > 0 else -1.0
178178
withW = True if "W" in [f.name for f in fieldset.get_fields()] else False
179179
withTime = True if len(fieldset.U.grid.time_full) > 1 else False
180-
ti = fieldset.U._time_index(time)[0]
180+
ti = fieldset.U._time_index(time)
181181
ds_t = particle.dt
182182
if withTime:
183183
tau = (time - fieldset.U.grid.time[ti]) / (fieldset.U.grid.time[ti + 1] - fieldset.U.grid.time[ti])

parcels/field.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -964,13 +964,13 @@ def _time_index(self, time):
964964
if time_index.all():
965965
# If given time > last known field time, use
966966
# the last field frame without interpolation
967-
return (len(self.grid.time) - 1, 0)
967+
return len(self.grid.time) - 1
968968
elif np.logical_not(time_index).all():
969969
# If given time < any time in the field, use
970970
# the first field frame without interpolation
971-
return (0, 0)
971+
return 0
972972
else:
973-
return (time_index.argmin() - 1 if time_index.any() else 0, 0)
973+
return time_index.argmin() - 1 if time_index.any() else 0
974974

975975
def _check_velocitysampling(self):
976976
if self.name in ["U", "V", "W"]:
@@ -997,8 +997,7 @@ def eval(self, time, z, y, x, particle=None, applyConversion=True):
997997
conversion to the result. Note that we defer to
998998
scipy.interpolate to perform spatial interpolation.
999999
"""
1000-
(ti, periods) = self._time_index(time)
1001-
time -= periods * (self.grid.time_full[-1] - self.grid.time_full[0])
1000+
ti = self._time_index(time)
10021001
if self.gridindexingtype == "croco" and self not in [self.fieldset.H, self.fieldset.Zeta]:
10031002
z = _croco_from_z_to_sigma_scipy(self.fieldset, time, z, y, x, particle=particle)
10041003
if ti < self.grid.tdim - 1 and time > self.grid.time[ti]:
@@ -1791,8 +1790,7 @@ def eval(self, time, z, y, x, particle=None, applyConversion=True):
17911790
"freeslip": {"2D": self.spatial_slip_interpolation, "3D": self.spatial_slip_interpolation},
17921791
}
17931792
grid = self.U.grid
1794-
(ti, periods) = self.U._time_index(time)
1795-
time -= periods * (grid.time_full[-1] - grid.time_full[0])
1793+
ti = self.U._time_index(time)
17961794
if ti < grid.tdim - 1 and time > grid.time[ti]:
17971795
t0 = grid.time[ti]
17981796
t1 = grid.time[ti + 1]

parcels/grid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def _computeTimeChunk(self, f, time, signdt):
224224
self._update_status = "updated"
225225
if self._ti == -1:
226226
self.time = self.time_full
227-
self._ti, _ = f._time_index(time)
227+
self._ti = f._time_index(time)
228228

229229
if signdt == -1 and self._ti > 0 and self.time_full[self._ti] == time:
230230
self._ti -= 1

0 commit comments

Comments
 (0)