From 80aa42641c8ad177433d79d56bcf56392a00f62a Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 19 Oct 2020 17:42:26 -0500
Subject: [PATCH] snapshot...

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

diff --git a/modules/amv/intercompare.py b/modules/amv/intercompare.py
index 3a23c86e..7cbfb6f8 100644
--- a/modules/amv/intercompare.py
+++ b/modules/amv/intercompare.py
@@ -1042,10 +1042,11 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
 
 
 def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcst_dir, fcst_alt,
+                      amv_uwind=None, amv_vwind=None,
                       fcst_uwind=None, fcst_vwind=None,
-                      alt_top=25000.0, alt_bot=0.0, bf_half_width=500.0, constraint_half_width=400.0):
+                      alt_top=25000.0, alt_bot=0.0, bf_half_width=1000.0, constraint_half_width=1000.0):
     verbose = False
-    fcst_num_levels = fcst_spd.shape[0]
+    fcst_num_levels = fcst_alt.shape[0]
 
     flag = 3
     bf_tup = (np.nan, np.nan, np.nan, flag)
@@ -1066,8 +1067,9 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
         return bf_tup
 
     # Compute U anv V for both AMVs and forecast
-    amv_uwind = -amv_spd * np.sin((np.pi/180.0)*amv_dir)
-    amv_vwind = -amv_spd * np.cos((np.pi/180.0)*amv_dir)
+    if amv_uwind is None:
+        amv_uwind = -amv_spd * np.sin((np.pi/180.0)*amv_dir)
+        amv_vwind = -amv_spd * np.cos((np.pi/180.0)*amv_dir)
     if fcst_uwind is None:
         fcst_uwind = -fcst_spd * np.sin((np.pi/180.0)*fcst_dir)
         fcst_vwind = -fcst_spd * np.cos((np.pi/180.0)*fcst_dir)
@@ -1141,7 +1143,7 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
     mm = np.where(fcst_alt > (sat_wind_best_fit_alt + constraint_half_width))[0]
     nn = np.where(fcst_alt < (sat_wind_best_fit_alt - constraint_half_width))[0]
 
-    if (np.sum(vec_diff[mm] < (vec_diff + 2.0)) + np.sum(vec_diff[nn] < (vec_diff + 2.0))) > 0:
+    if (np.sum(vec_diff[mm] < (vdiff + 2.0)) + np.sum(vec_diff[nn] < (vdiff + 2.0))) > 0:
         good_constraint = 0
         flag = 1
 
-- 
GitLab