From c54248f3b241bd5158d56fb00dfe84a9d82372f0 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Tue, 22 Jun 2021 16:59:52 -0500
Subject: [PATCH] snapshot...

---
 modules/aeolus/aeolus_amv.py | 65 +++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 30 deletions(-)

diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py
index 9034c254..768f952f 100644
--- a/modules/aeolus/aeolus_amv.py
+++ b/modules/aeolus/aeolus_amv.py
@@ -1743,7 +1743,7 @@ def match_amvs_to_aeolus_fast(aeolus_dict, amv_files_path, amv_source='OPS', ban
             # 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]
-            match_dict[key].append(param_nd)
+            match_dict[key].append((cc, ll, f_idx, prof, param_nd))
 
     return match_dict
 
@@ -1928,12 +1928,13 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct, amv_files, cld_lyr=Fals
 
     rootgrp.close()
 
-def create_file_new(match_dct, filename, amv_params):
+def create_file_new(match_dct, filename, clvrx_params):
     grd_x_len = 9
     grd_y_len = 9
     num_aparams = 7
     num_aprofs = len(match_dct)
     max_num_alevels = 0
+    max_num_amvs = 0
 
     alons = []
     alats = []
@@ -1944,19 +1945,20 @@ def create_file_new(match_dct, filename, amv_params):
     # scan to get max num levels
     keys = list(match_dct.keys())
     for key in keys:
-        tup = match_dct.get(key)
-        prof = tup[4]
-        lat = prof[0, 0]
-        lon = prof[0, 1]
-        alons.append(lon)
-        alats.append(lat)
-        atimes.append(tup[0])
-        elems.append(tup[1])
-        lines.append(tup[2])
-
-        nlevs = prof.shape[0]
-        if nlevs > max_num_alevels:
-            max_num_alevels = nlevs
+        tup_s = match_dct.get(key)
+        for tup in tup_s:
+            prof = tup[3]
+            lat = prof[0, 0]
+            lon = prof[0, 1]
+            alons.append(lon)
+            alats.append(lat)
+            atimes.append(key)
+            elems.append(tup[0])
+            lines.append(tup[1])
+
+            nlevs = prof.shape[0]
+            if nlevs > max_num_alevels:
+                max_num_alevels = nlevs
 
     alons = np.array(alons)
     alats = np.array(alats)
@@ -1998,7 +2000,7 @@ def create_file_new(match_dct, filename, amv_params):
     # ----- Product variables ----------------
     nc4_vars = []
     var_s = rg_exmpl.variables
-    for pidx, param in enumerate(amv_params):
+    for pidx, param in enumerate(clvrx_params):
         v = var_s[param]
         attr_s = v.ncattrs()
         if '_FillValue' in attr_s:
@@ -2018,20 +2020,23 @@ def create_file_new(match_dct, filename, amv_params):
     prf_line[:] = lines
     prf_time[:] = atimes
 
-    for idx, key in enumerate(keys):
-        tup = match_dct.get(key)
-        prof = tup[4]
-        param_nd = tup[5]
-
-        nlevs = prof.shape[0]
-        for k in range(nlevs):
-            prf_spd[idx,k] = prof[k,6]
-            prf_azm[idx,k] = prof[k,5]
-            prf_hht[idx,k] = prof[k,3]
-            prf_hhb[idx,k] = prof[k,4]
-
-        for pidx, param in enumerate(clvrx_params):
-            nc4_vars[pidx][idx, :, :] = param_nd[pidx, :, :]
+    idx = 0
+    for key in enumerate(keys):
+        tup_s = match_dct.get(key)
+        for tup in tup_s:
+            prof = tup[3]
+            param_nd = tup[4]
+
+            nlevs = prof.shape[0]
+            for k in range(nlevs):
+                prf_spd[idx,k] = prof[k,6]
+                prf_azm[idx,k] = prof[k,5]
+                prf_hht[idx,k] = prof[k,3]
+                prf_hhb[idx,k] = prof[k,4]
+
+            for pidx, param in enumerate(clvrx_params):
+                nc4_vars[pidx][idx, :, :] = param_nd[pidx, :, :]
+            idx += 1
 
     rg_exmpl.close()
     rootgrp.close()
-- 
GitLab