diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index 0a3937561592f910366fccc31af3dd432689d045..1b5ac5bb6f94b05a7f070752df4e8767b1b09ff9 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -879,7 +879,6 @@ def analyze2(filename, filename_l1b): iint = f['icing_intensity'][:] icing_alt = f['flight_altitude'][:] num_obs = iint.size - print('num obs: ', num_obs) iint = np.broadcast_to(iint.reshape(num_obs, 1), (num_obs, 256)).flatten() icing_alt = np.broadcast_to(icing_alt.reshape(num_obs, 1), (num_obs, 256)).flatten() @@ -889,6 +888,8 @@ def analyze2(filename, filename_l1b): iint = iint[keep_mask] icing_alt = icing_alt[keep_mask] + num_obs = iint.size + print('num obs: ', num_obs) no_ice = iint == -1 ice = iint >= 1 @@ -927,21 +928,59 @@ def analyze2(filename, filename_l1b): cld_mask = np.where(cld_mask > 1, 1, 0) # cld_frac = np.sum(cld_mask, axis=1) / 256 # need to do this earlier + # Simple model + preds = cld_top_tmp < 273.15 + + true_ice = ice & preds + false_ice = no_ice & preds + + true_no_ice = no_ice & np.invert(preds) + false_no_ice = ice & np.invert(preds) + + tp = np.sum(true_ice).astype(np.float32) + tn = np.sum(true_no_ice).astype(np.float32) + fp = np.sum(false_ice).astype(np.float32) + fn = np.sum(false_no_ice).astype(np.float32) + print(tp, tn, fp, fn) + + recall = tp / (tp + fn) + precision = tp / (tp + fp) + f1 = 2 * (precision * recall) / (precision + recall) + mcc = ((tp * tn) - (fp * fn)) / np.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn)) + acc = (tp + tn) / num_obs + + print('Total (Positive/Icing Prediction: ') + print('True icing: ', np.sum(true_ice)) + print('-------------------------') + print('False no icing (False Negative/Miss): ', np.sum(false_no_ice)) + print('---------------------------------------------------') + print('---------------------------------------------------') + + print('Total (Negative/No Icing Prediction: ') + print('True no icing: ', np.sum(true_no_ice)) + print('-------------------------') + print('* False icing (False Positive/False Alarm) *: ', np.sum(false_ice)) + print('-------------------------') + + print('ACC: ', acc) + print('Recall: ', recall) + print('Precision: ', precision) + print('F1: ', f1) + print('MCC: ', mcc) + # -------------------------------------------------------------------------------------------------------- f.close() f_l1b.close() - # return (icing_alt[tr_ice], icing_alt[tr_plus_ice], - # cld_top_hgt[tr_ice], cld_top_hgt[tr_plus_ice], - # cld_top_tmp[tr_ice], cld_top_tmp[tr_plus_ice], - # cld_opd[tr_ice], cld_opd[tr_plus_ice], - # cld_reff[tr_ice], cld_reff[tr_plus_ice]) return (icing_alt[no_ice], icing_alt[ice], cld_top_hgt[no_ice], cld_top_hgt[ice], cld_top_tmp[no_ice], cld_top_tmp[ice], cld_opd[no_ice], cld_opd[ice], - cld_reff[no_ice], cld_reff[ice]) + cld_reff[no_ice], cld_reff[ice], + cld_lwc[no_ice], cld_lwc[ice], + cld_iwc[no_ice], cld_iwc[ice], + sc_cld_frac[no_ice], sc_cld_frac[ice]) # --------------------------------------------