From 9c8c89294a6a6e07f717467370b1107783d406ea Mon Sep 17 00:00:00 2001 From: rink <rink@ssec.wisc.edu> Date: Tue, 29 Sep 2020 10:35:51 -0500 Subject: [PATCH] improve get_aeolus_time_dict_s --- modules/aeolus/aeolus_amv.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py index 48c1a50b..8ae6c894 100644 --- a/modules/aeolus/aeolus_amv.py +++ b/modules/aeolus/aeolus_amv.py @@ -193,9 +193,26 @@ def concat(t_dct_0, t_dct_1): return t_dct_0 -def get_aeolus_time_dict_s(filenames, lon360=False, do_sort=True): +def get_aeolus_time_dict_s(files_path, lon360=False, do_sort=True): + ftimes = [] + fnames = glob.glob(files_path + 'mie1day.out.*') + time_dct = {} + for pathname in fnames: + fname = os.path.split(pathname)[1] + toks = fname.split('.') + dstr = toks[2] + dto = datetime.datetime.strptime(dstr, '%Y-%m-%d').replace(tzinfo=timezone.utc) + ts = dto.timestamp() + ftimes.append(ts) + time_dct[ts] = fname + + sorted_filenames = [] + ftimes.sort() + for t in ftimes: + sorted_filenames.append(time_dct.get(t)) + dct_s = [] - for fname in filenames: + for fname in sorted_filenames: a_dct = get_aeolus_time_dict(fname, lon360=lon360, do_sort=do_sort) t_dct = time_dict_to_nd(a_dct) dct_s.append(t_dct) -- GitLab