diff --git a/modules/deeplearning/amv_raob.py b/modules/deeplearning/amv_raob.py index 0e0febb002db9696d667ecc6d8168c73e014bd81..a7bc0933835f5e80dc463d3c02efce9310d8c6d9 100644 --- a/modules/deeplearning/amv_raob.py +++ b/modules/deeplearning/amv_raob.py @@ -23,6 +23,7 @@ dt_str_pat = '_s\d{11}' dir_fmt = '%Y_%m_%d_%j' gfs_directory = '/apollo/cloud/Ancil_Data/clavrx_ancil_data/dynamic/gfs/' +gfs_name_pattern = r'gfs\.(\d{8})_F\d{3}\.h5' gfs_date_format = '%y%m%d' h4_to_h5_path = home_dir + '/h4toh5convert' @@ -532,10 +533,9 @@ def get_bounding_gfs_files(timestamp): filelist = flist_0 + flist_1 ftimes = [] - for pname in filelist: # TODO: make better with regular expressions (someday) - fname = os.path.split(pname)[1] - toks = fname.split('.') - tstr = toks[1].split('_')[0] + for pname in filelist: + match = re.search(gfs_name_pattern, pname) + tstr = match[1] dto = datetime.datetime.strptime(tstr, gfs_date_format+'%H').replace(tzinfo=timezone.utc) dto = dto + datetime.timedelta(hours=12) ftimes.append(dto.timestamp())