Skip to content
Snippets Groups Projects
Commit 6f6ac7e6 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 8c1d6f7a
No related branches found
No related tags found
No related merge requests found
...@@ -2422,138 +2422,6 @@ def tiles_info(filename): ...@@ -2422,138 +2422,6 @@ def tiles_info(filename):
print('Icing 6: ', np.sum(iint == 6)) print('Icing 6: ', np.sum(iint == 6))
# def analyze(preds_file, labels, prob_avg, test_file):
#
# if preds_file is not None:
# labels, prob_avg, cm_avg = pickle.load(open(preds_file, 'rb'))
#
# h5f = h5py.File(test_file, 'r')
# nda = h5f['flight_altitude'][:]
# iint = h5f['icing_intensity'][:]
# cld_hgt = h5f['cld_height_acha'][:]
# 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)
#
# nda[np.logical_and(nda >= 0, nda < 2000)] = 0
# nda[np.logical_and(nda >= 2000, nda < 4000)] = 1
# nda[np.logical_and(nda >= 4000, nda < 6000)] = 2
# nda[np.logical_and(nda >= 6000, nda < 8000)] = 3
# nda[np.logical_and(nda >= 8000, nda < 15000)] = 4
#
# print(np.sum(nda == 0), np.sum(nda == 1), np.sum(nda == 2), np.sum(nda == 3), np.sum(nda == 4))
# print('No icing: ', np.histogram(nda[iint == 0], bins=5)[0])
# print('---------------------------')
# print('Icing: ', np.histogram(nda[iint == 1], bins=5)[0])
# print('---------------------------')
#
# 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)]), 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)]), 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)]), 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)]), 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)]), 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('----------------------------------------------------------')
#
# if prob_avg is None:
# return
#
# 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 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_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_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_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_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_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 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_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_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_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_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_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 analyze(preds_file, labels, prob_avg, test_file): def analyze(preds_file, labels, prob_avg, test_file):
if preds_file is not None: if preds_file is not None:
...@@ -2573,42 +2441,20 @@ def analyze(preds_file, labels, prob_avg, test_file): ...@@ -2573,42 +2441,20 @@ def analyze(preds_file, labels, prob_avg, test_file):
iint = np.where(iint == -1, 0, iint) iint = np.where(iint == -1, 0, iint)
iint = np.where(iint != 0, 1, iint) iint = np.where(iint != 0, 1, iint)
# nda[np.logical_and(nda >= 0, nda < 2000)] = 0 nda[np.logical_and(nda >= 300, nda < 4000)] = 0
# nda[np.logical_and(nda >= 2000, nda < 4000)] = 1 nda[np.logical_and(nda >= 4000, nda < 7000)] = 1
# nda[np.logical_and(nda >= 4000, nda < 15000)] = 2 nda[np.logical_and(nda >= 7000, nda < 15000)] = 2
nda[np.logical_and(nda >= 0, nda < 3000)] = 0
nda[np.logical_and(nda >= 3000, nda < 6000)] = 1
# nda[np.logical_and(nda >= 5200, nda < 6000)] = 2
# nda[np.logical_and(nda >= 6000, nda < 8000)] = 3 # nda[np.logical_and(nda >= 6000, nda < 8000)] = 3
# nda[np.logical_and(nda >= 8000, nda < 15000)] = 4 # nda[np.logical_and(nda >= 8000, nda < 15000)] = 4
print(np.sum(nda == 0), np.sum(nda == 1), np.sum(nda == 2)) print(np.sum(nda == 0), np.sum(nda == 1), np.sum(nda == 2))
print('No icing: ', np.sum((iint == 0) & (nda == 0)), np.sum((iint == 0) & (nda == 1))) print('No icing: ', np.sum((iint == 0) & (nda == 0)), np.sum((iint == 0) & (nda == 1)), np.sum((iint == 0) & (nda == 2)))
print('---------------------------') print('---------------------------')
print('Icing: ', np.sum((iint == 1) & (nda == 0)), np.sum((iint == 1) & (nda == 1))) print('Icing: ', np.sum((iint == 1) & (nda == 0)), np.sum((iint == 1) & (nda == 1)), np.sum((iint == 1) & (nda == 2)))
print('---------------------------') print('---------------------------')
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)]), 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)]), 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)]), 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('----------------------------------------------------------') print('----------------------------------------------------------')
print('----------------------------------------------------------') print('----------------------------------------------------------')
# return flt_alt[iint == 0], flt_alt[iint == 1]
if prob_avg is None: if prob_avg is None:
return return
...@@ -2621,91 +2467,53 @@ def analyze(preds_file, labels, prob_avg, test_file): ...@@ -2621,91 +2467,53 @@ def analyze(preds_file, labels, prob_avg, test_file):
true_no_ice = (labels == 0) & (preds == 0) true_no_ice = (labels == 0) & (preds == 0)
false_no_ice = (labels == 1) & (preds == 0) false_no_ice = (labels == 1) & (preds == 0)
# tp = true_ice
# tn = true_no_ice
# fp = false_ice
# fn = false_no_ice
tp_0 = np.sum(true_ice & (nda == 0)) tp_0 = np.sum(true_ice & (nda == 0))
tp_1 = np.sum(true_ice & (nda == 1)) tp_1 = np.sum(true_ice & (nda == 1))
tp_2 = np.sum(true_ice & (nda == 2))
tn_0 = np.sum(true_no_ice & (nda == 0)) tn_0 = np.sum(true_no_ice & (nda == 0))
tn_1 = np.sum(true_no_ice & (nda == 1)) tn_1 = np.sum(true_no_ice & (nda == 1))
tn_2 = np.sum(true_no_ice & (nda == 2))
fp_0 = np.sum(false_ice & (nda == 0)) fp_0 = np.sum(false_ice & (nda == 0))
fp_1 = np.sum(false_ice & (nda == 1)) fp_1 = np.sum(false_ice & (nda == 1))
fp_2 = np.sum(false_ice & (nda == 2))
fn_0 = np.sum(false_no_ice & (nda == 0)) fn_0 = np.sum(false_no_ice & (nda == 0))
fn_1 = np.sum(false_no_ice & (nda == 1)) fn_1 = np.sum(false_no_ice & (nda == 1))
fn_2 = np.sum(false_no_ice & (nda == 2))
recall_0 = tp_0 / (tp_0 + fn_0) recall_0 = tp_0 / (tp_0 + fn_0)
recall_1 = tp_1 / (tp_1 + fn_1) recall_1 = tp_1 / (tp_1 + fn_1)
recall_2 = tp_2 / (tp_2 + fn_2)
precision_0 = tp_0 / (tp_0 + fp_0) precision_0 = tp_0 / (tp_0 + fp_0)
precision_1 = tp_1 / (tp_1 + fp_1) precision_1 = tp_1 / (tp_1 + fp_1)
precision_2 = tp_2 / (tp_2 + fp_2)
mcc_0 = ((tp_0 * tn_0) - (fp_0 * fn_0)) / np.sqrt((tp_0 + fp_0) * (tp_0 + fn_0) * (tn_0 + fp_0) * (tn_0 + fn_0)) mcc_0 = ((tp_0 * tn_0) - (fp_0 * fn_0)) / np.sqrt((tp_0 + fp_0) * (tp_0 + fn_0) * (tn_0 + fp_0) * (tn_0 + fn_0))
mcc_1 = ((tp_1 * tn_1) - (fp_1 * fn_1)) / np.sqrt((tp_1 + fp_1) * (tp_1 + fn_1) * (tn_1 + fp_1) * (tn_1 + fn_1)) mcc_1 = ((tp_1 * tn_1) - (fp_1 * fn_1)) / np.sqrt((tp_1 + fp_1) * (tp_1 + fn_1) * (tn_1 + fp_1) * (tn_1 + fn_1))
mcc_2 = ((tp_2 * tn_2) - (fp_2 * fn_2)) / np.sqrt((tp_2 + fp_2) * (tp_2 + fn_2) * (tn_2 + fp_2) * (tn_2 + fn_2))
# precision = true_ice / (true_ice + false_ice)
# recall = true_ice / (true_ice + false_no_ice)
# f1 = 2 * (precision * recall) / (precision + recall)
# tp = true_ice
# tn = true_no_ice
# fp = false_ice
# fn = false_no_ice
# mcc = ((tp * tn) - (fp * fn)) / np.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn))
print('Total (Positive/Icing Prediction: ') print('Total (Positive/Icing Prediction: ')
print('True icing: ', np.sum(true_ice & (nda == 0)), np.sum(true_ice & (nda == 1))) print('True icing: ', np.sum(true_ice & (nda == 0)), np.sum(true_ice & (nda == 1)), np.sum(true_ice & (nda == 2)))
print('-------------------------') print('-------------------------')
print('False no icing (False Negative/Miss): ', np.sum(false_no_ice & (nda == 0)), np.sum(false_no_ice & (nda == 1))) print('False no icing (False Negative/Miss): ', np.sum(false_no_ice & (nda == 0)), np.sum(false_no_ice & (nda == 1)), np.sum(false_no_ice & (nda == 2)))
# 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_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_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_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('---------------------------------------------------') print('---------------------------------------------------')
print('---------------------------------------------------') print('---------------------------------------------------')
print('Total (Negative/No Icing Prediction: ') print('Total (Negative/No Icing Prediction: ')
print('True no icing: ', np.sum(true_no_ice & (nda == 0)), np.sum(true_no_ice & (nda == 1))) print('True no icing: ', np.sum(true_no_ice & (nda == 0)), np.sum(true_no_ice & (nda == 1)), np.sum(true_no_ice & (nda == 2)))
print('-------------------------') print('-------------------------')
print('* False icing (False Positive/False Alarm) *: ', np.sum(false_ice & (nda == 0)), np.sum(false_ice & (nda == 1))) print('* False icing (False Positive/False Alarm) *: ', np.sum(false_ice & (nda == 0)), np.sum(false_ice & (nda == 1)), np.sum(false_ice & (nda == 2)))
print('-------------------------') print('-------------------------')
print('Recall: ', recall_0, recall_1) print('Recall: ', recall_0, recall_1, recall_2)
print('Precision: ', precision_0, precision_1) print('Precision: ', precision_0, precision_1, precision_2)
print('MCC: ', mcc_0, mcc_1) print('MCC: ', mcc_0, mcc_1, mcc_2)
return labels[nda == 0], prob_avg[nda == 0], labels[nda == 1], prob_avg[nda == 1], labels[nda == 2], prob_avg[nda == 2]
# print('level 0: ')
# 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_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_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('------------')
def get_training_parameters(day_night='DAY', l1b_andor_l2='both'): def get_training_parameters(day_night='DAY', l1b_andor_l2='both'):
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment