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

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

diff --git a/modules/amv/intercompare.py b/modules/amv/intercompare.py
index d6b597c3..3a23c86e 100644
--- a/modules/amv/intercompare.py
+++ b/modules/amv/intercompare.py
@@ -1042,6 +1042,7 @@ 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,
+                      fcst_uwind=None, fcst_vwind=None,
                       alt_top=25000.0, alt_bot=0.0, bf_half_width=500.0, constraint_half_width=400.0):
     verbose = False
     fcst_num_levels = fcst_spd.shape[0]
@@ -1064,17 +1065,20 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
             print('AMV location lat,lon,alt ({0},{1},{2}) failed to find fcst alt around AMV'.format(amv_lat,amv_lon,amv_alt))
         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 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)
+    else:
+        fcst_spd = np.sqrt(fcst_uwind**2 + fcst_vwind**2)
+
     # Diagnostic field: Find the model minimum speed and maximum speed within PressDiff of the AMV.
     if verbose:
         sat_wind_min_spd = min(fcst_spd[kk])
         sat_wind_max_spd = max(fcst_spd[kk])
 
-    # 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)
-    fcst_uwind = -fcst_spd * np.sin((np.pi/180.0)*fcst_dir)
-    fcst_vwind = -fcst_spd * np.cos((np.pi/180.0)*fcst_dir)
-
     # Calculate the vector difference between the AMV and model background at all levels.
     vec_diff = np.sqrt((amv_uwind - fcst_uwind) ** 2 + (amv_vwind - fcst_vwind) ** 2)
 
-- 
GitLab