Skip to content
Snippets Groups Projects
Commit 818c2433 authored by tomrink's avatar tomrink
Browse files

simplify date time extraction using regex for goes16 files

parent c81521e1
No related branches found
No related tags found
No related merge requests found
......@@ -14,10 +14,12 @@ from scipy.interpolate import interp2d
from metpy import *
#import cartopy.crs as ccrs
import random
import re
goes16_directory = '/arcdata/goes/grb/goes16' # /year/date/abi/L1b/RadC
goes_date_format = '%Y%j%H'
dt_str_pat = '_s\d{11}'
dir_fmt = '%Y_%m_%d_%j'
gfs_directory = '/apollo/cloud/Ancil_Data/clavrx_ancil_data/dynamic/gfs/'
......@@ -478,11 +480,9 @@ def get_bounding_goes16_files(timestamp, ch_str, file_time_span=5):
return None, None, None, None, None, None
ftimes = []
for pname in flist: # TODO: make better with regular expressions (someday)
for pname in flist:
fname = os.path.split(pname)[1]
toks = fname.split('_')
tstr = toks[3]
tstr = tstr[1:12]
tstr = re.search(dt_str_pat, fname).group()[2:]
dto = datetime.datetime.strptime(tstr, goes_date_format+'%M').replace(tzinfo=timezone.utc)
ftimes.append(dto.timestamp())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment