Exemplo n.º 1
0
def read_ohc(filename):

    indata = np.genfromtxt(filename, dtype=(float), skip_header=1)
     
    hadley = utils.Timeseries("OHC", indata[:, 0], indata[:, 1])
    csiro = utils.Timeseries("OHC", indata[:, 0], indata[:, 3])
    pmel = utils.Timeseries("OHC", indata[:, 0], indata[:, 5])
    ncei = utils.Timeseries("OHC", indata[:, 0], indata[:, 7])
    mri = utils.Timeseries("OHC", indata[:, 0], indata[:, 9])
    iap = utils.Timeseries("OHC", indata[:, 0], indata[:, 9])

    # reapply updated climatology
    dummy, hadley = utils.calculate_climatology_and_anomalies_1d(hadley, 1993, 2016)
    dummy, csiro = utils.calculate_climatology_and_anomalies_1d(csiro, 1993, 2016)
    dummy, pmel = utils.calculate_climatology_and_anomalies_1d(pmel, 1993, 2016)
    dummy, ncei = utils.calculate_climatology_and_anomalies_1d(ncei, 1993, 2016)
    dummy, mri = utils.calculate_climatology_and_anomalies_1d(mri, 1993, 2016)
    dummy, iap = utils.calculate_climatology_and_anomalies_1d(iap, 1993, 2016)

    return hadley, csiro, pmel, ncei, mri, iap # read_ohc
Exemplo n.º 2
0
def run_all_plots():

    #***********************
    # MODIS - centre

    cubelist = iris.load(
        os.path.join(data_loc,
                     "MODIS.CMG.{}.SOS.EOS.Anomaly.nc".format(settings.YEAR)))

    for c, cube in enumerate(cubelist):
        if cube.name() == "SOS":
            sos_cube = cubelist[c]

    # deal with NANS
    sos_cube.data = np.ma.masked_where(sos_cube.data != sos_cube.data,
                                       sos_cube.data)

    # read in sites

    us_locations = read_us_phenocam(os.path.join(data_loc,
                                                 "phenocam_locs.txt"))

    fig = plt.figure(figsize=(8, 12))
    plt.clf()

    # set up plot settings
    BOUNDS = [-100, -20, -10, -5, -2, 0, 2, 5, 10, 20, 100]

    LABELS = "(c) Start of Season (SOS)"  #, "(b) End of Season (EOS)"]

    # boundary circle
    theta = np.linspace(0, 2 * np.pi, 100)
    center, radius = [0.5, 0.5], 0.5
    verts = np.vstack([np.sin(theta), np.cos(theta)]).T
    circle = mpath.Path(verts * radius + center)

    # axes for polar plot
    ax = plt.axes(
        [0.05, 0.01, 0.9, 0.65],
        projection=cartopy.crs.NorthPolarStereo(central_longitude=300.0))

    plot_cube = sos_cube

    if settings.OUTFMT in [".eps", ".pdf"]:
        if plot_cube.coord("latitude").points.shape[0] > 90 or plot_cube.coord(
                "longitude").points.shape[0] > 360:
            regrid_size = 1.0
            print(
                "Regridding cube for {} output to {} degree resolution".format(
                    settings.OUTFMT, regrid_size))
            print("Old Shape {}".format(plot_cube.data.shape))
            plot_cube = utils.regrid_cube(plot_cube, regrid_size, regrid_size)
            print("New Shape {}".format(plot_cube.data.shape))

    ax.gridlines()  #draw_labels=True)
    ax.add_feature(cartopy.feature.LAND,
                   zorder=0,
                   facecolor="0.9",
                   edgecolor="k")
    ax.coastlines()
    ax.set_boundary(circle, transform=ax.transAxes)

    cmap = settings.COLOURMAP_DICT["phenological_r"]
    norm = mpl.cm.colors.BoundaryNorm(BOUNDS, cmap.N)
    mesh = iris.plot.pcolormesh(plot_cube, cmap=cmap, norm=norm, axes=ax)

    # plot scatter
    COL = "yellow"
    ax.scatter(us_locations[1],
               us_locations[0],
               c=COL,
               s=100,
               edgecolor="k",
               transform=cartopy.crs.Geodetic(),
               zorder=10)
    ax.scatter(-2.9376,
               54.3739,
               c=COL,
               s=100,
               edgecolor="k",
               transform=cartopy.crs.Geodetic(),
               zorder=10)

    # uk box
    region = [-10.0, 49.0, 3.0, 60.0]
    ax.plot([region[0], region[0]], [region[1], region[3]],
            c=COL,
            ls='-',
            lw=4,
            zorder=10,
            transform=cartopy.crs.PlateCarree())
    ax.plot([region[2], region[2]], [region[1], region[3]],
            c=COL,
            ls='-',
            lw=4,
            zorder=10,
            transform=cartopy.crs.PlateCarree())
    ax.plot([region[0], region[2]], [region[1], region[1]],
            c=COL,
            ls='-',
            lw=4,
            zorder=10,
            transform=cartopy.crs.Geodetic())
    ax.plot([region[0], region[2]], [region[3], region[3]],
            c=COL,
            ls='-',
            lw=4,
            zorder=10,
            transform=cartopy.crs.Geodetic())

    COL = "k"
    ax.plot([region[0], region[0]], [region[1], region[3]],
            c=COL,
            ls='-',
            lw=5,
            zorder=9,
            transform=cartopy.crs.PlateCarree())
    ax.plot([region[2], region[2]], [region[1], region[3]],
            c=COL,
            ls='-',
            lw=5,
            zorder=9,
            transform=cartopy.crs.PlateCarree())
    ax.plot([region[0], region[2]], [region[1], region[1]],
            c=COL,
            ls='-',
            lw=5,
            zorder=9,
            transform=cartopy.crs.Geodetic())
    ax.plot([region[0], region[2]], [region[3], region[3]],
            c=COL,
            ls='-',
            lw=5,
            zorder=9,
            transform=cartopy.crs.Geodetic())

    # label axes
    ax.text(-0.1,
            1.0,
            LABELS,
            fontsize=settings.FONTSIZE * 0.8,
            transform=ax.transAxes)

    cb = plt.colorbar(mesh,
                      orientation='horizontal',
                      ticks=BOUNDS[1:-1],
                      label="Anomaly (days)",
                      drawedges=True,
                      fraction=0.1,
                      pad=0.05,
                      aspect=15,
                      shrink=0.8)
    # prettify
    cb.set_ticklabels(["{:g}".format(b) for b in BOUNDS[1:-1]])
    cb.outline.set_linewidth(2)
    cb.dividers.set_color('k')
    cb.dividers.set_linewidth(2)

    ax.set_extent([-180, 180, 30, 90], cartopy.crs.PlateCarree())

    for lat in range(30, 100, 10):
        ax.text(180,
                lat,
                '{}$^\circ$N'.format(lat),
                transform=cartopy.crs.Geodetic())

    fig.subplots_adjust(bottom=0.05,
                        top=0.95,
                        left=0.04,
                        right=0.95,
                        wspace=0.02)

    del sos_cube
    del cubelist

    #***********************
    # MODIS timeseries - 2018

    sos_na, sos_ea, sprt_na_orig, sprt_ea_orig = read_modis_ts(
        os.path.join(
            data_loc,
            "MODIS.CMG.{}.SOS.EOS.SPRT.FALT.TS.csv".format(settings.YEAR)))

    dummy, sos_na = utils.calculate_climatology_and_anomalies_1d(
        sos_na, 2000, 2010)
    dummy, sos_ea = utils.calculate_climatology_and_anomalies_1d(
        sos_ea, 2000, 2010)

    dummy, sprt_na = utils.calculate_climatology_and_anomalies_1d(
        sprt_na_orig, 2000, 2010)
    dummy, sprt_ea = utils.calculate_climatology_and_anomalies_1d(
        sprt_ea_orig, 2000, 2010)

    ax = plt.axes([0.1, 0.7, 0.8, 0.15])
    label = "(b) North America"
    anomalies = [
        "2018 SOS Anomaly = 1.86 days",
        "2018 Spring T anomaly = -0.75 " + r'$^{\circ}$' + "C"
    ]

    plot_modis_ts(ax, sos_na, sprt_na, sprt_na_orig, label, anomalies,
                  LEGEND_LOC)

    na_trend = -0.64 / 10
    ax.plot([sos_na.times[0], sos_na.times[-1]],
            utils.trendline(na_trend, sos_na.times),
            ls="--",
            zorder=10,
            c="g",
            lw=2)
    print(utils.trendline(na_trend, sos_na.times))

    ax1 = plt.axes([0.1, 0.85, 0.8, 0.15], sharex=ax)
    label = "(a) Eurasia"
    anomalies = [
        "2018 SOS Anomaly = 2.01 days",
        "2018 Spring T anomaly = 0.13 " + r'$^{\circ}$' + "C"
    ]

    plot_modis_ts(ax1, sos_ea, sprt_ea, sprt_ea_orig, label, anomalies, "")

    ea_trend = -1.59 / 10
    ax1.plot([sos_ea.times[0], sos_ea.times[-1]],
             utils.trendline(ea_trend, sos_ea.times),
             ls="--",
             zorder=10,
             c="g",
             lw=2)
    print(utils.trendline(ea_trend, sos_ea.times))

    plt.setp(ax1.get_xticklabels(), visible=False)
    plt.setp(ax.get_xticklabels(), visible=True)

    fig.text(0.05, 0.92, "SOS Anomaly (days)", rotation="vertical")
    fig.text(0.95,
             0.92,
             "Temperature Anomaly (" + r'$^{\circ}$' + "C)",
             rotation="vertical")

    plt.savefig(image_loc +
                "PHEN_modis_{}{}".format(settings.YEAR, settings.OUTFMT))

    #***********************
    # US timeseries - 2018

    fig = plt.figure(figsize=(8, 10))
    plt.clf()

    barrow, ozarks, turkey = read_us_phenocam_csv(
        os.path.join(data_loc, "Richardson PhenoCam plots for Sidebar.csv"))

    ax = plt.axes([0.1, 0.03, 0.35, 0.17])
    plot_us_phenocam(ax, barrow, [160, 229], "Barrow")
    ax.text(0.05, 0.85, "(e) Barrow", transform=ax.transAxes)
    ax = plt.axes([0.1, 0.23, 0.35, 0.17])
    plot_us_phenocam(ax,
                     ozarks, [90, 159],
                     "Ozarks",
                     ylabel="Vegetation Greenness Index",
                     legend=True)
    ax.text(0.05, 0.85, "(d) Ozarks", transform=ax.transAxes)
    ax = plt.axes([0.1, 0.43, 0.35, 0.17])
    plot_us_phenocam(ax, turkey, [60, 129], "Turkey Point")
    ax.text(0.05, 0.85, "(c) Turkey Point", transform=ax.transAxes)

    ax = plt.axes([0.48, 0.02, 0.25, 0.2])
    plot_images(ax, "barrow_2017_06_27_100002.jpg")
    ax = plt.axes([0.48, 0.22, 0.25, 0.2])
    plot_images(ax, "missouriozarks_2017_04_30_163113.jpg")
    ax = plt.axes([0.48, 0.42, 0.25, 0.2])
    plot_images(ax, "turkeypointenf39_2017_04_18_113106.jpg")

    ax = plt.axes([0.73, 0.02, 0.25, 0.2])
    plot_images(ax, "barrow_2018_06_27_103003.jpg")
    ax = plt.axes([0.73, 0.22, 0.25, 0.2])
    plot_images(ax, "missouriozarks_2018_04_30_163113.jpg")
    ax = plt.axes([0.73, 0.42, 0.25, 0.2])
    plot_images(ax, "turkeypointenf39_2018_04_18_113302.jpg")

    plt.figtext(0.6, 0.02, "2017")
    plt.figtext(0.85, 0.02, "2018")

    #***********************
    # UK timeseries - 2018

    ax = plt.axes([0.1, 0.65, 0.85, 0.15])

    oak = read_uk_oak_csv(
        os.path.join(data_loc, "UK Oak budburst 2000-2018.csv"))
    utils.plot_ts_panel(ax, [oak], "-", "phenological", loc="lower left")
    ax.set_ylim([94, 124])
    ax.text(0.03, 0.8, "(b) Oak Budburst", transform=ax.transAxes)
    # fix the legend label to be italic
    handles, labels = ax.get_legend_handles_labels()
    labels[
        0] = "$\mathregular{\mathit{Quercus}}$" + " " + "$\mathregular{\mathit{robur}}$"
    ax.legend(handles, labels, frameon=False, loc="lower left")

    # need legend once have other panel's data
    north, south = read_windermere_csv(
        os.path.join(data_loc, "Windermere_2000-2018.csv"))
    ax2 = plt.axes([0.1, 0.8, 0.85, 0.15], sharex=ax)
    utils.plot_ts_panel(ax2, [north, south],
                        "-",
                        "phenological",
                        loc="lower right")
    ax2.set_ylim([79, 159])
    plt.setp(ax2.get_xticklabels(), visible=False)
    ax2.text(0.03, 0.8, "(a) Windermere", transform=ax2.transAxes)

    ax2.set_xlim([1998, 2020])
    ax.set_xlim([1998, 2020])

    fig.text(0.03, 0.835, "Day of year", rotation="vertical")

    plt.savefig(image_loc +
                "PHEN_timeseries_{}{}".format(settings.YEAR, settings.OUTFMT))
    plt.close()

    return  # run_all_plots
Exemplo n.º 3
0
def run_all_plots():

    if True:
        # multipanel timeseries

        COLOURS = settings.COLOURS["temperature"]
        fig, (ax1, ax2, ax3, ax4, ax5, ax6) = plt.subplots(6,
                                                           figsize=(8, 19),
                                                           sharex=True)

        # ERA5
        era5_globe, era5_ocean, era5_land, era5tropics = utils.era5_ts_read(
            settings.REANALYSISLOC, "sat", annual=True)
        land_era5_clim, land_era5_anoms = utils.calculate_climatology_and_anomalies_1d(
            era5_land, 1981, 2010)
        ocean_era5_clim, ocean_era5_anoms = utils.calculate_climatology_and_anomalies_1d(
            era5_ocean, 1981, 2010)
        global_era5_clim, global_era5_anoms = utils.calculate_climatology_and_anomalies_1d(
            era5_globe, 1981, 2010)

        #*******************
        # in situ L+O
        noaa, nasa, jma = read_global_t(DATALOC +
                                        "{}_LO.csv".format(IS_timeseries_root))

        hadcrut = read_hadcrut_crutem(DATALOC + "hadcrut4.1981-2010.csv")

        p0 = ax1.plot(noaa.times,
                      noaa.data,
                      c=COLOURS[noaa.name],
                      ls='-',
                      label=noaa.name,
                      lw=LW)
        p1 = ax1.plot(nasa.times,
                      nasa.data,
                      c=COLOURS[nasa.name],
                      ls='-',
                      label=nasa.name,
                      lw=LW)
        #     p2 = ax1.plot(jma.times, jma.data, c=COLOURS[jma.name], ls='-', label=jma.name, lw=LW)
        p3 = ax1.plot(hadcrut.times,
                      hadcrut.data,
                      c=COLOURS[hadcrut.name],
                      ls='-',
                      label=hadcrut.name,
                      lw=LW)
        ax1.fill_between(hadcrut.times, hadcrut.lower, hadcrut.upper, \
                             where=hadcrut.upper > hadcrut.lower, color='0.5', alpha=0.7)
        p4 = ax1.fill(np.NaN, np.NaN, '0.5', alpha=0.7)

        ax1.axhline(0, c='0.5', ls='--')

        ax1.legend([p0[0], p1[0], (p3[0], p4[0])], [noaa.name, nasa.name, hadcrut.name], \
                       loc=LEGEND_LOC, ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, \
                       labelspacing=0.1, columnspacing=0.5, bbox_to_anchor=BBOX)

        ax1.text(0.02,
                 0.9,
                 "(a) In Situ Land and Ocean",
                 transform=ax1.transAxes,
                 fontsize=settings.FONTSIZE)

        utils.thicken_panel_border(ax1)
        # ax1.yaxis.set_ticks_position('left')

        #*******************
        # reanalysis L+O

        merra = utils.read_merra(
            settings.REANALYSISLOC +
            "MERRA-2_SfcAnom{}.dat".format(settings.YEAR), "temperature", "LO")
        jra_actuals, jra_anoms = utils.read_jra55(
            settings.REANALYSISLOC + "JRA-55_tmp2m_global_ts.txt",
            "temperature")
        twenty_cr_actuals = utils.read_20cr(
            settings.REANALYSISLOC + "global.2mt.skt.txt", "temperature")
        dummy, twenty_cr_anoms = utils.calculate_climatology_and_anomalies_1d(
            twenty_cr_actuals, 1981, 2010)
        twenty_cr_anoms.zorder = -1

        # 2018 no MERRA
        utils.plot_ts_panel(ax2, [jra_anoms, global_era5_anoms],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC,
                            bbox=BBOX)

        ax2.text(0.02,
                 0.9,
                 "(b) Reanalysis Land and Ocean",
                 transform=ax2.transAxes,
                 fontsize=settings.FONTSIZE)

        #*******************
        # in situ L

        noaa, nasa, jma = read_global_t(DATALOC +
                                        "{}_L.csv".format(IS_timeseries_root))
        crutem = read_hadcrut_crutem(DATALOC +
                                     "crutem4_new_logo.1981-2010.csv")

        p0 = ax3.plot(noaa.times,
                      noaa.data,
                      ls='-',
                      c=COLOURS[noaa.name],
                      label=noaa.name,
                      lw=LW)
        p1 = ax3.plot(nasa.times,
                      nasa.data,
                      ls='-',
                      c=COLOURS[nasa.name],
                      label=nasa.name,
                      lw=LW)
        #    p2 = ax3.plot(jma.times, jma.data, ls='-', c=COLOURS[jma.name], label=jma.name, lw=LW)
        #    p3 = ax3.plot(berkeley.times, berkeley.data, ls = '-', c = COLOURS[berkeley.name], label = berkeley.name, lw = LW)
        p4 = ax3.plot(crutem.times,
                      crutem.data,
                      ls='-',
                      c=COLOURS[crutem.name],
                      label=crutem.name,
                      lw=LW)
        ax3.fill_between(crutem.times, crutem.lower, crutem.upper, \
                             where=crutem.upper > crutem.lower, color='0.5', alpha=0.7)
        p5 = ax1.fill(np.NaN, np.NaN, '0.5', alpha=0.7)

        ax3.axhline(0, c='0.5', ls='--')

        ax3.legend([p0[0], p1[0], (p4[0], p5[0])], [noaa.name, nasa.name, crutem.name], \
                       loc=LEGEND_LOC, ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, \
                       labelspacing=0.1, columnspacing=0.5, bbox_to_anchor=BBOX)

        ax3.text(0.02,
                 0.9,
                 "(c) In Situ Land only",
                 transform=ax3.transAxes,
                 fontsize=settings.FONTSIZE)

        utils.thicken_panel_border(ax3)
        #    ax3.yaxis.set_ticks_position('left')

        #*******************
        # reanalysis L

        merra = utils.read_merra(
            settings.REANALYSISLOC +
            "MERRA-2_SfcAnom{}.dat".format(settings.YEAR), "temperature", "L")
        jra_actual, jra_anoms = utils.read_jra55(
            settings.REANALYSISLOC + "JRA-55_tmp2m_globalland_ts.txt",
            "temperature")
        twenty_cr_actuals = utils.read_20cr(
            settings.REANALYSISLOC + "air2mland.txt", "temperature")
        dummy, twenty_cr_anoms = utils.calculate_climatology_and_anomalies_1d(
            twenty_cr_actuals, 1981, 2010)
        twenty_cr_anoms.zorder = -1

        # 2018 - No MERRA
        utils.plot_ts_panel(ax4, [jra_anoms, land_era5_anoms],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC,
                            bbox=BBOX)

        ax4.text(0.02,
                 0.9,
                 "(d) Reanalysis Land only",
                 transform=ax4.transAxes,
                 fontsize=settings.FONTSIZE)

        #*******************
        # in situ O

        noaa, nasa, jma = read_global_t(DATALOC +
                                        "{}_O.csv".format(IS_timeseries_root))
        hadsst = read_hadcrut_crutem(DATALOC +
                                     "hadsst3_new_logo.1981-2010.csv")

        p0 = ax5.plot(noaa.times,
                      noaa.data,
                      ls='-',
                      c=COLOURS[noaa.name],
                      label=noaa.name,
                      lw=LW)
        p1 = ax5.plot(nasa.times,
                      nasa.data,
                      ls='-',
                      c=COLOURS[nasa.name],
                      label=nasa.name,
                      lw=LW)
        #     p2 = ax5.plot(jma.times, jma.data, ls='-', c=COLOURS[jma.name], label=jma.name, lw=LW)
        p3 = ax5.plot(hadsst.times,
                      hadsst.data,
                      ls='-',
                      c=COLOURS[hadsst.name],
                      label=hadsst.name,
                      lw=LW)
        ax5.fill_between(hadsst.times, hadsst.lower, hadsst.upper, \
                             where=hadsst.upper > hadsst.lower, color='0.5', alpha=0.7)
        p4 = ax1.fill(np.NaN, np.NaN, '0.5', alpha=0.7)

        ax5.axhline(0, c='0.5', ls='--')

        ax5.legend([p0[0], p1[0], (p3[0], p4[0])], [noaa.name, nasa.name, hadsst.name], \
                       loc=LEGEND_LOC, ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, \
                       labelspacing=0.1, columnspacing=0.5, bbox_to_anchor=BBOX)

        ax5.text(0.02,
                 0.9,
                 "(e) In Situ Ocean only",
                 transform=ax5.transAxes,
                 fontsize=settings.FONTSIZE)

        utils.thicken_panel_border(ax5)
        #    ax5.yaxis.set_ticks_position('left')

        #*******************
        # reanalysis O

        merra = utils.read_merra(
            settings.REANALYSISLOC +
            "MERRA-2_SfcAnom{}.dat".format(settings.YEAR), "temperature", "O")
        jra_actual, jra_anoms = utils.read_jra55(
            settings.REANALYSISLOC + "JRA-55_tmp2m_globalocean_ts.txt",
            "temperature")
        twenty_cr_actuals = utils.read_20cr(
            settings.REANALYSISLOC + "airsktocean.txt", "temperature")
        dummy, twenty_cr_anoms = utils.calculate_climatology_and_anomalies_1d(
            twenty_cr_actuals, 1981, 2010)
        twenty_cr_anoms.zorder = -1

        # 2018 no MERRA
        utils.plot_ts_panel(ax6, [jra_anoms, ocean_era5_anoms],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC,
                            bbox=BBOX)

        ax6.text(0.02,
                 0.9,
                 "(f) Reanalysis Ocean only",
                 transform=ax6.transAxes,
                 fontsize=settings.FONTSIZE)

        #*******************
        # prettify

        fig.text(0.03,
                 0.5,
                 "Anomalies (" + r'$^{\circ}$' + "C)",
                 va='center',
                 rotation='vertical',
                 fontsize=settings.FONTSIZE)

        plt.xlim([1900, int(settings.YEAR) + 2])

        minorLocator = MultipleLocator(5)
        for ax in [ax1, ax2, ax3, ax4, ax5, ax6]:
            ax.set_ylim(YLIM)
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
            ax.xaxis.set_minor_locator(minorLocator)

        for tick in ax6.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)

        fig.subplots_adjust(right=0.96, top=0.995, bottom=0.02, hspace=0.001)

        plt.savefig(settings.IMAGELOC + "SAT_ts{}".format(settings.OUTFMT))

        plt.close()

    #************************************************************************
    # ERA5 Anomaly figure

    if True:
        # Read in ERA anomalies

        cube_list = iris.load(settings.REANALYSISLOC +
                              "era5_t2m_{}01-{}12_ann_ano.nc".format(
                                  settings.YEAR, settings.YEAR))
        for cube in cube_list:
            if cube.var_name == "T2M":
                break

        cube.coord('latitude').guess_bounds()
        cube.coord('longitude').guess_bounds()

        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]

        utils.plot_smooth_map_iris(
            settings.IMAGELOC + "SAT_{}_anoms_era5".format(settings.YEAR),
            cube[0],
            settings.COLOURMAP_DICT["temperature"],
            bounds,
            "Anomalies from 1981-2010 (" + r'$^{\circ}$' + "C)",
            title="ERA5")

    #************************************************************************
    # MERRA2 Anomaly figure
    if True:
        cube_list = iris.load(settings.REANALYSISLOC +
                              "MERRA-2_SfcAnom_{}.nc".format(settings.YEAR))
        for cube in cube_list:
            if cube.var_name == "t2ma":
                break

        cube.coord('latitude').guess_bounds()
        cube.coord('longitude').guess_bounds()

        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "SAT_{}_anoms_merra".format(settings.YEAR), cube[0], \
                                       settings.COLOURMAP_DICT["temperature"], bounds, \
                                       "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="MERRA-2")

    #************************************************************************
    # HadCRUT4 Anomaly figure
    if True:
        cube_list = iris.load(DATALOC + "HadCRUT.4.6.0.0.median.nc")
        for cube in cube_list:
            if cube.var_name == "temperature_anomaly":
                break

        cube.coord('latitude').guess_bounds()
        cube.coord('longitude').guess_bounds()

        # restrict to 1851 to last full year
        date_constraint = utils.periodConstraint(
            cube, dt.datetime(1850, 1, 1),
            dt.datetime(int(settings.YEAR) + 1, 1, 1))
        cube = cube.extract(date_constraint)

        # convert to 1981-2010 climatology.
        clim_constraint = utils.periodConstraint(cube, dt.datetime(1981, 1, 1),
                                                 dt.datetime(2011, 1, 1))
        clim_cube = cube.extract(clim_constraint)

        clim_data = clim_cube.data.reshape(-1, 12, clim_cube.data.shape[-2],
                                           clim_cube.data.shape[-1])

        # more than 15 years present
        climatology = np.ma.mean(clim_data, axis=0)
        nyears = np.ma.count(clim_data, axis=0)
        climatology = np.ma.masked_where(nyears <= 15,
                                         climatology)  # Kate keeps GT 15.

        # extract final year
        final_year_constraint = utils.periodConstraint(
            cube, dt.datetime(int(settings.YEAR), 1, 1),
            dt.datetime(int(settings.YEAR) + 1, 1, 1))
        final_year_cube = cube.extract(final_year_constraint)

        final_year_cube.data = final_year_cube.data - climatology

        # more than 6 months present
        annual_cube = final_year_cube.collapsed(['time'], iris.analysis.MEAN)
        nmonths = np.ma.count(final_year_cube.data, axis=0)
        annual_cube.data = np.ma.masked_where(nmonths <= 6, annual_cube.data)

        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "SAT_{}_anoms_hadcrut4".format(settings.YEAR), annual_cube, \
                                       settings.COLOURMAP_DICT["temperature"], bounds, \
                                       "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="HadCRUT 4.6")

    #************************************************************************
    # NOAA data Anomaly figure - incl plate 2.1
    if True:
        cube = read_noaa_mlost(DATALOC + "mlost-box.ytd.12.1981-2010bp.txt",
                               int(settings.YEAR))

        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_SAT_{}_anoms_noaa".format(settings.YEAR), cube, \
                                       settings.COLOURMAP_DICT["temperature"], bounds, \
                                       "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", \
                                       figtext="(a) Surface Temperature", \
                                       save_netcdf_filename="{}MLOST_for_NOAA_{}.nc".format(DATALOC, dt.datetime.strftime(dt.datetime.now(), "%d-%b-%Y")))

        utils.plot_smooth_map_iris(settings.IMAGELOC + "SAT_{}_anoms_noaa".format(settings.YEAR), cube, \
                                       settings.COLOURMAP_DICT["temperature"], bounds, \
                                       "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="NOAAGlobalTemp")

    #************************************************************************
    # JRA55 data Anomaly figure
    if True:
        cube_list = iris.load(settings.REANALYSISLOC +
                              "jra55_t2m_{}01-{}12_ann_ano.nc".format(
                                  settings.YEAR, settings.YEAR))
        for cube in cube_list:
            if cube.var_name == "T2M":
                break

        cube.coord('latitude').guess_bounds()
        cube.coord('longitude').guess_bounds()

        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "SAT_{}_anoms_jra55".format(settings.YEAR), cube[0,0], \
                                       settings.COLOURMAP_DICT["temperature"], bounds, \
                                       "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="JRA-55")

    #************************************************************************
    # NASA GISS Anomaly figure
    if True:
        #cube = read_nasa_giss(DATALOC + "nasa-2015-anomalies-wrt1981-2010bp")

        cube = iris.load(DATALOC + "gistemp1200_GHCNv4_ERSSTv5.nc")[0]

        # convert to 1981-2010 climatology.
        clim_constraint = utils.periodConstraint(cube, dt.datetime(1981, 1, 1),
                                                 dt.datetime(2011, 1, 1))
        clim_cube = cube.extract(clim_constraint)

        clim_data = clim_cube.data.reshape(-1, 12, clim_cube.data.shape[-2],
                                           clim_cube.data.shape[-1])

        # more than 15 years present
        climatology = np.ma.mean(clim_data, axis=0)
        nyears = np.ma.count(clim_data, axis=0)
        climatology = np.ma.masked_where(nyears <= 15,
                                         climatology)  # Kate keeps GT 15.

        # extract final year
        final_year_constraint = utils.periodConstraint(cube, dt.datetime(int(settings.YEAR), 1, 1), \
                                                           dt.datetime(int(settings.YEAR)+1, 1, 1))
        final_year_cube = cube.extract(final_year_constraint)

        final_year_cube.data = final_year_cube.data - climatology

        # more than 6 months present
        annual_cube = final_year_cube.collapsed(['time'], iris.analysis.MEAN)
        nmonths = np.ma.count(final_year_cube.data, axis=0)
        annual_cube.data = np.ma.masked_where(nmonths <= 6, annual_cube.data)

        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "SAT_{}_anoms_nasa".format(settings.YEAR), annual_cube, \
                                       settings.COLOURMAP_DICT["temperature"], bounds, \
                                       "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="NASA GISS")

    return  # run_all_plots
Exemplo n.º 4
0
# D - SURFACE TEMPERATURE
print("Surface Air Temperature")

import sat
# in situ
noaa, nasa, jma = sat.read_global_t(DATALOC + "{}/{}_LO.csv".format("SAT", sat.IS_timeseries_root))
hadcrut = sat.read_hadcrut_crutem(DATALOC+"{}/hadcrut4.1981-2010.csv".format("SAT"))

make_plot(ax_d, [noaa, nasa, jma, hadcrut], insitu)

# reanalyses
merra = utils.read_merra(settings.REANALYSISLOC + "MERRA-2_SfcAnom{}.dat".format(settings.YEAR), "temperature", "LO")
jra_actuals, jra_anoms = utils.read_jra55(settings.REANALYSISLOC + "JRA-55_tmp2m_global_ts.txt", "temperature")

era5_globe, era5_ocean, era5_land, era5tropics = utils.era5_ts_read(settings.REANALYSISLOC, "sat", annual=True)
global_era5_clim, global_era5_anoms = utils.calculate_climatology_and_anomalies_1d(era5_globe, 1981, 2010)

make_plot(ax_d, [merra, jra_anoms, era5_globe], reanalyses, plot_label="(d) Surface Temperature\n(1981-2010)", ylabel='$^{\circ}$'+"C", ylim=[-0.9, 1.2])

#***************************
# E - LOWER TROP TEMPERATURE
print("Lower Tropospheric Temperature")

import ltt

raobcore, rich, ratpac, UAH, rss, era5, jra,  merra= ltt.read_csv(DATALOC + "{}/SotC_AnnTemps_2020_0220_LTTGL.csv".format("LTT"))

# in situ
make_plot(ax_e, [raobcore, rich, ratpac], insitu)
# satellite
make_plot(ax_e, [UAH, rss], satellite)
Exemplo n.º 5
0
def run_all_plots():

    #************************************************************************
    # Read in Australian # Data
    #     aus_lat, aus_lon, aus_anom_8110, aus_trend_79_pres, aus_years, aus_anomalies, aus_clim_8110 = \
    #         read_australia("{}/u_Extracted_ANN_{}_v2.csv".format(DATALOC, settings.YEAR), start_year = 1979)
    # #        read_australia("{}/u_Extracted_ANN_1974_{}_RD.csv".format(DATALOC, settings.YEAR))

    # Timeseries figure
    if True:

        # ERA data
        era5_globe, era5_ocean, era5_land, era5tropics = utils.era5_ts_read(
            settings.REANALYSISLOC, "wnd", annual=True)

        land_era5_clim, land_era5_anoms = utils.calculate_climatology_and_anomalies_1d(
            era5_land, CLIMSTART, 2010)

        land_merra_anoms = utils.read_merra(settings.REANALYSISLOC + "MERRA-2_SfcAnom{}.dat".format(settings.YEAR), \
                                            "wind", "L", anomalies=True)

        jra_actuals, jra_anoms = utils.read_jra55(
            settings.REANALYSISLOC + "JRA-55_ws10m_globalland_ts.txt",
            "windspeed")

        twenty_cr_actuals = utils.read_20cr(
            settings.REANALYSISLOC + "wspd10m.land.txt", "wind speed")
        dummy, twenty_cr_anoms = utils.calculate_climatology_and_anomalies_1d(
            twenty_cr_actuals, CLIMSTART, 2010)

        # Plot timeseries figure
        fig, (ax1, ax2, ax3, ax4) = plt.subplots(4,
                                                 figsize=(8, 13),
                                                 sharex=True)

        print("{} {} {} {} {}".format("name", "mean", "anomaly", "trend/dec",
                                      "N station"))
        for region in all_regions:

            if region.name == "Australia":
                # use the Australian data

                years = aus_years
                anomalies = aus_anomalies

                print(anomalies)

                region.nstat = len(aus_lat)
                region.slope = np.mean(
                    aus_trend_79_pres
                )  # just do the mean of all station slopes
                region.mean = np.mean(aus_clim_8110)

            else:
                # Read in the HadISD annual anomalies
                years, anomalies, m3, m10 = read_hadisd_annual_anomalies(
                    region)

            # Print data for table
            print("{} {} {} {} {}".format(region.name, region.mean,
                                          anomalies[-1], region.slope * 10.,
                                          region.nstat))

            order = anomalies.argsort()
            ranks = order.argsort() + 1

            print("{} highest {} lowest".format(
                len(ranks) - ranks[-1], ranks[-1]))

            # plot data
            if region.fname == "GlobalNoOz":
                ax1.plot(years,
                         anomalies,
                         c=region.color,
                         label=region.name,
                         lw=3,
                         zorder=10)
            else:
                ax1.plot(years,
                         anomalies,
                         c=region.color,
                         label=region.name,
                         lw=2)

            if region.fname == "GlobalNoOz":
                ax3.plot(years, m3, c=region.color, lw=3, zorder=10)
                ax4.plot(years, m10, c=region.color, lw=3)
            elif region.name != "Australia":
                ax3.plot(years, m3, c=region.color, lw=2)
                ax4.plot(years, m10, c=region.color, lw=2)

        # plot reanalyses separately
        ax2.plot(land_era5_anoms.times, land_era5_anoms.data, c=settings.COLOURS["circulation"]["ERA5"], \
                     label="ERA5 (land only)", lw=2)
        ax2.plot(land_merra_anoms.times, land_merra_anoms.data, c=settings.COLOURS["circulation"]["MERRA-2"], \
                     label="MERRA-2 (land only)", lw=2)
        #        ax2.plot(jra_anoms.times, jra_anoms.data, c=settings.COLOURS["circulation"]["JRA-55"], \
        #                             label="JRA-55 (land only)", lw=2)
        ax2.plot(twenty_cr_anoms.times, twenty_cr_anoms.data, c=settings.COLOURS["circulation"]["20CRv3"], \
                     label="20CRv3 (land only)", lw=2)

        # finish off plot
        ax1.axhline(0, c='0.5', ls='--')
        ax2.axhline(0, c='0.5', ls='--')

        ax1.text(0.02,
                 0.9,
                 "(a) In Situ - all Speeds",
                 transform=ax1.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax2.text(0.02,
                 0.9,
                 "(b) Reanalyses - all Speeds",
                 transform=ax2.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax3.text(0.02, 0.9, "(c) In Situ >3 m s"+r'$^{-1}$'+" Winds", transform=ax3.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)
        ax4.text(0.02, 0.9, "(d) In Situ >10 m s"+r'$^{-1}$'+" Winds", transform=ax4.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)

        fig.text(0.02, 0.72, "Wind Anomaly (m s"+r'$^{-1}$'+")", va='center', rotation='vertical', \
                     fontsize=settings.LABEL_FONTSIZE)
        fig.text(0.02, 0.3, "Wind Frequency (% yr"+r'$^{-1}$'+")", va='center', rotation='vertical', \
                     fontsize=settings.LABEL_FONTSIZE)

        ax1.legend(loc="upper right", ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, \
                       labelspacing=0.1, columnspacing=0.5, bbox_to_anchor=(1.0, 0.9))
        ax2.legend(loc="upper right", ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, \
                       labelspacing=0.1, columnspacing=0.5, bbox_to_anchor=(1.0, 0.9))

        plt.setp([a.get_xticklabels() for a in fig.axes[:-1]], visible=False)

        fig.subplots_adjust(right=0.96, top=0.99, bottom=0.03, hspace=0.001)

        for tick in ax4.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)

        plt.xlim([1970, int(settings.YEAR) + 1])
        ax1.set_ylim([-0.39, 1.0])
        ax2.set_ylim([-0.39, 1.0])
        ax3.set_ylim([23, 68])
        ax4.set_ylim([0, 6.5])

        minorLocator = MultipleLocator(1)
        for ax in [ax1, ax2, ax3, ax4]:
            utils.thicken_panel_border(ax)
            ax.set_yticks(ax.get_yticks()[1:])
            ax.xaxis.set_minor_locator(minorLocator)
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
            ax.yaxis.set_ticks_position('left')

        plt.savefig(settings.IMAGELOC +
                    "WND_land_ts{}".format(settings.OUTFMT))
        plt.close()

    #************************************************************************
    # HadISD Anomaly figure
    if True:

        # Read in HadISD station anomalies
        stn_id, hadisd_lons, hadisd_lats, mean8110, hadisd_anomaly_8110, hadisd_trend_79_pres = read_hadisd_global_summary(
        )

        # combine together
        lats = hadisd_lats
        lons = hadisd_lons
        anom = hadisd_anomaly_8110
        trend = hadisd_trend_79_pres * 10

        # lats = np.append(hadisd_lats, aus_lat)
        # lons = np.append(hadisd_lons, aus_lon)
        # anom = combine_arrays((hadisd_anomaly_8110, aus_anom_8110))
        # trend = combine_arrays((hadisd_trend_79_pres, aus_trend_79_pres)) * 10.

        #    bounds = [-100, -0.8, -0.4, -0.2, -0.1, 0, 0.1, 0.2, 0.4, 0.8, 100]
        bounds = [-100, -0.4, -0.2, -0.1, -0.05, 0, 0.05, 0.1, 0.2, 0.4, 100]
        utils.scatter_plot_map(settings.IMAGELOC + "WND_{}_obs_trend".format(settings.YEAR), trend, \
                                   lons, lats, settings.COLOURMAP_DICT["circulation_r"], bounds, "Trend from {}-{} (m s".format(TRENDSTART, settings.YEAR)+r'$^{-1}$'+" decade"+r'$^{-1}$)')

        bounds = [-100, -1.2, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8, 1.2, 100]
        utils.scatter_plot_map(settings.IMAGELOC + "WND_{}_obs_anomaly".format(settings.YEAR), anom, \
                               lons, lats, settings.COLOURMAP_DICT["circulation_r"], bounds, "Anomalies from {}-2010 (m s".format(CLIMSTART)+r'$^{-1}$)')

        total = float(len(anom.compressed()))
        pos, = np.ma.where(anom > 0)
        neg, = np.ma.where(anom < 0)
        print("Anomalies: positive {:5.3f} negative {:5.3f}".format(
            len(pos) / total,
            len(neg) / total))
        pos, = np.ma.where(anom > 0.5)
        neg, = np.ma.where(anom < -0.5)
        print("Anomalies: positive {:5.3f} negative {:5.3f} (than 0.5)".format(
            len(pos) / total,
            len(neg) / total))
        pos, = np.ma.where(anom > 1.0)
        neg, = np.ma.where(anom < -1.0)
        print("Anomalies: positive {:5.3f} negative {:5.3f} (than 1.0)".format(
            len(pos) / total,
            len(neg) / total))

        total = float(len(trend.compressed()))
        pos, = np.ma.where(trend > 0)
        neg, = np.ma.where(trend < 0)
        print("Trends: positive {:5.3f} negative {:5.3f}".format(
            len(pos) / total,
            len(neg) / total))

    #************************************************************************
    # ERA5 + HadISD Anomaly figure
    if True:
        # Read in ERA anomalies

        cube_list = iris.load(settings.REANALYSISLOC +
                              "era5_ws10_{}01-{}12_ann_ano.nc".format(
                                  settings.YEAR, settings.YEAR))

        cube = cube_list[0]
        cube.coord('latitude').guess_bounds()
        cube.coord('longitude').guess_bounds()

        bounds = [-4, -1.2, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8, 1.2, 4]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_era5_obs_anomaly".format(settings.YEAR), cube[0], \
            settings.COLOURMAP_DICT["circulation_r"], bounds, "Anomalies from {}-2010 (m s".format(CLIMSTART)+r'$^{-1}$)', scatter = (lons, lats, anom))
        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_era5_anomaly".format(settings.YEAR), cube[0], \
            settings.COLOURMAP_DICT["circulation_r"], bounds, "Anomalies from {}-2010 (m s".format(CLIMSTART)+r'$^{-1}$)')

    #************************************************************************
    # MERRA Anomaly figure
    if True:
        anoms = read_ocean_ncdf(
            DATALOC +
            "rss_wind_trend_anomaly_SOTC_{}_updated.nc".format(settings.YEAR),
            "MERRA2_wind_anomaly_map_{}".format(settings.YEAR))

        bounds = [-40, -1.2, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8, 1.2, 40]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_merra2_anomaly", anoms, settings.COLOURMAP_DICT["circulation_r"], bounds,\
                                       "Anomalies from 1981-2010 (m s"+r'$^{-1}$'+")")

    #************************************************************************
    # MERRA + HadISD Anomaly figure

    if True:
        # Read in MERRA anomalies

        cube_list = iris.load(
            settings.REANALYSISLOC +
            "MERRA-2_SfcAnom_{}.nc".format(settings.YEAR),
            "10m Wind Speed Anomaly (1981-2010)")

        cube = cube_list[0]
        cube.coord('latitude').guess_bounds()
        cube.coord('longitude').guess_bounds()

        bounds = [-4, -1.2, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8, 1.2, 4]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_merra_obs_anomaly".format(settings.YEAR), cube[0], \
                                       settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Anomalies from {}-2010 (m s".format(CLIMSTART)+r'$^{-1}$)', scatter=(lons, lats, anom))
        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_WND_{}_merra_obs_anomaly".format(settings.YEAR), cube[0], \
                                       settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Anomalies from {}-2010 (m s".format(CLIMSTART)+r'$^{-1}$)', figtext="(v) Surface Winds", scatter=(lons, lats, anom))
        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_merra_anomaly".format(settings.YEAR), cube[0], \
                                       settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Anomalies from {}-2010 (m s".format(CLIMSTART)+r'$^{-1}$)')

    #************************************************************************
    # MERRA/RSS ocean + HadISD Anomaly figure
    if True:
        # Read in MERRA/RSS trends
        anomalies = read_ocean_ncdf(
            DATALOC +
            "rss_wind_trend_anomaly_SOTC_{}_updated.nc".format(settings.YEAR),
            "Merged_wind_anomaly_map_{}".format(settings.YEAR))

        bounds = [-4, -1.2, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8, 1.2, 4]
        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_merra-rss_anomaly".format(settings.YEAR), \
                                       anomalies, settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Anomalies from 1981-2010 (m s"+r'$^{-1}$)')
        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_merra-rss_obs_anomaly".format(settings.YEAR), \
                                       anomalies, settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Anomalies from 1981-2010 (m s"+r'$^{-1}$)',
                                   scatter=(lons, lats, anom))
        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_WND_{}_merra-rss_obs_anomaly".format(settings.YEAR), \
                                       anomalies, settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Anomalies from 1981-2010 (m s"+r'$^{-1}$)', figtext="(v) Surface Winds", scatter=(lons, lats, anom))

    #************************************************************************
    # Ocean timeseries
    if True:

        satellite = read_ts_cube(
            DATALOC +
            "rss_wind_trend_anomaly_SOTC_{}.nc".format(settings.YEAR),
            "RSS_wind_global_annual_anom_ts", "Satellite MW Radiometers")
        satellite_clim, satellite_anom = utils.calculate_climatology_and_anomalies_1d(
            satellite, 1988, 2010)

        #    print("NO IN SITU OCEAN DATA FOR 2016, using 2015 data")
        #    nocs = read_ts_cube(DATALOC + "NOCSv2.0_oceanW_5by5_8110anoms_areaTS_FEB2016.nc", "Globally Average 70S-70N", "NOCSv2.0")
        #    WASwind = read_ts_cube(DATALOC + "waswind_v1_0_1.monthly_areaTS_19502011.nc","Globally Averaged Anomalies 70S-70N", "WASwind")
        #    print("FIXING WASWIND TIMES - DATAFILE HAS WRONG DESCRIPTOR")
        #    WASwind.times = WASwind.times - (1973-1950)

        jra_actuals, jra_anoms = utils.read_jra55(
            settings.REANALYSISLOC + "JRA-55_ws10m_globalocean_ts.txt", "wind")

        era5_globe, era5_ocean, era5_land, era5tropics = utils.era5_ts_read(
            settings.REANALYSISLOC, "wnd", annual=True)
        ocean_era5_clim, ocean_era5_anoms = utils.calculate_climatology_and_anomalies_1d(
            era5_ocean, 1988, 2010)

        merra_anoms = utils.read_merra(
            settings.REANALYSISLOC +
            "MERRA-2_SfcAnom{}.dat".format(settings.YEAR),
            "wind",
            "O",
            anomalies=True)

        twenty_cr_actuals = utils.read_20cr(
            settings.REANALYSISLOC + "wspd10m.ocean.txt", "wind speed")
        dummy, twenty_cr_anoms = utils.calculate_climatology_and_anomalies_1d(
            twenty_cr_actuals, 1988, 2010)

        fig, (ax1) = plt.subplots(1, figsize=(8, 5), sharex=True)

        # Satellite
        #    utils.plot_ts_panel(ax1, [satellite_anom], "-", "circulation", loc=LEGEND_LOC, bbox=BBOX)

        # In Situ
        #    utils.plot_ts_panel(ax2, [nocs, WASwind], "-", "circulation", loc=LEGEND_LOC, bbox=BBOX)
        #    ax2.set_ylabel("Anomaly (m s"+r'$^{-1}$'+")", fontsize = settings.FONTSIZE)

        # Reanalyses & Satellite single panel
        satellite_anom.lw = 4
        satellite_anom.zorder = 10
        utils.plot_ts_panel(
            ax1,
            [satellite_anom, ocean_era5_anoms, merra_anoms, twenty_cr_anoms],
            "-",
            "circulation",
            loc=LEGEND_LOC,
            bbox=BBOX)

        #*******************
        # prettify
        ax1.axhline(0, c='0.5', ls='--')
        plt.ylabel("Wind Anomaly (m s" + r'$^{-1}$' + ")",
                   fontsize=settings.LABEL_FONTSIZE)
        ax1.legend(loc="upper right", ncol=1, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, \
                       labelspacing=0.1, columnspacing=0.5, bbox_to_anchor=(1.0, 0.99))

        # sort formatting
        plt.xlim([1970, int(settings.YEAR) + 1])

        for tick in ax1.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
    #    for ax in [ax1, ax2, ax3]:
        for ax in [ax1]:
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
            ax.set_ylim([-0.28, 0.45])
            ax.yaxis.set_ticks([-0.2, 0.0, 0.2, 0.4])
            ax.yaxis.set_ticks_position('left')

        # sort labelling
        ax1.text(0.03,
                 0.9,
                 "Satellites & Reanalyses",
                 transform=ax1.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        #    ax2.text(0.03, 0.9, "(b) In Situ", transform=ax2.transAxes, fontsize=settings.LABEL_FONTSIZE)
        #    ax3.text(0.03, 0.9, "(b) Reanalyses", transform=ax3.transAxes, fontsize=settings.LABEL_FONTSIZE

        fig.subplots_adjust(right=0.95, top=0.95, hspace=0.001)

        plt.savefig(settings.IMAGELOC +
                    "WND_ocean_ts{}".format(settings.OUTFMT))

        plt.close()

    #************************************************************************
    # Ocean maps
    if True:
        anoms = read_ocean_ncdf(
            DATALOC +
            "rss_wind_trend_anomaly_SOTC_{}_updated.nc".format(settings.YEAR),
            "RSS_wind_anomaly_map_{}".format(settings.YEAR))

        bounds = [-40, -1.2, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8, 1.2, 40]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_rss_anomaly".format(settings.YEAR), anoms, settings.COLOURMAP_DICT["circulation_r"], bounds,\
                                       "Anomalies from 1981-2010 (m s"+r'$^{-1}$'+")")

    #************************************************************************
    # MERRA/RSS ocean + HadISD Trend figure
    if True:
        # Read in MERRA/RSS trends
        trends = read_ocean_ncdf(
            DATALOC +
            "rss_wind_trend_anomaly_SOTC_{}_updated.nc".format(settings.YEAR),
            "Wind_trend_map")

        bounds = [-4, -0.8, -0.4, -0.2, -0.1, 0, 0.1, 0.2, 0.4, 0.8, 4]
        bounds = [-100, -0.4, -0.2, -0.1, -0.05, 0, 0.05, 0.1, 0.2, 0.4, 100]
        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_merra-rss_trend".format(settings.YEAR), \
                                       trends, settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Trend from {}-{} (m s".format(TRENDSTART, settings.YEAR)+r'$^{-1}$'+" decade"+r'$^{-1}$)')
        utils.plot_smooth_map_iris(settings.IMAGELOC + "WND_{}_merra-rss_obs_trend".format(settings.YEAR), \
                                       trends, settings.COLOURMAP_DICT["circulation_r"], bounds, \
                                       "Trend from {}-{} (m s".format(TRENDSTART, settings.YEAR)+r'$^{-1}$'+" decade"+r'$^{-1}$)',
                                   scatter=(lons, lats, trend))

    return  # run_all_plots
Exemplo n.º 6
0
def run_all_plots():

    #************************************************************************
    # Timeseries figure (2 panels)
    if True:
        for region in ["global"]:

            if region == "global":
                raobcore, rich, ratpac, UAH, rss, era5, merra, jra = \
                    read_csv(DATALOC + "SotC_AnnTemps_2020_0520_LTTGL.csv")

            plt.clf()
            fig, (ax1, ax2, ax3) = plt.subplots(3, figsize=(8, 10), sharex=True)

            # sondes
            utils.plot_ts_panel(ax1, [raobcore, rich, ratpac], "-", "temperature", loc=LEGEND_LOC)

            # satellites
            utils.plot_ts_panel(ax2, [UAH, rss], "-", "temperature", loc=LEGEND_LOC)

            ax2.set_ylabel("Anomaly ("+r'$^\circ$'+"C)", fontsize=settings.FONTSIZE)


            # reanalyses
            if region == "global":
    #            jra_actuals, jra_anoms = utils.read_jra55(settings.REANALYSISLOC + "JRA-55_MSUch2LT_global_ts.txt", "temperature")
    #            merra_actuals, merra_anoms = utils.read_merra_LT_LS(settings.REANALYSISLOC + "MERRA2_MSU_Tanom_ann_{}.dat".format(settings.YEAR), LT=True)
    #            utils.plot_ts_panel(ax3, [erai, era5, jra_anoms, merra_anoms], "-", "temperature", loc=LEGEND_LOC)
                twenty_cr_actuals = utils.read_20cr(settings.REANALYSISLOC + "tlt.global.txt", "temperature")
                dummy, twenty_cr_anoms = utils.calculate_climatology_and_anomalies_1d(twenty_cr_actuals, 1981, 2010)


                utils.plot_ts_panel(ax3, [era5, jra, merra], "-", "temperature", loc=LEGEND_LOC)
            else:
                utils.plot_ts_panel(ax3, [era5], "-", "temperature", loc=LEGEND_LOC)


            # sort formatting
            plt.xlim([raobcore.times[0]-1, raobcore.times[-1]+1])
            ax1.set_ylim([-0.89, 0.89])
            ax2.set_ylim([-0.89, 0.89])
            ax3.set_ylim([-0.89, 0.89])

            for tick in ax3.xaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)

            for tick in ax1.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
            for tick in ax2.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
            for tick in ax3.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)

            # sort labelling
            ax1.text(0.02, 0.9, "(a) Radiosondes", transform=ax1.transAxes, fontsize=settings.LABEL_FONTSIZE)
            ax2.text(0.02, 0.9, "(b) Satellites", transform=ax2.transAxes, fontsize=settings.LABEL_FONTSIZE)
            ax3.text(0.02, 0.9, "(c) Reanalyses", transform=ax3.transAxes, fontsize=settings.LABEL_FONTSIZE)

            fig.subplots_adjust(right=0.98, top=0.98, bottom=0.05, hspace=0.001)

            plt.savefig(settings.IMAGELOC+"LTT_ts_{}{}".format(region, settings.OUTFMT))

            plt.close()

    # #************************************************************************
    # # Land Fraction - 2018

    # high, low = read_hilo(DATALOC + "high_low.dat")
    # fig, ax1 = plt.subplots(1, figsize=(8, 5))

    # ax1.plot(high.times, high.data, c="r", ls="-", lw=2, label=high.name)
    # ax1.plot(low.times, low.data, c="b", ls="-", lw=2, label=low.name)
    
    # ax1.legend(loc="upper right", ncol=2, frameon=False, prop={'size':settings.FONTSIZE})
    # ax1.set_xlim([1978, int(settings.YEAR)+2])
    # ax1.set_ylabel("Percentage of Global Area (%)", fontsize=settings.FONTSIZE)

    # for tick in ax1.yaxis.get_major_ticks():
    #     tick.label.set_fontsize(settings.FONTSIZE)
    # for tick in ax1.xaxis.get_major_ticks():
    #     tick.label.set_fontsize(settings.FONTSIZE)
    # utils.thicken_panel_border(ax1)

    # plt.savefig(settings.IMAGELOC+"LTT_land_area_ts{}".format(settings.OUTFMT))

    # plt.close()

    #************************************************************************
    # Read in ERA5 anomalies
    if False:
        cube_list = iris.load(DATALOC + "2019TLTAnom.nc")
        names = np.array([c.var_name for c in cube_list])

        loc, = np.where(names == "tltAnnualAnom")[0]

        cube = cube_list[loc]

        bounds = np.array([-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100])
        bounds = np.array([-100, -1.6, -1.2, -0.8, -0.4, 0, 0.4, 0.8, 1.2, 1.6, 100])
        bounds = np.array([-100, -2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 100])

        cmap = settings.COLOURMAP_DICT["temperature"]
        utils.plot_smooth_map_iris(settings.IMAGELOC + "LTT_{}_anoms_era5".format(settings.YEAR), cube, cmap, \
                                       bounds, "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="ERA5")
        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_LTT_{}_anoms_era5".format(settings.YEAR), cube, \
                                       cmap, bounds, "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", \
                                       figtext="(e) Lower Tropospheric Temperature")


    #************************************************************************
    # Read in ERA5 anomalies with record pixels
    if True:
        cube_list = iris.load(DATALOC + "2019TLTAnom_warmest.nc")
        names = np.array([c.var_name for c in cube_list])

        loc, = np.where(names == "tltAnnualAnom")[0]

        cube = cube_list[loc]

        loc, = np.where(names == "recordMask")[0]
        record = cube_list[loc]
        record.coord("latitude").guess_bounds()
        record.coord("longitude").guess_bounds()

        lats, lons, data = [], [], []
        for t, lat in enumerate(record.coord("latitude").points):
            for n, lon in enumerate(record.coord("longitude").points):
                if record.data[t, n] == 1:
                    data += [cube.data[t, n]]
                    lats += [np.mean(record.coord("latitude").bounds[t])]
                    lons += [np.mean(record.coord("longitude").bounds[n])]
        
        bounds = np.array([-100, -2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 100])

        cmap = settings.COLOURMAP_DICT["temperature"]
        utils.plot_smooth_map_iris(settings.IMAGELOC + "LTT_{}_anoms_era5".format(settings.YEAR), cube, cmap, \
                                       bounds, "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="ERA5", \
                                   scatter=(lons, lats, data), smarker="dots")
        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_LTT_{}_anoms_era5".format(settings.YEAR), cube, \
                                       cmap, bounds, "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", \
                                       figtext="(e) Lower Tropospheric Temperature", \
                                   scatter=(lons, lats, data), smarker="dots")

    #************************************************************************
    # ERA-I Hovmuller

    # times, latitudes, data = utils.erai_2dts_read(settings.REANALYSISLOC, "ltt")

    # bounds = np.array([-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100])
    # bounds = np.array([-100, -1.6, -1.2, -0.8, -0.4, 0, 0.4, 0.8, 1.2, 1.6, 100])

    # # sort the time axis
    # start = (times[0] - 101)/10000.
    # end = (times[-1] - 1201)/10000.

    # year = start
    # new_times = []

    # months = (np.arange(12))/12.

    # while year <= end:
    #     new_times += [np.array([year for i in range(12)]) + months]
    #     year += 1

    # new_times = np.array(new_times).reshape(-1)
    # # sort the climatology to 1981-2010 (monthly!)

    # # reshape to deal with monthly
    # data = data.reshape(-1, 12, data.shape[-1])
    # new_times = new_times.reshape(-1, 12)

    # # extract climatology period
    # start_loc, = np.where(new_times[:, 0] == CLIMSTART)
    # end_loc, = np.where(new_times[:, 0] == CLIMEND)
    # clim_data = data[start_loc[0]:end_loc[0] + 1, :, :]
    # climatology = np.mean(clim_data, axis=0)

    # # make anomalies
    # data = np.array([data[i, :, :] - climatology for i in range(data.shape[0])])

    # # return to original shapes
    # data = data.reshape(-1, data.shape[-1])
    # new_times = new_times.reshape(-1)

    # utils.plot_hovmuller(settings.IMAGELOC + "LTT_hovmuller_erai", new_times, latitudes, data.T, \
    #                          settings.COLOURMAP_DICT["temperature"], bounds, \
    #                          "Anomaly ("+r'$^{\circ}$'+"C)", cosine=True)


    # version with MEI on top
    # mei = read_mei(os.path.join(DATALOC, "MEI.dat"))


    # utils.plot_hovmuller(settings.IMAGELOC + "LTT_hovmuller_era_MEI", new_times, latitudes, data.T, \
    #                          settings.COLOURMAP_DICT["temperature"], bounds, \
    #                          "Anomaly ("+r'$^{\circ}$'+"C)", cosine=True, extra_ts=mei)


    return # run_all_plots
Exemplo n.º 7
0
def run_all_plots():

    #***********************
    # MODIS - centre
    if True:
        cubelist = iris.load(
            os.path.join(
                DATALOC,
                "MODIS.CMG.{}.SOS.EOS.Anomaly.nc".format(settings.YEAR)))
        names = np.array([c.name() for c in cubelist])
        # set up plot settings
        BOUNDS = [-100, -20, -10, -5, -2, 0, 2, 5, 10, 20, 100]
        LABELS = {
            "SOS": "(c) Start of Season (SOS)",
            "EOS": "(d) End of Season (EOS)"
        }

        for season in ["SOS", "EOS"]:

            c, = np.where(names == season)[0]

            cube = cubelist[c]

            # deal with NANS
            cube.data = np.ma.masked_where(cube.data != cube.data, cube.data)

            fig = plt.figure(figsize=(8, 11))
            plt.clf()

            # boundary circle
            theta = np.linspace(0, 2 * np.pi, 100)
            center, radius = [0.5, 0.5], 0.5
            verts = np.vstack([np.sin(theta), np.cos(theta)]).T
            circle = mpath.Path(verts * radius + center)

            # axes for polar plot
            ax = plt.axes([0.01, 0.02, 0.98, 0.65],
                          projection=cartopy.crs.NorthPolarStereo(
                              central_longitude=300.0))

            plot_cube = cube

            # regrid depending on output format
            if settings.OUTFMT in [".eps", ".pdf"]:
                if plot_cube.coord(
                        "latitude").points.shape[0] > 90 or plot_cube.coord(
                            "longitude").points.shape[0] > 360:
                    regrid_size = 1.0
                    print(
                        "Regridding cube for {} output to {} degree resolution"
                        .format(settings.OUTFMT, regrid_size))
                    print("Old Shape {}".format(plot_cube.data.shape))
                    plot_cube = utils.regrid_cube(plot_cube, regrid_size,
                                                  regrid_size)
                    print("New Shape {}".format(plot_cube.data.shape))

            # prettify
            ax.gridlines()  #draw_labels=True)
            ax.add_feature(cartopy.feature.LAND,
                           zorder=0,
                           facecolor="0.9",
                           edgecolor="k")
            ax.coastlines()
            ax.set_boundary(circle, transform=ax.transAxes)

            if season == "SOS":
                cmap = settings.COLOURMAP_DICT["phenological_r"]
            elif season == "EOS":
                cmap = settings.COLOURMAP_DICT["phenological"]

            norm = mpl.cm.colors.BoundaryNorm(BOUNDS, cmap.N)
            mesh = iris.plot.pcolormesh(plot_cube,
                                        cmap=cmap,
                                        norm=norm,
                                        axes=ax)

            # # read in sites
            if season == "EOS":
                pass
            elif season == "SOS":
                lake_locations = read_us_phenocam(
                    os.path.join(DATALOC, "lake_coords.csv"))
                # scatter
                COL = "chartreuse"
                ax.scatter(lake_locations[1],
                           lake_locations[0],
                           c=COL,
                           s=100,
                           edgecolor="k",
                           transform=cartopy.crs.Geodetic(),
                           zorder=10)
                COL = "m"
                # Harvard Forest - 2019
                ax.scatter(-72.17,
                           42.54,
                           c=COL,
                           s=100,
                           edgecolor="k",
                           transform=cartopy.crs.Geodetic(),
                           zorder=10)

                # uk box
                COL = "y"
                region = [-10.0, 49.0, 3.0, 60.0]
                ax.plot([region[0], region[0]], [region[1], region[3]],
                        c=COL,
                        ls='-',
                        lw=4,
                        zorder=10,
                        transform=cartopy.crs.PlateCarree())
                ax.plot([region[2], region[2]], [region[1], region[3]],
                        c=COL,
                        ls='-',
                        lw=4,
                        zorder=10,
                        transform=cartopy.crs.PlateCarree())
                ax.plot([region[0], region[2]], [region[1], region[1]],
                        c=COL,
                        ls='-',
                        lw=4,
                        zorder=10,
                        transform=cartopy.crs.Geodetic())
                ax.plot([region[0], region[2]], [region[3], region[3]],
                        c=COL,
                        ls='-',
                        lw=4,
                        zorder=10,
                        transform=cartopy.crs.Geodetic())

            # COL = "k"
            # ax.plot([region[0], region[0]], [region[1], region[3]], c=COL, ls='-', lw=5, zorder=9, transform=cartopy.crs.PlateCarree())
            # ax.plot([region[2], region[2]], [region[1], region[3]], c=COL, ls='-', lw=5, zorder=9, transform=cartopy.crs.PlateCarree())
            # ax.plot([region[0], region[2]], [region[1], region[1]], c=COL, ls='-', lw=5, zorder=9, transform=cartopy.crs.Geodetic())
            # ax.plot([region[0], region[2]], [region[3], region[3]], c=COL, ls='-', lw=5, zorder=9, transform=cartopy.crs.Geodetic())

            # label axes
            ax.text(-0.1,
                    1.0,
                    LABELS[season],
                    fontsize=settings.FONTSIZE,
                    transform=ax.transAxes)

            cb = plt.colorbar(mesh,
                              orientation='horizontal',
                              ticks=BOUNDS[1:-1],
                              drawedges=True,
                              fraction=0.1,
                              pad=0.01,
                              aspect=20,
                              shrink=0.8)
            # prettify
            cb.set_label(label="Anomaly (days)", fontsize=settings.FONTSIZE)
            cb.ax.tick_params(axis='x',
                              labelsize=settings.FONTSIZE,
                              direction='in',
                              size=0)
            cb.set_ticklabels(["{:g}".format(b) for b in BOUNDS[1:-1]])
            cb.outline.set_linewidth(2)
            cb.dividers.set_color('k')
            cb.dividers.set_linewidth(2)

            ax.set_extent([-180, 180, 30, 90], cartopy.crs.PlateCarree())

            for lat in range(30, 100, 10):
                ax.text(180,
                        lat,
                        '{}$^\circ$N'.format(lat),
                        transform=cartopy.crs.Geodetic())

            fig.subplots_adjust(bottom=0.05,
                                top=0.95,
                                left=0.04,
                                right=0.95,
                                wspace=0.02)

            del cube

            #***********************
            # MODIS timeserise
            sos_nh, eos_nh, sprt_nh_orig, falt_nh_orig = read_modis_ts(
                os.path.join(
                    DATALOC, "MODIS.CMG.{}.SOS.EOS.SPRT.FALT.TS.csv".format(
                        settings.YEAR)))

            dummy, sos_nh = utils.calculate_climatology_and_anomalies_1d(
                sos_nh, 2000, 2010)
            dummy, eos_nh = utils.calculate_climatology_and_anomalies_1d(
                eos_nh, 2000, 2010)

            dummy, sprt_nh = utils.calculate_climatology_and_anomalies_1d(
                sprt_nh_orig, 2000, 2010)
            dummy, falt_nh = utils.calculate_climatology_and_anomalies_1d(
                falt_nh_orig, 2000, 2010)

            ax = plt.axes([0.15, 0.73, 0.75, 0.23])
            if season == "SOS":
                label = "(a) Start of Season"
                anomalies = [
                    "{} SOS Anomaly = -4.3 days".format(settings.YEAR),
                    "{} Spr. T anomaly = 0.19 ".format(settings.YEAR) +
                    r'$^{\circ}$' + "C"
                ]

                plot_modis_ts(ax, sos_nh, sprt_nh, sprt_nh_orig, label,
                              anomalies, LEGEND_LOC)

            elif season == "EOS":
                label = "(b) End of Season"
                anomalies = [
                    "{} EOS Anomaly = 2.4 days".format(settings.YEAR),
                    "{} Fall T anomaly = -0.53 ".format(settings.YEAR) +
                    r'$^{\circ}$' + "C"
                ]

                plot_modis_ts(ax, eos_nh, falt_nh, falt_nh_orig, label,
                              anomalies, LEGEND_LOC)

            plt.savefig(settings.IMAGELOC + "PHEN_modis_{}_{}{}".format(
                settings.YEAR, season, settings.OUTFMT))

        del cubelist

#***********************
# US timeseries - 2018
    if True:
        fig = plt.figure(figsize=(8, 9.5))
        plt.clf()

        modis_sos, modis_eos, pheno_sos, pheno_eos = read_us_phenocam_csv(
            os.path.join(DATALOC, "Richardson Data for SOC 2019 Figures.csv"))

        # images
        ax = plt.axes([0.01, 0.66, 0.49, 0.3])
        plot_images(ax, "HarvardForest_20190511.jpg")
        ax = plt.axes([0.5, 0.66, 0.49, 0.3])
        plot_images(ax, "HarvardForest_20191024.jpg")

        # timeseries
        ax = plt.axes([0.11, 0.35, 0.84, 0.3])
        plot_us_phenocam(ax, modis_eos, pheno_eos, sos=False)
        #        ax.text(0.05, 0.85, "(a)", transform=ax.transAxes, fontsize=settings.FONTSIZE)
        ax.set_ylim([275, 369])
        plt.setp(ax.get_xticklabels(), visible=False)

        ax = plt.axes([0.11, 0.05, 0.84, 0.3])
        plot_us_phenocam(ax, modis_sos, pheno_sos)
        #        ax.text(0.05, 0.85, "(b)", transform=ax.transAxes, fontsize=settings.FONTSIZE)
        ax.set_ylim([101, 144])

        fig.text(0.02,
                 0.97,
                 "(a)",
                 transform=ax.transAxes,
                 fontsize=settings.FONTSIZE)
        fig.text(0.02,
                 0.3,
                 "Day of year",
                 rotation="vertical",
                 fontsize=settings.FONTSIZE)
        plt.savefig(
            settings.IMAGELOC +
            "PHEN_UStimeseries_{}{}".format(settings.YEAR, settings.OUTFMT))
        plt.close()

    #***********************
    # US timeseries - 2018
    if False:
        fig = plt.figure(figsize=(8, 7))
        plt.clf()

        modis_sos, modis_eos, pheno_sos, pheno_eos = read_us_phenocam_csv(
            os.path.join(DATALOC, "Richardson Data for SOC 2019 Figures.csv"))

        # timeseries
        ax = plt.axes([0.11, 0.5, 0.64, 0.45])
        plot_us_phenocam(ax, modis_eos, pheno_eos, sos=False)
        ax.text(0.05,
                0.85,
                "(c)",
                transform=ax.transAxes,
                fontsize=settings.FONTSIZE)
        ax.set_ylim([275, 369])
        plt.setp(ax.get_xticklabels(), visible=False)
        ax = plt.axes([0.75, 0.5, 0.25, 0.4])
        plot_images(ax, "HarvardForest_20191024.jpg")

        ax = plt.axes([0.11, 0.05, 0.64, 0.45])
        plot_us_phenocam(ax, modis_sos, pheno_sos)
        ax.text(0.05,
                0.85,
                "(d)",
                transform=ax.transAxes,
                fontsize=settings.FONTSIZE)
        ax.set_ylim([101, 144])
        ax = plt.axes([0.75, 0.05, 0.25, 0.4])
        plot_images(ax, "HarvardForest_20190511.jpg")

        fig.text(0.02,
                 0.4,
                 "Day of year",
                 rotation="vertical",
                 fontsize=settings.FONTSIZE)
        plt.savefig(
            settings.IMAGELOC +
            "PHEN_UStimeseries_{}{}".format(settings.YEAR, settings.OUTFMT))
        plt.close()

    #***********************
    # UK timeseries - 2018
    if True:
        from matplotlib.ticker import MultipleLocator
        majorLocator = MultipleLocator(5)

        fig = plt.figure(figsize=(8, 9.5))
        plt.clf()

        # images
        ax = plt.axes([0.01, 0.66, 0.48, 0.3])
        plot_images(ax, "Sarah Burgess first leaf.jpg")
        ax = plt.axes([0.5, 0.66, 0.48, 0.3])
        plot_images(ax, "Judith Garforth oak bare tree 2019.jpg")

        sos_uk, eos_uk = read_modis_uk_ts(
            os.path.join(
                DATALOC, "MODIS.CMG.{}.SOS.EOS.SPRT.FALT.TS.UK_DH.csv".format(
                    settings.YEAR)))
        oak_sos, oak_eos = read_uk_oak_csv(
            os.path.join(DATALOC, "UK_Oakleaf_data.csv"))

        # timeseries
        ax = plt.axes([0.11, 0.35, 0.84, 0.3])
        utils.plot_ts_panel(ax, [oak_eos, eos_uk],
                            "-",
                            "phenological",
                            loc="center left")
        #        ax.text(0.05, 0.85, "(c)", transform=ax.transAxes, fontsize=settings.FONTSIZE)
        ax.set_ylim([210, 354])
        plt.setp(ax.get_xticklabels(), visible=False)
        for tick in ax.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
        for tick in ax.yaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
        ax.xaxis.set_major_locator(majorLocator)

        # naughtily, manually tweak the upper oak plot
        for line in ax.get_lines():
            if line.get_color() == "g":
                line.set_color("#d95f0e")
        leg = ax.get_legend()
        for line in leg.get_lines():
            if line.get_color() == "g":
                line.set_color("#d95f0e")

        ax = plt.axes([0.11, 0.05, 0.84, 0.3])
        utils.plot_ts_panel(ax, [oak_sos, sos_uk],
                            "-",
                            "phenological",
                            loc="center left")
        #        ax.text(0.05, 0.85, "(d)", transform=ax.transAxes, fontsize=settings.FONTSIZE)
        ax.set_ylim([66, 132])
        for tick in ax.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
        for tick in ax.yaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
        ax.xaxis.set_major_locator(majorLocator)

        fig.text(0.02,
                 0.97,
                 "(b)",
                 transform=ax.transAxes,
                 fontsize=settings.FONTSIZE)
        fig.text(0.02,
                 0.3,
                 "Day of year",
                 rotation="vertical",
                 fontsize=settings.FONTSIZE)

        plt.savefig(
            settings.IMAGELOC +
            "PHEN_UKtimeseries_{}{}".format(settings.YEAR, settings.OUTFMT))
        plt.close()

    #***********************
    # Lake Boxplot
    if True:

        import pandas as pd

        df = pd.read_csv(DATALOC + "LakeData_forRobert.csv")

        # rename columns
        cols = []
        for col in df.columns:
            if len(col.split()) >= 2:
                df.rename(columns={col: col.split()[0]}, inplace=True)
                cols += [col.split()[0]]

        fig = plt.figure(figsize=(8, 7))
        plt.clf()
        ax = plt.axes([0.1, 0.25, 0.89, 0.74])
        df.boxplot(
            column=cols,
            ax=ax,
            grid=False,
        )

        # messily pull out 2019
        this_year = df.iloc[-1]
        this_year = this_year.to_frame()
        plt.plot(np.arange(11) + 1, this_year[19][1:], "ro")

        for tick in ax.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
            tick.label.set_rotation("vertical")

        for tick in ax.yaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)

        utils.thicken_panel_border(ax)

        plt.ylabel("Day of year", fontsize=settings.FONTSIZE)
        plt.savefig(
            settings.IMAGELOC +
            "PHEN_lakes_boxplot_{}{}".format(settings.YEAR, settings.OUTFMT))
        plt.close()

    return  # run_all_plots
Exemplo n.º 8
0
def run_all_plots():


    # #***********************
    # # Three panel timeseries - UK, DWD, Windermere
    


    # chlorophyll = read_lake_csv(os.path.join(data_loc, "timeseries", "Windermere.csv"))
    # betula_out = read_dwd_betula(os.path.join(data_loc, "timeseries", "dwd-data_per180112_Betula_pendula_leaf_out.csv"))
    # quercus_out, quercus_fall = read_dwd_quercus(os.path.join(data_loc, "timeseries", "dwd-data_per-180112_Quercus robur leave unf.csv"))
    # betula_fall, fagus_out, fagus_fall = read_dwd_fagus(os.path.join(data_loc, "timeseries", "dwd-data_per180112_Fagus sylvatica and Betula pendula leaf data.csv"))

    # alder, chestnut, oak, beech = read_uk_csv(os.path.join(data_loc, "timeseries", "details_for_climate_report.csv"))
    # long_oak = read_uk_oak_csv(os.path.join(data_loc, "timeseries", "NatureCalendar_pedunculate_oak_first_leaf_1753_1999.csv"))

    # fig, (ax1, ax2, ax3) = plt.subplots(3, figsize=(8, 7), sharex=True)

    # # DWD data - budburst
    # utils.plot_ts_panel(ax1, [betula_out, fagus_out, quercus_out], "-", "phenological", loc="")

    # lines, labels = ax1.get_legend_handles_labels()
    # newlabels = []
    # for ll in labels:
    #     newlabels += [r'${}$'.format(ll)]
    # ax1.legend(lines, newlabels, loc="lower left", ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, labelspacing=0.1, columnspacing=0.5)
    # ax4 = plt.axes([0.84, 0.84, 0.15, 0.15])  
    # img = mpimg.imread(os.path.join(data_loc, 'DWD_oak_leaf.jpg'))
    # ax4.imshow(img)
    # ax4.set_xticks([])
    # ax4.set_yticks([])
    

    # # UK data - budburst
    # utils.plot_ts_panel(ax2, [alder, chestnut, beech, long_oak, oak], "-", "phenological", loc="")
    # ax2.plot(long_oak.times, long_oak.data, ls=None, marker="o", c=settings.COLOURS["phenological"][long_oak.name], markeredgecolor=settings.COLOURS["phenological"][long_oak.name])
    # lines, labels = ax2.get_legend_handles_labels()
    # newlabels = []
    # for ll in labels:
    #     newlabels += [r'${}$'.format(ll)]
    # ax2.legend(lines, newlabels, loc="lower left", ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, labelspacing=0.1, columnspacing=0.5)
    # ax5 = plt.axes([0.84, 0.54, 0.15, 0.15])  
    # img = mpimg.imread(os.path.join(data_loc, '61d1c433-b65c-47bc-b831-7e44ab74a895.jpg'))
    # ax5.imshow(img)
    # ax5.set_xticks([])
    # ax5.set_yticks([])

    # # Windermere
    # utils.plot_ts_panel(ax3, [chlorophyll], "-", "phenological", loc="lower left")
    # ax6 = plt.axes([0.84, 0.23, 0.15, 0.15])  
    # img = mpimg.imread(os.path.join(data_loc, 'Asterionella and aulacoseira 05 May 2017.jpg'))
    # ax6.imshow(img)
    # ax6.set_xticks([])
    # ax6.set_yticks([])

    # # prettify
    # ax1.set_ylim([70, 160])
    # ax2.set_ylim([70, 160])
    # ax3.set_ylim([70, 160])

    # ax2.set_ylabel("Day of year", fontsize=settings.FONTSIZE)

    # ax1.text(0.02, 0.88, "(a) Germany - tree leaf unfurling", transform=ax1.transAxes, fontsize=settings.FONTSIZE)
    # ax2.text(0.02, 0.88, "(b) UK - tree bud burst & leaf out", transform=ax2.transAxes, fontsize=settings.FONTSIZE)
    # ax3.text(0.02, 0.88, "(c) UK - Windermere - plankton", transform=ax3.transAxes, fontsize=settings.FONTSIZE)

    # for tick in ax3.xaxis.get_major_ticks():
    #     tick.label.set_fontsize(settings.FONTSIZE) 

    # minorLocator = MultipleLocator(100)
    # for ax in [ax1, ax2, ax3]:
    #     utils.thicken_panel_border(ax)
    #     ax.set_yticks(ax.get_yticks()[1:-1])
    #     ax.xaxis.set_minor_locator(minorLocator)
    #     for tick in ax.yaxis.get_major_ticks():
    #         tick.label.set_fontsize(settings.FONTSIZE) 

    # ax1.set_xlim([1950, 2020])

    # plt.setp([a.get_xticklabels() for a in [ax1, ax2]], visible=False)
    # fig.subplots_adjust(right=0.95, top=0.95, bottom=0.05, hspace=0.001)

    # plt.savefig(image_loc+"PHEN_tree_ts{}".format(settings.OUTFMT))
    # plt.close()


    # #***********************
    # # Barlett start/end timeseries - image inset
    # #   Hand-copied data from "Bartlett Gcc Transition Dates 2008-2017.xlsx"

    # # up, down, diff = read_bartlett_green(os.path.join(data_loc, "timeseries", "Bartlett_greenupdown.dat"))

    # # fig = plt.figure(figsize = (8, 9))
    # # plt.clf()

    # # # make axes by hand
    # # ax1 = plt.axes([0.15,0.3,0.8,0.65])
    # # ax2 = plt.axes([0.15,0.1,0.8,0.2], sharex = ax1)
    
    # # print "need inset axes for images"

    # # # plot data
    # # ax1.plot(up.times, up.data, c = "g", ls = "-", lw = 2, label = "Green up")
    # # ax1.plot(down.times, down.data, c = "brown", ls = "-", lw = 2, label = "Green down")
    # # ax1.fill_between(up.times, up.data, down.data, color = "0.75")

    # # ax2.plot(diff.times, diff.data, c = "c", ls = "-", lw = 2)

    # # ax1.legend(loc="upper right", ncol = 1, frameon = False, prop = {'size':settings.LEGEND_FONTSIZE}, labelspacing = 0.1, columnspacing = 0.5)

    # # # sort axes
    # # ax1.set_xlim([2008, 2018])
    # # ax2.set_ylim([140,180])
    # # ax1.text(0.02, 0.93, "(a) Bartlett seasons", transform = ax1.transAxes, fontsize = settings.FONTSIZE)
    # # ax2.text(0.02, 0.85, "(b) Difference", transform = ax2.transAxes, fontsize = settings.FONTSIZE)

    # # # prettify
    # # ax1.set_ylabel("Day of Year", fontsize = settings.FONTSIZE)
    # # ax2.set_ylabel("Days", fontsize = settings.FONTSIZE)
    # # minorLocator = MultipleLocator(100)
    # # for ax in [ax1, ax2]:
    # #     utils.thicken_panel_border(ax)
    # #     ax.set_yticks(ax.get_yticks()[1:-1])
    # #     ax.xaxis.set_minor_locator(minorLocator)
    # #     for tick in ax.yaxis.get_major_ticks():
    # #         tick.label.set_fontsize(settings.FONTSIZE) 
    # #     for tick in ax.xaxis.get_major_ticks():
    # #         tick.label.set_fontsize(settings.FONTSIZE) 

    # # plt.setp(ax1.get_xticklabels(), visible=False)

    # # plt.savefig(image_loc+"PHEN_bartlett_ts{}".format(settings.OUTFMT))
    # # plt.close()

    # #***********************
    # # Barlett start/end timeseries - image inset
    # #   Hand-copied data from "Bartlett Gcc Transition Dates 2008-2017.xlsx"
    # #   https://matplotlib.org/examples/pylab_examples/broken_axis.html

    # up, down, diff = read_bartlett_green(os.path.join(data_loc, "timeseries", "Bartlett_greenupdown.dat"))

    # fig, (ax1, ax2, ax3) = plt.subplots(3, figsize=(8, 9), sharex=True)

    # print("need inset axes for images")

    # # plot same on both
    # ax1.plot(up.times, up.data, c="g", ls="-", lw=2, label="Green up", marker="o")
    # ax1.plot(down.times, down.data, c="brown", ls="-", lw=2, label="Green down", marker="o")
    # ax1.fill_between(up.times, up.data, down.data, color="lightgreen")

    # ax2.plot(up.times, up.data, c="g", ls="-", lw=2, marker="o")
    # ax2.plot(down.times, down.data, c="brown", ls="-", lw=2, marker="o")
    # ax2.fill_between(up.times, up.data, down.data, color="lightgreen")

    # ax1.invert_yaxis()
    # ax2.invert_yaxis()

    # # hide the spines between ax and ax2
    # ax1.spines['bottom'].set_visible(False)
    # ax2.spines['top'].set_visible(False)
    # ax1.xaxis.tick_top()
    # ax1.tick_params(labeltop='off')  # don't put tick labels at the top
    # ax2.xaxis.tick_bottom()

    # # and the difference
    # ax3.plot(diff.times, diff.data, c="c", ls="-", lw=2, marker="o")

    # # plot the legend
    # ax1.legend(loc="upper right", ncol=1, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, labelspacing=0.1, columnspacing=0.5)
    
    # # prettify
    # ax1.set_xlim([2007, int(settings.YEAR)+1])
    # ax2.set_ylabel("Day of Year", fontsize=settings.FONTSIZE)
    # ax3.set_ylabel("Days", fontsize=settings.FONTSIZE)
    # ax1.text(0.02, 0.88, "(a) Bartlett seasons", transform=ax1.transAxes, fontsize=settings.FONTSIZE)
    # ax3.text(0.02, 0.85, "(b) Difference", transform=ax3.transAxes, fontsize=settings.FONTSIZE)

    # # zoom in
    # ax1.set_ylim([150, 100])
    # ax2.set_ylim([300, 250])
    # ax3.set_ylim([136, 179])

    # minorLocator = MultipleLocator(100)
    # for ax in [ax1, ax2, ax3]:
    #     utils.thicken_panel_border(ax)
    #     ax.set_yticks(ax.get_yticks()[1:-1])
    #     ax.xaxis.set_minor_locator(minorLocator)
    #     for tick in ax.yaxis.get_major_ticks():
    #         tick.label.set_fontsize(settings.FONTSIZE) 
    #     for tick in ax.xaxis.get_major_ticks():
    #         tick.label.set_fontsize(settings.FONTSIZE) 

    # plt.setp(ax1.get_xticklabels(), visible=False)
    # fig.subplots_adjust(right=0.95, top=0.95, hspace=0.001)


    # plt.savefig(image_loc+"PHEN_bartlett_ts_gap{}".format(settings.OUTFMT))
    # plt.close()

    # #***********************
    # # Bartlett GPP & Duke separate

    # fig = plt.figure(figsize=(8, 6.5))
    # plt.clf()
    # ax1 = plt.axes([0.12, 0.52, 0.78, 0.44])
    # ax2 = ax1.twinx()
    # ax3 = plt.axes([0.12, 0.08, 0.78, 0.44], sharex=ax1)
    
    # gpp, gcc = read_bartlett_gpp(os.path.join(data_loc, "timeseries", "Bartlett GPP Flux and Canopy Greenness.csv"))


    # bartlett, duke = read_bartlett_duke(os.path.join(data_loc, "timeseries", "Bartlett 2008-2017 and Duke 2017 Camera Greenness.csv"))

    # utils.plot_ts_panel(ax1, [gcc], "-", "phenological", loc="")
    # utils.plot_ts_panel(ax2, [gpp], "-", "phenological", loc="")
    # utils.plot_ts_panel(ax3, [bartlett, duke], "-", "phenological", loc="upper right", ncol=1)
    # ax3.axhline(0.36, c='0.5', ls='--')
    # ax3.axvline(185, c='0.5', ls=":")
    
    
    # # fix the legend
    # lines1, labels1 = ax1.get_legend_handles_labels()
    # lines2, labels2 = ax2.get_legend_handles_labels()
    # ax2.legend(lines1 + lines2, labels1 + labels2, loc="upper right", ncol=1, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, labelspacing=0.1, columnspacing=0.5)

    # # prettify
    # ax2.yaxis.set_label_position("right")
    # ax2.yaxis.set_ticks_position('right')

    # ax1.set_ylim([0.34, 0.48])
    # ax3.set_ylim([0.34, 0.48])
    # ax2.set_ylim([-2, 12])

    # ax1.set_ylabel("Canopy Greeness", fontsize=settings.FONTSIZE)
    # ax2.set_ylabel("Gross Primary Productivity", fontsize=settings.FONTSIZE)
    # ax3.set_ylabel("Canopy Greeness", fontsize=settings.FONTSIZE)

    # ax1.text(0.02, 0.88, "(c)", transform=ax1.transAxes, fontsize=settings.FONTSIZE)
    # ax3.text(0.02, 0.85, "(d)", transform=ax3.transAxes, fontsize=settings.FONTSIZE)

    # for tick in ax3.xaxis.get_major_ticks():
    #     tick.label.set_fontsize(settings.FONTSIZE) 

    # minorLocator = MultipleLocator(100)
    # for ax in [ax1, ax3]:
    #     utils.thicken_panel_border(ax)
    #     ax.set_yticks(ax.get_yticks()[1:-1])
    #     ax.xaxis.set_minor_locator(minorLocator)
    #     for tick in ax.yaxis.get_major_ticks():
    #         tick.label.set_fontsize(settings.FONTSIZE) 

    # utils.thicken_panel_border(ax2)
    # ax2.set_yticks(ax2.get_yticks()[1:-1])
    # for tick in ax2.yaxis.get_major_ticks():
    #     tick.label2.set_fontsize(settings.FONTSIZE)
    
    # plt.setp(ax1.get_xticklabels(), visible=False)
    # plt.setp(ax2.get_xticklabels(), visible=False)
    # fig.subplots_adjust(right=0.95, top=0.95, hspace=0.001)

    # ax4 = plt.axes([0.14, 0.65, 0.15, 0.15])  
    # img = mpimg.imread(os.path.join(data_loc, 'bbc7_2017_01_20_140005.jpg'))
    # ax4.imshow(img)
    # ax4.set_xticks([])
    # ax4.set_yticks([])
    # ax4.set_title("January")
    # ax5 = plt.axes([0.72, 0.65, 0.15, 0.15])  
    # img = mpimg.imread(os.path.join(data_loc, 'bbc7_2017_07_17_130005.jpg'))
    # ax5.imshow(img)
    # ax5.set_xticks([])
    # ax5.set_yticks([])
    # ax5.set_title("July")

    # ax6 = plt.axes([0.14, 0.25, 0.15, 0.15])  
    # img = mpimg.imread(os.path.join(data_loc, 'bbc7_2017_07_04_124505.jpg'))
    # ax6.imshow(img)
    # ax6.set_xticks([])
    # ax6.set_yticks([])
    # ax6.set_title("Bartlett")
    # ax7 = plt.axes([0.72, 0.25, 0.15, 0.15])  
    # img = mpimg.imread(os.path.join(data_loc, 'dukehw_2017_07_04_120110.jpg'))
    # ax7.imshow(img)
    # ax7.set_xticks([])
    # ax7.set_yticks([])
    # ax7.set_title("Duke")


    # plt.savefig(image_loc+"PHEN_Bartlett_GPP_Duke_separate{}".format(settings.OUTFMT))
    # plt.close()

    # #***********************
    # # Bartlett GPP & Duke combined

    # # fig = plt.figure(figsize = (8, 5))
    # # plt.clf()
    # # ax1 = plt.axes([0.12, 0.1, 0.78, 0.8])
    # # ax2 = ax1.twinx()
    
    # # gpp, gcc = read_bartlett_gpp(os.path.join(data_loc, "timeseries", "Bartlett GPP Flux and Canopy Greenness.csv"))

    # # bartlett, duke = read_bartlett_duke(os.path.join(data_loc, "timeseries", "Bartlett 2008-2017 and Duke 2017 Camera Greenness.csv"))

    # # utils.plot_ts_panel(ax1, [gcc, duke], "-", "phenological", loc = "")
    # # utils.plot_ts_panel(ax2, [gpp], "-", "phenological", loc = "")
    
    # # # fix the legend
    # # lines1, labels1 = ax1.get_legend_handles_labels()
    # # lines2, labels2 = ax2.get_legend_handles_labels()
    # # # have to remove duplicate label
    # # ax2.legend(lines1 + lines2, labels1 + labels2, loc="upper right", ncol = 1, frameon = False, prop = {'size':settings.LEGEND_FONTSIZE}, labelspacing = 0.1, columnspacing = 0.5)

    # # # prettify
    # # ax2.yaxis.set_label_position("right")

    # # ax1.set_ylim([0.34, 0.48])
    # # ax2.set_ylim([-2, 12])

    # # ax1.set_ylabel("Canopy Greeness", fontsize = settings.FONTSIZE)
    # # ax2.set_ylabel("Gross Primary Productivity", fontsize = settings.FONTSIZE)
 
    # # for tick in ax1.xaxis.get_major_ticks():
    # #     tick.label.set_fontsize(settings.FONTSIZE) 

    # # minorLocator = MultipleLocator(100)
    # # for ax in [ax1, ax3]:
    # #     utils.thicken_panel_border(ax)
    # #     ax.set_yticks(ax.get_yticks()[1:])
    # #     ax.xaxis.set_minor_locator(minorLocator)
    # #     for tick in ax.yaxis.get_major_ticks():
    # #         tick.label.set_fontsize(settings.FONTSIZE) 

    # # utils.thicken_panel_border(ax2)
    # # ax2.set_yticks(ax2.get_yticks()[1:-1])
    # # for tick in ax2.yaxis.get_major_ticks():
    # #     tick.label2.set_fontsize(settings.FONTSIZE)
    
    # # fig.subplots_adjust(right = 0.95, top = 0.95, hspace = 0.001)

    # # plt.savefig(image_loc+"PHEN_Bartlett_GPP_Duke_combined{}".format(settings.OUTFMT))
    # # plt.close()

    # #***********************
    # # UK Map
    # import cartopy.feature as cfeature
    # land_50m = cfeature.NaturalEarthFeature('physical', 'land', '50m',
    #                                         edgecolor='face',
    #                                         facecolor=cfeature.COLORS['land'])
 
    # species, days, lats, lons = read_uk_map_csv(os.path.join(data_loc, "timeseries", "UK_Leafout_4Trees.csv"))
    
    # cmap = plt.cm.YlGn
    # bounds = np.arange(80, 160, 10)
    # norm = mpl.cm.colors.BoundaryNorm(bounds, cmap.N)

    # fig = plt.figure(figsize=(8, 10.5))
    # plt.clf()
    # ax = plt.axes([0.05, 0.05, 0.9, 0.9], projection=cartopy.crs.LambertConformal(central_longitude=-7.5))

    # ax.gridlines() #draw_labels=True)
    # ax.add_feature(land_50m, zorder=0, facecolor="0.9", edgecolor="k")
    # ax.set_extent([-10, 4, 48, 60], cartopy.crs.PlateCarree())

    # scat = ax.scatter(lons, lats, c=days, transform=cartopy.crs.PlateCarree(), cmap=cmap, norm=norm, s=25, edgecolor='0.5', linewidth='0.5', zorder=10)

    # utils.thicken_panel_border(ax)

    # cb = plt.colorbar(scat, orientation='horizontal', ticks=bounds[1:-1], label="Day of year", drawedges=True, fraction=0.1, pad=0.05, aspect=15, shrink=0.8)

    # # prettify
    # cb.set_ticklabels(["{:g}".format(b) for b in bounds[1:-1]])
    # cb.outline.set_linewidth(2)
    # cb.dividers.set_color('k')
    # cb.dividers.set_linewidth(2)

    # plt.savefig(image_loc + "PHEN_UK_map{}".format(settings.OUTFMT))
    # plt.close()


    #***********************
    # MODIS

    cubelist = iris.load(os.path.join(data_loc, "MODIS.CMG.{}.SOS.EOS.Anomaly.nc".format(settings.YEAR)))

    for c, cube in enumerate(cubelist):
        if cube.name() == "EOS":
            eos_cube = cubelist[c]
        elif cube.name() == "SOS":
            sos_cube = cubelist[c]
        elif cube.name() == "MAX":
            max_cube = cubelist[c]
       
    # deal with NANS
#    eos_cube.data = np.ma.masked_where(eos_cube.data != eos_cube.data, eos_cube.data)
    sos_cube.data = np.ma.masked_where(sos_cube.data != sos_cube.data, sos_cube.data)
#    max_cube.data = np.ma.masked_where(max_cube.data != max_cube.data, max_cube.data)


            
    # set up a 1 x 2 set of axes (2018 only needs one panel)
    fig = plt.figure(figsize=(8, 8))
    plt.clf()

    # set up plot settings
    BOUNDS = [[-100, -20, -10, -5, -2, 0, 2, 5, 10, 20, 100]]#, [-100, -20, -10, -5, -2, 0, 2, 5, 10, 20, 100]]
    CMAPS = [settings.COLOURMAP_DICT["phenological_r"]]#, settings.COLOURMAP_DICT["phenological"]]

    CUBES = [sos_cube]# eos_cube]
    LABELS = ["(a) Start of Season (SOS)"]#, "(b) End of Season (EOS)"]

    # boundary circle
    theta = np.linspace(0, 2*np.pi, 100)
    center, radius = [0.5, 0.5], 0.5
    verts = np.vstack([np.sin(theta), np.cos(theta)]).T
    circle = mpath.Path(verts * radius + center)

    # spin through axes
    for a in range(1):  

        ax = plt.subplot(1, 1, a+1, projection=cartopy.crs.NorthPolarStereo())

        plot_cube = CUBES[a]

        if settings.OUTFMT in [".eps", ".pdf"]:
            if plot_cube.coord("latitude").points.shape[0] > 90 or plot_cube.coord("longitude").points.shape[0] > 360:
                regrid_size = 1.0
                print("Regridding cube for {} output to {} degree resolution".format(settings.OUTFMT, regrid_size))
                print("Old Shape {}".format(plot_cube.data.shape))
                plot_cube = utils.regrid_cube(plot_cube, regrid_size, regrid_size)
                print("New Shape {}".format(plot_cube.data.shape))

        ax.gridlines() #draw_labels=True)
        ax.add_feature(cartopy.feature.LAND, zorder=0, facecolor="0.9", edgecolor="k")
        ax.coastlines()
        ax.set_boundary(circle, transform=ax.transAxes)
        ax.set_extent([-180, 180, 45, 90], cartopy.crs.PlateCarree())

        ext = ax.get_extent() # save the original extent

        cmap = CMAPS[a]
        norm = mpl.cm.colors.BoundaryNorm(BOUNDS[a], cmap.N)
        mesh = iris.plot.pcolormesh(plot_cube, cmap=cmap, norm=norm, axes=ax)

        ax.set_extent(ext, ax.projection) # fix the extent change from colormesh
        ax.text(-0.1, 1.0, LABELS[a], fontsize=settings.FONTSIZE * 0.8, transform=ax.transAxes)

        cb = plt.colorbar(mesh, orientation='horizontal', ticks=BOUNDS[a][1:-1], label="Anomaly (days)", drawedges=True, fraction=0.1, pad=0.05, aspect=15, shrink=0.8)
        # prettify
        cb.set_ticklabels(["{:g}".format(b) for b in BOUNDS[a][1:-1]])
        cb.outline.set_linewidth(2)
        cb.dividers.set_color('k')
        cb.dividers.set_linewidth(2)

        ax.set_extent([-180, 180, 45, 90], cartopy.crs.PlateCarree())

    fig.subplots_adjust(bottom=0.05, top=0.95, left=0.04, right=0.95, wspace=0.02)

    plt.title("")

    plt.savefig(image_loc + "PHEN_modis_polar{}".format(settings.OUTFMT))
    plt.close()

    del eos_cube
    del sos_cube
    del cubelist

    #***********************
    # MODIS LAI
    # max_cube.data = np.ma.masked_where(max_cube.data <= -9000, max_cube.data)
    # if settings.OUTFMT in [".eps", ".pdf"]:
    #     if max_cube.coord("latitude").points.shape[0] > 180 or max_cube.coord("longitude").points.shape[0] > 360:
    #         regrid_size = 1.0
    #         print("Regridding cube for {} output to {} degree resolution".format(settings.OUTFMT, regrid_size))
    #         print("Old Shape {}".format(max_cube.data.shape))
    #         max_cube = utils.regrid_cube(max_cube, regrid_size, regrid_size)
    #         print("New Shape {}".format(max_cube.data.shape))

    # fig = plt.figure(figsize=(8, 8))
    # plt.clf()
    # ax = plt.axes([0.05, 0.05, 0.9, 0.9], projection=cartopy.crs.NorthPolarStereo())

    # ax.gridlines() #draw_labels=True)
    # ax.add_feature(cartopy.feature.LAND, zorder=0, facecolor="0.9", edgecolor="k")
    # ax.coastlines()
    # ax.set_boundary(circle, transform=ax.transAxes)
    # ax.set_extent([-180, 180, 45, 90], cartopy.crs.PlateCarree())

    # ext = ax.get_extent() # save the original extent

    # cmap = settings.COLOURMAP_DICT["phenological_r"]
    # bounds = [-100, -5, -3, -2, -1, 0, 1, 2, 3, 5, 100]
    # norm = mpl.cm.colors.BoundaryNorm(bounds, cmap.N)
    # mesh = iris.plot.pcolormesh(max_cube, cmap=cmap, norm=norm, axes=ax)

    # ax.set_extent(ext, ax.projection) # fix the extent change from colormesh
    # ax.text(-0.1, 1.0, "Max Leaf Area Index", fontsize=settings.FONTSIZE * 0.8, transform=ax.transAxes)

    # cb = plt.colorbar(mesh, orientation='horizontal', ticks=bounds[1:-1], label="Anomaly (m"+r'$^2'+"/m"+r'$^2'+")", drawedges=True, fraction=0.1, pad=0.05, aspect=15, shrink=0.8)
    # # prettify
    # cb.set_ticklabels(["{:g}".format(b) for b in bounds[1:-1]])
    # cb.outline.set_linewidth(2)
    # cb.dividers.set_color('k')
    # cb.dividers.set_linewidth(2)

    # ax.set_extent([-180, 180, 45, 90], cartopy.crs.PlateCarree())

    # plt.savefig(image_loc + "PHEN_modis_lai{}".format(settings.OUTFMT))
    # plt.close()

    #***********************
    # MODIS timeseries - 2017

    # sos, eos, lai = read_modis_ts(os.path.join(data_loc, "MODIS.CMG.{}.SOS.EOS.MAX.AnomalyTS.csv".format(settings.YEAR)))


    # plt.clf()

    # fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 4), sharex=True)
    
    # # plot same on both
    # ax1.plot(sos.times, sos.data, c="g", ls="-", lw=2, label="Start of Season", marker="o")
    # ax1.plot(eos.times, eos.data, c="brown", ls="-", lw=2, label="End of Season", marker="o")
    # ax1.fill_between(eos.times, eos.data, sos.data, color="lightgreen")

    # ax2.plot(sos.times, sos.data, c="g", ls="-", lw=2, marker="o")
    # ax2.plot(eos.times, eos.data, c="brown", ls="-", lw=2, marker="o")
    # ax2.fill_between(eos.times, eos.data, sos.data, color="lightgreen")

    # # invert so green down is on the bottom
    # ax1.invert_yaxis()
    # ax2.invert_yaxis()

    # # hide the spines between ax and ax2
    # ax1.spines['bottom'].set_visible(False)
    # ax2.spines['top'].set_visible(False)
    # ax1.xaxis.tick_top()
    # ax1.tick_params(labeltop='off')  # don't put tick labels at the top
    # ax2.xaxis.tick_bottom()

    # # plot the legend
    # ax1.legend(loc="upper right", ncol=1, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, labelspacing=0.1, columnspacing=0.5)
    
    # # prettify
    # ax1.set_xlim([1999, 2018])
    # ax2.set_ylabel("Day of Year", fontsize=settings.FONTSIZE)

    # # zoom in
    # ax1.set_ylim([160, 110])
    # ax2.set_ylim([300, 250])

    # # set label
    # ax1.text(-0.1, 0.92, "(c)", transform=ax1.transAxes, fontsize=settings.FONTSIZE)

    # minorLocator = MultipleLocator(100)
    # for ax in [ax1, ax2]:
    #     utils.thicken_panel_border(ax)
    #     ax.set_yticks(ax.get_yticks()[1:-1])
    #     ax.xaxis.set_minor_locator(minorLocator)
    #     for tick in ax.yaxis.get_major_ticks():
    #         tick.label.set_fontsize(settings.FONTSIZE) 
    #     for tick in ax.xaxis.get_major_ticks():
    #         tick.label.set_fontsize(settings.FONTSIZE) 

    # plt.setp(ax1.get_xticklabels(), visible=False)
    # fig.subplots_adjust(right=0.95, top=0.95, hspace=0.001)

    # plt.savefig(image_loc+"PHEN_modis_ts{}".format(settings.OUTFMT))
    # plt.close()

    #***********************
    # MODIS timeseries - 2018
    
    sos_na, sos_ea, sprt_na, sprt_ea = read_modis_ts(os.path.join(data_loc, "MODIS.CMG.{}.SOS.EOS.SPRT.FALT.TS.csv".format(settings.YEAR)))

    dummy, sos_na = utils.calculate_climatology_and_anomalies_1d(sos_na, 2000, 2010)
    dummy, sos_ea = utils.calculate_climatology_and_anomalies_1d(sos_ea, 2000, 2010)

    fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 6.5), sharex=True)

    # North America
    # use un-anomalised spring T to get legend without the data
    utils.plot_ts_panel(ax1, [sos_na, sprt_na], "-", "phenological", loc=LEGEND_LOC)   

    # Eurasia
    utils.plot_ts_panel(ax2, [sos_ea, sprt_ea], "-", "phenological", loc=LEGEND_LOC)

    # make twin axes for Spring T
    dummy, sprt_na = utils.calculate_climatology_and_anomalies_1d(sprt_na, 2000, 2010)
    dummy, sprt_ea = utils.calculate_climatology_and_anomalies_1d(sprt_ea, 2000, 2010)

    ax3 = ax1.twinx()
    utils.plot_ts_panel(ax3, [sprt_na], "-", "phenological", loc="")   

    ax4 = ax2.twinx()
    utils.plot_ts_panel(ax4, [sprt_ea], "-", "phenological", loc="")   

    # prettify
    ax1.set_ylim([-8, 8])
    ax2.set_ylim([-8, 8])
    ax3.set_ylim([2, -2])
    ax4.set_ylim([2, -2])

    # labels
    ax1.text(0.02, 0.88, "(a) North America", transform=ax1.transAxes, fontsize=settings.FONTSIZE)
    ax2.text(0.02, 0.88, "(b) Eurasia", transform=ax2.transAxes, fontsize=settings.FONTSIZE)

    ax1.text(0.47, 0.88, "2018 SOS Anomaly = 1.86 days", transform=ax1.transAxes, fontsize=settings.FONTSIZE*0.8)
    ax1.text(0.47, 0.78, "2018 Spring T anomaly = -0.75 "+r'$^{\circ}$'+"C", transform=ax1.transAxes, fontsize=settings.FONTSIZE*0.8)
    ax2.text(0.47, 0.88, "2018 SOS Anomaly = 2.01 days", transform=ax2.transAxes, fontsize=settings.FONTSIZE*0.8)
    ax2.text(0.47, 0.78, "2018 Spring T anomaly = 0.13 "+r'$^{\circ}$'+"C", transform=ax2.transAxes, fontsize=settings.FONTSIZE*0.8)

    fig.text(0.01, 0.5, "SOS Anomaly (days)", va='center', rotation='vertical', fontsize = settings.FONTSIZE)
    fig.text(0.95, 0.5, "Temperature Anomaly ("+r'$^{\circ}$'+"C)", va='center', rotation='vertical', fontsize = settings.FONTSIZE)

    # ticks and labels
    for tick in ax2.xaxis.get_major_ticks():
        tick.label.set_fontsize(settings.FONTSIZE) 

    minorLocator = MultipleLocator(1)
    for ax in [ax1, ax2]:
        utils.thicken_panel_border(ax)
        ax.set_yticks(ax.get_yticks()[1:-1])
        ax.xaxis.set_minor_locator(minorLocator)
        for tick in ax.yaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE) 

    for ax in [ax3, ax4]:
        ax.yaxis.tick_right()
        utils.thicken_panel_border(ax)
        ax.set_yticks(ax.get_yticks()[1:-1])
        ax.xaxis.set_minor_locator(minorLocator)
        for tick in ax.yaxis.get_major_ticks():
            tick.label2.set_fontsize(settings.FONTSIZE) 

    # final settings
    ax1.set_xlim([1999, 2020])

    plt.setp([a.get_xticklabels() for a in [ax1]], visible=False)
    fig.subplots_adjust(left=0.1, right=0.85, top=0.95, bottom=0.05, hspace=0.001)

    plt.savefig(image_loc+"PHEN_modis_ts{}".format(settings.OUTFMT))
    plt.close()



    return # run_all_plots
Exemplo n.º 9
0
def run_all_plots():

    #************************************************************************
    # Precipitation Timeseries
    if False:

        ghcn, gpcc, gpcp, ghcn2, erai, merra2 = read_land(
            DATALOC + "Land_insitu_timeseries-1979.dat")

        fig = plt.figure(figsize=(8, 5))

        ax1 = plt.axes([0.1, 0.1, 0.85, 0.85])

        # Land
        utils.plot_ts_panel(ax1, [ghcn, gpcc, gpcp, ghcn2, erai, merra2],
                            "-",
                            "hydrological",
                            loc=LEGEND_LOC,
                            bbox=BBOX)

        ax1.set_ylim([-60, 100])
        ax1.yaxis.set_ticks([-50, -25, 0, 25, 50, 75, 100])
        ax1.set_ylabel("Anomaly (mm)", fontsize=settings.FONTSIZE)

        for tick in ax1.yaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
        for tick in ax1.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)

        # ax1.text(0.02, 0.9, "(a) Land in Situ", transform=ax1.transAxes, fontsize=settings.LABEL_FONTSIZE)

        plt.savefig(settings.IMAGELOC + "PCP_ts{}".format(settings.OUTFMT))
        plt.close()

    # old 3-panel plot for 2015 report
    if False:
        fig = plt.figure(figsize=(8, 8))

        ax1 = plt.axes([0.11, 0.68, 0.78, 0.3])
        ax2 = plt.axes([0.11, 0.38, 0.78, 0.3], sharex=ax1)
        ax3 = plt.axes([0.11, 0.08, 0.78, 0.3], sharex=ax1)

        # Land
        utils.plot_ts_panel(ax1, [ghcn, gpcc, gpcp, ghcn2, erai, merra2],
                            "-",
                            "hydrological",
                            loc=LEGEND_LOC,
                            bbox=BBOX)

        # Ocean
        ocean_year = read_domain(
            DATALOC + "gpcp_v23_globalocean_ann_1979_2018", "GPCP")

        o_clim, o_anoms = utils.calculate_climatology_and_anomalies_1d(
            ocean_year, 1981, 2010)

        ax2.plot(o_anoms.times,
                 o_anoms.data,
                 c="b",
                 ls="-",
                 label=o_anoms.name,
                 lw=2)

        # Nino and others
        land_year = read_domain(DATALOC + "gpcp_v23_globalland_ann_1979_2018",
                                "GPCP")
        l_clim, l_anoms = utils.calculate_climatology_and_anomalies_1d(
            land_year, 1981, 2010)
        combined_year = read_domain(
            DATALOC + "gpcp_v23_globallandocean_ann_1979_2018", "GPCP")
        c_clim, c_anoms = utils.calculate_climatology_and_anomalies_1d(
            combined_year, 1981, 2010)

        nino = read_domain(DATALOC + "nino34_1979_2018_ann_anomaly",
                           "Nino 3.4")

        ax3.plot(o_anoms.times,
                 o_anoms.data,
                 c="b",
                 ls="-",
                 label="{} Ocean".format(o_anoms.name),
                 lw=2,
                 zorder=10)
        ax3.plot(l_anoms.times,
                 l_anoms.data,
                 c="lime",
                 ls="-",
                 label="{} Land".format(l_anoms.name),
                 lw=2,
                 zorder=10)
        ax3.plot(c_anoms.times,
                 c_anoms.data,
                 c="r",
                 ls="-",
                 label="{} Land + Ocean".format(c_anoms.name),
                 lw=2,
                 zorder=10)
        ax3.plot([1960, 1961], [0, 0], c="k", label="Nino 3.4")

        ax4 = ax3.twinx()
        ax4.plot(nino.times, nino.data, c="k", zorder=1)
        ax4.fill_between(nino.times,
                         nino.data,
                         0,
                         color="0.5",
                         label=nino.name,
                         zorder=1)
        ax4.set_ylim([-1.9, 1.9])

        ax3.patch.set_visible(False)
        ax3.set_zorder(ax4.get_zorder() + 1)

        #*******************
        # prettify
        minorLocator = MultipleLocator(1)
        ax1.set_ylim([-60, 100])
        ax1.yaxis.set_ticks([-50, 0, 50, 100])
        for ax in [ax2, ax3]:
            ax.set_ylim([-50, 50])
            ax.axhline(0, c='0.5', ls='--')
            ax.legend(loc=LEGEND_LOC, ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, \
                              labelspacing=0.1, columnspacing=0.5, bbox_to_anchor=BBOX)
            ax.xaxis.set_minor_locator(minorLocator)
            ax.yaxis.set_ticks_position('left')
            utils.thicken_panel_border(ax)

        ax2.set_ylabel("Anomaly (mm yr" + r'$^{-1}$' + ")",
                       fontsize=settings.FONTSIZE)
        plt.setp(ax1.get_xticklabels(), visible=False)
        plt.setp(ax2.get_xticklabels(), visible=False)

        ax4.set_xlim([1979, int(settings.YEAR) + 1])
        ax4.yaxis.set_label_position("right")
        ax3.yaxis.set_tick_params(right=False)
        utils.thicken_panel_border(ax4)

        for ax in [ax1, ax2, ax3]:
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
        for tick in ax3.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)
        for tick in ax4.yaxis.get_major_ticks():
            tick.label2.set_fontsize(settings.FONTSIZE)

        # sort labelling
        ax1.text(0.02,
                 0.9,
                 "(a) Land in Situ",
                 transform=ax1.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax2.text(0.02,
                 0.9,
                 "(b) Ocean",
                 transform=ax2.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax3.text(0.02,
                 0.9,
                 "(c) Globe",
                 transform=ax3.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)

        plt.savefig(settings.IMAGELOC +
                    "PCP_ts_3panel{}".format(settings.OUTFMT))
        plt.close()

    # 3-panel plot for 2019 report
    if True:
        fig, (ax1, ax2, ax3) = plt.subplots(3, figsize=(8, 8), sharex=True)

        # Land
        ghcn, gpcc, gpcp = read_land(DATALOC +
                                     "Land_insitu_timeseries-1979.dat")
        utils.plot_ts_panel(ax1, [ghcn, gpcc, gpcp],
                            "-",
                            "hydrological",
                            loc=LEGEND_LOC,
                            bbox=BBOX)

        # Ocean
        gpcp = read_ocean(DATALOC + "Ocean_insitu_timeseries-1979.dat")
        utils.plot_ts_panel(ax2, [gpcp],
                            "-",
                            "hydrological",
                            loc="",
                            bbox=BBOX)

        # Globe
        gpcp = read_ocean(DATALOC + "Global_insitu_timeseries-1979.dat")
        utils.plot_ts_panel(ax3, [gpcp],
                            "-",
                            "hydrological",
                            loc="",
                            bbox=BBOX)

        #*******************
        # prettify
        fig.subplots_adjust(right=0.98, bottom=0.08, top=0.98, hspace=0.001)

        minorLocator = MultipleLocator(1)
        ax1.set_ylim([-60, 100])
        ax1.yaxis.set_ticks([-50, 0, 50, 100])
        ax2.set_ylim([-29, 43])
        ax3.set_ylim([-29, 43])
        for ax in [ax1, ax2, ax3]:
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)

        for tick in ax3.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)

        ax2.set_ylabel("Anomaly (mm yr" + r'$^{-1}$' + ")",
                       fontsize=settings.FONTSIZE)

        # sort labelling
        ax1.text(0.02,
                 0.9,
                 "(a) Land in Situ",
                 transform=ax1.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax2.text(0.02,
                 0.9,
                 "(b) Ocean",
                 transform=ax2.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax3.text(0.02,
                 0.9,
                 "(c) Globe",
                 transform=ax3.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)

        plt.savefig(settings.IMAGELOC +
                    "PCP_ts_3panel{}".format(settings.OUTFMT))
        plt.close()

    #************************************************************************
    # GPCP map
    if True:
        cube = read_map(
            DATALOC +
            "GPCP_{}anomaly_base_1981-2000.txt".format(settings.YEAR))
        bounds = [-2000, -400, -300, -200, -100, 0, 100, 200, 300, 400, 2000]

        utils.plot_smooth_map_iris(
            settings.IMAGELOC + "PCP_{}_anoms_gpcp".format(settings.YEAR),
            cube, settings.COLOURMAP_DICT["hydrological"], bounds,
            "Anomalies from 1981-2000 (mm)")
        utils.plot_smooth_map_iris(
            settings.IMAGELOC + "p2.1_PCP_{}_anoms_gpcp".format(settings.YEAR),
            cube,
            settings.COLOURMAP_DICT["hydrological"],
            bounds,
            "Anomalies from 1981-2000 (mm)",
            figtext="(k) Precipitation")

    #************************************************************************
    # GPCP map - Ocean only

    # # Read Oceans
    # print "FIX YEAR"
    # cube = iris.load(DATALOC + "ocean_precipitation_sotc2015.nc", "anomaly_map")[0]

    # # add in the coordinates which haven't been stored sensibly
    # for c, coord in enumerate(["latitude", "longitude"]):
    #     coord_cube = iris.load(DATALOC + "ocean_precipitation_sotc2015.nc", coord)[0]
    #     if c == 0:
    #         iris_coord = iris.coords.DimCoord(coord_cube.data[:,0], standard_name=coord, units='degrees')
    #     elif c == 1:
    #         iris_coord = iris.coords.DimCoord(coord_cube.data[0], standard_name=coord, units='degrees')

    #     cube.add_dim_coord(iris_coord,c)
    #     cube.coord(coord).guess_bounds()

    # bounds=[-2000, -400, -300, -200, -100, 0, 100, 200, 300, 400, 2000]

    # utils.plot_smooth_map_iris(settings.IMAGELOC + "PCP_{}_anoms_gpcp_ocean".format(settings.YEAR), cube, settings.COLOURMAP_DICT["hydrological"], bounds, "Anomalies from 1981-2000 (mm)")

    return  # run_all_plots