From 424874080176f12a615173a34a091cd8256b5702 Mon Sep 17 00:00:00 2001
From: rink <rink@ssec.wisc.edu>
Date: Sun, 27 Sep 2020 16:29:46 -0500
Subject: [PATCH] add distance from aeolus prof loc to each amv loc

---
 modules/aeolus/aeolus_amv.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py
index 81e7fbe8..307d9093 100644
--- a/modules/aeolus/aeolus_amv.py
+++ b/modules/aeolus/aeolus_amv.py
@@ -4,6 +4,7 @@ import glob
 import numpy as np
 from netCDF4 import Dataset, Dimension, Variable
 from aeolus.geos_nav import GEOSNavigation
+from util.util import haversine_np
 
 
 amv_file_duration = 60  # minutes
@@ -210,6 +211,10 @@ def get_aeolus_time_dict_s(filenames, lon360=False, do_sort=True):
     return t_dct
 
 
+def run_amv_aeolus_best_fit(match_dict):
+    return None
+
+
 def get_search_box(nav, lon, lat):
     cc, ll = nav.earth_to_lc(lon, lat)
     if cc is None:
@@ -301,7 +306,8 @@ def match_amvs_to_aelous(aeolus_dict, amv_files_path, amv_source='OPS', band='14
         num_amvs = np.sum(in_box)
         if num_amvs == 0:
             continue
-        match_dict[key] = (amv_lons[in_box], amv_lats[in_box], amv_pres[in_box], amv_spd[in_box], amv_dir[in_box])
+        dist = haversine_np(lon, lat, amv_lons[in_box], amv_lats[in_box])
+        match_dict[key] = (amv_lons[in_box], amv_lats[in_box], amv_pres[in_box], amv_spd[in_box], amv_dir[in_box], dist)
 
     return match_dict
 
@@ -319,7 +325,7 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
     namvs = 0
     nlevs = 0
     for key in keys:
-        lons, lats, pres, spd, dir = aeolus_to_amv_dct.get(key)
+        lons, lats, pres, spd, dir, _ = aeolus_to_amv_dct.get(key)
         num_amvs.append(len(lons))
         namvs += len(lons)
 
@@ -369,7 +375,7 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
         i_b = i_a + namvs
         i_d = i_c + nlevs
 
-        lons, lats, pres, spd, dir = aeolus_to_amv_dct.get(key)
+        lons, lats, pres, spd, dir, _ = aeolus_to_amv_dct.get(key)
         amv_lon[i_a:i_b] = lons[:]
         amv_lat[i_a:i_b] = lats[:]
         amv_spd[i_a:i_b] = spd[:]
-- 
GitLab