diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py index 74b31ae8536f790f225fd78f9829444dbccc935a..95f3c3b52e9be7c76c6dfcdf3670e04c86cbbf37 100644 --- a/modules/aeolus/aeolus_amv.py +++ b/modules/aeolus/aeolus_amv.py @@ -46,6 +46,15 @@ def get_datetime_ops(pathname): return dto +def get_datetime_carr(pathname): + fname = os.path.split(pathname)[1] + toks = fname.split('_') + dtstr = toks[3] + dto = datetime.datetime.strptime(dtstr, '%Y%j.%H%M').replace(tzinfo=timezone.utc) + + return dto + + def get_file_containing_time(timestamp, files_path, file_time_span, amv_source='OPS', band='14'): global first_time, ftimes, flist @@ -57,6 +66,9 @@ def get_file_containing_time(timestamp, files_path, file_time_span, amv_source=' elif amv_source == 'SSEC': flist = glob.glob(files_path + '*WINDS_AMV_EN-'+band+'*.nc') dto_func = get_datetime + elif amv_source == 'CARR': + flist = glob.glob(files_path + 'tdw_qc_GOES*'+'ch_'+band+'.nc') + dto_func = get_datetime_carr for pname in flist: # TODO: make better with regular expressions (someday) dto = dto_func(pname) @@ -219,6 +231,15 @@ def get_search_box(nav, lon, lat): return c_rng, l_rng +amv_dir_name = 'Wind_Dir' +amv_spd_name = 'Wind_Speed' +amv_lon_name = 'Longitude' +amv_lat_name = 'Latitude' +amv_elem_name = 'Element' +amv_line_name = 'Line' +amv_press_name = 'MedianPress' + + # aeolus_dict: time -> profiles # amv_files_path: directory containing AMVs, '/home/user/amvdir/' # return dict: aeolus time -> tuple (amv_lon, amv_lat, amv_pres, amv_spd, amv_dir) @@ -250,13 +271,13 @@ def match_amvs_to_aelous(aeolus_dict, amv_files_path, amv_source='OPS', band='14 if f_idx != last_f_idx: last_f_idx = f_idx ds = Dataset(fname) - amv_lons = ds['Longitude'][:] - amv_lats = ds['Latitude'][:] - amv_spd = ds['Wind_Speed'][:] - amv_dir = ds['Wind_Dir'][:] - amv_pres = ds['MedianPress'][:] - cc = ds['Element'][:] - ll = ds['Line'][:] + amv_lons = ds[amv_lon_name][:] + amv_lats = ds[amv_lat_name][:] + amv_spd = ds[amv_spd_name][:] + amv_dir = ds[amv_dir_name][:] + amv_pres = ds[amv_press_name][:] + cc = ds[amv_elem_name][:] + ll = ds[amv_line_name][:] # cc, ll = nav.earth_to_lc_s(amv_lons, amv_lats) ds.close()