diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py index 2a8c9ba2ccd4d5aafc701a59c2366d2f86c8800e..6af7a69441fa9024fb6f700a499fbb3f17464354 100644 --- a/modules/aeolus/aeolus_amv.py +++ b/modules/aeolus/aeolus_amv.py @@ -944,6 +944,80 @@ def analyze2(amvs_list, bf_list, raob_match_list, bf_gfs_list, amv_prod_list): np.average(np.abs(bin_spd[i])), np.average(bin_spd[i]), np.average(np.abs(bin_dir[i])), np.average(bin_dir[i]))) + # Comparison to Level of Best Fits (LBF) GFS to RAOB ------------------------------------------------------------------ + # ------------------------------------------------------------------------------------------------------------ + vld_bf = bfs[:, 3] == 0 + vld_bf_gfs = bfs_gfs[:, 3] == 0 + keep_idxs = np.logical_and(vld_bf, vld_bf_gfs) + + amv_p = good_amvs[keep_idxs, pidx] + bf_p = bfs[keep_idxs, 2] + bf_p_gfs = bfs_gfs[keep_idxs, 2] + diff = bf_p - bf_p_gfs + mad = np.average(np.abs(diff)) + bias = np.average(diff) + print('********************************************************') + print('Number of good best fits to GFS: ', bf_p.shape[0]) + print('press, MAD: {0:.2f}'.format(mad)) + print('press, bias: {0:.2f}'.format(bias)) + pd_std = np.std(diff) + pd_mean = np.mean(diff) + print('press bias/rms: {0:.2f} {1:.2f} '.format(pd_mean, np.sqrt(pd_mean**2 + pd_std**2))) + print('------------------------------------------') + + bin_pres = bin_data_by(diff, amv_p, bin_ranges) + + amv_spd = good_amvs[keep_idxs, sidx] + amv_dir = good_amvs[keep_idxs, didx] + bf_gfs_spd, bf_gfs_dir = spd_dir_from_uv(bfs_gfs[keep_idxs, 0], bfs_gfs[keep_idxs, 1]) + bf_spd, bf_dir = spd_dir_from_uv(bfs[keep_idxs, 0], bfs[keep_idxs, 1]) + + diff = bf_spd - bf_gfs_spd + diff = diff.magnitude + spd_mad = np.average(np.abs(diff)) + spd_bias = np.average(diff) + print('spd, MAD: {0:.2f}'.format(spd_mad)) + print('spd, bias: {0:.2f}'.format(spd_bias)) + spd_mean = np.mean(diff) + spd_std = np.std(diff) + print('spd MAD/bias/rms: {0:.2f} {1:.2f} {2:.2f}'.format(np.average(np.abs(diff)), spd_mean, np.sqrt(spd_mean**2 + spd_std**2))) + print('-----------------') + bin_spd = bin_data_by(diff, amv_p, bin_ranges) + + dir_diff = direction_difference(bf_dir.magnitude, bf_gfs_dir.magnitude) + print('dir, MAD: {0:.2f}'.format(np.average(np.abs(dir_diff)))) + print('dir bias: {0:.2f}'.format(np.average(dir_diff))) + print('-------------------------------------') + bin_dir = bin_data_by(dir_diff, amv_p, bin_ranges) + + u_diffs = bfs[keep_idxs, 0] - bfs_gfs[keep_idxs, 0] + v_diffs = bfs[keep_idxs, 1] - bfs_gfs[keep_idxs, 1] + + vd = np.sqrt(u_diffs**2 + v_diffs**2) + vd_mean = np.mean(vd) + vd_std = np.std(vd) + print('VD bias/rms: {0:.2f} {1:.2f}'.format(vd_mean, np.sqrt(vd_mean**2 + vd_std**2))) + print('******************************************************') + + x_values = [] + num_pres = [] + num_spd = [] + num_dir = [] + print('level num cases hgt MAD/bias spd MAD/bias dir MAD/bias') + print('-------------------------------------------------------------------') + for i in range(len(bin_ranges)): + x_values.append(np.average(bin_ranges[i])) + num_pres.append(bin_pres[i].shape[0]) + num_spd.append(bin_spd[i].shape[0]) + num_dir.append(bin_dir[i].shape[0]) + + print('{0:d} {1:d} {2:.2f}/{3:.2f} {4:.2f}/{5:.2f} {6:.2f}/{7:.2f}' + .format(int(x_values[i]), num_pres[i], np.average(np.abs(bin_pres[i])), np.average(bin_pres[i]), + np.average(np.abs(bin_spd[i])), np.average(bin_spd[i]), np.average(np.abs(bin_dir[i])), np.average(bin_dir[i]))) + + return bin_ranges, bin_pres, bin_spd, bin_dir + + def compare_amvs_bestfit(amvs_list, bfs_list, bin_size=200): amvs = np.concatenate(amvs_list, axis=1) amvs = np.transpose(amvs, axes=[1, 0])