From d5ff6d1caa53982a719bc7e88b9097d2fd6dd9db Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 9 May 2022 10:05:57 -0500
Subject: [PATCH] snapshot...

---
 modules/icing/pirep_goes.py | 306 ++++++++++++++++++++++++++++++------
 1 file changed, 262 insertions(+), 44 deletions(-)

diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py
index 38839a46..9bcab5bd 100644
--- a/modules/icing/pirep_goes.py
+++ b/modules/icing/pirep_goes.py
@@ -381,6 +381,149 @@ def run(pirep_dct, platform, outfile=None, outfile_l1b=None, dt_str_start=None,
         create_file(outfile_l1b, data_dct, l1b_ds_list, l1b_ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids)
 
 
+def run_viirs(pirep_dct, platform='VIIRS', outfile=None, outfile_l1b=None, dt_str_start=None, dt_str_end=None):
+    time_keys = list(pirep_dct.keys())
+    l1b_grd_dct = {name: [] for name in l1b_ds_list}
+    ds_grd_dct = {name: [] for name in ds_list}
+
+    t_start = None
+    t_end = None
+    if (dt_str_start is not None) and (dt_str_end is not None):
+        dto = datetime.datetime.strptime(dt_str_start, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc)
+        dto.replace(tzinfo=timezone.utc)
+        t_start = dto.timestamp()
+
+        dto = datetime.datetime.strptime(dt_str_end, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc)
+        dto.replace(tzinfo=timezone.utc)
+        t_end = dto.timestamp()
+
+    lon_s = np.zeros(1)
+    lat_s = np.zeros(1)
+    last_clvr_file = None
+    last_h5f = None
+    nav = None
+
+    lon_c = []
+    lat_c = []
+    time_s = []
+    fl_alt_s = []
+    ice_int_s = []
+    unq_ids = []
+    num_rpts = 0
+    num_rpts_match = 0
+
+    for idx, time in enumerate(time_keys):
+        if t_start is not None:
+            if time < t_start:
+                continue
+            if time > t_end:
+                continue
+        num_rpts += 1
+
+        try:
+            clvr_ds = get_clavrx_datasource(time, platform)
+        except Exception:
+            print('run: Problem retrieving Datasource')
+            continue
+
+        clvr_file = clvr_ds.get_file_containing_time(time)[0]
+        if clvr_file is None:
+            continue
+
+        if clvr_file != last_clvr_file:
+            try:
+                h5f = h5py.File(clvr_file, 'r')
+                nav = clvr_ds.get_navigation(h5f)
+            except Exception:
+                if h5f is not None:
+                    h5f.close()
+                print('Problem with file: ', clvr_file)
+                continue
+            if last_h5f is not None:
+                last_h5f.close()
+            last_h5f = h5f
+            last_clvr_file = clvr_file
+        else:
+            h5f = last_h5f
+
+        cc = ll = -1
+        reports = pirep_dct[time]
+        for tup in reports:
+            lat, lon, fl, I, uid, rpt_str = tup
+            lat_s[0] = lat
+            lon_s[0] = lon
+            print('        ',lon, lat)
+            if not nav.check_inside(lon, lat):
+                print('missed range check')
+                continue
+
+            cc_a, ll_a = nav.earth_to_lc_s(lon_s, lat_s)  # non-navigable, skip
+            if cc_a[0] < 0:
+                print('cant navigate')
+                continue
+
+            if cc_a[0] == cc and ll_a[0] == ll:  # time adjacent duplicate, skip
+                continue
+            else:
+                cc = cc_a[0]
+                ll = ll_a[0]
+
+            cnt_a = 0
+            for didx, ds_name in enumerate(ds_list):
+                gvals = get_grid_values(h5f, ds_name, ll_a[0], cc_a[0], 20, fill_value_name=None, range_name=ds_range[didx], fill_value=ds_fill[didx])
+                if gvals is not None:
+                    ds_grd_dct[ds_name].append(gvals)
+                    cnt_a += 1
+
+            cnt_b = 0
+            for didx, ds_name in enumerate(l1b_ds_list):
+                gvals = get_grid_values(h5f, ds_name, ll_a[0], cc_a[0], 20, fill_value_name=None, range_name=l1b_ds_range[didx], fill_value=l1b_ds_fill[didx])
+                if gvals is not None:
+                    l1b_grd_dct[ds_name].append(gvals)
+                    cnt_b += 1
+
+            if cnt_a > 0 and cnt_a != len(ds_list):
+                raise GenericException('weirdness')
+            if cnt_b > 0 and cnt_b != len(l1b_ds_list):
+                raise GenericException('weirdness')
+
+            if cnt_a == len(ds_list) and cnt_b == len(l1b_ds_list):
+                lon_c.append(lon_s[0])
+                lat_c.append(lat_s[0])
+                time_s.append(time)
+                fl_alt_s.append(fl)
+                ice_int_s.append(I)
+                unq_ids.append(uid)
+    print('num reports: ', num_rpts)
+    if len(time_s) == 0:
+        return
+
+    t_start = time_s[0]
+    t_end = time_s[len(time_s)-1]
+
+    data_dct = {}
+    for ds_name in ds_list:
+        data_dct[ds_name] = np.array(ds_grd_dct[ds_name])
+    lon_c = np.array(lon_c)
+    lat_c = np.array(lat_c)
+    time_s = np.array(time_s)
+    fl_alt_s = np.array(fl_alt_s)
+    ice_int_s = np.array(ice_int_s)
+    unq_ids = np.array(unq_ids)
+
+    if outfile is not None:
+        outfile = add_time_range_to_filename(outfile, t_start, t_end)
+        create_file(outfile, data_dct, ds_list, ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids)
+
+    data_dct = {}
+    for ds_name in l1b_ds_list:
+        data_dct[ds_name] = np.array(l1b_grd_dct[ds_name])
+
+    if outfile_l1b is not None:
+        outfile_l1b = add_time_range_to_filename(outfile_l1b, t_start, t_end)
+        create_file(outfile_l1b, data_dct, l1b_ds_list, l1b_ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids)
+
+
 def pirep_info(pirep_dct):
     time_keys = list(pirep_dct.keys())
 
@@ -1710,6 +1853,26 @@ def run_mean_std_3(train_file_path, check_cloudy=False, params=train_params_day)
     pickle.dump(mean_std_lo_hi_dct, f)
     f.close()
 
+# Special VIIRS date/times -----------------------------------------------------------
+# time_ranges = [[get_timestamp('2019-03-12_00:00'), get_timestamp('2019-03-15_23:59')],
+#                [get_timestamp('2019-03-20_00:00'), get_timestamp('2019-03-26_23:59')],
+#                [get_timestamp('2019-03-29_00:00'), get_timestamp('2019-03-29_23:59')],
+#                [get_timestamp('2019-04-17_00:00'), get_timestamp('2019-04-17_23:59')],
+#                [get_timestamp('2019-04-20_00:00'), get_timestamp('2019-04-20_23:59')],
+#                [get_timestamp('2019-04-23_00:00'), get_timestamp('2019-04-23_23:59')],
+#                [get_timestamp('2019-04-27_00:00'), get_timestamp('2019-04-27_23:59')],
+#                [get_timestamp('2019-04-29_00:00'), get_timestamp('2019-04-29_23:59')],
+#                [get_timestamp('2019-05-09_00:00'), get_timestamp('2019-05-09_23:59')],
+#                [get_timestamp('2019-05-12_00:00'), get_timestamp('2019-05-12_23:59')],
+#                [get_timestamp('2019-05-14_00:00'), get_timestamp('2019-05-14_23:59')],
+#                [get_timestamp('2019-05-19_00:00'), get_timestamp('2019-05-19_23:59')],
+#                [get_timestamp('2019-06-13_00:00'), get_timestamp('2019-06-13_23:59')],
+#                [get_timestamp('2019-07-22_00:00'), get_timestamp('2019-07-22_23:59')],
+#                [get_timestamp('2019-07-24_00:00'), get_timestamp('2019-07-24_29:59')],
+#                [get_timestamp('2019-08-20_00:00'), get_timestamp('2019-08-20_23:59')],
+#                [get_timestamp('2019-09-09_00:00'), get_timestamp('2019-09-09_23:59')],
+#                [get_timestamp('2019-09-09_00:00'), get_timestamp('2019-09-11_23:59')]]
+
 
 def split_data(times):
     time_idxs = np.arange(times.shape[0])
@@ -1732,6 +1895,35 @@ def split_data(times):
                    [get_timestamp('2022-03-01_00:00'), get_timestamp('2022-03-07_23:59')],
                    [get_timestamp('2022-04-01_00:00'), get_timestamp('2022-04-04_23:59')]]
 
+    # time_ranges_lunar = [[get_timestamp('2018-01-01_00:00'), get_timestamp('2018-01-06_23:59')],
+    #                [get_timestamp('2018-03-01_00:00'), get_timestamp('2018-03-06_23:59')],
+    #                [get_timestamp('2018-05-01_00:00'), get_timestamp('2018-05-06_23:59')],
+    #                [get_timestamp('2018-07-01_00:00'), get_timestamp('2018-07-06_23:59')],
+    #                [get_timestamp('2018-09-01_00:00'), get_timestamp('2018-09-06_23:59')],
+    #                [get_timestamp('2018-11-01_00:00'), get_timestamp('2018-11-06_23:59')],
+    #                [get_timestamp('2019-01-01_00:00'), get_timestamp('2019-01-06_23:59')],
+    #                #[get_timestamp('2019-03-01_00:00'), get_timestamp('2019-03-07_23:59')],
+    #                [get_timestamp('2019-03-12_00:00'), get_timestamp('2019-03-15_23:59')],
+    #                [get_timestamp('2019-03-20_00:00'), get_timestamp('2019-03-26_23:59')],
+    #                [get_timestamp('2019-03-29_00:00'), get_timestamp('2019-03-29_23:59')],
+    #                [get_timestamp('2019-05-01_00:00'), get_timestamp('2019-05-03_23:59')],
+    #                [get_timestamp('2019-05-09_00:00'), get_timestamp('2019-05-09_23:59')],
+    #                [get_timestamp('2019-05-12_00:00'), get_timestamp('2019-05-12_23:59')],
+    #                [get_timestamp('2019-05-14_00:00'), get_timestamp('2019-05-14_23:59')],
+    #                [get_timestamp('2019-05-19_00:00'), get_timestamp('2019-05-19_23:59')],
+    #                [get_timestamp('2019-07-01_00:00'), get_timestamp('2019-07-05_23:59')],
+    #                [get_timestamp('2019-07-22_00:00'), get_timestamp('2019-07-22_23:59')],
+    #                [get_timestamp('2019-07-24_00:00'), get_timestamp('2019-07-24_23:59')],
+    #                [get_timestamp('2019-09-01_00:00'), get_timestamp('2019-09-05_23:59')],
+    #                [get_timestamp('2019-09-09_00:00'), get_timestamp('2019-09-09_23:59')],
+    #                [get_timestamp('2019-09-09_00:00'), get_timestamp('2019-09-11_23:59')],
+    #                [get_timestamp('2019-11-01_00:00'), get_timestamp('2019-11-07_23:59')],
+    #                [get_timestamp('2021-09-24_00:00'), get_timestamp('2021-10-01_23:59')],
+    #                [get_timestamp('2021-11-01_00:00'), get_timestamp('2021-11-07_23:59')],
+    #                [get_timestamp('2022-01-01_00:00'), get_timestamp('2022-01-07_23:59')],
+    #                [get_timestamp('2022-03-01_00:00'), get_timestamp('2022-03-07_23:59')],
+    #                [get_timestamp('2022-04-01_00:00'), get_timestamp('2022-04-04_23:59')]]
+
     keep_out = 10800  # 3 hrs
 
     vld_time_idxs = []
@@ -1762,6 +1954,32 @@ def split_data(times):
                    [get_timestamp('2022-03-26_00:00'), get_timestamp('2022-03-30_23:59')],
                    [get_timestamp('2022-04-07_00:00'), get_timestamp('2022-04-10_23:59')]]
 
+    # time_ranges_lunar = [[get_timestamp('2018-02-01_00:00'), get_timestamp('2018-02-04_23:59')],
+    #                [get_timestamp('2018-04-01_00:00'), get_timestamp('2018-04-04_23:59')],
+    #                [get_timestamp('2018-06-01_00:00'), get_timestamp('2018-06-04_23:59')],
+    #                [get_timestamp('2018-08-01_00:00'), get_timestamp('2018-08-04_23:59')],
+    #                [get_timestamp('2018-10-01_00:00'), get_timestamp('2018-10-04_23:59')],
+    #                [get_timestamp('2018-12-01_00:00'), get_timestamp('2018-12-04_23:59')],
+    #                [get_timestamp('2019-02-01_00:00'), get_timestamp('2019-02-04_23:59')],
+    #                #[get_timestamp('2019-04-01_00:00'), get_timestamp('2019-04-04_23:59')],
+    #                [get_timestamp('2019-04-17_00:00'), get_timestamp('2019-04-17_23:59')],
+    #                [get_timestamp('2019-04-20_00:00'), get_timestamp('2019-04-20_23:59')],
+    #                [get_timestamp('2019-04-23_00:00'), get_timestamp('2019-04-23_23:59')],
+    #                [get_timestamp('2019-04-27_00:00'), get_timestamp('2019-04-27_23:59')],
+    #                [get_timestamp('2019-04-29_00:00'), get_timestamp('2019-04-29_23:59')],
+    #                [get_timestamp('2019-06-01_00:00'), get_timestamp('2019-06-03_23:59')],
+    #                [get_timestamp('2019-06-13_00:00'), get_timestamp('2019-06-13_23:59')],
+    #                [get_timestamp('2019-08-01_00:00'), get_timestamp('2019-08-03_23:59')],
+    #                [get_timestamp('2019-08-20_00:00'), get_timestamp('2019-08-20_23:59')],
+    #                [get_timestamp('2019-10-01_00:00'), get_timestamp('2019-10-04_23:59')],
+    #                [get_timestamp('2019-12-01_00:00'), get_timestamp('2019-12-04_23:59')],
+    #
+    #                [get_timestamp('2021-10-05_00:00'), get_timestamp('2021-10-10_23:59')],
+    #                [get_timestamp('2021-12-01_00:00'), get_timestamp('2021-12-04_23:59')],
+    #                [get_timestamp('2022-02-01_00:00'), get_timestamp('2022-02-04_23:59')],
+    #                [get_timestamp('2022-03-26_00:00'), get_timestamp('2022-03-30_23:59')],
+    #                [get_timestamp('2022-04-07_00:00'), get_timestamp('2022-04-10_23:59')]]
+
     tst_time_idxs = []
     for t_rng in time_ranges:
         t_rng[0] -= keep_out
@@ -2002,7 +2220,7 @@ def tiles_info(filename):
     print('Icing 6:  ', np.sum(iint == 6))
 
 
-def analyze(preds_file, test_file='/Users/tomrink/data/icing_ml/tiles_202109240000_202111212359_l2_test_v3_DAY.h5'):
+def analyze(preds_file, labels, prob_avg, test_file):
     h5f = h5py.File(test_file, 'r')
     nda = h5f['flight_altitude'][:]
     iint = h5f['icing_intensity'][:]
@@ -2010,6 +2228,8 @@ def analyze(preds_file, test_file='/Users/tomrink/data/icing_ml/tiles_2021092400
     cld_dz = h5f['cld_geo_thick'][:]
     cld_tmp = h5f['cld_temp_acha'][:]
 
+    print('report altitude (m): ', np.histogram(nda, bins=12))
+
     iint = np.where(iint == -1, 0, iint)
     iint = np.where(iint != 0, 1, iint)
 
@@ -2028,106 +2248,104 @@ def analyze(preds_file, test_file='/Users/tomrink/data/icing_ml/tiles_2021092400
     print('No Icing(Negative): mean cld_dz, cld_hgt')
     print('Icing(Positive):         ",          "')
     print('level 0: ')
-    print(np.nanmean(cld_dz[(nda == 0) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 0) & (iint == 0)]))
-    print(np.nanmean(cld_dz[(nda == 0) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 0) & (iint == 1)]))
+    print(np.nanmean(cld_dz[(nda == 0) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 0) & (iint == 0)]), np.nanmean(cld_tmp[(nda == 0) & (iint == 0)]))
+    print(np.nanmean(cld_dz[(nda == 0) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 0) & (iint == 1)]), np.nanmean(cld_tmp[(nda == 0) & (iint == 1)]))
     print('------------')
 
     print('level 1: ')
-    print(np.nanmean(cld_dz[(nda == 1) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 1) & (iint == 0)]))
-    print(np.nanmean(cld_dz[(nda == 1) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 1) & (iint == 1)]))
+    print(np.nanmean(cld_dz[(nda == 1) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 1) & (iint == 0)]), np.nanmean(cld_tmp[(nda == 1) & (iint == 0)]))
+    print(np.nanmean(cld_dz[(nda == 1) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 1) & (iint == 1)]), np.nanmean(cld_tmp[(nda == 1) & (iint == 1)]))
     print('------------')
 
     print('level 2: ')
-    print(np.nanmean(cld_dz[(nda == 2) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 2) & (iint == 0)]))
-    print(np.nanmean(cld_dz[(nda == 2) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 2) & (iint == 1)]))
+    print(np.nanmean(cld_dz[(nda == 2) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 2) & (iint == 0)]), np.nanmean(cld_tmp[(nda == 2) & (iint == 0)]))
+    print(np.nanmean(cld_dz[(nda == 2) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 2) & (iint == 1)]), np.nanmean(cld_tmp[(nda == 2) & (iint == 1)]))
     print('------------')
 
     print('level 3: ')
-    print(np.nanmean(cld_dz[(nda == 3) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 3) & (iint == 0)]))
-    print(np.nanmean(cld_dz[(nda == 3) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 3) & (iint == 1)]))
+    print(np.nanmean(cld_dz[(nda == 3) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 3) & (iint == 0)]), np.nanmean(cld_tmp[(nda == 3) & (iint == 0)]))
+    print(np.nanmean(cld_dz[(nda == 3) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 3) & (iint == 1)]), np.nanmean(cld_tmp[(nda == 3) & (iint == 1)]))
     print('------------')
 
     print('level 4: ')
-    print(np.nanmean(cld_dz[(nda == 4) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 4) & (iint == 0)]))
-    print(np.nanmean(cld_dz[(nda == 4) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 4) & (iint == 1)]))
-    print('-----------------------------')
-    print('----------------------------')
-
-    if preds_file is None:
-        return
+    print(np.nanmean(cld_dz[(nda == 4) & (iint == 0)]), np.nanmean(cld_hgt[(nda == 4) & (iint == 0)]), np.nanmean(cld_tmp[(nda == 4) & (iint == 0)]))
+    print(np.nanmean(cld_dz[(nda == 4) & (iint == 1)]), np.nanmean(cld_hgt[(nda == 4) & (iint == 1)]), np.nanmean(cld_tmp[(nda == 4) & (iint == 1)]))
+    print('----------------------------------------------------------')
+    print('----------------------------------------------------------')
 
-    labels, prob_avg, cm_avg = pickle.load(open(preds_file, 'rb'))
+    if preds_file is not None:
+        labels, prob_avg, cm_avg = pickle.load(open(preds_file, 'rb'))
 
     preds = np.where(prob_avg > 0.5, 1, 0)
 
     true_ice = (labels == 1) & (preds == 1)
     false_ice = (labels == 0) & (preds == 1)
 
+    true_no_ice = (labels == 0) & (preds == 0)
+    false_no_ice = (labels == 1) & (preds == 0)
+
     print('Total (Positive/Icing Prediction: ')
     print('True icing:                         ', np.histogram(nda[true_ice], bins=5)[0])
     print('-------------------------')
-    print('False icing (False Positive/Alarm): ', np.histogram(nda[false_ice], bins=5)[0])
+    print('False no icing (False Negative/Miss): ', np.histogram(nda[false_no_ice], bins=5)[0])
     print('By flight level:')
     print('No Icing(Negative): mean cld_dz, cld_hgt')
     print('Icing(Positive):         ",          "')
     print('level 0: ')
-    print(np.nanmean(cld_dz[(nda == 0) & false_ice]), np.nanmean(cld_hgt[(nda == 0) & false_ice]))
-    print(np.nanmean(cld_dz[(nda == 0) & true_ice]), np.nanmean(cld_hgt[(nda == 0) & true_ice]))
+    print(np.nanmean(cld_dz[(nda == 0) & false_no_ice]), np.nanmean(cld_hgt[(nda == 0) & false_no_ice]), np.nanmean(cld_tmp[(nda == 0) & false_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 0) & true_ice]), np.nanmean(cld_hgt[(nda == 0) & true_ice]), np.nanmean(cld_tmp[(nda == 0) & true_ice]))
     print('------------')
 
     print('level 1: ')
-    print(np.nanmean(cld_dz[(nda == 1) & false_ice]), np.nanmean(cld_hgt[(nda == 1) & false_ice]))
-    print(np.nanmean(cld_dz[(nda == 1) & true_ice]), np.nanmean(cld_hgt[(nda == 1) & true_ice]))
+    print(np.nanmean(cld_dz[(nda == 1) & false_no_ice]), np.nanmean(cld_hgt[(nda == 1) & false_no_ice]), np.nanmean(cld_tmp[(nda == 1) & false_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 1) & true_ice]), np.nanmean(cld_hgt[(nda == 1) & true_ice]), np.nanmean(cld_tmp[(nda == 1) & true_ice]))
     print('------------')
 
     print('level 2: ')
-    print(np.nanmean(cld_dz[(nda == 2) & false_ice]), np.nanmean(cld_hgt[(nda == 2) & false_ice]))
-    print(np.nanmean(cld_dz[(nda == 2) & true_ice]), np.nanmean(cld_hgt[(nda == 2) & true_ice]))
+    print(np.nanmean(cld_dz[(nda == 2) & false_no_ice]), np.nanmean(cld_hgt[(nda == 2) & false_no_ice]), np.nanmean(cld_tmp[(nda == 2) & false_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 2) & true_ice]), np.nanmean(cld_hgt[(nda == 2) & true_ice]), np.nanmean(cld_tmp[(nda == 2) & true_ice]))
     print('------------')
 
     print('level 3: ')
-    print(np.nanmean(cld_dz[(nda == 3) & false_ice]), np.nanmean(cld_hgt[(nda == 3) & false_ice]))
-    print(np.nanmean(cld_dz[(nda == 3) & true_ice]), np.nanmean(cld_hgt[(nda == 3) & true_ice]))
+    print(np.nanmean(cld_dz[(nda == 3) & false_no_ice]), np.nanmean(cld_hgt[(nda == 3) & false_no_ice]), np.nanmean(cld_tmp[(nda == 3) & false_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 3) & true_ice]), np.nanmean(cld_hgt[(nda == 3) & true_ice]), np.nanmean(cld_tmp[(nda == 3) & true_ice]))
     print('------------')
 
     print('level 4: ')
-    print(np.nanmean(cld_dz[(nda == 4) & false_ice]), np.nanmean(cld_hgt[(nda == 4) & false_ice]))
-    print(np.nanmean(cld_dz[(nda == 4) & true_ice]), np.nanmean(cld_hgt[(nda == 4) & true_ice]))
-    print('-------------')
-    print('-------------')
-
-    true_no_ice = (labels == 0) & (preds == 0)
-    false_no_ice = (labels == 1) & (preds == 0)
+    print(np.nanmean(cld_dz[(nda == 4) & false_no_ice]), np.nanmean(cld_hgt[(nda == 4) & false_no_ice]), np.nanmean(cld_tmp[(nda == 4) & false_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 4) & true_ice]), np.nanmean(cld_hgt[(nda == 4) & true_ice]), np.nanmean(cld_tmp[(nda == 4) & true_ice]))
+    print('---------------------------------------------------')
+    print('---------------------------------------------------')
 
     print('Total (Negative/No Icing Prediction: ')
     print('True no icing:                             ', np.histogram(nda[true_no_ice], bins=5)[0])
     print('-------------------------')
-    print('* False no icing (False Negative/Miss) *:  ', np.histogram(nda[false_no_ice], bins=5)[0])
+    print('* False icing (False Positive/False Alarm) *:  ', np.histogram(nda[false_ice], bins=5)[0])
     print('-------------------------')
 
     print('level 0: ')
-    print(np.nanmean(cld_dz[(nda == 0) & false_no_ice]), np.nanmean(cld_hgt[(nda == 0) & false_no_ice]))
-    print(np.nanmean(cld_dz[(nda == 0) & true_no_ice]), np.nanmean(cld_hgt[(nda == 0) & true_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 0) & false_ice]), np.nanmean(cld_hgt[(nda == 0) & false_ice]), np.nanmean(cld_tmp[(nda == 0) & false_ice]))
+    print(np.nanmean(cld_dz[(nda == 0) & true_no_ice]), np.nanmean(cld_hgt[(nda == 0) & true_no_ice]), np.nanmean(cld_tmp[(nda == 0) & true_no_ice]))
     print('------------')
 
     print('level 1: ')
-    print(np.nanmean(cld_dz[(nda == 1) & false_no_ice]), np.nanmean(cld_hgt[(nda == 1) & false_no_ice]))
-    print(np.nanmean(cld_dz[(nda == 1) & true_no_ice]), np.nanmean(cld_hgt[(nda == 1) & true_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 1) & false_ice]), np.nanmean(cld_hgt[(nda == 1) & false_ice]), np.nanmean(cld_tmp[(nda == 1) & false_ice]))
+    print(np.nanmean(cld_dz[(nda == 1) & true_no_ice]), np.nanmean(cld_hgt[(nda == 1) & true_no_ice]), np.nanmean(cld_tmp[(nda == 1) & true_no_ice]))
     print('------------')
 
     print('level 2: ')
-    print(np.nanmean(cld_dz[(nda == 2) & false_no_ice]), np.nanmean(cld_hgt[(nda == 2) & false_no_ice]))
-    print(np.nanmean(cld_dz[(nda == 2) & true_no_ice]), np.nanmean(cld_hgt[(nda == 2) & true_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 2) & false_ice]), np.nanmean(cld_hgt[(nda == 2) & false_ice]), np.nanmean(cld_tmp[(nda == 2) & false_ice]))
+    print(np.nanmean(cld_dz[(nda == 2) & true_no_ice]), np.nanmean(cld_hgt[(nda == 2) & true_no_ice]), np.nanmean(cld_tmp[(nda == 2) & true_no_ice]))
     print('------------')
 
     print('level 3: ')
-    print(np.nanmean(cld_dz[(nda == 3) & false_no_ice]), np.nanmean(cld_hgt[(nda == 3) & false_no_ice]))
-    print(np.nanmean(cld_dz[(nda == 3) & true_no_ice]), np.nanmean(cld_hgt[(nda == 3) & true_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 3) & false_ice]), np.nanmean(cld_hgt[(nda == 3) & false_ice]), np.nanmean(cld_tmp[(nda == 3) & false_ice]))
+    print(np.nanmean(cld_dz[(nda == 3) & true_no_ice]), np.nanmean(cld_hgt[(nda == 3) & true_no_ice]), np.nanmean(cld_tmp[(nda == 3) & true_no_ice]))
     print('------------')
 
     print('level 4: ')
-    print(np.nanmean(cld_dz[(nda == 4) & false_no_ice]), np.nanmean(cld_hgt[(nda == 4) & false_no_ice]))
-    print(np.nanmean(cld_dz[(nda == 4) & true_no_ice]), np.nanmean(cld_hgt[(nda == 4) & true_no_ice]))
+    print(np.nanmean(cld_dz[(nda == 4) & false_ice]), np.nanmean(cld_hgt[(nda == 4) & false_ice]), np.nanmean(cld_tmp[(nda == 4) & false_ice]))
+    print(np.nanmean(cld_dz[(nda == 4) & true_no_ice]), np.nanmean(cld_hgt[(nda == 4) & true_no_ice]), np.nanmean(cld_tmp[(nda == 4) & true_no_ice]))
 
 
 def get_training_parameters(day_night='DAY', l1b_andor_l2='both'):
-- 
GitLab