예제 #1
0
            xba.append('{} - {}'.format(bi0, bi1))
            okke = (bi0 <= invfr) & (invfr < bi1)
            gig = np.sum(ps[okke])
            barz.append(gig)
        ax.bar(np.arange(len(barz))+shi, barz, color = col, width = 0.15)

    ax.set_xticks(np.arange(len(barz)))
    ax.set_xticklabels(xba, rotation = 30)

    ax.set_title(ru)
    if ax in axs[1, :]:
        ax.set_xticks(np.arange(len(barz)))
        ax.set_xticklabels(xba, rotation = 30)
        ax.set_xlabel('period (yr)')

ctl.adjust_ax_scale(axs.flatten())
fig.savefig(cart_out + 'enso_spectra_bins_varying.pdf')


fig, ax = plt.subplots(figsize = (16,12))
allshi = [-0.3, -0.1, 0.1, 0.3]

for ru, col, shi in zip(allru, colors, allshi):
    piuz = enso[ru]['tos'].groupby('time.year').mean()
    data_all = piuz.values.flatten()

    allcose = []
    for ich, ye1 in zip(range(nchu), yesta):
        data = data_all[ye1:ye1+nye]
        ps = np.abs(np.fft.rfft(data, norm='forward'))**2
예제 #2
0
        allfreqs[(ssp, area, season, tip, reg)] = []
        for mod, col in zip(modoks, coloks):
            frdiff = results_ssp585[mod]['freq_clus'][reg] - results_hist[mod][
                'freq_clus'][reg]
            ax.scatter(i, frdiff, marker='D', color=col, s=25)
            allfreqs[(ssp, area, season, tip,
                      reg)].append(results_ssp585[mod]['freq_clus'][reg] -
                                   results_hist[mod]['freq_clus'][reg])
            # allfreqs[('hist', tip, reg)].append(results_hist[mod]['freq_clus'][reg])
            i += 1

        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, modoks, ncol=4)
    fig.suptitle('Change of WR freq. in 2050-2100 wrt 1964-2014')

    fig.savefig(cart_out + 'WR_freq_change_dtr_{}_{}_{}_{}.pdf'.format(*ke))

    # Same but only for long-lasting (> 5 days) regimes
    for mod in modoks:
        results_ssp585[mod]['av_res'] = np.array([
            np.mean(results_ssp585[mod]['resid_times'][reg])
            for reg in range(4)
        ])
        results_hist[mod]['av_res'] = np.array([
            np.mean(results_hist[mod]['resid_times'][reg]) for reg in range(4)
        ])
예제 #3
0
    axes = []
    for llo1, llo2 in lon_sect:
        i += 1
        ax = plt.subplot(3, 3, i)
        for num, col in zip(allnums, colors):
            ax.plot(dtclmpd.dayofyear,
                    np.mean(clm_fullperiod[num][:, lla1:lla2, llo1:llo2],
                            axis=(1, 2)),
                    color=col)

        if lla2 is None: lla2 = -1
        if llo2 is None: llo2 = -1
        ax.set_title('lat {:2.0f}/{:2.0f}, lon {:3.0f}/{:3.0f}'.format(
            lat_area[lla1], lat_area[lla2], lon_area[llo1], lon_area[llo2]))
        axes.append(ax)
    ctl.adjust_ax_scale(axes)

fig.tight_layout()
fig = ctl.custom_legend(fig, colors, ['{}'.format(i) for i in allnums])
fig.savefig(cart_out + 'mean_climatology_zg.pdf')

figs = []
axaxes = [[], [], []]
colors = ctl.color_set(len(climate_mean_area))

for num in allnums:
    cosone = climate_mean_dict[num]
    ref = clm_fullperiod[num]

    fig = plt.figure(figsize=(16, 12))
    i = 0
예제 #4
0
okplostoc = np.mean(stoc_fut, axis=0)
ax.plot(lat, okplobase, label='base fut', linewidth=2.0)
ax.plot(lat, okplostoc, label='stoc fut', linewidth=2.0)
ax.plot(lat,
        10 * (okplostoc - okplobase),
        label='(diff s-b) x 10',
        linewidth=1.0,
        linestyle='--')
plt.xlabel('Latitude')
plt.ylabel('Heat flux (W)')
plt.legend()
plt.grid()
figures.append(fig)
axes.append(ax)

ctl.adjust_ax_scale(axes, sel_axis='both')

ctl.plot_pdfpages(figure_file, figures)
plt.close('all')

figure_file = cart_out + 'global_diff_net_fluxes.pdf'
figures = []
axes = []

fig = plt.figure()
ax = plt.subplot(1, 1, 1)
plt.title('Net flux at TOA')
for lett, tim in zip(['a', 'f'], ['_hist', '_fut']):
    for cosone, ls in zip(['stoc', 'base'], [':', '--']):
        coso = radclim[('global', cosone + tim, 'toa_balance')]
        ax.plot(years[lett], coso, linewidth=0.5, color='grey', linestyle=ls)
예제 #5
0
                    okjet = jetind[okin]
            jetlat_comp[(mod, reg, tag)] = okjet

            pdf = ctl.calc_pdf(okjet)
            if vv in ['LR', 'OBS']:
                axes[reg].plot(latgri, pdf(latgri), color = col, label = mod, linewidth = linewidth, linestyle = sty)
            if vv in ['HR', 'OBS']:
                axes_HR[reg].plot(latgri, pdf(latgri), color = col, label = mod, linewidth = linewidth, linestyle = sty)

        pdf = ctl.calc_pdf(jetind)
        if vv in ['LR', 'OBS']:
            ax_all.plot(latgri, pdf(latgri), color = col, label = mod, linewidth = linewidth, linestyle = sty)
        if vv in ['HR', 'OBS']:
            ax_all_HR.plot(latgri, pdf(latgri), color = col, label = mod, linewidth = linewidth, linestyle = sty)

    ctl.adjust_ax_scale(axes+axes_HR)
    # ctl.custom_legend(fig, colors_wERA, model_names_all)
    ctl.custom_legend(fig, colors_wERA2[0::2], model_coups + ['OBS'])
    ctl.custom_legend(fig_HR, colors_wERA2[0::2], model_coups + ['OBS'])
    #fig.suptitle('Jet Latitude and Weather Regimes (SR)')
    fig.savefig(cart_out + 'jetlat_compos_LR{}.pdf'.format(tag))
    #fig_HR.suptitle('Jet Latitude and Weather Regimes (HR)')
    fig_HR.savefig(cart_out + 'jetlat_compos_HR{}.pdf'.format(tag))
    # fig.savefig(cart_out + 'jetlat_compos_wECEstream2.pdf')

    ctl.adjust_ax_scale([ax_all, ax_all_HR])
    ctl.custom_legend(fig_all, colors_wERA2[0::2], model_coups + ['OBS'])
    #ctl.custom_legend(fig_all, colors_wERA, model_names_all)
    fig_all.savefig(cart_out + 'jetlat_allregs_LR{}.pdf'.format(tag))
    ctl.custom_legend(fig_all_HR, colors_wERA2[0::2], model_coups + ['OBS'])
    fig_all_HR.savefig(cart_out + 'jetlat_allregs_HR{}.pdf'.format(tag))
예제 #6
0
        posthicks = [1.5, 4.5, 7.5, 10.5]
        ax.boxplot(allfr, positions=np.array(pos))
        ax.set_xticks(posthicks)
        ax.set_xticklabels(reg_names)
        ax.set_ylabel('WR frequency')

        ax_all_ul[ise].boxplot(allfr, positions=np.array(pos))
        ax_all_ul[ise].set_xticks(posthicks)
        ax_all_ul[ise].set_xticklabels(reg_names)
        ax_all_ul[ise].set_ylabel('WR frequency')
        ax_all_ul[ise].set_title('season: {}'.format(seas))

        fig.suptitle('Upper vs lower tercile of {} index'.format(indexname))

        fig.savefig(cart_out +
                    'ERA_{}_vs_WRfreq_upperlowertercile_{}.pdf'.format(
                        indexname, seas))

    ctl.adjust_ax_scale(ax_all + ax_all_ul)
    fig_all.suptitle('Positive vs negative {} index'.format(indexname))
    fig_all.savefig(cart_out_ind +
                    'ERA_{}_vs_WRfreq_posneg_allseas.pdf'.format(indexname))

    fig_all_ul.suptitle('Upper vs lower tercile of {} index'.format(indexname))
    fig_all_ul.savefig(
        cart_out_ind +
        'ERA_{}_vs_WRfreq_upperlowertercile_allseas.pdf'.format(indexname))

pickle.dump([ref_corrs, ref_freqs_posneg, ref_freqs_terc],
            open(cart_out_all + 'ref_corrfreq_AMV_ENSO.p', 'wb'))
예제 #7
0
            ctl.primavera_boxplot_on_ax(ax,
                                        allpercs,
                                        model_names_all,
                                        colors_wERA,
                                        color_main,
                                        vers,
                                        ens_names,
                                        ens_colors,
                                        wi=0.5,
                                        plot_mean=plot_mean)

            ax.set_title(reg)
            ax.set_ylabel(allylabels[nam])
            axes.append(ax)

        ctl.adjust_ax_scale(axes)

        #fig.suptitle(alltits[nam], fontsize = titlefont)
        plt.subplots_adjust(top=0.9)

        ctl.custom_legend(fig,
                          colors_wERA + ens_colors,
                          model_names_all + ens_names,
                          ncol=6)
        fig.savefig(cart_out + '{}_bootstraps_v7_k{}.pdf'.format(nam, numclus))
        allfigs.append(fig)

    ax_pers_2 = []
    fig_pers = plt.figure(figsize=(20, 12))
    for i in range(numclus):
        ax_pers_2.append(plt.subplot(2, 3, i + 1))
예제 #8
0
                            color='indianred')
            ax.fill_between(np.arange(len(dat)),
                            dat,
                            np.zeros(len(dat)),
                            where=dat <= 0.,
                            interpolate=True,
                            color='steelblue')
            ax.plot(np.arange(len(dat)), dat, color='grey', lw=0.1)

        if ru != allru[-1]:
            ax.set_xticks([])
        else:
            ax.set_xticks(np.arange(2100, 2601, 100))
            ax.set_xticklabels(np.arange(0, 501, 100))

    ctl.adjust_ax_scale(axs, sel_axis='y')

    fig.savefig(cart_out + 'allru_redblue_{}.pdf'.format(ind))

    # 2) plot variance: a) running mean all-in-one, b) boxplot (with dot for transient) (as function of eq. temperature? no)
    fig, ax = plt.subplots(figsize=(12, 8))

    allpercs = dict()
    for nu in [10, 25, 50, 75, 90]:
        allpercs['p{}'.format(nu)] = [
            np.percentile(enso_abs50[ru], nu) for ru in allru
        ]
    allpercs['mean'] = [np.mean(enso_abs50[ru]) for ru in allru]
    allpercs['min'] = [np.min(enso_abs50[ru]) for ru in allru]
    allpercs['max'] = [np.max(enso_abs50[ru]) for ru in allru]
예제 #9
0
    tas10 = np.percentile(tasanom_pac[oknino], 10, axis=0)
    axl.fill_between(paclons, tas10, tas90, color='indianred', alpha=0.3)
    tasanom_pac[oknino].mean('year').plot(ax=axl,
                                          linewidth=2,
                                          color='indianred')

    # tasanom_pac[oknina].plot(ax = axl, x = 'lon', hue = 'year', linewidth = 0.1, color = 'steelblue')
    tas90 = np.percentile(tasanom_pac[oknina], 90, axis=0)
    tas10 = np.percentile(tasanom_pac[oknina], 10, axis=0)
    axl.fill_between(paclons, tas10, tas90, color='steelblue', alpha=0.3)
    tasanom_pac[oknina].mean('year').plot(ax=axl,
                                          linewidth=2,
                                          color='steelblue')

    axl.set_title(ru)
    axl.grid()

    ninodist = np.argmax(tasanom_pac[oknino].values, axis=1)
    ninadist = np.argmin(tasanom_pac[oknina].values, axis=1)

    axo.hist(paclons[ninodist], color=col, bins=np.arange(190, 271, 5))
    axa.hist(paclons[ninadist], color=col, bins=np.arange(190, 271, 5))

ctl.adjust_ax_scale(axs_o.flatten())
ctl.adjust_ax_scale(axs_a.flatten())
ctl.adjust_ax_scale(axsli.flatten())

fig_o.savefig(cart_out + 'nino_lon_hist.pdf')
fig_a.savefig(cart_out + 'nina_lon_hist.pdf')
figli.savefig(cart_out + 'nino_lon_anom.pdf')