diff --git a/modules/util/util.py b/modules/util/util.py index 2eecfd136ebd0bd1457fb3446afa933b327cb58d..65a2df0bcad339306023c03d3fa055b886b34f12 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -259,9 +259,11 @@ def get_grid_values_all(h5f, grid_name, scale_factor_name='scale_factor', add_of # dt_str_0: start datetime string in format YYYY-MM-DD_HH:MM +# dt_str_1: stop datetime string, if not None num_steps is computed # num_steps with increment of days, hours, minutes or seconds +# dt_str_1 and num_steps cannot both be None # return num_steps+1 lists of datetime strings and timestamps for the times eries -def make_times(dt_str_0, num_steps, days=None, hours=None, minutes=None, seconds=None): +def make_times(dt_str_0, dt_str_1=None, num_steps=None, days=None, hours=None, minutes=None, seconds=None): if days is not None: inc = 86400*days elif hours is not None: @@ -275,6 +277,10 @@ def make_times(dt_str_0, num_steps, days=None, hours=None, minutes=None, seconds ts_s = [] dto_0 = datetime.datetime.strptime(dt_str_0, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc) ts_0 = dto_0.timestamp() + if dt_str_1 is not None: + dto_1 = datetime.datetime.strptime(dt_str_1, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc) + ts_1 = dto_1.timestamp() + num_steps = int((ts_1 - ts_0)/inc) dt_obj_s.append(dto_0) ts_s.append(ts_0)