From 3099f06dfbef56ecc608a6b02c6d1ff601ef98ae Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Sun, 6 Dec 2020 11:27:06 -0600
Subject: [PATCH] snapshot...

---
 modules/amv/intercompare.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/modules/amv/intercompare.py b/modules/amv/intercompare.py
index 57952df3..bad32b7a 100644
--- a/modules/amv/intercompare.py
+++ b/modules/amv/intercompare.py
@@ -583,12 +583,16 @@ def run_best_fit_gfs(amvs, gfs_filename, amv_lat_idx=amv_lat_idx, amv_lon_idx=am
     bestfits = []
 
     gfs_press = xr_dataset['pressure levels']
+    gfs_press = gfs_press.data
+    gfs_press = gfs_press[::-1]
 
-    uv_wind = get_vert_profile_s(xr_dataset, ['u-wind', 'v-wind'], amvs[:, amv_lon_idx], amvs[:, amv_lat_idx])
+    uv_wind = get_vert_profile_s(xr_dataset, ['u-wind', 'v-wind'], amvs[:, amv_lon_idx], amvs[:, amv_lat_idx], method='nearest')
     uv_wind = uv_wind.data
     wspd, wdir = spd_dir_from_uv(uv_wind[0,:,:], uv_wind[1,:,:])
     wspd = wspd.magnitude
     wdir = wdir.magnitude
+    wspd = wspd[:,::-1]
+    wdir = wdir[:,::-1]
 
     for j in range(num_amvs):
 
@@ -598,10 +602,10 @@ def run_best_fit_gfs(amvs, gfs_filename, amv_lat_idx=amv_lat_idx, amv_lon_idx=am
         alat = amvs[j, amv_lat_idx]
         alon = amvs[j, amv_lon_idx]
 
-        rspd = wspd[j]
-        rdir = wdir[j]
+        gfs_spd = wspd[j]
+        gfs_dir = wdir[j]
 
-        bf = best_fit(aspd, adir, aprs, alat, alon, rspd, rdir, gfs_press)
+        bf = best_fit(aspd, adir, aprs, alat, alon, gfs_spd, gfs_dir, gfs_press)
         bf = (j, bf[0], bf[1], bf[2], bf[3])
         if bf[4] == 0:
             bestfits.append(bf)
@@ -619,6 +623,10 @@ def run_best_fit_gfs2(xr_dataset, gfs_press, amv_lat, amv_lon, amv_prs, amv_spd,
     rspd = rspd.flatten()
     rdir = rdir.flatten()
 
+    gfs_press = gfs_press[::-1]
+    rspd = rspd[::-1]
+    rdir = rdir[::-1]
+
     bf = best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, rspd, rdir, gfs_press)
     bf = (bf[0], bf[1], bf[2], bf[3])
 
-- 
GitLab