Skip to content
Snippets Groups Projects
Commit 018b45a9 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 59ab78d4
No related branches found
No related tags found
No related merge requests found
......@@ -1731,6 +1731,72 @@ def match_amvs_to_aeolus_fast(aeolus_dict, amv_files_path, amv_source='OPS', ban
return match_dict
def match_calipso_clavrx_to_amvs(calipso_clavrx_file, amv_files_path, amv_source='OPS', band='14', amv_files=None):
if amv_files is None:
amv_files = get_datasource(amv_files_path, amv_source, band=band)
nav = amv_files.get_navigation()
amv_params = amv_files.get_parameters()
all_params = [amv_files.lon_name, amv_files.lat_name, amv_files.elem_name, amv_files.line_name] + amv_params
match_dict = {}
coords = {'num_params': all_params}
dims = ['num_params', 'num_amvs']
calipso_clavrx_ds = None
nom_time = calipso_clavrx_ds.get_datetime(calipso_clavrx_file).timestamp()
fname, ftime, f_idx = amv_files.get_file_containing_time(nom_time)
if f_idx is None:
return
match_dict[nom_time] = []
amv_ds = Dataset(fname)
amv_lons = amv_ds[amv_files.lon_name][:]
amv_lats = amv_ds[amv_files.lat_name][:]
amv_cc = amv_ds[amv_files.elem_name][:]
amv_ll = amv_ds[amv_files.line_name][:]
param_s = []
param_s.append(amv_lons)
param_s.append(amv_lats)
param_s.append(cc)
param_s.append(ll)
for param in amv_params:
if param == 'V_3D':
param_s.append(amv_ds[param][:, 0])
param_s.append(amv_ds[param][:, 1])
else:
param_s.append(amv_ds[param][:])
amv_ds.close()
xs = calipso_clavrx_ds['x'][:]
ys = calipso_clavrx_ds['y'][:]
clvr_xy_s = zip(xs, ys)
for clvr_xy in clvr_xy_s:
cc, ll = clvr_xy
c_rng, l_rng = get_search_box(cc, ll)
in_cc = np.logical_and(amv_cc > c_rng[0], amv_cc < c_rng[1])
in_ll = np.logical_and(amv_ll > l_rng[0], amv_ll < l_rng[1])
in_box = np.logical_and(in_cc, in_ll)
num_amvs = np.sum(in_box)
if num_amvs == 0:
continue
# dist = haversine_np(lon, lat, amv_lons[in_box], amv_lats[in_box])
param_nd = np.vstack(param_s)
param_nd = param_nd[:, in_box]
amvs_da = xr.DataArray(param_nd, coords=coords, dims=dims)
match_dict[nom_time].append((cc, ll, f_idx, None, amvs_da))
return match_dict
# 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)
......
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