From 4958c81930e925addb8f4634a8b4065c366f5de1 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 6 Nov 2023 11:03:07 -0600
Subject: [PATCH] snapshot...

---
 modules/icing/util.py | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/modules/icing/util.py b/modules/icing/util.py
index 276ceac8..f98eb907 100644
--- a/modules/icing/util.py
+++ b/modules/icing/util.py
@@ -784,24 +784,39 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
 
         satzen = ancil_data_dct['sensor_zenith_angle']
         solzen = ancil_data_dct['solar_zenith_angle']
+        cth = ancil_data_dct['cld_height_acha']
         bt_10_4 = ancil_data_dct[bt_fld_name]
         day_idxs = []
         nght_idxs = []
         all_idxs = []
         avg_bt = []
+        day_cth_max = []
+        nght_cth_max = []
+
         for j in range(num_lines):
             for i in range(num_elems):
                 k = i + j*num_elems
                 avg_bt.append(get_median(bt_10_4[k]))
 
+                c = cth[k].flatten()
+                c_m = np.mean(np.sort(c[np.invert(np.isnan(c))])[-2:])
+
+                c_m = 0 if 2000 > c_m >= 0 else c_m
+                c_m = 1 if 4000 > c_m >= 2000 else c_m
+                c_m = 2 if 6000 > c_m >= 4000 else c_m
+                c_m = 3 if 8000 > c_m >= 6000 else c_m
+                c_m = 4 if 15000 > c_m >= 8000 else c_m
+
                 if not check_oblique(satzen[k]):
                     continue
 
                 all_idxs.append(k)
                 if is_day(solzen[k]):
                     day_idxs.append(k)
+                    day_cth_max.append(c_m)
                 else:
                     nght_idxs.append(k)
+                    nght_cth_max.append(c_m)
 
         num_tiles = len(all_idxs)
         num_day_tiles = len(day_idxs)
@@ -827,6 +842,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
                 day_grd_dct = {name: None for name in day_train_params}
                 for ds_name in day_train_params:
                     day_grd_dct[ds_name] = np.stack(day_data_dct[ds_name])
+                day_grd_dct['cth_high_avg'] = day_cth_max
 
                 preds_day_dct, probs_day_dct = \
                     model_module.run_evaluate_static_2(day_model, day_grd_dct, num_day_tiles, prob_thresh=prob_thresh,
@@ -856,6 +872,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
                 nght_grd_dct = {name: None for name in nght_train_params}
                 for ds_name in nght_train_params:
                     nght_grd_dct[ds_name] = np.stack(nght_data_dct[ds_name])
+                nght_grd_dct['cth_high_avg'] = nght_cth_max
 
                 preds_nght_dct, probs_nght_dct = \
                     model_module.run_evaluate_static_2(night_model, nght_grd_dct, num_nght_tiles,
@@ -1161,7 +1178,6 @@ def run_icing_predict_image(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output
             day_grd_dct = {name: None for name in day_train_params}
             for ds_name in day_train_params:
                 day_grd_dct[ds_name] = np.stack(day_data_dct[ds_name])
-
             day_grd_dct['cth_high_avg'] = day_cth_max
 
             preds_day_dct, probs_day_dct = \
@@ -1187,7 +1203,6 @@ def run_icing_predict_image(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output
             nght_grd_dct = {name: None for name in nght_train_params}
             for ds_name in nght_train_params:
                 nght_grd_dct[ds_name] = np.stack(nght_data_dct[ds_name])
-
             nght_grd_dct['cth_high_avg'] = nght_cth_max
 
             preds_nght_dct, probs_nght_dct = \
-- 
GitLab