marzeion_gic_nat_mb = da.DimArray(marzeion_gic_nat_mb[:, 1:],
                                  axes=[marzeion_gic_nat_mb[:, 0], models], dims=["time", "model"])

fullfile = inputdatadir + "glaciers_marzeion14/global_mean_specific_mb_full_rgi_v4.txt"
marzeion_gic_full_mb = np.loadtxt(fullfile, skiprows=2)
models = np.genfromtxt(fullfile, skip_header=1, dtype=None)[0, 1:]
marzeion_gic_full_mb = da.DimArray(marzeion_gic_full_mb[:, 1:],
                                   axes=[marzeion_gic_full_mb[:, 0], models], dims=["time", "model"])

anthropogenic_frac = (marzeion_gic_full_mb.mean(axis=1)
                      - marzeion_gic_nat_mb.mean(axis=1)) / marzeion_gic_full_mb.mean(axis=1)
anthropogenic_frac_perc = ((marzeion_gic_full_mb.T.to_pandas().quantile([0.05, 0.5, 0.95])
                            - marzeion_gic_nat_mb.T.to_pandas().quantile([0.05, 0.5, 0.95]))
                           / marzeion_gic_full_mb.T.to_pandas().quantile([0.05, 0.5, 0.95]))
anthropogenic_frac_perc = da.from_pandas(
    anthropogenic_frac_perc, dims=[
        "percentile", "time"])
# TODO: reference motivate linear increase of anth fraction
#anthropogenic_frac_lin = da.DimArray(np.linspace(0,1.,2056-1870),axes=np.arange(1870,2056,1),dims="time")

# linear fit to fraction since 1900
tlin = np.arange(1870, 2056, 1)
anthropogenic_frac_lin_1900 = da.DimArray(
    6.78606933e-03 *
    tlin -
    1.28443788e+01,
    axes=tlin,
    dims="time")


######## Greenland surface mass balance ########
    divider = make_axes_locatable(ax)
    axy = divider.append_axes("right", size=0.6, pad=0.0, sharey=ax, axisbg="grey")
    axy.axis("off")
    axy.axvspan(0, 10, facecolor="0.5", alpha=0.2, lw=0)
    # print name
    xloc = 10  # ipcc
    oloc = 4  # our estimates
    # single_contribs[name] = {}
    for k, scen in enumerate(["RCP85", "RCP45", "RCP3PD"]):

        contrib = projection_data[scen][name]
        # anomaly to 1986-2005
        contrib = contrib - contrib[1986:2005, :].mean(axis="time")

        contrib = contrib.T.to_pandas()
        percentiles = da.from_pandas(contrib.quantile([0.05, 0.5, 0.95]))[:, plot_period]

        ax.fill_between(
            plot_period, percentiles[0.05] * 1e3, percentiles[0.95] * 1e3, color=rcpcoldict[scen], alpha=0.4, lw=0.5
        )
        ax.plot(
            plot_period, percentiles[0.5] * 1e3, lw=3, color=rcpcoldict[scen], alpha=1.0, label=rcpnamedict[scen]
        )  # ,label=name)

        print "##", name, scen, ": ", percentiles[0.05][2100] * 1e3, percentiles[0.5][2100] * 1e3, percentiles[0.95][
            2100
        ] * 1e3

        oloc -= 1.0
        xloc -= 1.0
        med = percentiles[0.5][np.arange(2081, 2100, 1)].mean() * 1e3
Esempio n. 3
0
def fig3(projection_data):

    labels = {"gic": "Mountain glaciers", "thermexp": "Thermal expansion", "gis_sid": "Greenland SID",
              "gis_smb": "Greenland SMB", "ant_sid": "Antarctica SID", "ant_smb": "Antarctica SMB"}

    plt.subplots_adjust(left=0.1, bottom=0.06, right=1.0, top=0.97,
                        wspace=0.1, hspace=None)

    # print "## sl contribtioon, scenario, 5th percentiles in 2100, median in
    # 2100, 95th percentile in 2100"

    plot_period = np.arange(2000, 2101, 1)
    axs = []
    plotlb = "abcdef"
    for i, name in enumerate(contrib_ids[0:6]):
        ax = plt.subplot(3, 2, i + 1)
        # ax = plt.subplot(111)
        divider = make_axes_locatable(ax)
        axy = divider.append_axes(
            "right",
            size=0.6,
            pad=0.0,
            sharey=ax,
            axisbg="grey")
        axy.axis("off")
        axy.axvspan(0, 10, facecolor='0.5', alpha=0.2, lw=0)
        # print name
        xloc = 10  # ipcc
        oloc = 4  # our estimates
        # single_contribs[name] = {}
        for k, scen in enumerate(["RCP85", "RCP45", "RCP3PD"]):

            contrib = projection_data[scen][name]
            # anomaly to 1986-2005
            contrib = contrib - contrib[1986:2005, :].mean(axis="time")
            # pandas handles NaNs within percentile calculus
            contrib = contrib.T.to_pandas()
            percentiles = da.from_pandas(contrib.quantile([0.05, 0.5, 0.95]))[
                :, plot_period]
            ax.fill_between(
                plot_period,
                percentiles[0.05] * 1e3,
                percentiles[0.95] * 1e3,
                color=rcpcoldict[scen],
                alpha=.4,
                lw=.5)
            ax.plot(
                plot_period,
                percentiles[0.5] * 1e3,
                lw=3,
                color=rcpcoldict[scen],
                alpha=1.,
                label=rcpnamedict[scen])

            oloc -= 1.
            xloc -= 1.
            med = percentiles[0.5][np.arange(2081, 2100, 1)].mean() * 1e3
            low = percentiles[0.05][np.arange(2081, 2100, 1)].mean() * 1e3
            upp = percentiles[0.95][np.arange(2081, 2100, 1)].mean() * 1e3
            axy.plot([oloc - 1, oloc + 1], [med, med],
                     lw=3, color=rcpcoldict[scen])

            axy.fill_between([oloc - 1, oloc + 1], [low, low],
                             [upp, upp], color=rcpcoldict[scen], alpha=.4, lw=0.)

            low, med, upp = ipcc.ipcc_contrib_estimates[name][scen]
            axy.fill_between([xloc - 1, xloc + 1], [low, low],
                             [upp, upp], color=rcpcoldict[scen], alpha=.4, lw=0.)
            axy.plot([xloc - 1, xloc + 1], [med, med],
                     color=rcpcoldict[scen], lw=3, alpha=1.)
            axy.set_xlim(-1, 11)

        ax.text(0.05, 0.9, plotlb[i], transform=ax.transAxes,
                fontdict={'family': 'sans-serif', 'weight': 'bold', "size": 16})
        ax.text(0.05, 0.8, labels[name], transform=ax.transAxes,
                fontdict={'family': 'sans-serif', 'weight': 'bold'})
        if i == 0:
            axy.text(1.5, 440, "M16", rotation="vertical", horizontalalignment='center',
                     verticalalignment='center')
            axy.text(7.5, 440, "IPCC", rotation="vertical", horizontalalignment='center',
                     verticalalignment='center')

        l1 = ax.legend(ncol=1, loc="center left")
        l1.draw_frame(0)
        for l in l1.get_lines():
            l.set_alpha(1)

        axs.append(ax)
        ax.set_xlim(plot_period[0], plot_period[-1])

    for ax in axs[-2:]:
        ax.set_xlabel("Time in years")
    for ax in [axs[0], axs[2], axs[4]]:
        ax.set_ylabel("Sea level in mm")

    axs[3].set_ylim(0, 500)
                              sharey=ax,
                              axisbg="grey")
    axy.axis("off")
    axy.axvspan(0, 10, facecolor='0.5', alpha=0.2, lw=0)
    # print name
    xloc = 10  # ipcc
    oloc = 4  # our estimates
    # single_contribs[name] = {}
    for k, scen in enumerate(["RCP85", "RCP45", "RCP3PD"]):

        contrib = projection_data[scen][name]
        # anomaly to 1986-2005
        contrib = contrib - contrib[1986:2005, :].mean(axis="time")

        contrib = contrib.T.to_pandas()
        percentiles = da.from_pandas(contrib.quantile([0.05, 0.5,
                                                       0.95]))[:, plot_period]

        ax.fill_between(plot_period,
                        percentiles[0.05] * 1e3,
                        percentiles[0.95] * 1e3,
                        color=rcpcoldict[scen],
                        alpha=.4,
                        lw=.5)
        ax.plot(plot_period,
                percentiles[0.5] * 1e3,
                lw=3,
                color=rcpcoldict[scen],
                alpha=1.,
                label=rcpnamedict[scen])  # ,label=name)

        print "##", name, scen, ": ", percentiles[0.05][
Esempio n. 5
0
fullfile = inputdatadir + "glaciers_marzeion14/global_mean_specific_mb_full_rgi_v4.txt"
marzeion_gic_full_mb = np.loadtxt(fullfile, skiprows=2)
models = np.genfromtxt(fullfile, skip_header=1, dtype=None)[0, 1:]
marzeion_gic_full_mb = da.DimArray(marzeion_gic_full_mb[:, 1:],
                                   axes=[marzeion_gic_full_mb[:, 0], models],
                                   dims=["time", "model"])

anthropogenic_frac = (
    marzeion_gic_full_mb.mean(axis=1) -
    marzeion_gic_nat_mb.mean(axis=1)) / marzeion_gic_full_mb.mean(axis=1)
anthropogenic_frac_perc = (
    (marzeion_gic_full_mb.T.to_pandas().quantile([0.05, 0.5, 0.95]) -
     marzeion_gic_nat_mb.T.to_pandas().quantile([0.05, 0.5, 0.95])) /
    marzeion_gic_full_mb.T.to_pandas().quantile([0.05, 0.5, 0.95]))
anthropogenic_frac_perc = da.from_pandas(anthropogenic_frac_perc,
                                         dims=["percentile", "time"])
# TODO: reference motivate linear increase of anth fraction
#anthropogenic_frac_lin = da.DimArray(np.linspace(0,1.,2056-1870),axes=np.arange(1870,2056,1),dims="time")

# linear fit to fraction since 1900
tlin = np.arange(1870, 2056, 1)
anthropogenic_frac_lin_1900 = da.DimArray(6.78606933e-03 * tlin -
                                          1.28443788e+01,
                                          axes=tlin,
                                          dims="time")

######## Greenland surface mass balance ########


def convert_raw_mb_to_sl(rawdata):