From ce681f7a9809d17e4c053c0763a9fdf1173b7d18 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 7 Jun 2021 09:49:31 -0500
Subject: [PATCH] temp code

---
 modules/aeolus/aeolus_amv.py | 68 ++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py
index 511cb039..20fcd96b 100644
--- a/modules/aeolus/aeolus_amv.py
+++ b/modules/aeolus/aeolus_amv.py
@@ -322,6 +322,74 @@ def run_best_fit_all(amv_dir, source, product_dir, product, raob_path, gfs_path,
         tup = (amvs, bfs, prd)
         return tup
 
+def run_best_fit_all_no_product(amv_dir, source, raob_path, gfs_path, full_domain=False):
+    amv_files = get_datasource(amv_dir, source)
+    gfs_files = get_datasource(gfs_path, 'GFS')
+    raob_ds = get_datasource(raob_path, 'RAOB')
+    raob_files = raob_ds.flist
+
+    out_list = []
+    amvs_list = []
+    bfs_list = []
+    rb_list = []
+    bfs_gfs_list = []
+    if not full_domain:
+        for k, file in enumerate(raob_files):
+            raob_dct = get_raob_dict_cdf(file)
+            ts = raob_ds.ftimes[k,0]
+            m_d = match_amvs_to_raobs(raob_dct, ts, amv_files)
+            if m_d is None:
+                continue
+            gfs_file = gfs_files.get_file(ts)[0]
+            if gfs_file is None:
+                continue
+            bf_dct = run_best_fit(m_d, raob_dct, gfs_file)
+            out_list.append((bf_dct, prd_dct))
+
+        for tup in out_list:
+            ab_dct = tup[0]
+
+            keys = list(ab_dct.keys())
+            for key in keys:
+                tup = ab_dct.get(key)
+                amvs_list.append(tup[0])
+                bfs_list.append(tup[1])
+                rb_list.append(tup[2])
+                bfs_gfs_list.append(tup[3])
+
+
+        amvs = np.concatenate(amvs_list)
+        bfs = np.concatenate(bfs_list)
+        rbm = np.concatenate(rb_list)
+        bfs_gfs = np.concatenate(bfs_gfs_list)
+
+        tup = (amvs, bfs, bfs_gfs, rbm)
+        return tup
+    else:
+        for k, file in enumerate(raob_files):
+            raob_dct = get_raob_dict_cdf(file)
+            ts = raob_ds.ftimes[k,0]
+            amvs = get_amvs(amv_files, ts)
+            if amvs is None:
+                continue
+            gfs_file = gfs_files.get_file(ts)[0]
+            if gfs_file is None:
+                continue
+            bfs = run_best_fit_gfs(amvs, gfs_file, amv_lat_idx=0, amv_lon_idx=1, amv_prs_idx=4, amv_spd_idx=5, amv_dir_idx=6)
+            alons = amvs[:, 0]
+            alats = amvs[:, 1]
+
+            out_list.append((amvs, np.array(bfs)))
+
+        for tup in out_list:
+            amvs_list.append(tup[0])
+            bfs_list.append(tup[1])
+
+        amvs = np.concatenate(amvs_list)
+        bfs = np.concatenate(bfs_list)
+
+        tup = (amvs, bfs)
+        return tup
 
 def get_product_at_locs(raob_to_amv_dct, ts, files, filepath=None):
     keys = list(raob_to_amv_dct.keys())
-- 
GitLab