From 63ed75896a5d56dead1db1bf95526450aceec6bf Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Sun, 27 Nov 2022 12:55:53 -0600
Subject: [PATCH] snapshot...

---
 modules/icing/pirep_goes.py | 138 +++++++++++++++++++-----------------
 1 file changed, 72 insertions(+), 66 deletions(-)

diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py
index 82245672..8d2f9684 100644
--- a/modules/icing/pirep_goes.py
+++ b/modules/icing/pirep_goes.py
@@ -545,69 +545,69 @@ def pirep_info(pirep_dct):
 
     return flt_lvl_s, ice_intensity_s, lat_s, lon_s
 
-
-def analyze(ice_dct, no_ice_dct):
-
-    last_file = None
-    ice_files = []
-    ice_times = []
-    for ts in list(ice_dct.keys()):
-        try:
-            ds = get_goes_datasource(ts)
-            goes_file, t_0, _ = ds.get_file(ts)
-            if goes_file is not None and goes_file != last_file:
-                ice_files.append(goes_file)
-                ice_times.append(t_0)
-                last_file = goes_file
-        except Exception:
-            continue
-
-    last_file = None
-    no_ice_files = []
-    no_ice_times = []
-    for ts in list(no_ice_dct.keys()):
-        try:
-            ds = get_goes_datasource(ts)
-            goes_file, t_0, _ = ds.get_file(ts)
-            if goes_file is not None and goes_file != last_file:
-                no_ice_files.append(goes_file)
-                no_ice_times.append(t_0)
-                last_file = goes_file
-        except Exception:
-            continue
-
-    ice_times = np.array(ice_times)
-    no_ice_times = np.array(no_ice_times)
-
-    itrsct_vals, comm1, comm2 = np.intersect1d(no_ice_times, ice_times, return_indices=True)
-
-    ice_indexes = np.arange(len(ice_times))
-
-    ucomm2 = np.setxor1d(comm2, ice_indexes)
-    np.random.seed(42)
-    np.random.shuffle(ucomm2)
-    ucomm2 = ucomm2[0:8000]
-
-    files_comm = []
-    for i in comm2:
-        files_comm.append(ice_files[i])
-
-    files_extra = []
-    times_extra = []
-    for i in ucomm2:
-        files_extra.append(ice_files[i])
-        times_extra.append(ice_times[i])
-
-    files = files_comm + files_extra
-    times = itrsct_vals.tolist() + times_extra
-    times = np.array(times)
-
-    sidxs = np.argsort(times)
-    for i in sidxs:
-        filename = os.path.split(files[i])[1]
-        so = re.search('_s\\d{11}', filename)
-        dt_str = so.group()
-        print(dt_str[2:])
+# Keep for example
+# def analyze(ice_dct, no_ice_dct):
+#
+#     last_file = None
+#     ice_files = []
+#     ice_times = []
+#     for ts in list(ice_dct.keys()):
+#         try:
+#             ds = get_goes_datasource(ts)
+#             goes_file, t_0, _ = ds.get_file(ts)
+#             if goes_file is not None and goes_file != last_file:
+#                 ice_files.append(goes_file)
+#                 ice_times.append(t_0)
+#                 last_file = goes_file
+#         except Exception:
+#             continue
+#
+#     last_file = None
+#     no_ice_files = []
+#     no_ice_times = []
+#     for ts in list(no_ice_dct.keys()):
+#         try:
+#             ds = get_goes_datasource(ts)
+#             goes_file, t_0, _ = ds.get_file(ts)
+#             if goes_file is not None and goes_file != last_file:
+#                 no_ice_files.append(goes_file)
+#                 no_ice_times.append(t_0)
+#                 last_file = goes_file
+#         except Exception:
+#             continue
+#
+#     ice_times = np.array(ice_times)
+#     no_ice_times = np.array(no_ice_times)
+#
+#     itrsct_vals, comm1, comm2 = np.intersect1d(no_ice_times, ice_times, return_indices=True)
+#
+#     ice_indexes = np.arange(len(ice_times))
+#
+#     ucomm2 = np.setxor1d(comm2, ice_indexes)
+#     np.random.seed(42)
+#     np.random.shuffle(ucomm2)
+#     ucomm2 = ucomm2[0:8000]
+#
+#     files_comm = []
+#     for i in comm2:
+#         files_comm.append(ice_files[i])
+#
+#     files_extra = []
+#     times_extra = []
+#     for i in ucomm2:
+#         files_extra.append(ice_files[i])
+#         times_extra.append(ice_times[i])
+#
+#     files = files_comm + files_extra
+#     times = itrsct_vals.tolist() + times_extra
+#     times = np.array(times)
+#
+#     sidxs = np.argsort(times)
+#     for i in sidxs:
+#         filename = os.path.split(files[i])[1]
+#         so = re.search('_s\\d{11}', filename)
+#         dt_str = so.group()
+#         print(dt_str[2:])
 
 
 lon_space_hdeg = np.linspace(-180, 180, 721)
@@ -1079,7 +1079,9 @@ def apply_qc_icing_pireps(icing_alt, cld_top_hgt, cld_geo_dz, cld_phase, cld_opd
         opd_thin_threshold = 0.1
 
     closeness_top = 100.0  # meters
-    closeness_bot = 200.0  # meters
+    closeness_bot = 100.0
+    max_depth = 3000.0
+
     num_obs = len(icing_alt)
     cld_mask = cld_mask.reshape((num_obs, -1))
     cld_top_hgt = cld_top_hgt.reshape((num_obs, -1))
@@ -1112,7 +1114,8 @@ def apply_qc_icing_pireps(icing_alt, cld_top_hgt, cld_geo_dz, cld_phase, cld_opd
 
         # Test 1
         keep = np.where(keep, (cld_top_hgt[i,] + closeness_top) > icing_alt[i], False)
-        keep = np.where(keep, (cld_top_hgt[i,] - cld_geo_dz[i,] - closeness_bot) < icing_alt[i], False)
+        # keep = np.where(keep, (cld_top_hgt[i,] - cld_geo_dz[i,] - closeness_bot) < icing_alt[i], False)
+        keep = np.where(keep, (cld_top_hgt[i,] - max_depth) < icing_alt[i], False)
 
         # # Test2
         # keep = np.where(keep,
@@ -1147,6 +1150,8 @@ def apply_qc_no_icing_pireps(icing_alt, cld_top_hgt, cld_geo_dz, cld_phase, cld_
 
     closeness_top = 100.0  # meters
     closeness_bot = 200.0
+    max_depth = 3000.0
+
     num_obs = len(icing_alt)
     cld_mask = cld_mask.reshape((num_obs, -1))
     cld_top_hgt = cld_top_hgt.reshape((num_obs, -1))
@@ -1178,7 +1183,8 @@ def apply_qc_no_icing_pireps(icing_alt, cld_top_hgt, cld_geo_dz, cld_phase, cld_
             continue
 
         keep = np.where(keep, (cld_top_hgt[i,] + closeness_top) > icing_alt[i], False)
-        keep = np.where(keep, (cld_top_hgt[i,] - cld_geo_dz[i,] - closeness_bot) < icing_alt[i], False)
+        # keep = np.where(keep, (cld_top_hgt[i,] - cld_geo_dz[i,] - closeness_bot) < icing_alt[i], False)
+        keep = np.where(keep, (cld_top_hgt[i,] - max_depth) < icing_alt[i], False)
 
         # keep = np.where(keep, np.logical_and(bt_11um[i,] > 228.0, bt_11um[i,] < 273.0), False)
 
-- 
GitLab