From 6e103987a8c7487e6f66ad72282c0437cb7f6fe7 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Wed, 5 Oct 2022 11:18:25 -0500
Subject: [PATCH] snapshot...

---
 modules/amv/caliop_clavrx_amv.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/modules/amv/caliop_clavrx_amv.py b/modules/amv/caliop_clavrx_amv.py
index bff52e8c..337eb4c5 100644
--- a/modules/amv/caliop_clavrx_amv.py
+++ b/modules/amv/caliop_clavrx_amv.py
@@ -47,8 +47,8 @@ def match_calipso_clavrx_to_amvs(nom_time, calipso_clavrx_nc4, amv_files, calips
     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']
+    coords = {'num_params': all_params}
 
     amv_fname, ftime, f_idx = amv_files.get_file(nom_time)
     if f_idx is None:
@@ -124,15 +124,18 @@ def match_calipso_clavrx_to_amvs(nom_time, calipso_clavrx_nc4, amv_files, calips
         data_nd = np.vstack(calipso_clavrx_data)
         data_da = xr.DataArray(data_nd[:, idx], coords=coords_a, dims=dims_a)
 
-        lons = param_nd[0, :]
-        lats = param_nd[1, :]
+        #lons = param_nd[0, :]
+        #lats = param_nd[1, :]
+        lons = amvs_da[amv_files.lon_name, :]
+        lats = amvs_da[amv_files.lat_name, :]
         temp_prof = get_vert_profile_s(gfs_xr, ['temperature'], lons, lats, method='linear')
         temp_prof = temp_prof.values
         temp_prof_s = temp_prof[0, :, :]
 
         alt_s = []
         for k in range(num_amvs):
-            alt = pressure_to_altitude(param_nd[4, k], None, gfs_press, temp_prof_s[k, :])
+            #alt = pressure_to_altitude(param_nd[4, k], None, gfs_press, temp_prof_s[k, :])
+            alt = pressure_to_altitude(amvs_da[amv_files.press_name, k], None, gfs_press, temp_prof_s[k, :])
             alt_s.append(alt)
         alt_s = np.array(alt_s)
 
@@ -276,6 +279,9 @@ def create_file(match_dct, output_path, target_filepath, caliop_clavrx_params, a
             dist = tup[7]
             alt = tup[8]
 
+            dst_to_amvs[idx, 0:cnt] = dist
+            amv_geom_hgt[idx, 0:cnt] = alt
+
             for pidx, param in enumerate(caliop_clavrx_params):
                 nda = data_nd[pidx]
                 nc4_vars_cc[pidx][idx] = nda
@@ -296,9 +302,6 @@ def create_file(match_dct, output_path, target_filepath, caliop_clavrx_params, a
             cnt = nda.shape[0]
             amv_line[idx, 0:cnt] = nda
 
-            dst_to_amvs[idx, 0:cnt] = dist
-            amv_geom_hgt[idx, 0:cnt] = alt
-
             for pidx, param in enumerate(amv_params):
                 nda = amvs_nd[pidx+4,]
                 cnt = nda.shape[0]
-- 
GitLab