]) bias = np.array( [0, taylor_stats4['bias'], taylor_stats2['bias'], taylor_stats3['bias']]) label = ['Non-Dimensional Observation', 'E', 'G', 'F', 'D'] sm.taylor_diagram( sdev, crmsd, ccoef, markerLabel=label, locationColorBar='EastOutside', markerDisplayed='colorbar', titleColorBar='Bias', # markerLabelColor='r', markerSize=10, markerLegend='off', cmapzdata=bias, colRMS='g', styleRMS=':', widthRMS=2.0, titleRMS='on', colSTD='b', styleSTD='-.', widthSTD=1.0, titleSTD='on', colCOR='k', styleCOR='--', widthCOR=1.0, titleCOR='on') # Write plot to file plt.savefig('Taylor_Diagram.png') # Show plot plt.show()
choices for SDEV, CRMSD, and CCOEFF variables to show effect. Increase the line width of all lines. For an exhaustive list of options to customize your diagram, please call the function at a Python command line: >> taylor_diagram ''' sm.taylor_diagram(sdev, crmsd, ccoef, markerLabel=label, markerLabelColor='r', tickRMS=np.arange(0, 60, 10), tickRMSangle=110.0, colRMS='m', styleRMS=':', widthRMS=2.0, tickSTD=np.arange(0, 80, 20), axismax=60.0, colSTD='b', styleSTD='-.', widthSTD=1.0, colCOR='k', styleCOR='--', widthCOR=1.0) # Write plot to file plt.savefig('taylor4.png') # Show plot plt.show()
choices for SDEV, CRMSD, and CCOEFF variables to show effect. Increase the line width of all lines. Suppress axes titles and add a legend. For an exhaustive list of options to customize your diagram, please call the function at a Python command line: >> taylor_diagram ''' sm.taylor_diagram(sdev, crmsd, ccoef, markerLabel=label, markerLabelColor='r', markerLegend='on', markerColor='r', styleOBS='-', colOBS='r', markerobs='o', markerSize=6, tickRMS=[0.0, 1.0, 2.0, 3.0], tickRMSangle=115, showlabelsRMS='on', titleRMS='on', titleOBS='Ref', checkstats='on') # Write plot to file plt.savefig('taylor10.png') # Show plot plt.show()
Increase the line width of all lines. For an exhaustive list of options to customize your diagram, please call the function at a Python command line: >> taylor_diagram ''' sm.taylor_diagram(sdev, crmsd, ccoef, numberPanels=2, markerLabel=label, markerLabelColor='r', tickRMS=range(0, 90, 10), tickRMSangle=150.0, colRMS='m', styleRMS=':', widthRMS=2.0, titleRMS='off', tickSTD=range(0, 80, 20), axismax=60.0, colSTD='b', styleSTD='-.', widthSTD=1.0, colCOR='k', styleCOR='--', widthCOR=1.0) # Calculate a negative correlation for one of the data values. data.pred3['data'] = -data.pred3['data'] taylor_stats3 = sm.taylor_statistics(data.pred3, data.ref, 'data') sdev = np.array([taylor_stats3['sdev'][0], taylor_stats3['sdev'][1]]) crmsd = np.array([taylor_stats3['crmsd'][0], taylor_stats3['crmsd'][1]])
for i, nc in enumerate(cmip.ncPaths): if i == 0: continue data = cmip.getData(i, allTime=False, timeIndex=0) data = data.reshape(data.size) std = data.std() rmse = sm.rmsd(data, observationData) coef = np.ma.corrcoef(data, observationData)[0, 1] stds.append(std) rmses.append(rmse) coefs.append(coef) # intervalsCOR = np.concatenate((np.arange(0,1.0,0.2), [0.9, 0.95, 0.99, 1])) sm.taylor_diagram( np.array(stds), np.array(rmses), np.array(coefs), markerLabel=cmip.markerLabels, # tickRMS = np.arange(0,25,10), # tickSTD = np.arange(9,20,5), # tickCOR = intervalsCOR, rmslabelformat=':.1f') plt.savefig(cmip.output, format='png', transparent=True) plt.close('all') print('******** CMIP-PY-START') print('SUCCESS') print('******** CMIP-PY-END') except Exception as instance: print(instance) sys.exit(1)
the line width of all lines. For an exhaustive list of options to customize your diagram, please call the function at a Python command line: >> taylor_diagram ''' sm.taylor_diagram(sdev, crmsd, ccoef, markerDisplayed='colorBar', titleColorbar='RMSD', nonRMSDz='on', titleRMS='off', tickRMS=range(0, 60, 10), tickRMSangle=110.0, colRMS='m', styleRMS=':', widthRMS=2.0, tickSTD=range(0, 80, 20), axismax=60.0, colSTD='b', styleSTD='-.', widthSTD=1.0, colCOR='k', styleCOR='--', widthCOR=1.0) # Write plot to file plt.savefig('taylor6.png') # Show plot plt.show()
plt.figure(figsize=(7, 7)) sm.taylor_diagram(sdev, crmsd, ccoef, alpha=1.0, axismax=0.60, markerLabel=label, markerLabelColor='r', markerColor='r', markerLegend='on', markersize=12, styleOBS='-', titleOBS='RAPID ARRAY', widthOBS=1.5, tickRMS=[0.0, 0.2, 0.4, 0.6], tickRMSangle=115.0, colRMS='g', styleRMS='--', widthRMS=2.0, titleRMS='on', tickSTD=[0.0, 0.2, 0.4, 0.6], colSTD='k', styleSTD=':', widthSTD=2.0, titleSTD='on', colCOR='b', styleCOR='-.', widthCOR=2.0, titleCOR='on') plt.yticks(fontsize=12) plt.xticks(fontsize=12)
For an exhaustive list of options to customize your diagram, please call the function at a Python command line: >> taylor_diagram ''' sm.taylor_diagram(sdev, crmsd, ccoef, markerLabel=label, markerLabelColor='r', markerColor='r', markerLegend='on', tickRMS=range(0, 60, 10), colRMS='m', styleRMS=':', widthRMS=2.0, titleRMS='on', tickSTD=range(0, 80, 20), axismax=60.0, colSTD='b', styleSTD='-.', widthSTD=1.0, titleSTD='on', colCOR='k', styleCOR='--', widthCOR=1.0, titleCOR='on', markerSize=10, alpha=0.0) # Write plot to file plt.savefig('taylor9.png')
'Non-Dimensional Observation', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'M10' ] label2 = [ 'Non-Dimensional Observation', 'M1: NNLS', 'M2: X2-I', 'M3: X2-L1', 'M4: X2-L2', 'M5: L-curve-I', 'M6: L-curve-L1', 'M7: L-curve-L2', 'M8: GCV-I', 'M9: GCV-L1', 'M10: GCV-L2' ] sm.taylor_diagram(sdev, crmsd, ccoef, MarkerDisplayed='marker', markerLabel=label1, markerColor='red', colRMS='green', colSTD='blue', colCOR='black', alpha=0.5, markerSize=13, titleOBS='observation', styleOBS='-') plt.savefig(path + 'taylor_SNR.png', dpi=300) plt.close('all') sm.taylor_diagram(sdev, crmsd, ccoef, MarkerDisplayed='marker', markerLabel=label2, colRMS='green',
taylor_stats2 = sm.taylor_statistics(data.pred2,data.ref,'data') taylor_stats3 = sm.taylor_statistics(data.pred3,data.ref,'data') # Store statistics in arrays sdev = np.array([taylor_stats1['sdev'][0], taylor_stats1['sdev'][1], taylor_stats2['sdev'][1], taylor_stats3['sdev'][1]]) crmsd = np.array([taylor_stats1['crmsd'][0], taylor_stats1['crmsd'][1], taylor_stats2['crmsd'][1], taylor_stats3['crmsd'][1]]) ccoef = np.array([taylor_stats1['ccoef'][0], taylor_stats1['ccoef'][1], taylor_stats2['ccoef'][1], taylor_stats3['ccoef'][1]]) ''' Produce the Taylor diagram Note that the first index corresponds to the reference series for the diagram. For example sdev[0] is the standard deviation of the reference series and sdev[1:4] are the standard deviations of the other 3 series. The value of sdev[0] is used to define the origin of the RMSD contours. The other values are used to plot the points (total of 3) that appear in the diagram. ''' sm.taylor_diagram(sdev,crmsd,ccoef, styleOBS = '-', colOBS = 'r', markerobs = 'o', titleOBS = 'observation') # Write plot to file plt.savefig('taylor2.png') # Show plot plt.show()
def make_model_evaluation(df_nonnan, model_path, ls_pred_dt, cfg_tds, cfg_op): X_test_ls = [] y_test_ls = [] cmap_pred_dt = plt.cm.get_cmap('viridis_r') ## Import dictionary with selected models: train_path_name = os.path.join( model_path, "model_dict_t0diff_maxdepth6_selfeat_gain.pkl") with open(train_path_name, "rb") as file: dict_sel_model = pickle.load(file) plt.close() fig = plt.figure(num=1, figsize=(7, 6)) ## Loop over lead times: for i, pred_dt in enumerate(ls_pred_dt): if i == 0: xgb_model_ls = [] pred_model_ls = [] Rank_obs_ls = [] top_features_ls = [] df_param_ls_diff = [] df_param_ls_rank = [] df_param_ls_rank_PM = [] df_param_ls_rank_pers = [] Rank_pred_XGB_ls = [] Rank_pred_XGB_PM_ls = [] if len(X_test_ls) == len(ls_pred_dt) and len(y_test_ls) == len( ls_pred_dt): X_test = X_test_ls[i] y_test = y_test_ls[i] else: if i == 0: X_test_ls = [] y_test_ls = [] X_train, X_test, y_train, y_test = ipt.get_model_input( df_nonnan, del_TRTeqZero_tpred=True, split_Xy_traintest=True, X_normalise=False, pred_dt=pred_dt, check_for_nans=False, verbose=True) del (X_train, y_train) X_test_ls.append(X_test) y_test_ls.append(y_test) ## Load XGB model fitted to all features: with open( os.path.join(model_path, "model_%i_t0diff_maxdepth6.pkl" % pred_dt), "rb") as file: xgb_model_feat = pickle.load(file) xgb_model_ls.append(xgb_model_feat) top_features = pd.DataFrame.from_dict( xgb_model_feat.get_booster().get_score(importance_type='gain'), orient="index", columns=["F_score"]).sort_values(by=['F_score'], ascending=False) top_features_ls.append(top_features) ## Get specific predictive model for this leadtime: pred_model = dict_sel_model["pred_mod_%i" % pred_dt] pred_model_ls.append(pred_model) ## Check that features agree: features_pred_model = pred_model.get_booster().feature_names n_features = len(features_pred_model) if set(features_pred_model) != set(top_features.index[:n_features]): raise ValueError( "Features of predictive model and top features of model fitted with all features do not agree" ) ## Make prediction of TRT Rank differences: TRT_diff_pred = pred_model.predict(X_test[features_pred_model]) ## Get set of different TRT Rank predictions: Rank_obs, Rank_pred_XGB, Rank_pred_XGB_PM, Rank_pred_pers, Rank_pred_pers_PM, \ Rank_pred_diff, Diff_pred_XGB = get_obs_fcst_TRT_Rank(X_test["TRT_Rank|0"], TRT_diff_pred, y_test, X_test["TRT_Rank|-5"]) Rank_obs_ls.append(Rank_obs) Rank_pred_XGB_ls.append(Rank_pred_XGB) Rank_pred_XGB_PM_ls.append(Rank_pred_XGB_PM) ## Plot scatterplots obs vs. predicted: plot_pred_vs_obs_core(y_test, Diff_pred_XGB.values, pred_dt, "_XGB%i" % n_features, cfg_tds, outtype="TRT_Rank_diff") plot_pred_vs_obs_core(Rank_obs, Rank_pred_XGB.values, pred_dt, "_XGB%i" % n_features, cfg_tds, outtype="TRT_Rank") plot_pred_vs_obs_core(Rank_obs, Rank_pred_XGB_PM.values, pred_dt, "_XGB%i-ProbMatch" % n_features, cfg_tds, outtype="TRT_Rank") plot_pred_vs_obs_core(Rank_obs, Rank_pred_pers.values, pred_dt, "_Pers", cfg_tds, outtype="TRT_Rank") plot_pred_vs_obs_core(Rank_obs, Rank_pred_pers_PM.values, pred_dt, "_Pers-ProbMatch", cfg_tds, outtype="TRT_Rank") plot_pred_vs_obs_core(Rank_obs, Rank_pred_diff.values, pred_dt, "_ConstDiff", cfg_tds, outtype="TRT_Rank") ## Calculate different term elements for R^2 / Brier Score calculation: df_param_ls_diff.append( get_R2_param(y_test.values, Diff_pred_XGB.values)) df_param_ls_rank.append( get_R2_param(Rank_obs.values, Rank_pred_XGB.values)) df_param_ls_rank_PM.append( get_R2_param(Rank_obs.values, Rank_pred_XGB_PM.values)) df_param_ls_rank_pers.append( get_R2_param(Rank_obs.values, Rank_pred_pers.values)) ## Calculate statistics for Taylor Diagram: stat_pred_XGB = sm.taylor_statistics(predicted=Rank_pred_XGB.values, reference=Rank_obs.values) stat_pred_XGB_PM = sm.taylor_statistics( predicted=Rank_pred_XGB_PM.values, reference=Rank_obs.values) stat_pred_pred_pers = sm.taylor_statistics( predicted=Rank_pred_pers.values, reference=Rank_obs.values) stat_pred_pred_diff = sm.taylor_statistics( predicted=Rank_pred_diff.values, reference=Rank_obs.values) stat_pred_pred_pers_PM = sm.taylor_statistics( predicted=Rank_pred_pers_PM.values, reference=Rank_obs.values) sdev = np.array([ stat_pred_XGB['sdev'][0], stat_pred_XGB['sdev'][1], stat_pred_XGB_PM['sdev'][1], stat_pred_pred_pers['sdev'][1] ]) crmsd = np.array([ stat_pred_XGB['crmsd'][0], stat_pred_XGB['crmsd'][1], stat_pred_XGB_PM['crmsd'][1], stat_pred_pred_pers['crmsd'][1] ]) ccoef = np.array([ stat_pred_XGB['ccoef'][0], stat_pred_XGB['ccoef'][1], stat_pred_XGB_PM['ccoef'][1], stat_pred_pred_pers['ccoef'][1] ]) #sdev = np.array([stat_pred_XGB['sdev'][0], stat_pred_XGB['sdev'][1], stat_pred_XGB_PM['sdev'][1], stat_pred_pred_pers['sdev'][1], stat_pred_pred_diff['sdev'][1]]) #crmsd = np.array([stat_pred_XGB['crmsd'][0], stat_pred_XGB['crmsd'][1], stat_pred_XGB_PM['crmsd'][1], stat_pred_pred_pers['crmsd'][1], stat_pred_pred_diff['crmsd'][1]]) #ccoef = np.array([stat_pred_XGB['ccoef'][0], stat_pred_XGB['ccoef'][1], stat_pred_XGB_PM['ccoef'][1], stat_pred_pred_pers['ccoef'][1], stat_pred_pred_diff['ccoef'][1]]) ## Plot Taylor Diagram: col_point = cmap_pred_dt(float(i) / len(ls_pred_dt)) col_point = (col_point[0], col_point[1], col_point[2], 0.8) plot_markerLabel = ["Obs", "+%imin" % pred_dt, "", ""] plot_markerLabelColor = "black" if i == 0: plot_markerLegend = 'on' plot_overlay = 'off' else: plot_markerLegend = "on" plot_overlay = 'on' #plot_markerLabelColor = None if i == len(ls_pred_dt) - 1: plot_markerLabelColor = None plot_markerLabel = ["Obs", "XGB", "XGB (PM)", "Persistance"] sm.taylor_diagram( sdev / sdev[0], crmsd, ccoef, styleOBS='-', colOBS='darkred', markerobs='o', titleOBS='Obs', markerLabel=plot_markerLabel, markerLabelColor=plot_markerLabelColor, alpha=0.1, markerColor=col_point, markerLegend=plot_markerLegend, axismax=1.2, markerSize=5, colRMS='grey', styleRMS='--', widthRMS=0.8, rincRMS=0.25, tickRMS=np.arange(0.25, 1.5, 0.25), #titleRMSangle = 110, colSTD='grey', styleSTD='-.', widthSTD=0.8, colCOR='grey', styleCOR=':', widthCOR=0.8, overlay=plot_overlay) ## Save Taylor Diagram: get_time_delta_colorbar(fig, ls_pred_dt, cmap_pred_dt, [0.7, 0.5, 0.05, 0.3]) plt.savefig( os.path.join(cfg_tds["fig_output_path"], "Taylor_Diagram_cmap.pdf")) plt.close() ## Plot histogram showing the effect of probability matching: print( "Save dataframe with observed, predicted, and predicted & PM TRT Ranks" ) Rank_obs_df = pd.concat(Rank_obs_ls, axis=1, sort=True) Rank_obs_df.columns = [ "TRT_Rank_obs|%i" % pred_dt for pred_dt in ls_pred_dt ] Rank_pred_XGB_df = pd.concat(Rank_pred_XGB_ls, axis=1, sort=True) Rank_pred_XGB_df.columns = [ "TRT_Rank_pred|%i" % pred_dt for pred_dt in ls_pred_dt ] Rank_pred_XGB_PM_df = pd.concat(Rank_pred_XGB_PM_ls, axis=1, sort=True) Rank_pred_XGB_PM_df.columns = [ "TRT_Rank_pred_PM|%i" % pred_dt for pred_dt in ls_pred_dt ] #plot_hist_probmatch(Rank_pred_XGB_df, Rank_pred_XGB_PM_df) Rank_obs_pred_df = pd.concat( [Rank_obs_df, Rank_pred_XGB_df, Rank_pred_XGB_PM_df], axis=1, sort=True) ## Get dataframe with observed, predicted, and predicted & PM TRT Ranks for operational PM: op_path_name = os.path.join(cfg_op["XGB_model_path"], "TRT_Rank_obs_pred.pkl") with open(op_path_name, "wb") as file: pickle.dump(Rank_obs_pred_df, file, protocol=2) print(" saved dict to 'XGB_model_path' location:\n %s" % op_path_name) prt_txt = """ --------------------------------------------------------------------------------- The file 'TRT_Rank_obs_pred.pkl' in the directory '%s' is now used for the operational probability matching procedure, be aware of that! ---------------------------------------------------------------------------------\n""" % ( cfg_op["XGB_model_path"]) print(prt_txt) ## Plot skill scores as function of lead-time: df_R2_param_rank = pd.concat(df_param_ls_rank, axis=0).set_index(np.array(ls_pred_dt)) df_R2_param_rank_PM = pd.concat(df_param_ls_rank_PM, axis=0).set_index(np.array(ls_pred_dt)) df_R2_param_diff = pd.concat(df_param_ls_diff, axis=0).set_index(np.array(ls_pred_dt)) df_R2_param_rank_pers = pd.concat(df_param_ls_rank_pers, axis=0).set_index(np.array(ls_pred_dt)) plot_stats(df_R2_param_rank, "TRT_Rank", cfg_tds) plot_stats(df_R2_param_diff, "TRT_Rank_diff", cfg_tds) plot_stats_nice(df_R2_param_rank, "TRT_Rank", cfg_tds) plot_stats_nice(df_R2_param_diff, "TRT_Rank_diff", cfg_tds) plot_stats_nice(df_R2_param_rank_pers, "TRT_Rank_pers", cfg_tds) plot_stats_nice(df_R2_param_rank_PM, "TRT_Rank_PM", cfg_tds) ## Print IDs of long TRT cells in testing dataset: print( "\nThese are the IDs of long TRT cells (>25 time steps) in the testing dataset:" ) TRT_ID = X_test_ls[-1].index TRT_ID = [TRT_ID_i[13:] for TRT_ID_i in TRT_ID.values] TRT_ID_count = Counter(TRT_ID) TRT_ID_count_sort = [ (k, TRT_ID_count[k]) for k in sorted(TRT_ID_count, key=TRT_ID_count.get, reverse=True) ] TRT_ID_count_sort_pd = pd.DataFrame(np.array(TRT_ID_count_sort), columns=["TRT_ID", "Count"]) TRT_ID_count_sort_pd["Count"] = TRT_ID_count_sort_pd["Count"].astype( np.uint16, inplace=True) TRT_ID_long = TRT_ID_count_sort_pd.loc[TRT_ID_count_sort_pd["Count"] > 25] print(TRT_ID_long) TRT_ID_casestudy = [ "2018080721250094", "2018080721300099", "2018080711400069", "2018080710200036" ] print(" Making analysis for TRT IDs (hardcoded!): %s" % TRT_ID_casestudy) TRT_ID_long_sel = TRT_ID_long.loc[TRT_ID_long['TRT_ID'].isin( TRT_ID_casestudy)] df_feature_ts_plot = pd.DataFrame.from_dict({ "Radar": ["CZC_lt57dBZ|-45|SUM", "CZC_lt57dBZ|-45|SUM", "CZC_lt57dBZ|-45|SUM"], "Satellite": [ "IR_097_stat|-20|PERC05", "IR_097_stat|-15|PERC01", "IR_097_stat|-20|MIN" ], "COSMO": [ "CAPE_MU_stat|-10|PERC50", "CAPE_MU_stat|-5|PERC75", "CAPE_ML_stat|0|SUM" ], "Lightning": [ "THX_densIC_stat|-30|SUM", "THX_curr_pos_stat|-40|SUM", "THX_curr_pos_stat|-30|SUM" ] }) for i_sel in range(len(TRT_ID_long_sel)): print(" Working on cell %s" % TRT_ID_long_sel.iloc[i_sel]["TRT_ID"]) plot_pred_time_series(TRT_ID_long_sel.iloc[i_sel], df_nonnan, Rank_pred_XGB_ls, ls_pred_dt, cfg_tds) plot_pred_time_series(TRT_ID_long_sel.iloc[i_sel], df_nonnan, Rank_pred_XGB_PM_ls, ls_pred_dt, cfg_tds, path_addon="PM", title_addon=" (PM)") plot_var_time_series_dt0_multiquant(TRT_ID_long_sel.iloc[i_sel], df_nonnan, cfg_tds) for i_pred_dt, pred_dt in enumerate([10, 20, 30]): fig = plt.figure(figsize=[10, 6]) ax_rad = fig.add_subplot(2, 2, 1) ax_sat = fig.add_subplot(2, 2, 2) ax_cos = fig.add_subplot(2, 2, 3) ax_thx = fig.add_subplot(2, 2, 4) ax_ls = [ax_rad, ax_sat, ax_cos, ax_thx] #fig, axes = plt.subplots(2,2) #fig.set_size_inches(8,6) for i_source, source in enumerate( ["Radar", "Satellite", "COSMO", "Lightning"]): ls_feat_param = df_feature_ts_plot[source].iloc[ i_pred_dt].split("|") past_dt = np.arange(-45, 0, 5) if int(ls_feat_param[1]) != 0 else [0] ax_ls[i_source] = plot_var_time_series( TRT_ID_long_sel.iloc[i_sel], df_nonnan, ls_feat_param[0], ls_feat_param[2], past_dt=past_dt, dt_highlight=int(ls_feat_param[1]), ax=ax_ls[i_source]) plt.tight_layout() plt.savefig( os.path.join( cfg_tds["fig_output_path"], "Feat_series_%i_%s.pdf" % (pred_dt, TRT_ID_long_sel.iloc[i_sel]["TRT_ID"]))) plt.close()
# Read Taylor statistics for ERA Interim (stats1) and TRMM (stats2) # data with respect to APHRODITE observations for each of years 2001 to # 2014 from pickle file stats = load_obj('Mekong_Basin_data_interannual') # observations # Specify labels for points in a dictionary because only desire labels # for each data set. label = {'ERA-5': 'r', 'TRMM': 'b'} ''' Produce the Taylor diagram for the first dataset ''' sm.taylor_diagram(stats.taylor_stats1['sdev'], stats.taylor_stats1['crmsd'], stats.taylor_stats1['ccoef'], markercolor='r', alpha=0.0, titleRMS='off', showlabelsRMS='off', tickRMS=[0.0]) ''' Overlay the second dataset ''' sm.taylor_diagram(stats.taylor_stats2['sdev'], stats.taylor_stats2['crmsd'], stats.taylor_stats2['ccoef'], markercolor='b', alpha=0.0, overlay='on', markerLabel=label) # Write plot to file
]) crmsd = np.array([ taylor_stats1['crmsd'][0], taylor_stats1['crmsd'][1], taylor_stats2['crmsd'][1], taylor_stats3['crmsd'][1] ]) ccoef = np.array([ taylor_stats1['ccoef'][0], taylor_stats1['ccoef'][1], taylor_stats2['ccoef'][1], taylor_stats3['ccoef'][1] ]) ''' Produce the Taylor diagram Note that the first index corresponds to the reference series for the diagram. For example sdev[0] is the standard deviation of the reference series and sdev[1:4] are the standard deviations of the other 3 series. The value of sdev[0] is used to define the origin of the RMSD contours. The other values are used to plot the points (total of 3) that appear in the diagram. For an exhaustive list of options to customize your diagram, please call the function at a Python command line: >> taylor_diagram ''' sm.taylor_diagram(sdev, crmsd, ccoef) # Write plot to file plt.savefig('taylor1.png') # Show plot plt.show()
plt.close('all') # Read Taylor statistics for ERA Interim (stats1) and TRMM (stats2) # data with respect to APHRODITE observations for each of years 2001 to # 2014 from pickle file stats = load_obj('Mekong_Basin_data') # observations # Specify labels for points in a dictionary because only desire labels # for each data set. label = {'ERA-5': 'r', 'TRMM': 'b'} ''' Produce the Taylor diagram for the first dataset ''' sm.taylor_diagram(stats.taylor_stats1['sdev'], stats.taylor_stats1['crmsd'], stats.taylor_stats1['ccoef'], markercolor='r', alpha=0.0) ''' Overlay the second dataset ''' sm.taylor_diagram(stats.taylor_stats2['sdev'], stats.taylor_stats2['crmsd'], stats.taylor_stats2['ccoef'], markercolor='b', alpha=0.0, overlay='on', markerLabel=label) # Write plot to file plt.savefig('taylor12.png', dpi=150, facecolor='w', bbox_inches='tight')
ccoef_ke_zinb = np.array(l_ccoef_ke_zinb) ccoef_ke_rf = np.array(l_ccoef_ke_rf) mksize = 14 plt.subplot(1, 2, 1) # poidi = sm.taylor_diagram(stdev_poi, crmsd_poi, ccoef_sp_poi, markerSize=mksize, markerLabel=l_names_poi, markerLegend = 'on', colCOR='k', colSTD='k', colRMS='darkmagenta', axismax = 8.0, titleCOR="on", markerobs = 'H', markercolor="y") # nbdi = sm.taylor_diagram(stdev_nb, crmsd_nb, ccoef_sp_nb, overlay = 'on', markerSize=mksize, markerLabel=l_names_nb, markerLegend = 'on', markercolor="r") nbdi = sm.taylor_diagram(stdev_nb, crmsd_nb, ccoef_sp_nb, markerSize=mksize, markerLabel=l_names_nb, markerLegend='on', colCOR='k', colSTD='k', colRMS='darkmagenta', axismax=8.0, titleCOR="on", markerobs='H', markercolor="r") poidi = sm.taylor_diagram(stdev_poi, crmsd_poi, ccoef_sp_poi, overlay='on', markerSize=mksize, markerLabel=l_names_poi, markerLegend='on', markercolor="b") zipdi = sm.taylor_diagram(stdev_zip,