Skip to content

Commit b99732f

Browse files
FIX times computation
1 parent 00aec62 commit b99732f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

surfer/viz.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from math import floor
12
import os
23
from os.path import join as pjoin
3-
import sys
44
from tempfile import mkdtemp
55
from warnings import warn
66

@@ -2180,15 +2180,15 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
21802180
"(%r)" % (tmin, self._times[0]))
21812181

21822182
# find indexes at which to create frames
2183-
tstep = 1. / (framerate * time_dilation)
21842183
if tmax is None:
21852184
tmax = self._times[-1]
21862185
elif tmax > self._times[-1]:
21872186
raise ValueError("tmax=%r is greater than the latest time point "
21882187
"(%r)" % (tmax, self._times[-1]))
2189-
times = np.arange(tmin, tmax + sys.float_info.epsilon, tstep)
2190-
if times[-1] > tmax:
2191-
times = times[:-1]
2188+
n_frames = floor((tmax - tmin) * time_dilation * framerate)
2189+
times = np.arange(n_frames)
2190+
times /= framerate * time_dilation
2191+
times += tmin
21922192
interp_func = interp1d(self._times, np.arange(self.n_times))
21932193
time_idx = interp_func(times)
21942194

0 commit comments

Comments
 (0)