From 8f26d4f12da2496b841b6925e39c5693c4f40591 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Tue, 21 Jun 2022 10:30:01 -0500
Subject: [PATCH] fix some cf issues

---
 modules/aeolus/aeolus_amv.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py
index 89c9ec89..7bf11878 100644
--- a/modules/aeolus/aeolus_amv.py
+++ b/modules/aeolus/aeolus_amv.py
@@ -267,7 +267,7 @@ def run_best_fit_driver(output_path, amv_dir, source, raob_path, gfs_path, produ
 
     for k, raob_filename in enumerate(raob_files):
         raob_dct = get_raob_dict_cdf(raob_filename)
-        keys = list(raob_dct.keys())
+        raob_locs = list(raob_dct.keys())
         ts = raob_ds.ftimes[k,0]
         m_d, amv_filename = match_amvs_to_raobs(raob_dct, ts, amv_ds)
         if m_d is None:
@@ -282,7 +282,7 @@ def run_best_fit_driver(output_path, amv_dir, source, raob_path, gfs_path, produ
         ts_last = ts
 
         if gfs_file is not None:
-            locs = np.array(keys)
+            locs = np.array(raob_locs)
             xr_dataset = xr.open_dataset(gfs_file)
             gfs_press = xr_dataset['pressure levels']
             gfs_press = gfs_press.values
@@ -301,9 +301,8 @@ def run_best_fit_driver(output_path, amv_dir, source, raob_path, gfs_path, produ
             gfs_dir = wdir[:, ::-1]
 
             gfs_at_raob_dct = {}
-            keys = list(raob_dct.keys())
-            for key_idx, key in enumerate(keys):
-                gfs_at_raob_dct[key] = (gfs_spd[key_idx], gfs_dir[key_idx], gfs_press)
+            for key_idx, loc in enumerate(raob_locs):
+                gfs_at_raob_dct[loc] = (gfs_spd[key_idx], gfs_dir[key_idx], gfs_press)
 
         bf_dct = run_best_fit(m_d, raob_dct, gfs_at_raob_dct)
 
@@ -1358,6 +1357,7 @@ def time_dict_to_nd_0(time_dict):
 
     return time_dict
 
+
 # # make each profile at a timestamp a numpy array
 def time_dict_to_nd(time_dict):
     params = ['latitude', 'longitude', 'hhh', 'hht', 'hhb', 'azimuth', 'wind_speed']
@@ -1375,6 +1375,7 @@ def time_dict_to_nd(time_dict):
 
     return time_dict
 
+
 def time_dict_to_nd_2(time_dict):
     keys = list(time_dict.keys())
     for key in keys:
@@ -1384,6 +1385,7 @@ def time_dict_to_nd_2(time_dict):
 
     return time_dict
 
+
 def concat(t_dct_0, t_dct_1):
     keys_0 = list(t_dct_0.keys())
     nda_0 = np.array(keys_0)
@@ -2350,7 +2352,6 @@ def match_amv_to_aeolus(aeolus_files_dir, amv_files_dir, outfile, amv_source='OP
         a_d = get_aeolus_time_dict(aeolus_files_dir)
     a_d = time_dict_to_nd(a_d)
 
-    amv_files = None
     if amv_source == 'CARR':
         amv_files = get_datasource(amv_files_dir, 'CARR', file_time_span=60, band=band)
     else:
-- 
GitLab