for lead in range(N_fcst): print("computing lead: {}".format(lead)) with h5py.File( REFCST_dir + "{}_{}_lead{}.hdf".format(prefix_raw, year, lead), 'r') as h5io: AnEn_ = h5io[key_raw][:, :EN, ...] if type_ind == 0 or type_ind == 1: # id 0 and 1 are flattened grid points, reshape them to 2d. AnEn_full[..., ~land_mask_bc] = AnEn_ AnEn_stn = AnEn_full[..., indx, indy] else: AnEn_stn = AnEn_[..., indx, indy] # cnn outputs can be negative, fix it here. AnEn_stn = ana.cnn_precip_fix(AnEn_stn) # extracting the 90-th threshold for initializaiton time + lead time for mon in range(12): flag_ = flag_pick[:, lead] == mon # stn obs obs_ = BCH_obs[flag_, lead, :] # fcst pred_ = AnEn_stn[flag_, ...] # station-wise threshold thres_ = BCH_90th[mon, :] # Brier Score ( ">=" is applied) obs_flag = obs_ >= thres_ obs_flag[np.isnan(obs_)] = np.nan pred_flag = pred_ >= thres_
for lead in range(N_fcst): with h5py.File( REFCST_dir + "{}_{}_lead{}.hdf".format(prefix_raw, y, lead), 'r') as h5io: AnEn_ = h5io[key_raw][:, :EN, ...] if type_ind == 0 or type_ind == 1: # id 0 and 1 are flattened grid points, reshape them to 2d. AnEn_full[..., ~land_mask_bc] = AnEn_ AnEn_stn[flag_pick, lead, ...] = AnEn_full[..., indx, indy] else: # cnn outputs can be negative, fix it here. AnEn_stn[flag_pick, lead, ...] = ana.cnn_precip_fix(AnEn_[..., indx, indy]) # ========== Calibration ========== # # params N_bins = 15 N_boost = 100 hist_bins = np.linspace(0, 1, N_bins) N_lead_day = 7 # number of forecasted days # 3-hr lead times to days fcst_leads_ini = np.arange(0, 72 * 3 + 3, 3, dtype=np.float) # date_base = datetime(2017, 1, 1, 0) # 2017 as a reference DAYS = [] for lead in fcst_leads_ini: date_temp = date_base + timedelta(hours=lead)