def test_mpi_he_plot_bootstrapped_skill_over_leadyear_ds( PM_ds_initialized_1d, PM_ds_control_1d): """ Checks plots from bootstrap_perfect_model works for xr.Dataset with one variable. """ res = bootstrap_perfect_model( PM_ds_initialized_1d, PM_ds_control_1d, metric="pearson_r", iterations=ITERATIONS, ) res_ax = plot_bootstrapped_skill_over_leadyear(res) assert res_ax is not None
def test_mpi_pm_plot_bootstrapped_skill_over_leadyear_da( PM_da_initialized_1d, PM_da_control_1d): """ Checks plots from bootstrap_perfect_model works for xr.DataArray. """ res = bootstrap_perfect_model( PM_da_initialized_1d, PM_da_control_1d, metric='pearson_r', iterations=ITERATIONS, ) res_ax = plot_bootstrapped_skill_over_leadyear(res) assert res_ax is not None
def test_PerfectModelEnsemble_plot_bootstrapped_skill_over_leadyear( perfectModelEnsemble_initialized_control, ): """ Checks plots from PerfectModelEnsemble.bootstrap(). """ res = perfectModelEnsemble_initialized_control.bootstrap( metric="pearson_r", iterations=ITERATIONS, reference=["uninitialized", "persistence"], comparison="m2e", dim=["init", "member"], ) res_ax = plot_bootstrapped_skill_over_leadyear(res) assert res_ax is not None
def test_mpi_he_plot_bootstrapped_skill_over_leadyear_single_uninit_lead( PM_da_initialized_1d, PM_da_control_1d): """ Checks plots from bootstrap_perfect_model works for xr.DataArray. """ res = bootstrap_perfect_model( PM_da_initialized_1d, PM_da_control_1d, metric="pearson_r", iterations=ITERATIONS, ) # set all but first uninit lead to nan res[:, 2, 1:] = [np.nan] * (res.lead.size - 1) res_ax = plot_bootstrapped_skill_over_leadyear(res) assert res_ax is not None
def test_mpi_pm_plot_bootstrapped_skill_over_leadyear(): """ Checks plots from bootstrap_perfect_model works. """ da = load_dataset('MPI-PM-DP-1D').isel(area=1, period=-1) PM_da_ds1d = da['tos'] da = load_dataset('MPI-control-1D').isel(area=1, period=-1) PM_da_control1d = da['tos'] # sig = 95 bootstrap = 5 res = bootstrap_perfect_model( PM_da_ds1d, PM_da_control1d, metric='pearson_r', bootstrap=bootstrap ) res_ax = plot_bootstrapped_skill_over_leadyear(res, 95) assert res_ax is not None
axes[1, 0].legend(fontsize=10, frameon=False) plt.tight_layout(h_pad=.1) mpl.rcParams['savefig.dpi'] = 300 mpl.rcParams['savefig.format'] = 'jpg' # plot and save plot_fig2(bs_acc, bs_rmse) if savefig: plt.savefig(path_paper + 'Figure1_predictability_skill', bbox_inches='tight') # extra plot for OSM 2020 savefig = True fig, ax = plt.subplots(1, 3, figsize=(18, 3)) plot_bootstrapped_skill_over_leadyear(bs_acc['CO2'].isel( lead=slice(None, 7)), 95, plot_persistence=False, ax=ax[0]) ax[0].set_ylabel('ACC [ ]') # ax[0].get_legend().remove() plot_bootstrapped_skill_over_leadyear(bs_rmse['CO2'].isel( lead=slice(None, 7)), 95, plot_persistence=False, ax=ax[1]) ax[1].set_ylabel('RMSE [ppm]') ax[1].get_legend().remove() plot_both_skill(bs_acc['CO2'], bs_rmse['CO2'], ax=ax[2], unit='ppm', not_all=True, sig=95) ax[2].legend(loc='lower left', frameon=False) ax[2].set_xlabel('RMSE [ppm]') if savefig: plt.savefig(path_paper + 'Figure_predictability_skill', bbox_inches='tight')