From bb1c32411b7fcaf760636ac5c4cd642f50a1f971 Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Sun, 20 Dec 2020 17:44:26 -0600 Subject: [PATCH] snapshot... --- modules/aeolus/aeolus_amv.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py index c24515bc..fac7df04 100644 --- a/modules/aeolus/aeolus_amv.py +++ b/modules/aeolus/aeolus_amv.py @@ -470,12 +470,16 @@ def run_best_fit_all(): raob_dct, ts = get_raob_dict_cdf(raob_dir+file) m_d = match_amvs_to_raobs(raob_dct, ts, amv_files=amv_files) #bf_dct = run_best_fit(m_d, raob_dct, gfs_dir+gfs_files[k]) - prd_dct = get_product_at_locs(m_d, ts, prd_files) + #prd_dct = get_product_at_locs(m_d, ts, prd_files) #out_list.append((bf_dct, prd_dct)) amvs = get_amvs(amv_files, ts) bfs = run_best_fit_gfs(amvs, gfs_dir+gfs_files[k], amv_lat_idx=0, amv_lon_idx=1, amv_prs_idx=4, amv_spd_idx=5, amv_dir_idx=6) - out_list.append((amvs, np.array(bfs), prd_dct)) + alons = amvs[0, :] + alats = amvs[1, :] + prds = get_product_at_lat_lons(prd_files, ts, alons, alats, filepath=None) + + out_list.append((amvs, np.array(bfs), prds)) return out_list @@ -555,6 +559,32 @@ def get_product_at_locs1x1(raob_to_amv_dct, ts, files, filepath=None): return m_dct +def get_product_at_lat_lons(files, ts, lons, lats, filepath=None): + nav = files.get_navigation() + the_params = files.get_parameters() + num_params = len(the_params) + + if filepath is None: + filepath, ftime, f_idx = files.get_file(ts) + ds = Dataset(filepath) + + var_s = [] + for pstr in the_params: + var = ds[pstr] + var_s.append(var) + + num = lons.shape[0] + + cc, ll = nav.earth_to_lc_s(lons, lats) + + aaa = np.zeros((num_params, num), dtype=np.float) + for vidx, var in enumerate(var_s): + for k in range(num): + aaa[vidx, k] = var[ll[k], cc[k]].data + + return np.transpose(aaa, axes=[1, 0]) + + def run_best_fit2(raob_to_amv_dct, raob_dct, gfs_filename=None): bfs_dct ={} keys = list(raob_to_amv_dct.keys()) -- GitLab