Skip to content

Commit

Permalink
Merge pull request #418 from OceanParcels/progressbar_min_Nsteps
Browse files Browse the repository at this point in the history
Showing progressbar if total runtime  > 10 seconds
  • Loading branch information
erikvansebille authored Aug 22, 2018
2 parents 618924d + f0a0d44 commit c4143dd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions parcels/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from parcels.loggers import logger
import numpy as np
import progressbar
import time as time_module
from collections import Iterable
from datetime import timedelta as delta
from datetime import datetime, date
Expand Down Expand Up @@ -228,7 +229,7 @@ def remove(self, indices):

def execute(self, pyfunc=AdvectionRK4, endtime=None, runtime=None, dt=1.,
moviedt=None, recovery=None, output_file=None, movie_background_field=None,
verbose_progress=True):
verbose_progress=None):
"""Execute a given kernel function over the particle set for
multiple timesteps. Optionally also provide sub-timestepping
for particle output.
Expand Down Expand Up @@ -340,9 +341,15 @@ def execute(self, pyfunc=AdvectionRK4, endtime=None, runtime=None, dt=1.,
next_input = self.fieldset.computeTimeChunk(time, np.sign(dt))

tol = 1e-12
if verbose_progress is None:
walltime_start = time_module.time()
if verbose_progress:
pbar = progressbar.ProgressBar(max_value=abs(endtime - _starttime))
pbar = progressbar.ProgressBar(max_value=abs(endtime - _starttime)).start()
while (time < endtime and dt > 0) or (time > endtime and dt < 0) or dt == 0:
if verbose_progress is None and time_module.time() - walltime_start > 10:
# Showing progressbar if runtime > 10 seconds
pbar = progressbar.ProgressBar(max_value=abs(endtime - _starttime)).start()
verbose_progress = True
if dt > 0:
time = min(next_prelease, next_input, next_output, next_movie, endtime)
else:
Expand Down

0 comments on commit c4143dd

Please sign in to comment.