df_dwd2 = transform_to_bools( df_dwd2, percentile_level) df_rea2 = transform_to_bools( df_rea2, percentile_level) # except Exception as msg: # print(msg) cmn_vals1 = df_dwd1.loc[cmn_idx].values.ravel() cmn_vals2 = df_dwd2.loc[cmn_idx].values.ravel() cmn_rea1 = df_rea1.loc[cmn_idx].values.ravel() cmn_rea2 = df_rea2.loc[cmn_idx].values.ravel() # np.nansum(df_dwd1) # df_dwd1.max() try: spr_corr = spr(cmn_vals1, cmn_vals2)[0] prs_corr = prs(cmn_vals1, cmn_vals2)[0] sep_dist = distance_sorted[ix2] spr_corr_rea = spr(cmn_rea1, cmn_rea2)[0] prs_corr_rea = prs(cmn_rea1, cmn_rea2)[0] # sep_dist_rea = distance_sorted[ix2] except Exception as msg: print(msg) if np.isnan(spr_corr): print('corr_is_nan') df_distance_corr.loc[stn_id, 'sep_dist_%s' % _id2] = sep_dist df_distance_corr.loc[stn_id, 'pears_corr_%s' % _id2] = spr_corr df_distance_corr.loc[stn_id,
dwd_pcp = dwd_hdf5_de.get_pandas_dataframe(stn_id).dropna() in_df_rea6_stn = in_df_rea6.loc[:, stn_id].dropna() cmn_idx = dwd_pcp.index.intersection(in_df_rea6_stn.index) #break df_dwd1 = resampleDf(dwd_pcp.loc[cmn_idx,:], temp_agg) df_rea1 = resampleDf(in_df_rea6_stn.loc[cmn_idx], temp_agg) if df_dwd1.size > 0: if test_for_extremes: df_dwd1 = transform_to_bools(df_dwd1, percentile_level) df_rea1 = transform_to_bools(df_rea1, percentile_level) spr_corr_dwd_rea = spr(df_dwd1.values.ravel(), df_rea1.values.ravel())[0] prs_corr_dwd_rea = prs(df_dwd1.values.ravel(), df_rea1.values.ravel())[0] else: spr_corr_dwd_rea = spr(df_dwd1.values.ravel(), df_rea1.values.ravel())[0] prs_corr_dwd_rea = prs(df_dwd1.values.ravel(), df_rea1.values.ravel())[0] df_distance_corr.loc[stn_id, 'prs_corr_dwd_rea'] = prs_corr_dwd_rea df_distance_corr.loc[stn_id, 'spr_corr_dwd_rea'] = spr_corr_dwd_rea # all stns #======================================================================