Esempio n. 1
0
    edge_colors = ['steelblue', 'indianred'] * len(modoks)

    positions.append(pos + 0.5)
    positions.append(pos + 1.5)

    fig = plt.figure(figsize=(16, 12))
    axes = []
    for reg in range(4):
        ax = fig.add_subplot(2, 2, reg + 1)
        axes.append(ax)

        ctl.boxplot_on_ax(ax,
                          allpercs_regs[reg],
                          modoks_dub,
                          coloks_dub,
                          edge_colors=edge_colors,
                          positions=positions,
                          versions=versions,
                          ens_colors=['steelblue', 'indianred'],
                          ens_names=['hist', 'ssp585'],
                          plot_mean=False)

        ax.axhline(0, color='gray', linewidth=0.5)
        ax.set_xticks([])
        ax.set_title(reg_names[reg])

    ctl.adjust_ax_scale(axes)
    ctl.custom_legend(fig,
                      coloks + ['steelblue', 'indianred'],
                      modoks + ['hist', 'ssp585'],
                      ncol=4)
    fig.suptitle(
Esempio n. 2
0
    for area in ['NATL', 'NEPAC', 'SPAC']:
        xose = dict()
        for ru in allru:
            gigi = resdict[(ru, 'jli', area, season)]
            seasme = gigi.reshape((-1, lensea)).mean(axis = 1)
            xose[ru] = seasme

        allpercs = dict()
        for nu in [10, 25, 50, 75, 90]:
            allpercs['p{}'.format(nu)] = [np.percentile(xose[ru], nu) for ru in allru]
        allpercs['mean'] = [np.mean(xose[ru]) for ru in allru]
        allpercs['min'] = [np.min(xose[ru]) for ru in allru]
        allpercs['max'] = [np.max(xose[ru]) for ru in allru]

        fig, ax = plt.subplots(figsize = (12,8))
        ctl.boxplot_on_ax(ax, allpercs, allru, colors, plot_ensmeans=False)
        ax.set_xticklabels(allru)
        ax.set_ylabel('{} {} mean jet lat'.format(area, season))
        fig.savefig(cart_out + 'seamean_jetlat_{}_{}.pdf'.format(area, season))

        xose2 = dict()
        for ru in allru:
            gigi = resdict[(ru, 'jli', area, season)]
            seasstd = gigi.reshape((-1, lensea)).std(axis = 1)
            xose2[ru] = seasstd

        fig, ax = plt.subplots(figsize = (12,8))
        allpercs = dict()
        for nu in [10, 25, 50, 75, 90]:
            allpercs['p{}'.format(nu)] = [np.percentile(xose2[ru], nu) for ru in allru]
        allpercs['mean'] = [np.mean(xose2[ru]) for ru in allru]
Esempio n. 3
0
#     obsperc['p{}'.format(nu)] = np.percentile(enso[ru]['tos'], nu)
# obsperc['mean'] = np.mean(enso[ru]['tos']).values
# obsperc['min'] = np.min(enso[ru]['tos']).values
# obsperc['max'] = np.max(enso[ru]['tos']).values

nams = ['pi'] + [ru+'_'+vers for ru in allru[1:] for vers in ['tr', 'st']]
edgecol = np.append(['black'], np.concatenate([(col, col) for col in colors[1:]]))

positions = [0.]
posticks = [0.]
for i in range(len(allru[1:])):
    positions.append(positions[-1]+0.7+0.4)
    positions.append(positions[-1]+0.7)
    posticks.append(np.mean(positions[-2:]))

ctl.boxplot_on_ax(ax, allpercs, nams, colors_vtr, positions = positions, edge_colors = edgecol, plot_mean = False, plot_minmax = True, plot_ensmeans = False)#, obsperc = obsperc, obs_color = 'black', obs_name = 'pi')
# ax.axhline(0, color = 'gray', linewidth = 0.5)
ax.set_xticks(posticks)
ax.set_xticklabels(allru)
#ax.set_title(tit)

#ctl.custom_legend(fig, colors_vtr, ['pi'] + nams, ncol = 4, add_space_below = 0.1)
ax.set_ylabel('ENSO index (K)')

fig.savefig(cart_out + 'enso_boxplot.pdf')


############# enso plot with tas/net_toa

glomeans, pimean = pickle.load(open(cart_or + 'seasmean/bottino_glomeans.p', 'rb'))
Esempio n. 4
0
        ax = figall.add_subplot(2, 2, reg + 1)
        axes.append(ax)

        allpercs = dict()
        for nu in [10, 25, 50, 75, 90]:
            allpercs['p{}'.format(nu)] = [
                np.percentile(freqs[(ssp, 'all', cos)][:, reg], nu)
                for ssp in allsims
            ]

        ax.axhline(allpercs['p50'][0], color='gray', linewidth=0.5)

        ctl.boxplot_on_ax(ax,
                          allpercs,
                          allsims,
                          colsim,
                          plot_mean=False,
                          plot_ensmeans=False,
                          plot_minmax=False)
        ax.set_xticks([])
        ax.set_title(reg_names[reg])
        if reg == 0: ax.set_ylabel('Regime frequency')

        ax.scatter(0,
                   results_ref['freq_clus'][reg],
                   color='black',
                   marker='*',
                   s=5)

    ctl.custom_legend(figall, colsim, allsims, ncol=4)
    figall.savefig(cart_out + 'WRfreq_cmip5_{}.pdf'.format(area))
Esempio n. 5
0
    axes = []
    for reg in range(4):
        ax = figall.add_subplot(2, 2, reg + 1)
        axes.append(ax)

        allpercs = dict()
        for nu in [10, 25, 50, 75, 90]:
            allpercs['p{}'.format(nu)] = [
                np.percentile(freqs[(ssp, tip)][:, reg], nu) - histme[reg]
                for tip in alltips
            ]

        ctl.boxplot_on_ax(ax,
                          allpercs,
                          alltips,
                          colorz,
                          plot_mean=False,
                          plot_ensmeans=False,
                          plot_minmax=False)
        ax.axhline(0, color='gray', linewidth=0.5)
        ax.set_xticks([])
        ax.set_title(reg_names[reg])

        if reg == 0 or reg == 2: ax.set_ylabel('Regime frequency anomaly')

    ctl.adjust_ax_scale(axes)

    #ctl.custom_legend(figall, colorz, alltips, ncol = 2)
    ctl.custom_legend(figall,
                      colorz, ['MPI-ESM1-2-LR', 'UKESM1-0-LL'],
                      ncol=2,
Esempio n. 6
0
        allpercs = dict()
        for nu in [10, 25, 50, 75, 90]:
            allpercs['p{}'.format(nu)] = [
                np.percentile(freqs[(ssp, 'all', cos)][:, reg], nu)
                for ssp in allsims
            ]

        ax.axhline(allpercs['p50'][0], color='gray', linewidth=0.5)

        positions = list(np.arange(len(allsims) - 1) * 0.7)
        positions.append(positions[-1] + 0.3 + 0.7)
        ctl.boxplot_on_ax(ax,
                          allpercs,
                          allsims,
                          colsim,
                          plot_mean=False,
                          plot_ensmeans=False,
                          plot_minmax=False,
                          positions=positions)
        ax.set_xticks([])
        ax.set_title(reg_names[reg])
        if reg == 0: ax.set_ylabel('Regime frequency')

        ax.scatter(0,
                   results_ref['freq_clus'][reg],
                   color='black',
                   marker='*',
                   s=5)
        ax.axvline(np.mean([positions[-1], positions[-2]]),
                   color='lightslategray',
                   linewidth=0.2,
Esempio n. 7
0
            fig = plt.figure(figsize = (16,12))
            axes = []
            for reg in range(4):
                ax = fig.add_subplot(2, 2, reg + 1)
                axes.append(ax)

                allpercs = dict()
                allpercs['mean'] = [np.mean(trend_ssp[(ssp, 'all', pio, cos, reg)]) for ssp in allsims[1:]]

                for nu in [10, 25, 50, 75, 90]:
                    allpercs['p{}'.format(nu)] = [np.percentile(trend_ssp[(ssp, 'all', pio, cos, reg)], nu) for ssp in allsims[1:]]

                allpercs['ens_min'] = [np.min(trend_ssp[(ssp, 'all', pio, cos, reg)]) for ssp in allsims[1:]]
                allpercs['ens_max'] = [np.max(trend_ssp[(ssp, 'all', pio, cos, reg)]) for ssp in allsims[1:]]

                ctl.boxplot_on_ax(ax, allpercs, allsims[1:], colsim[1:], plot_mean = False, plot_ensmeans = False, plot_minmax = True)

                ax.axhline(0, color = 'gray', linewidth = 0.5)
                ax.set_xticks([])
                ax.set_title(reg_names[reg])

            ctl.adjust_ax_scale(axes)

            ctl.custom_legend(fig, colsim[1:], allsims[1:], ncol = 4)
            #fig.suptitle('30yr bsp of WR freq. in 2050-2100 wrt 1964-2014')
            fig.savefig(cart_out + '{}_WRfreq_allssp_{}_{}.pdf'.format(pio, area, cos))


        fig = plt.figure(figsize = (16,12))
        axes = []
        for reg in range(4):
Esempio n. 8
0
    obsperc = dict()
    for nu in [10, 25, 50, 75, 90]:
        obsperc['p{}'.format(nu)] = np.percentile(cose[area]['obs'], nu)
    obsperc['mean'] = np.mean(cose[area]['obs'])

    #nomi = [mod + '_' + vers for mod in mod_names for vers in versions]
    # allvers = [vers for mod in mod_names for vers in versions]
    nomi = mod_list

    ctl.boxplot_on_ax(ax,
                      allpercs,
                      nomi,
                      colors,
                      versions=allvers,
                      plot_mean=True,
                      plot_ensmeans=True,
                      ens_colors=['steelblue', 'indianred'],
                      ens_names=['LR', 'HR'],
                      obsperc=obsperc,
                      obs_color='black',
                      obs_name='ERA5',
                      plot_minmax=False,
                      positions=positions)
    # ax.axhline(0, color = 'gray', linewidth = 0.5)
    ax.set_xticks(posticks)
    ax.set_xticklabels(mod_names + ['ERA5', 'LR', 'HR'])
    #ax.set_title(tit)

    #ctl.custom_legend(fig, colors, nomi, ncol = 2, add_space_below = 0.1)
    ax.set_ylabel('LWA (m/s)')

    #plt.title('cmip6 vs cmip6 var_fr '+tip)
Esempio n. 9
0
    allpercs['min'] = [np.min(enso_abs50[ru]) for ru in allru]
    allpercs['max'] = [np.max(enso_abs50[ru]) for ru in allru]

    nams = ['pi'] + allru[1:]
    edgecol = colors

    positions = 0.7 * np.arange(len(allru))
    posticks = 0.7 * np.arange(len(allru))

    ax.axhline(0., color='grey', lw=0.1)
    ctl.boxplot_on_ax(
        ax,
        allpercs,
        nams,
        colors,
        positions=positions,
        edge_colors=edgecol,
        plot_mean=False,
        plot_minmax=False,
        plot_ensmeans=False
    )  #, obsperc = obsperc, obs_color = 'black', obs_name = 'pi')

    # for ru, col, pos in zip(allru[1:], colors[1:], positions[1:]):
    #     ax.scatter(pos, enso_abs50[ru][0], color = col, marker = 'D', s = 100)

    # ax.axhline(0, color = 'gray', linewidth = 0.5)
    ax.set_xticks(posticks)
    ax.set_xticklabels(allru)
    #ax.set_title(tit)

    #ctl.custom_legend(fig, colors_vtr, ['pi'] + nams, ncol = 4, add_space_below = 0.1)
Esempio n. 10
0
            allpercs['p{}'.format(nu)] = [
                np.percentile(plocos[cose, cos + tip, area], nu)
                for area in ['EAT', 'PNA'] for cos in ['cmip5', 'cmip6']
            ]
        colorzi = [
            colormip[(cos, area)] for area in ['EAT', 'PNA']
            for cos in ['cmip5', 'cmip6']
        ]
        nomi = [
            cos + ' ' + aa for aa in ['EAT', 'PAC']
            for cos in ['cmip5', 'cmip6']
        ]
        ctl.boxplot_on_ax(ax,
                          allpercs,
                          nomi,
                          colorzi,
                          plot_mean=False,
                          plot_ensmeans=False,
                          plot_minmax=False,
                          positions=positions)
        # ax.axhline(0, color = 'gray', linewidth = 0.5)
        ax.set_xticks([])
        #ax.set_title(tit)
        #ax.axvline(np.mean([positions[-1], positions[-2]]), color = 'lightslategray', linewidth = 0.2, linestyle = '--')

        ax.axvline(1.25, color='lightslategray', linewidth=0.2, linestyle='--')
        ax.text(0.25,
                1.05,
                'EAT',
                horizontalalignment='center',
                verticalalignment='center',
                rotation='horizontal',
Esempio n. 11
0
            ]
        allpercs['mean'] = [np.mean(cose) for cose in dist_cose]

        # obsperc = dict()
        # for nu in [10, 25, 50, 75, 90]:
        #     obsperc['p{}'.format(nu)] = np.percentile(dist_obs, nu)
        # obsperc['mean'] = np.mean(dist_obs)

        positions = [0., 0.7, 1.4, 2.1]  #, 3.2]
        #ctl.boxplot_on_ax(ax, allpercs, keall, colorz, plot_mean = True, plot_ensmeans = False, obsperc = obsperc, obs_color = 'black', obs_name = 'ERA', plot_minmax = False, positions = positions)
        ctl.boxplot_on_ax(ax,
                          allpercs,
                          keall,
                          colorz,
                          plot_mean=True,
                          plot_ensmeans=False,
                          obsperc=None,
                          obs_color='black',
                          obs_name=None,
                          plot_minmax=False,
                          positions=positions,
                          wi=0.4)

        for pos, tte1, tte5 in zip(positions, ttests01, ttests05):
            if tte1:
                ax.scatter(pos, 0, color='black', marker='*', s=80)
            elif tte5:
                ax.scatter(pos,
                           0,
                           color='black',
                           marker='*',
                           s=80,
Esempio n. 12
0
                                      nu) for ssp in allsims[1:]
                    ]

                allpercs['ens_min'] = [
                    np.min(trend_ssp[(ssp, 'all', pio, cos, reg)])
                    for ssp in allsims[1:]
                ]
                allpercs['ens_max'] = [
                    np.max(trend_ssp[(ssp, 'all', pio, cos, reg)])
                    for ssp in allsims[1:]
                ]

                ctl.boxplot_on_ax(ax,
                                  allpercs,
                                  allsims[1:],
                                  colsim[1:],
                                  plot_mean=False,
                                  plot_ensmeans=False,
                                  plot_minmax=True)

                ax.axhline(0, color='gray', linewidth=0.5)
                ax.set_xticks([])
                ax.set_title(reg_names[reg])

            ctl.adjust_ax_scale(axes)

            ctl.custom_legend(fig, colsim[1:], allsims[1:], ncol=3)
            #fig.suptitle('30yr bsp of WR freq. in 2050-2100 wrt 1964-2014')
            fig.savefig(cart_out +
                        '{}_WRfreq_allssp_{}_{}.pdf'.format(pio, area, cos))