diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py index 2f56668ea35bbab99b147d5170ff49412e1e6a9c..e2a4db41af386b570a3d1c810dd63def441bf03c 100644 --- a/modules/aeolus/aeolus_amv.py +++ b/modules/aeolus/aeolus_amv.py @@ -438,8 +438,11 @@ def create_amv_to_aeolus_match_file(aeolus_files_dir, amv_files_dir, outfile=Non create_file(outfile, m_d, a_d) -def get_subset(pathname, t_0, t_1): - rootgrp = Dataset(pathname, 'r', format='NETCDF4') +# match_file: pathname for the product file +# dt_str_0: start time (YYYY-MM-DD_HH:MM) +# dt_str_1: end time (YYYY-MM-DD_HH:MM) +def get_subset(match_file, dt_str_0, dt_str_1): + rootgrp = Dataset(match_file, 'r', format='NETCDF4') all_dims = rootgrp.dimensions t_var = rootgrp['time'] @@ -457,6 +460,16 @@ def get_subset(pathname, t_0, t_1): p_hhb_v = rootgrp['prof_hhb'] p_hht_v = rootgrp['prof_hht'] + dto = datetime.datetime.strptime(dt_str_0, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc) + t_0 = dto.timestamp() + dto = datetime.datetime.strptime(dt_str_1, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc) + t_1 = dto.timestamp() + + if t_1 < t_0: + t = t_0 + t_1 = t_0 + t_0 = t + times = t_var[:] time_idxs = np.arange(n_profs) valid = np.logical_and(times >= t_0, times < t_1)