Exemple #1
0
def read_map(filename):

    resolution = 2.5

    lats = np.arange(88.75, -88.75 - resolution, -resolution)
    lons = np.arange(-178.75, 178.75 + resolution, resolution)

    data = np.zeros((len(lats), len(lons)))

    lat_ctr = 0
    this_lat = []
    with open(filename, 'r') as infile:

        for ll, line in enumerate(infile):
            for ls in line.split():
                this_lat.append(ls)

            if len(this_lat) == len(lons):
                # read in all for one longitude
                data[lat_ctr, :] = this_lat
                lat_ctr += 1

                this_lat = []

    data = np.ma.masked_where(data <= -99999.99, data)

    cube = utils.make_iris_cube_2d(data, lats, lons, "PCP_anom", "mm")

    return cube
Exemple #2
0
def read_dwd_percentile(filename):
    """
    Read data from .txt file into Iris cube

    :param str filename: file to process

    :returns: cube
    """
    # use header to hard code the final array shapes

    # read in the dat
    indata = np.genfromtxt(filename, dtype=(float))

    longitudes = np.unique(indata[:, 0])
    latitudes = np.unique(indata[:, 1])

    data = np.ma.zeros((latitudes.shape[0], longitudes.shape[0]))
    data.mask = np.ones(data.shape)

    for val in indata:

        yloc, = np.where(longitudes == val[0])
        xloc, = np.where(latitudes == val[1])

        data[xloc[0], yloc[0]] = val[2]

    # mask the missing values
    data = np.ma.masked_where(data <= -99999.99, data)

    cube = utils.make_iris_cube_2d(data, latitudes, longitudes, "R90p", "%")

    return cube  # read_dwd_percentile
Exemple #3
0
def read_maps(filename, name, units, footer=False):

    if footer:
        indata = np.genfromtxt(filename, dtype=(float), skip_footer=2)
    else:
        indata = np.genfromtxt(filename, dtype=(float))

    indata = np.ma.masked_where(indata <= -99.999, indata)

    indata = indata[::-1, :]


    nlat, nlon = indata.shape

    delta_lat = 180./nlat
    delta_lon = 360./nlon
    
    # presume -90 --> 90, -180  --> 180

    LATS = np.arange(-90. + (delta_lat/2.), 90. + (delta_lat/2.), delta_lat)
    LONS = np.arange(-180. + (delta_lon/2.), 180. + (delta_lon/2.), delta_lon)

    cube = utils.make_iris_cube_2d(indata, LATS, LONS, name, units)

    return cube # read_maps
Exemple #4
0
def read_map_data(filename):
    '''
    Read data for maps and convert to cube.  Given as single list files

    :param str filename: file to read

    :returns: cube
    '''

    grace = np.genfromtxt(filename, dtype=(float))

    lats = grace[:, 0]
    lons = grace[:, 1]
    anoms = grace[:, 2]

    longitudes = np.unique(lons)
    latitudes = np.unique(lats)

    data = np.ma.zeros((len(latitudes), len(longitudes)))
    data.mask = np.ones(data.shape)

    for v, val in enumerate(anoms):

        xloc, = np.where(longitudes == lons[v])
        yloc, = np.where(latitudes == lats[v])

        data[yloc[0], xloc[0]] = val

    data = np.ma.masked_where(data == -9999.0, data)

    cube = utils.make_iris_cube_2d(data, latitudes, longitudes, "TWS_anom",
                                   "mm")

    return cube
Exemple #5
0
def read_noaa_mlost(filename, year):
    """
    Read the NOAA MLOST data and returns a cube of the year.

    :param str filename: filename to read
    :param int year: year to extract

    :returns: cube of 1 year of temperature anomalies
    """

    all_mlost = np.genfromtxt(filename, dtype=(float))

    DELTA = 5
    # read from i, j columns to get the size of the array
    longitudes = np.arange(-180 + (DELTA / 2.), 180 + (DELTA / 2.), DELTA)
    latitudes = np.arange(-90 + (DELTA / 2.), 90 + (DELTA / 2.), DELTA)

    # set up a masked data array
    data = np.ma.zeros((len(latitudes), len(longitudes)))
    data.mask = np.ones(data.shape)

    # spin through each line
    for line in all_mlost:
        if line[0] == year:

            lat_loc, = np.where(latitudes == line[1])
            lon_loc, = np.where(longitudes == line[2])

            data[lat_loc, lon_loc] = line[3]
            data.mask[lat_loc, lon_loc] = False

    cube = utils.make_iris_cube_2d(data, latitudes, longitudes, "temperature",
                                   "C")

    return cube  # read_noaa_mlost
Exemple #6
0
def read_map(filename, name, units):
    '''
    Read data for maps and convert to cube.  Given as single list files

    :param str filename: file to read

    :returns: cube
    '''

    indata = np.genfromtxt(filename, dtype=(float), skip_header=1)

    lons = np.arange(-177.5, 177.5 + 5, 5)  # hard coded from header
    lats = np.arange(-57.5, 57.5 + 5, 5)  # hard coded from header
    anoms = indata[:, 1:]

    cube = utils.make_iris_cube_2d(anoms.T, lats, lons, name, units)

    return cube
Exemple #7
0
def read_nasa_giss(filename):
    """
    Read the NASA GISS data and returns a cube of the year.

    :param str filename: filename to read

    :returns: cube of 1 year of temperature anomalies
    """

    all_giss = np.genfromtxt(filename, dtype=(float), skip_header=2)

    # 2 degree, but just in case
    # read from i, j columns to get the size of the array
    latitudes = np.zeros(np.max(all_giss[:, 1]).astype(int))
    longitudes = np.zeros(np.max(all_giss[:, 0]).astype(int))

    # set up a masked data array
    data = np.ma.zeros(
        (np.max(all_giss[:, 1]).astype(int), np.max(all_giss[:,
                                                             0]).astype(int)))
    data.mask = np.ones(data.shape)

    # spin through each line
    for line in all_giss:
        # use the indexing provided
        i = line[1]
        j = line[0]

        data[i - 1, j - 1] = line[4]

        # and read in the coordinates too
        if j == 1:
            longitudes[i - 1] = line[2]
        if i == 1:
            latitudes[j - 1] = line[3]

    # mask the missing data
    data = np.ma.masked_where(data > 1000, data)

    cube = utils.make_iris_cube_2d(data, latitudes, longitudes, "temperature",
                                   "C")

    return cube  # read_nasa_giss
Exemple #8
0
def read_map(data_loc, name):
    '''
    Read the map data

    :param str data_loc: location where to find files
    :param str name: name of measuring platform

    :returns: cube
    '''

    lons = np.genfromtxt(data_loc + "{}_lon_map.aa".format(name),
                         dtype=(float),
                         skip_header=5)
    lats = np.genfromtxt(data_loc + "{}_lat_map.aa".format(name),
                         dtype=(float),
                         skip_header=5)

    data = np.zeros((len(lats), len(lons)))

    this_lat = []
    lon_ctr = 0
    lat_ctr = 0

    with open(data_loc + "{}_{}_anom_map.aa".format(name, settings.YEAR),
              'r') as infile:
        for ll, line in enumerate(infile):
            if ll > 4:  # skip the first 5 lines
                for ls in line.split():
                    this_lat.append(ls)

                if len(this_lat) == len(lons):
                    # read in all for one longitude
                    data[lat_ctr, :] = this_lat
                    lat_ctr += 1

                    this_lat = []

    cube = utils.make_iris_cube_2d(data, lats, lons, "UTH_anom", "%")

    return cube  # read_map
Exemple #9
0
def read_map(filename):
    """
    Read user supplied CSV for GLE for anomaly map
    """

    indata = np.genfromtxt(filename, delimiter=",", dtype=(float), \
                               missing_values="NaN", filling_values=-99.9)

    # 21 Feb 2018 - the missing_value/filling_value doesn't seem to work for some reason
    indata = np.ma.masked_where(indata == -99.9, indata)
    indata = np.ma.masked_where(indata == 0, indata)
    indata = np.ma.masked_where(indata != indata,
                                indata)  # catch any final NaNs

    # from email - 83.5N to 56 S at 0.25 degree resoln
    delta = 0.25
    lats = np.arange(90 - (delta / 2.), -90, -delta)
    lons = np.arange(-180 + (delta / 2.), 180, delta)

    cube = utils.make_iris_cube_2d(indata, lats, lons, "GLE", "mm/yr")

    return cube  # read_map
Exemple #10
0
def read_era5(filename):

    fieldwidths = (7, 7, 7, 7, 7, 7, 7, 7, 7, 7)

    try:
        with open(DATALOC + filename, "r", encoding="latin-1") as infile:

            latitudes = []
            data = []
            for lc, line in enumerate(infile):
                # skip header
                if lc < 2:
                    continue

                sp_line = line.split()
                if sp_line[0] == "latitude":
                    # read in last data
                    if lc > 3:
                        data += [values]

                    latitudes += [float(sp_line[1])]
                    values = []
                else:
                    values += [float(t) for t in parse(line, fieldwidths)]

            # and final one
            data += [values]
            data = np.array(data)
            latitudes = np.array(latitudes)

    except IOError:
        print("{} doesn't exist".format(DATALOC + filename))

    longitudes = np.arange(0, 360, 0.28125)

    cube = utils.make_iris_cube_2d(data, latitudes, longitudes,
                                   "max Precipitation", "mm")

    return cube
Exemple #11
0
def read_data(filename):
    """
    Read data from .txt file into Iris cube

    :param str filename: file to process

    :returns: cube
    """
    # use header to hard code the final array shapes
    longitudes = np.arange(0.625, 360.625, 1.25)
    latitudes = np.arange(-89.5, 90.5, 1.)

    data = np.ma.zeros((latitudes.shape[0], longitudes.shape[0]))

    # read in the dat
    indata = np.genfromtxt(filename, dtype=(float), skip_header=4)

    this_lat = []
    tl = 0
    # process each row, append until have complete latitude band
    for row in indata:
        this_lat += [r for r in row]

        if len(this_lat) == longitudes.shape[0]:
            # copy into final array and reset
            data[tl, :] = this_lat
            tl += 1
            this_lat = []

    # mask the missing values
    data = np.ma.masked_where(data <= -999.000, data)

    cube = utils.make_iris_cube_2d(data, latitudes, longitudes, "SOZ_anom",
                                   "DU")

    return cube  # read_data
Exemple #12
0
def read_data(filename, mdi):
    '''
    Read text format data into data array and return a cube
    Not used in SotC2016

    :param str filename: file to read

    :returns: cube
    '''

    data = np.genfromtxt(filename, dtype=(float))

    nlats = data.shape[0]
    nlons = data.shape[1]

    latitudes = np.arange(90, -90, -180. / nlats)
    longitudes = np.arange(0, 360, 360. / nlons)

    data = np.ma.masked_where(data == mdi, data)

    cube = utils.make_iris_cube_2d(data, latitudes, longitudes, "BOB",
                                   "g C/m2/yr")

    return cube  # read_data
Exemple #13
0
def run_all_plots():
    #************************************************************************
    # Timeseries

    data = read_binary_ts(DATALOC + "TimeSeries_faparanomaliesglobal_bams_v{}_C6_2020.bin".format(int(settings.YEAR)-1))

    fig = plt.figure(figsize=(8, 6))
    ax = plt.axes([0.13, 0.07, 0.8, 0.86])

    COLOURS = settings.COLOURS["land_surface"]

    for dataset in data:
        print(dataset.name)
        ls = "--"
        if dataset.name.split(" ")[-1] == "Smoothed":
            ls = "-"
        ax.plot(dataset.times, dataset.data, c=COLOURS[dataset.name], ls=ls, label=dataset.name, lw=LW)

    ax.axhline(0, c='0.5', ls='--')
    utils.thicken_panel_border(ax)

    ax.legend(loc=LEGEND_LOC, ncol=2, frameon=False, prop={'size':settings.LEGEND_FONTSIZE}, labelspacing=0.1, columnspacing=0.5)

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

    fig.text(0.01, 0.5, "Anomaly (FAPAR)", va='center', rotation='vertical', fontsize=settings.FONTSIZE)

    plt.xlim([1998-1, int(settings.YEAR)+2])
    plt.ylim([-0.022, None])

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

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

    #************************************************************************
    # Hovmullers
    data = read_binary(DATALOC + "Hovmuller_Global_lat_fapar1998_2010_bams_trois_C6.eps_{}.bin".format(int(settings.YEAR)+1))

    # reshape - from Readme
    data = data.reshape(360, DURATION)

    data = np.ma.masked_where(data == 0., data)

    lats = np.arange(-90, 90, 0.5)

    bounds = [-20, -0.04, -0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03, 0.04, 20]
    utils.plot_hovmuller(settings.IMAGELOC + "FPR_hovmuller", times, lats, data, settings.COLOURMAP_DICT["phenological"], bounds, "Anomaly (FAPAR)")


    #************************************************************************
    # Anomalies
    data = read_binary(DATALOC + "DataXFigure1fapar1998_2010_bams_trois_C6_v2.eps_v2020.bin")
    data = data.reshape(360, 720)

    data = np.ma.masked_where(data == -100, data) # land/ocean mask
    data = np.ma.masked_where(data <= -9999., data) # missing data
    data = np.ma.masked_where(np.logical_and(data > -0.001, data < 0.001), data) # missing data

    lons = np.arange(-180, 180, 0.5)
    lats = np.arange(-90, 90, 0.5)

    cube = utils.make_iris_cube_2d(data, lats, lons, "FAPAR", "%")

    bounds = [-20, -0.04, -0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03, 0.04, 20]
    utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_FPR_{}".format(settings.YEAR), cube, settings.COLOURMAP_DICT["phenological"], bounds, "Anomalies from 1998-{} (FAPAR)".format(2010), figtext="(ae) Fraction of Absorbed Photosynthetically Active Radiation")
    utils.plot_smooth_map_iris(settings.IMAGELOC + "FPR_{}".format(settings.YEAR), cube, settings.COLOURMAP_DICT["phenological"], bounds, "Anomalies from 1998-{} (FAPAR)".format(2010))


    return # run_all_plots
Exemple #14
0
def run_all_plots():

    if True:
        #***************
        # Figure 1

        euro, africa, tibet, canada = read_ts(DATALOC +
                                              "BAMS2020Fig1_data_LSWT.csv")
        #        euro_fit, africa_fit, tibet_fit, canada_fit = read_ts(DATALOC + "Fig1_lines_LSWT.csv")

        euro_fit = utils.Timeseries("Lake", [1994, 2020],
                                    [-0.5136, (2020 - 1994) * 0.0386 - 0.5136])
        africa_fit = utils.Timeseries(
            "Lake", [1994, 2020], [0.0204, (2020 - 1994) * 0.0036 + 0.0204])
        tibet_fit = utils.Timeseries("Lake", [1994, 2020],
                                     [0.0878, (2020 - 1994) * 0.0017 + 0.0878])
        canada_fit = utils.Timeseries(
            "Lake", [1994, 2020], [-0.2018, (2020 - 1994) * 0.0223 - 0.2018])

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

        #***************
        # the timeseries
        LEGEND_LOC = ""

        utils.plot_ts_panel(ax1, [euro], "-", "temperature", loc=LEGEND_LOC)
        ax1.plot(euro_fit.times,
                 euro_fit.data,
                 c=settings.COLOURS["temperature"][euro_fit.name],
                 lw=2,
                 ls="--")
        ax1.text(1995, 0.8, "Europe, 127 lakes", fontsize=settings.FONTSIZE)
        utils.plot_ts_panel(ax2, [africa], "-", "temperature", loc=LEGEND_LOC)
        ax2.plot(africa_fit.times,
                 africa_fit.data,
                 c=settings.COLOURS["temperature"][africa_fit.name],
                 lw=2,
                 ls="--")
        ax2.text(1995, 0.8, "Africa, 68 lakes", fontsize=settings.FONTSIZE)
        utils.plot_ts_panel(ax3, [tibet], "-", "temperature", loc=LEGEND_LOC)
        ax3.plot(tibet_fit.times,
                 tibet_fit.data,
                 c=settings.COLOURS["temperature"][tibet_fit.name],
                 lw=2,
                 ls="--")
        ax3.text(1995,
                 0.8,
                 "Tibetan Plateau, 106 lakes",
                 fontsize=settings.FONTSIZE)
        utils.plot_ts_panel(ax4, [canada], "-", "temperature", loc=LEGEND_LOC)
        ax4.plot(canada_fit.times,
                 canada_fit.data,
                 c=settings.COLOURS["temperature"][canada_fit.name],
                 lw=2,
                 ls="--")
        ax4.text(1995, 0.8, "Canada, 244 lakes", fontsize=settings.FONTSIZE)

        # prettify
        for ax in [ax1, ax2, ax3, ax4]:
            ax.axhline(0, c='0.5', ls='--')
            utils.thicken_panel_border(ax)
            ax.set_ylim([-1, 1.2])
            ax.set_xlim([euro.times[0] - 1, int(settings.YEAR) + 1])
            ax.yaxis.set_ticks_position('left')
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
        for tick in ax4.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)

        fig.text(0.01,
                 0.35,
                 "Anomaly from 1996-2016 (" + r'$^\circ$' + "C)",
                 fontsize=settings.FONTSIZE,
                 rotation="vertical")
        fig.subplots_adjust(bottom=0.03, right=0.96, top=0.99, hspace=0.001)

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

        plt.close()

    #***************
    # Anomaly Scatter map
    if True:
        anomalies = read_lakes(DATALOC + "PlateX_data_LSWT.csv")

        bounds = [-8, -2, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2, 8]
        #        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]

        lons = np.arange(-90, 120, 30)
        lats = np.arange(-180, 210, 30)
        dummy = np.ma.zeros((len(lats), len(lons)))
        dummy.mask = np.ones(dummy.shape)

        cube = utils.make_iris_cube_2d(dummy, lats, lons, "blank", "m")

        utils.plot_smooth_map_iris(settings.IMAGELOC + "LKT_anomaly", cube, settings.COLOURMAP_DICT["temperature"], \
                                       bounds, "Anomalies from 1996-2016 ("+r"$^{\circ}$"+"C)", \
                                       scatter=[anomalies[1], anomalies[0], anomalies[2]], figtext="", title="")

        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_LKT_anomaly", cube, settings.COLOURMAP_DICT["temperature"], \
                                       bounds, "Anomalies from 1996-2016 ("+r"$^{\circ}$"+"C)", \
                                       scatter=[anomalies[1], anomalies[0], anomalies[2]], \
                                       figtext="(b) Lake Temperatures", title="")

    #***************
    # Insets Scatter map
    if True:

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

        anomalies = read_lakes(DATALOC + "Fig2_data_LSWT.csv")

        bounds = [-8, -2, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2, 8]
        #        bounds = [-100, -4, -2, -1, -0.5, 0, 0.5, 1, 2, 4, 100]
        cmap = settings.COLOURMAP_DICT["temperature"]
        norm = mpl.cm.colors.BoundaryNorm(bounds, cmap.N)
        this_cmap = copy.copy(cmap)

        # first_cube = iris.load(DATALOC + "amaps_1st_quarter_2018_250km.nc")[0]
        # third_cube = iris.load(DATALOC + "amaps_3rd_quarter_2018_250km.nc")[0]
        # annual_cube = iris.load(DATALOC + "amaps_annual_2018_250km.nc")[0]

        cube = iris.load(DATALOC + "lswt_anom_1979_2019.nc")[0]
        if settings.OUTFMT in [".eps", ".pdf"]:
            if cube.coord("latitude").points.shape[0] > 180 or 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(cube.data.shape))
                plot_cube = utils.regrid_cube(cube, regrid_size, regrid_size)
                print("New Shape {}".format(plot_cube.data.shape))
            else:
                plot_cube = copy.deepcopy(cube)
        else:
            plot_cube = copy.deepcopy(cube)

        # make axes by hand
        axes = ([0.01, 0.55, 0.59,
                 0.41], [0.565, 0.45, 0.47,
                         0.50], [0.01, 0.13, 0.59,
                                 0.41], [0.61, 0.07, 0.38,
                                         0.41], [0.1, 0.1, 0.8, 0.03])

        # Europe
        ax = plt.axes(axes[0], projection=cartopy.crs.PlateCarree())

        ax.gridlines()  #draw_labels=True)
        ax.add_feature(cartopy.feature.LAND,
                       zorder=0,
                       facecolor="0.9",
                       edgecolor="k")
        ax.coastlines(resolution="50m")
        #ax.add_feature(cartopy.feature.BORDERS.with_scale('110m'), linewidth=.5)
        ax.set_extent([-25, 40, 34, 72], cartopy.crs.PlateCarree())

        mesh = iris.plot.pcolormesh(plot_cube,
                                    cmap=this_cmap,
                                    norm=norm,
                                    axes=ax)
        plt.scatter(anomalies[1], anomalies[0], c=anomalies[2], cmap=this_cmap, norm=norm, s=25, \
                                transform=cartopy.crs.Geodetic(), edgecolor='0.1', linewidth=0.5, zorder=10)

        ax.text(0.05,
                1.05,
                "(a) Europe",
                fontsize=settings.FONTSIZE * 0.8,
                transform=ax.transAxes)
        utils.thicken_panel_border(ax)

        # Africa
        ax = plt.axes(axes[1], projection=cartopy.crs.PlateCarree())

        ax.gridlines()  #draw_labels=True)
        ax.add_feature(cartopy.feature.LAND,
                       zorder=0,
                       facecolor="0.9",
                       edgecolor="k")
        ax.coastlines(resolution="50m")
        #ax.add_feature(cartopy.feature.BORDERS.with_scale('110m'), linewidth=.5)
        ax.set_extent([-19, 43, -40, 33], cartopy.crs.PlateCarree())

        # lat_constraint = utils.latConstraint([25, 90])
        # nh_cube = third_cube.extract(lat_constraint)
        # lat_constraint = utils.latConstraint([-90, -25])
        # sh_cube = first_cube.extract(lat_constraint)
        # lat_constraint = utils.latConstraint([-25, 25])
        # trop_cube = annual_cube.extract(lat_constraint)

        # mesh = iris.plot.pcolormesh(nh_cube, cmap=this_cmap, norm=norm, axes=ax)
        # mesh = iris.plot.pcolormesh(trop_cube, cmap=this_cmap, norm=norm, axes=ax)
        # mesh = iris.plot.pcolormesh(sh_cube, cmap=this_cmap, norm=norm, axes=ax)
        mesh = iris.plot.pcolormesh(plot_cube,
                                    cmap=this_cmap,
                                    norm=norm,
                                    axes=ax)

        plt.scatter(anomalies[1], anomalies[0], c=anomalies[2], cmap=this_cmap, norm=norm, s=25, \
                                transform=cartopy.crs.Geodetic(), edgecolor='0.1', linewidth=0.5, zorder=10)

        ax.text(0.05,
                1.05,
                "(b) Africa",
                fontsize=settings.FONTSIZE * 0.8,
                transform=ax.transAxes)
        utils.thicken_panel_border(ax)

        # Canada
        ax = plt.axes(axes[2], projection=cartopy.crs.PlateCarree())

        ax.gridlines()  #draw_labels=True)
        ax.add_feature(cartopy.feature.LAND,
                       zorder=0,
                       facecolor="0.9",
                       edgecolor="k")
        ax.coastlines(resolution="50m")
        #ax.add_feature(cartopy.feature.BORDERS.with_scale('110m'), linewidth=.5)
        ax.set_extent([-140, -55, 42, 82], cartopy.crs.PlateCarree())

        mesh = iris.plot.pcolormesh(plot_cube,
                                    cmap=this_cmap,
                                    norm=norm,
                                    axes=ax)
        plt.scatter(anomalies[1], anomalies[0], c=anomalies[2], cmap=this_cmap, norm=norm, s=25, \
                                transform=cartopy.crs.Geodetic(), edgecolor='0.1', linewidth=0.5, zorder=10)

        ax.text(0.05,
                1.05,
                "(c) Canada",
                fontsize=settings.FONTSIZE * 0.8,
                transform=ax.transAxes)
        utils.thicken_panel_border(ax)

        # Tibet
        ax = plt.axes(axes[3], projection=cartopy.crs.PlateCarree())

        ax.gridlines()  #draw_labels=True)
        ax.add_feature(cartopy.feature.LAND,
                       zorder=0,
                       facecolor="0.9",
                       edgecolor="k")
        ax.coastlines(resolution="50m")
        ax.add_feature(cartopy.feature.BORDERS.with_scale('50m'), linewidth=.5)
        ax.set_extent([78, 102, 28, 39], cartopy.crs.PlateCarree())

        mesh = iris.plot.pcolormesh(plot_cube,
                                    cmap=this_cmap,
                                    norm=norm,
                                    axes=ax)
        plt.scatter(anomalies[1], anomalies[0], c=anomalies[2], cmap=this_cmap, norm=norm, s=25, \
                                transform=cartopy.crs.Geodetic(), edgecolor='0.1', linewidth=0.5, zorder=10)

        ax.text(0.05,
                1.05,
                "(d) Tibetan Plateau",
                fontsize=settings.FONTSIZE * 0.8,
                transform=ax.transAxes)
        utils.thicken_panel_border(ax)

        # colourbar
        cb = plt.colorbar(mesh,
                          cax=plt.axes(axes[4]),
                          orientation='horizontal',
                          ticks=bounds[1:-1],
                          drawedges=True)

        # prettify
        cb.ax.tick_params(axis='x',
                          labelsize=settings.FONTSIZE,
                          direction='in',
                          size=0)
        cb.set_label(label="Anomalies from 1996-2016 (" + r"$^{\circ}$" + "C)",
                     fontsize=settings.FONTSIZE)
        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(settings.IMAGELOC +
                    "LKT_Regions_scatter_map{}".format(settings.OUTFMT))
        plt.close()
Exemple #15
0
def run_all_plots():

    #************************************************************************
    # Timeseries - 2016
    if False:
        grasp, erai, era_presat, merra, jra55 = read_uaw_ts(DATALOC +
                                                            "20N-40N300.nc",
                                                            smooth=True)
        qbo = read_QBO(DATALOC + "qbo_1908_2015_REC_ERA40_ERAINT.txt")

        fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5,
                                                      figsize=(8, 12),
                                                      sharex=True)

        # Observations
        utils.plot_ts_panel(ax1, [grasp],
                            "-",
                            "circulation",
                            loc=LEGEND_LOC,
                            ncol=2,
                            extra_labels=[" (0.02)"])

        # Reanalyses
        utils.plot_ts_panel(
            ax2, [erai, era_presat, jra55, merra],
            "-",
            "circulation",
            loc=LEGEND_LOC,
            ncol=2,
            extra_labels=[" (-0.20)", " (0.33)", " (-0.13)", " (-0.07)"])

        grasp, erai, era_presat, merra, jra55 = read_uaw_ts(DATALOC +
                                                            "10S-10N50.nc",
                                                            smooth=False)

        # Observations
        utils.plot_ts_panel(ax3, [qbo, grasp],
                            "-",
                            "circulation",
                            loc=LEGEND_LOC,
                            ncol=2,
                            extra_labels=["", " (-0.31)"])
        ax3.set_ylabel("Zonal Anomaly (m s" + r'$^{-1}$' + ")",
                       fontsize=settings.FONTSIZE)

        # Reanalyses
        utils.plot_ts_panel(
            ax4, [erai, era_presat, jra55, merra],
            "-",
            "circulation",
            loc=LEGEND_LOC,
            ncol=2,
            extra_labels=[" (-0.33)", " (-0.16)", " (-0.37)", " (0.30)"])

        fig.subplots_adjust(left=0.11, right=0.99, top=0.99, hspace=0.001)

        # turn on 4th axis ticks

        for tick in ax4.get_xticklabels():
            tick.set_visible(True)

        # delete the 5th axis and recreate - to break the sharex link
        fig.delaxes(ax5)
        ax5 = fig.add_subplot(515)
        pos = ax5.get_position()
        new_pos = [pos.x0, pos.y0 - 0.05, pos.width, pos.height]
        ax5.set_position(new_pos)

        # Obs & Reanalyses
        utils.plot_ts_panel(ax5, [grasp, erai, jra55, merra],
                            "-",
                            "circulation",
                            loc=LEGEND_LOC,
                            ncol=2)

        # sort formatting
        for ax in [ax4, ax5]:
            for tick in ax.xaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)

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

        # x + y limit
        ax1.set_xlim([1930, 2017.9])
        ax1.set_ylim([-13, 6])
        ax1.yaxis.set_ticks([-10, -5, 0])
        ax2.set_ylim([-3.8, 3.8])
        ax2.yaxis.set_ticks([-2, 0, 2, 4])
        ax3.set_ylim([-34, 24])
        ax4.set_ylim([-34, 24])
        ax5.set_ylim([-34, 24])

        ax5.set_xlim([2000, 2017.9])

        # sort labelling
        ax1.text(0.02,
                 0.87,
                 "(a) Observations 20" + r'$^\circ$' + " - 40" + r'$^\circ$' +
                 "N 300hPa",
                 transform=ax1.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax2.text(0.02,
                 0.87,
                 "(b) Reanalyses 20" + r'$^\circ$' + " - 40" + r'$^\circ$' +
                 "N 300hPa",
                 transform=ax2.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax3.text(0.02,
                 0.87,
                 "(c) Observations & Reconstructions 10" + r'$^\circ$' +
                 "S - 10" + r'$^\circ$' + "N 50hPa",
                 transform=ax3.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax4.text(0.02,
                 0.87,
                 "(d) Reanalyses 10" + r'$^\circ$' + "S - 10" + r'$^\circ$' +
                 "N 50hPa",
                 transform=ax4.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax5.text(0.02,
                 0.87,
                 "(e) Observations & Reanalyses 10" + r'$^\circ$' + "S - 10" +
                 r'$^\circ$' + "N 50hPa",
                 transform=ax5.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)

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

    #************************************************************************
    # Timeseries - 2018
    if True:
        plt.figure(figsize=(8, 5))
        plt.clf()
        ax = plt.axes([0.12, 0.10, 0.87, 0.87])

        # Globe
        #    grasp, erai, cera, merra, jra55 = read_uaw_ts(DATALOC + "Globe850.nc", annual=True)
        era5, erai, merra, jra55 = read_uaw_ts(DATALOC + "Globe850_v2.nc",
                                               annual=True)
        utils.plot_ts_panel(ax, [merra, erai, era5, jra55], "-", "circulation", \
                            loc=LEGEND_LOC, ncol=2, extra_labels=[" (0.03)", " (0.07)", \
                                                                      " (0.03)", " (0.06)"])

        # sort formatting
        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)

        # x + y limit
        ax.set_xlim([1958, int(settings.YEAR) + 0.9])
        ax.set_ylim([-0.39, 1.0])
        ax.yaxis.set_ticks_position('left')
        ax.set_ylabel("Wind Anomaly (m s" + r'$^{-1}$' + ")",
                      fontsize=settings.LABEL_FONTSIZE)

        # # sort labelling
        ax.text(0.02,
                0.87,
                "Globe 850hPa",
                transform=ax.transAxes,
                fontsize=settings.LABEL_FONTSIZE)

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

    #*******
    # Tropics timeseries
    if False:
        fig = plt.figure(figsize=(8, 5))
        plt.clf()
        ax = plt.axes([0.10, 0.10, 0.87, 0.87])

        # 10N to 10S
        grasp, erai, cera, merra, jra55 = read_uaw_ts(DATALOC + "10S-10N50.nc")
        utils.plot_ts_panel(ax, [merra, erai, jra55, grasp], "-", "circulation",\
                                loc=LEGEND_LOC, ncol=2, extra_labels=[" (0.17)", " (-0.40)", \
                                                                          " (-0.51)", " (-0.30)"])

        # sort formatting
        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)

        # x + y limit
        ax.set_xlim([2000, int(settings.YEAR) + 2])
        ax.set_ylim([-28, 18])
        ax.yaxis.set_ticks_position('left')
        ax.set_ylabel("Wind Anomaly (m s" + r'$^{-1}$' + ")",
                      fontsize=settings.LABEL_FONTSIZE)

        # # sort labelling
        ax.text(0.02, 0.87, "10"+r'$^\circ$'+"S - 10"+r'$^\circ$'+"N 50hPa", \
                    transform=ax.transAxes, fontsize=settings.LABEL_FONTSIZE)

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

    #************************************************************************
    # Global Map - ERA5 Anomaly figure
    if True:
        # Read in ERA5 anomalies

        # IRIS doesn't like the Conventions attribute
        ncfile = ncdf.Dataset(DATALOC + "ERA5_850_u.nc", 'r')

        var = ncfile.variables["u"][:]  # this is a masked array
        lons = ncfile.variables["longitude"][:]
        lats = ncfile.variables["latitude"][:]

        ncfile.close()

        # monthly data, so take mean
        print("not complete year used in 2019")
        mean = np.mean(var[7:], axis=0)

        cube = utils.make_iris_cube_2d(mean, lats, lons, "UAW_ANOM", "m/s")

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

        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_UAW_{}_anoms_era5".format(settings.YEAR), \
                                       cube, settings.COLOURMAP_DICT["circulation"], bounds, \
                                       "Anomalies from 1981-2010 (m s"+r'$^{-1}$'+")", \
                                       figtext="(w) Upper Air (850-hPa) Eastward Winds (ASOND)")
        utils.plot_smooth_map_iris(settings.IMAGELOC + "UAW_{}_anoms_era5".format(settings.YEAR), \
                                       cube, settings.COLOURMAP_DICT["circulation"], bounds, \
                                       "Anomalies from 1981-2010 (m s"+r'$^{-1}$'+")")

    #************************************************************************
    # QBO plot - https://www.geo.fu-berlin.de/en/met/ag/strat/produkte/qbo/index.html
    if False:
        levels = np.array([70., 50., 40., 30., 20., 15., 10.])
        times = []
        dttimes = []
        data = np.zeros((levels.shape[0], 13))
        factor = 0.1
        j = 0

        with open(DATALOC + "qbo.dat", "r") as infile:

            for line in infile:
                line = line.split()

                if len(line) > 0:

                    # get current year
                    try:
                        if int(line[1][:2]) >= int(settings.YEAR[-2:]) and int(
                                line[1][:2]) <= int(settings.YEAR[-2:]) + 1:
                            month = int(line[1][-2:])
                            times += [month]
                            dttimes += [
                                dt.datetime(int(settings.YEAR), month, 1)
                            ]
                            data[:, j] = [float(i) * factor for i in line[2:]]
                            j += 1
                    except ValueError:
                        pass

        data = np.array(data)
        times = np.array(times)
        times[-1] += 12

        # And now plot
        cmap = settings.COLOURMAP_DICT["circulation"]
        bounds = [
            -100., -45., -30., -15., -10., -5., 0., 5., 10., 15., 30., 45., 100
        ]
        norm = mpl.cm.colors.BoundaryNorm(bounds, cmap.N)

        fig = plt.figure(figsize=(8, 8))
        plt.clf()
        ax = plt.axes([0.12, 0.07, 0.8, 0.9])

        times, levels = np.meshgrid(times, levels)

        con = plt.contourf(times,
                           levels,
                           data,
                           bounds,
                           cmap=cmap,
                           norm=norm,
                           vmax=bounds[-1],
                           vmin=bounds[1])

        plt.ylabel("Pressure (hPa)", fontsize=settings.FONTSIZE)
        plt.xlabel(settings.YEAR, fontsize=settings.FONTSIZE)
        plt.xticks(times[0], [dt.datetime.strftime(d, "%b") for d in dttimes],
                   fontsize=settings.FONTSIZE * 0.8)

        plt.xlim([1, 13])
        plt.ylim([70, 10])

        ax.set_yscale("log", subsy=[])
        plt.gca().yaxis.set_major_locator(
            matplotlib.ticker.MultipleLocator(10))
        plt.gca().yaxis.set_minor_locator(matplotlib.ticker.NullLocator())
        plt.gca().yaxis.set_major_formatter(
            matplotlib.ticker.ScalarFormatter())

        plt.yticks(np.arange(70, 0, -10),
                   ["{}".format(l) for l in np.arange(70, 0, -10)],
                   fontsize=settings.FONTSIZE)

        # colourbar and prettify
        cb = plt.colorbar(con, orientation='horizontal', pad=0.1, fraction=0.05, aspect=30, \
                              ticks=bounds[1:-1], label="zonal wind (m/s)", drawedges=True)

        cb.set_ticklabels(["{:g}".format(b) for b in bounds[1:-1]])
        cb.ax.tick_params(axis='x',
                          labelsize=settings.FONTSIZE * 0.6,
                          direction='in')

        cb.set_label(label="zonal wind (m/s)",
                     fontsize=settings.FONTSIZE * 0.6)
        #    cb.outline.set_color('k')
        cb.outline.set_linewidth(2)
        cb.dividers.set_color('k')
        cb.dividers.set_linewidth(2)

        utils.thicken_panel_border(ax)

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

    #************************************************************************
    # https://www.geo.fu-berlin.de/met/ag/strat/produkte/qbo/singapore2019.dat
    if True:
        levels = []
        times = np.arange(1, 13, 1)
        data = []
        factor = 0.1
        j = 0

        with open(DATALOC + "singapore{}.dat".format(settings.YEAR),
                  "r") as infile:
            read = False
            for line in infile:
                line = line.split()
                if len(line) == 0:
                    continue

                if line[0] == "hPa":
                    read = True
                    continue
                elif read:

                    if len(line) > 0:

                        levels += [int(line[0])]
                        data += [[float(l) * 0.1 for l in line[1:]]]

                else:
                    continue

        # convert ot arrays and reorder
        levels = np.array(levels)
        levels = levels[::-1]
        data = np.array(data)
        data = data[::-1, :]

        # And now plot
        cmap = settings.COLOURMAP_DICT["circulation"]
        bounds = [
            -100., -45., -30., -15., -10., -5., 0., 5., 10., 15., 30., 45., 100
        ]
        norm = mpl.cm.colors.BoundaryNorm(bounds, cmap.N)

        fig = plt.figure(figsize=(8, 8))
        plt.clf()
        ax = plt.axes([0.12, 0.07, 0.85, 0.9])

        times, levels = np.meshgrid(times, levels)

        con = plt.contourf(times,
                           levels,
                           data,
                           bounds,
                           cmap=cmap,
                           norm=norm,
                           vmax=bounds[-1],
                           vmin=bounds[1])

        plt.ylabel("Pressure (hPa)", fontsize=settings.FONTSIZE)
        plt.xlabel(settings.YEAR, fontsize=settings.FONTSIZE)
        dttimes = [
            dt.datetime(int(settings.YEAR), m + 1, 1) for m in range(12)
        ]
        plt.xticks(times[0], [dt.datetime.strftime(d, "%b") for d in dttimes],
                   fontsize=settings.FONTSIZE)

        plt.xlim([1, 12])
        plt.ylim([100, 10])

        ax.set_yscale("log", subsy=[])
        plt.gca().yaxis.set_major_locator(
            matplotlib.ticker.MultipleLocator(10))
        plt.gca().yaxis.set_minor_locator(matplotlib.ticker.NullLocator())
        plt.gca().yaxis.set_major_formatter(
            matplotlib.ticker.ScalarFormatter())

        plt.yticks(np.arange(100, 0, -10),
                   ["{}".format(l) for l in np.arange(100, 0, -10)],
                   fontsize=settings.FONTSIZE)

        # colourbar and prettify
        cb = plt.colorbar(con, orientation='horizontal', pad=0.1, fraction=0.05, aspect=30, \
                              ticks=bounds[1:-1], drawedges=True)

        cb.set_ticklabels(["{:g}".format(b) for b in bounds[1:-1]])
        cb.set_label(label="zonal wind (m/s)", fontsize=settings.FONTSIZE)
        cb.ax.tick_params(axis='x',
                          labelsize=settings.FONTSIZE,
                          direction='in')

        cb.set_label(label="zonal wind (m/s)", fontsize=settings.FONTSIZE)
        #    cb.outline.set_color('k')
        cb.outline.set_linewidth(2)
        cb.dividers.set_color('k')
        cb.dividers.set_linewidth(2)

        utils.thicken_panel_border(ax)

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

    #************************************************************************
    # 200hPa winds in 1980 and 2018
    if False:
        cube_list = iris.load(DATALOC + "ws200_spread_197901_201801.nc")
        names = np.array([str(cube.var_name) for cube in cube_list])

        # hard coded labels
        mu = {"1980": "1.8", "2018": "1.0"}
        rms = {"1980": "2.0", "2018": "1.1"}
        label = {"1980": "(a)", "2018": "(b)"}
        bounds = [0, 0.5, 1, 1.5, 2, 2.5, 3.0, 100]
        for name in names:
            print(name)
            cube_index, = np.where(names == name)
            cube = cube_list[cube_index[0]]

            year = name.split("_")[-1][:4]

            utils.plot_smooth_map_iris(
                settings.IMAGELOC + "UAW_200hPa_Jan{}".format(year),
                cube,
                plt.cm.BuPu,
                bounds,
                "m/s",
                figtext="{} January {}, mean={}, RMS={}".format(
                    label[year], year, mu[year], rms[year]))

    #************************************************************************
    # Plots
    if False:
        label = {"1980": "(c)", "2018": "(d)"}
        for year in ["1980", "2018"]:

            cube_list = iris.load(DATALOC + "v200_zonal_{}01.nc".format(year))

            for cube in cube_list:
                if cube.var_name == "products":
                    names = cube
                elif cube.var_name == "v200_array":
                    data_array = cube

            latitudes = data_array.coord("latitude").points
            plt.figure()
            ax = plt.axes([0.13, 0.13, 0.85, 0.85])

            COLOURS = {
                "ERA5 ens. mean": "red",
                "ERA5 ensemble": "orange",
                "ERA5 HRES": "orange",
                "JRA55": "c",
                "MERRA-2": "m",
                "ERA-Interim": "orange"
            }

            for name, data in zip(names.data, data_array.data):

                str_name = "".join(str(name.compressed(), "latin-1").rstrip())
                # manually fix names
                if str_name == "ERAI":
                    str_name = "ERA-Interim"
                elif str_name == "ERA5 ens mean":
                    str_name = "ERA5 ens. mean"

                if str_name[:3] == "mem":
                    plt.plot(latitudes[1:], data[1:], c="orange")
                elif str_name == "ERA-Interim":
                    plt.plot(latitudes[1:],
                             data[1:],
                             c=COLOURS[str_name],
                             label=str_name,
                             lw=2,
                             ls="--")
                else:
                    plt.plot(latitudes[1:],
                             data[1:],
                             c=COLOURS[str_name],
                             label=str_name,
                             lw=2)

            plt.legend(loc="upper right", ncol=1, frameon=False)
            plt.xlabel("Latitude", fontsize=settings.FONTSIZE * 0.8)
            plt.ylabel("m/s", fontsize=settings.FONTSIZE * 0.8)
            plt.text(0.03,
                     0.92,
                     "{} January {}".format(label[year], year),
                     transform=ax.transAxes,
                     fontsize=settings.FONTSIZE * 0.8)

            plt.xlim([-90, 90])
            plt.xticks(np.arange(-90, 120, 30))
            plt.ylim([-1, 4])
            for tick in ax.xaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE * 0.8)
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE * 0.8)
            utils.thicken_panel_border(ax)

            plt.savefig(settings.IMAGELOC +
                        "UAW_200hPa_Jan{}_ts{}".format(year, settings.OUTFMT))

    return
#plot_lakes(ax, anomalies[1], anomalies[0], anomalies[2], cmap, norm, "Lake Temperature Anomaly\n("+r"$^{\circ}$"+"C)", bounds, "(c)")

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

#***************
# Anomaly Scatter map

bounds = [-8, -2, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2, 8]

lons = np.arange(-90, 120, 30)
lats = np.arange(-180, 210, 30)
dummy = np.ma.zeros((len(lats), len(lons)))
dummy.mask = np.ones(dummy.shape)

cube = utils.make_iris_cube_2d(dummy, lats, lons, "blank", "m")

utils.plot_smooth_map_iris(image_loc + "LKT_anomaly",
                           cube,
                           settings.COLOURMAP_DICT["temperature"],
                           bounds,
                           "Anomaly (" + r"$^{\circ}$" + "C)",
                           scatter=[anomalies[1], anomalies[0], anomalies[2]],
                           figtext="",
                           title="")
utils.plot_smooth_map_iris(image_loc + "p2.1_LKT_anomaly",
                           cube,
                           settings.COLOURMAP_DICT["temperature"],
                           bounds,
                           "Anomaly (" + r"$^{\circ}$" + "C)",
                           scatter=[anomalies[1], anomalies[0], anomalies[2]],
Exemple #17
0
def run_all_plots():

    #************************************************************************
    # Timeseries
    if True:

        IRdata = read_binary_ts(
            DATALOC +
            "TimeseriesBHRNIR_C7_poids_{}.bin".format(int(settings.YEAR) + 1))
        Vdata = read_binary_ts(
            DATALOC +
            "TimeseriesBHRV_C7_poids_{}.bin".format(int(settings.YEAR) + 1))

        fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 6.5), sharex=True)
        COLOURS = settings.COLOURS["land_surface"]

        for dataset in Vdata:
            print(dataset.name)
            locs, = np.where(dataset.data != 0)
            ls = "--"
            lw = 1
            if dataset.name.split(" ")[-1] == "Smoothed":
                ls = "-"
                lw = 2
            ax1.plot(dataset.times[locs],
                     dataset.data[locs],
                     c=COLOURS[dataset.name],
                     ls=ls,
                     label=dataset.name,
                     lw=lw)

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

        for dataset in IRdata:
            print(dataset.name)
            locs, = np.where(
                dataset.data != 0)  # remove zero bits (mainly for smoothed)
            ls = "--"
            lw = 1
            if dataset.name.split(" ")[-1] == "Smoothed":
                ls = "-"
                lw = 2
            ax2.plot(dataset.times[locs],
                     dataset.data[locs],
                     c=COLOURS[dataset.name],
                     ls=ls,
                     label=dataset.name,
                     lw=lw)

        ax2.legend(loc=LEGEND_LOC,
                   ncol=2,
                   frameon=False,
                   prop={'size': settings.LEGEND_FONTSIZE * 0.8},
                   labelspacing=0.1,
                   columnspacing=0.5)
        ax2.axhline(0, c='0.5', ls='--')
        utils.thicken_panel_border(ax2)

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

        fig.text(0.01,
                 0.5,
                 "Normalized Anomalies (%)",
                 va='center',
                 rotation='vertical',
                 fontsize=settings.FONTSIZE)

        plt.xlim([2002.5, int(settings.YEAR) + 1.5])
        ax2.set_ylim([-5.8, None])
        for ax in [ax1, ax2]:
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)
            ax.xaxis.set_minor_locator(minorLocator)
            ax.set_yticks(ax.get_yticks()[1:-1])
            ax.yaxis.set_ticks_position('left')
        for tick in ax2.xaxis.get_major_ticks():
            tick.label.set_fontsize(settings.FONTSIZE)

        ax1.text(0.02,
                 0.9,
                 "(a) Visible",
                 transform=ax1.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)
        ax2.text(0.02,
                 0.9,
                 "(b) Near Infrared",
                 transform=ax2.transAxes,
                 fontsize=settings.LABEL_FONTSIZE)

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

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

    #************************************************************************
    # Hovmullers
    if True:
        IRdata = read_binary(
            DATALOC +
            "HovMullerBHRNIR_C7_{}.bin".format(int(settings.YEAR) + 1))
        Vdata = read_binary(
            DATALOC + "HovMullerBHRV_C7_{}.bin".format(int(settings.YEAR) + 1))

        # reshape - from Readme
        IRdata = IRdata.reshape(360, DURATION)
        Vdata = Vdata.reshape(360, DURATION)

        IRdata = np.ma.masked_where(IRdata <= -100.,
                                    IRdata)  # * 100 # from readme
        Vdata = np.ma.masked_where(Vdata <= -100., Vdata)  # * 100

        lats = np.arange(-90, 90, 0.5)

        # curtail times
        locs, = np.where(times > int(settings.YEAR) + 1)
        IRdata.mask[:, locs] = True
        Vdata.mask[:, locs] = True
        times.mask[locs] = True

        # cant use "cmap.set_bad" for contour as ignored when contouring

        bounds = [-100, -20, -15, -10, -5, -1, 1, 5, 10, 15, 20, 100]
        utils.plot_hovmuller(settings.IMAGELOC + "ABD_NIR_hovmuller",
                             times,
                             lats,
                             IRdata,
                             settings.COLOURMAP_DICT["land_surface_r"],
                             bounds,
                             "Normalized Anomalies (%)",
                             figtext="(b)",
                             background="0.7")
        utils.plot_hovmuller(settings.IMAGELOC + "ABD_V_hovmuller",
                             times,
                             lats,
                             Vdata,
                             settings.COLOURMAP_DICT["land_surface_r"],
                             bounds,
                             "Normalized Anomalies (%)",
                             figtext="(a)",
                             background="0.7")

    #************************************************************************
    # Anomalies
    if True:
        IRdata = read_binary(
            DATALOC + "Annual_BHRNIR_C7_{}.bin".format(int(settings.YEAR) + 1))
        Vdata = read_binary(
            DATALOC + "Annual_BHRV_C7_{}.bin".format(int(settings.YEAR) + 1))

        # reshape - from Readme
        IRdata = IRdata.reshape(360, 720)
        Vdata = Vdata.reshape(360, 720)

        IRdata = np.ma.masked_where(IRdata <= -9999., IRdata)
        Vdata = np.ma.masked_where(Vdata <= -9999., Vdata)

        IRdata = np.ma.masked_where(IRdata == 0., IRdata)
        Vdata = np.ma.masked_where(Vdata == 0., Vdata)

        delta = 0.5
        lons = np.arange(-180 + (delta / 2.), 180, delta)
        lats = np.arange(-90 + (delta / 2.), 90, delta)

        ir_cube = utils.make_iris_cube_2d(IRdata, lats, lons, "IR Albedo", "%")
        v_cube = utils.make_iris_cube_2d(Vdata, lats, lons, "V Albedo", "%")

        bounds = [-100, -20, -15, -10, -5, 0, 5, 10, 15, 20, 100]

        utils.plot_smooth_map_iris(
            settings.IMAGELOC + "p2.1_ABD_V_{}".format(settings.YEAR),
            v_cube,
            settings.COLOURMAP_DICT["land_surface_r"],
            bounds,
            "Anomalies from 2003-{} (%)".format(2010),
            figtext="(ac) Land Surface Albedo in the Visible")
        utils.plot_smooth_map_iris(
            settings.IMAGELOC + "ABD_V_{}".format(settings.YEAR), v_cube,
            settings.COLOURMAP_DICT["land_surface_r"], bounds,
            "Anomalies from 2003-{} (%)".format(2010))

        utils.plot_smooth_map_iris(
            settings.IMAGELOC + "p2.1_ABD_NIR_{}".format(settings.YEAR),
            ir_cube,
            settings.COLOURMAP_DICT["land_surface_r"],
            bounds,
            "Anomalies from 2003-{} (%)".format(2010),
            figtext="(ad) Land Surface Albedo in the Near Infrared")
        utils.plot_smooth_map_iris(
            settings.IMAGELOC + "ABD_NIR_{}".format(settings.YEAR), ir_cube,
            settings.COLOURMAP_DICT["land_surface_r"], bounds,
            "Anomalies from 2003-{} (%)".format(2010))

    return  # run_all_plots
Exemple #18
0
def run_all_plots():

    #************************************************************************
    # Cloudiness timeseries
    if True:
        plt.clf()
        fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 6.5), sharex=True)

        infilename = os.path.join(
            DATALOC,
            "{}_global_cloudiness_timeseries_v2.txt".format(settings.YEAR))

        # anomalies
        patmosx, hirs, misr, modis, calipso, ceres, satcorps, clara_a2, patmosdx, cci = \
            read_ts(infilename, anomaly=True)

        utils.plot_ts_panel(ax1, [
            patmosx, hirs, misr, modis, calipso, ceres, satcorps, clara_a2,
            patmosdx, cci
        ],
                            "-",
                            "hydrological",
                            loc="")

        ax1.text(0.02,
                 0.9,
                 "(a) Satellite - Anomalies",
                 transform=ax1.transAxes,
                 fontsize=settings.FONTSIZE)

        # actuals
        patmosx, hirs, misr, modis, calipso, ceres, satcorps, clara_a2, patmosdx, cci = \
            read_ts(infilename)

        utils.plot_ts_panel(ax2, [
            patmosx, hirs, misr, modis, calipso, ceres, satcorps, clara_a2,
            patmosdx, cci
        ],
                            "-",
                            "hydrological",
                            loc=LEGEND_LOC,
                            ncol=3)

        ax2.text(0.02,
                 0.9,
                 "(b) Satellite - Actual",
                 transform=ax2.transAxes,
                 fontsize=settings.FONTSIZE)

        #*******************
        # prettify
        ax1.set_ylabel("Anomaly (%)", fontsize=settings.FONTSIZE)
        ax2.set_ylabel("(%)", fontsize=settings.FONTSIZE)

        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:])
            ax.xaxis.set_minor_locator(minorLocator)
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)

        plt.setp([a.get_xticklabels() for a in fig.axes[:-1]], visible=False)
        fig.subplots_adjust(right=0.96,
                            top=0.99,
                            bottom=0.04,
                            left=0.09,
                            hspace=0.001)

        plt.xlim([hirs.times[0] - 1, hirs.times[-1] + 1])
        ax1.set_ylim([-4.4, 6.9])
        ax2.set_ylim([0, 95])

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

    #************************************************************************
    # make a version using the full base period of the data and only the pre2000 datasets
    if False:
        plt.clf()
        fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 6.5), sharex=True)

        # anomalies
        patmosx, hirs, misr, modis, calipso, ceres, satcorps, clara_a2, patmosdx, cci = \
            read_ts(DATALOC + "{}_global_cloudiness_timeseries.txt".format(settings.YEAR), \
                        anomaly=True, fullbase=True)

        utils.plot_ts_panel(ax1, [patmosx, hirs, satcorps, clara_a2, cci],
                            "-",
                            "hydrological",
                            loc="")

        ax1.text(0.02,
                 0.9,
                 "(a) Satellite - Anomalies",
                 transform=ax1.transAxes,
                 fontsize=settings.FONTSIZE)

        # actuals
        patmosx, hirs, misr, modis, calipso, ceres, satcorps, clara_a2, patmosdx, cci = \
            read_ts(DATALOC + "{}_global_cloudiness_timeseries.txt".format(settings.YEAR))

        utils.plot_ts_panel(ax2, [patmosx, hirs, satcorps, clara_a2, cci], "-", "hydrological", \
                                loc=LEGEND_LOC, ncol=3)

        ax2.text(0.02,
                 0.9,
                 "(b) Satellite - Actual",
                 transform=ax2.transAxes,
                 fontsize=settings.FONTSIZE)

        #*******************
        # prettify
        ax1.set_ylabel("Anomaly (%)", fontsize=settings.FONTSIZE)
        ax2.set_ylabel("(%)", fontsize=settings.FONTSIZE)

        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:])
            ax.xaxis.set_minor_locator(minorLocator)
            for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(settings.FONTSIZE)

        plt.setp([a.get_xticklabels() for a in fig.axes[:-1]], visible=False)
        fig.subplots_adjust(right=0.95, top=0.95, hspace=0.001)

        plt.xlim([hirs.times[0] - 1, hirs.times[-1] + 1])
        ax1.set_ylim([-4.9, 4.4])
        ax2.set_ylim([0, 95])

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

    #************************************************************************
    # Cloudiness map
    if True:
        mapfile_dict = scipy.io.readsav(
            DATALOC +
            "patmosx_global_monthly_cloudiness_anomaly_map_{}.sav".format(
                settings.YEAR))

        annual_anoms = mapfile_dict["annual_anom"] * 100.
        djf_anoms = mapfile_dict["djf_anom"] * 100.
        jja_anoms = mapfile_dict["jja_anom"] * 100.
        mam_anoms = mapfile_dict["mam_anom"] * 100.
        son_anoms = mapfile_dict["son_anom"] * 100.

        lats = mapfile_dict["lat"]
        lons = mapfile_dict["lon"]

        cube = utils.make_iris_cube_2d(annual_anoms, lats[:, 0], lons[0],
                                       "CLD_anom", "%")

        bounds = [-100, -15, -10, -5, -2.5, 0, 2.5, 5, 10, 15, 100]

        utils.plot_smooth_map_iris(settings.IMAGELOC + "CLD_{}_anoms".format(settings.YEAR), cube, \
                                       settings.COLOURMAP_DICT["hydrological"], bounds, \
                                       "Anomalies from 1981-2010 (%)")
        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_CLD_{}_anoms".format(settings.YEAR), \
                                       cube, settings.COLOURMAP_DICT["hydrological"], bounds, \
                                       "Anomalies from 1981-2010 (%)", figtext="(n) Cloudiness")

    #************************************************************************
    # Cloudiness Seasonal Map
    if True:
        cubelist = []
        for season in [djf_anoms, mam_anoms, jja_anoms, son_anoms]:

            cube = utils.make_iris_cube_2d(season, lats[:, 0], lons[0],
                                           "CLD_anom", "%")
            cubelist += [cube]


        utils.plot_smooth_map_iris_multipanel(settings.IMAGELOC + "CLD_{}_anoms_seasons".format(settings.YEAR), \
                                                  cubelist, settings.COLOURMAP_DICT["hydrological"], \
                                                  bounds, "Anomaly (%)", shape=(2, 2), \
                                                  title=["DJF", "MAM", "JJA", "SON"], \
                                                  figtext=["(a)", "(b)", "(c)", "(d)"])

    #************************************************************************
    # Cloudiness Hovmoller
    if True:
        data_dict = scipy.io.readsav(
            DATALOC +
            "patmosx_global_monthly_cloudiness_hovmuller_{}.sav".format(
                settings.YEAR))

        lats = data_dict["latitude"]
        times = data_dict["hov_time"]
        anoms = data_dict["hov_anom"] * 100.

        utils.plot_hovmuller(settings.IMAGELOC + "CLD_hovmuller", times, lats,
                             anoms, settings.COLOURMAP_DICT["hydrological"],
                             bounds, "Anomaly (%)")

    return  # run_all_plots
Exemple #19
0
def run_all_plots():

    #***************
    # Anomaly Scatter map
    anomalies = read_lakes(DATALOC +
                           "DATA_StateOfTheClimate_WaterLevelsAnom_v2.csv")

    bounds = [-2, -1, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1, 2]

    lons = np.arange(-90, 120, 30)
    lats = np.arange(-180, 210, 30)
    dummy = np.ma.zeros((len(lats), len(lons)))
    dummy.mask = np.ones(dummy.shape)

    cube = utils.make_iris_cube_2d(dummy, lats, lons, "blank", "m")

    utils.plot_smooth_map_iris(settings.IMAGELOC + "LWL_anomaly", cube, settings.COLOURMAP_DICT["hydrological"], \
                                   bounds, "Anomalies from 1992-2002 (m)", \
                                   scatter=[anomalies[1], anomalies[0], anomalies[2]], figtext="", title="")
    utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_LWL_{}_anomaly".format(settings.YEAR), cube, settings.COLOURMAP_DICT["hydrological"], \
                                   bounds, "Anomalies from 1992-2002 (m)", \
                                   scatter=[anomalies[1], anomalies[0], anomalies[2]], figtext="(m) Lake Water Level", title="")

    #***************
    # multi-panel time series
    indata = read_continuous_csv(
        os.path.join(
            DATALOC,
            "DATA_StateOfTheLakes_WaterLevelAnomTimeSeries_sub_v1.csv"))
    names = np.array([d.name for d in indata])

    lake_order = [
        "Huron", "Superior", "Balkhash", "Tanganyika", "Caspian Sea",
        "Large Aral Sea", "Urmia", "Rukwa"
    ]

    # match HUM plot size

    fig, axes = plt.subplots(nrows=2, ncols=4, figsize=(16, 8), sharex=True)

    counter = 0
    for row in axes:
        for ax in row:

            lake, = np.where(names == lake_order[counter])[0]
            lake = indata[lake]

            utils.thicken_panel_border(ax)
            ax.plot(lake.times, lake.data, "k-")

            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)

            ax.xaxis.set_major_locator(mdates.YearLocator(10))
            ax.xaxis.set_minor_locator(mdates.YearLocator(1))

            ax.text(0.1,
                    0.9,
                    lake.name,
                    fontsize=settings.FONTSIZE,
                    transform=ax.transAxes)

            ylim = ax.get_ylim()
            ax.set_ylim([ylim[0], ylim[1] * 1.2])

            counter += 1

    fig.text(0.01,
             0.5,
             "Lake Level (m)",
             rotation="vertical",
             va="center",
             fontsize=settings.FONTSIZE)
    fig.subplots_adjust(left=0.07,
                        right=0.99,
                        bottom=0.05,
                        top=0.99,
                        hspace=0.001)
    plt.savefig(settings.IMAGELOC +
                "LWL_ts_{}{}".format(settings.YEAR, settings.OUTFMT))

    #***************
    # Lake Cutouts

    EXTENTS = {
        "GL": (86, 45, [-93, -78, 41, 49]),
        "RU": (62, 42, [43, 81, 35, 48]),
        "AF": (31, -6, [28.5, 33, -10, -3])
    }

    for region in ["GL", "RU", "AF"]:
        if region == "AF":
            fig = plt.figure(figsize=(6, 8))
        elif region == "RU":
            fig = plt.figure(figsize=(18, 8))
        elif region == "GL":
            fig = plt.figure(figsize=(12, 8))

        plt.clf()
        ax = plt.axes([0.05, 0.05, 0.9, 0.9],
                      projection=cartopy.crs.PlateCarree(
                          central_longitude=EXTENTS[region][0]))

        ax.set_extent(EXTENTS[region][2], cartopy.crs.PlateCarree())

        ax.add_feature(cartopy.feature.LAND.with_scale('10m'),
                       zorder=0,
                       facecolor="0.75",
                       edgecolor="k")
        ax.add_feature(cartopy.feature.OCEAN.with_scale('10m'),
                       zorder=0,
                       facecolor="#e0ffff",
                       edgecolor="k")
        ax.add_feature(cartopy.feature.LAKES.with_scale('10m'),
                       zorder=0,
                       facecolor="#e0ffff",
                       edgecolor="k")
        ax.add_feature(cartopy.feature.RIVERS.with_scale('10m'),
                       zorder=0,
                       edgecolor="#e0ffff")
        ax.coastlines(resolution="10m", linewidth=0.5)

        # add other features
        gl = ax.gridlines(draw_labels=True)
        gl.xlabel_style = {'size': settings.FONTSIZE}
        gl.ylabel_style = {'size': settings.FONTSIZE}

        # add labels
        if region == "AF":
            ax.text(30,
                    -5,
                    "Tanganyika",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
            ax.text(32,
                    -7.5,
                    "Rukwa",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
        elif region == "RU":
            ax.text(46,
                    38,
                    "Urmia",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
            ax.text(52,
                    44,
                    "Caspian Sea",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
            ax.text(60.5,
                    45,
                    "Large Aral Sea",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
            ax.text(75,
                    45.5,
                    "Balkhash",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
        elif region == "GL":
            ax.text(-91,
                    46.2,
                    "Superior",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
            ax.text(-89,
                    42,
                    "Michigan",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())
            ax.text(-84.5,
                    44.5,
                    "Huron",
                    fontsize=settings.FONTSIZE,
                    transform=cartopy.crs.Geodetic())

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

    return  # run_all_plots
Exemple #20
0
def run_all_plots():

    #************************************************************************
    # Timeseries figures
    if True:

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

        UAH, rss, ratpac, raobcore, rich, noaa, jra, merra = read_csv(
            DATALOC + "SotC_AnnTemps_2020_0220_LSTGL.csv")
        #        ssu2, ncar = read_ssu_csv(DATALOC + "2018_LTT_LST_SSU_date0401_SSU.csv")

        eral, erao, eralo = read_era5(DATALOC + "ERA5_TLS_GLOBAL")
        eralo_ann = utils.Timeseries("ERA5",
                                     np.reshape(eralo.times, [-1, 12])[:, 0],
                                     utils.annual_average(eralo.data))

        # Sondes [no RATPAC for 2019]
        utils.plot_ts_panel(ax1, [raobcore, rich],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC)

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

        # reanalyses
        jra_actuals, jra_anoms = utils.read_jra55(
            settings.REANALYSISLOC + "JRA-55_MSUch4_global_ts.txt",
            "temperature")
        merra_actuals, merra_anoms = utils.read_merra_LT_LS(
            settings.REANALYSISLOC +
            "MERRA2_MSU_Tanom_ann_{}.dat".format(settings.YEAR),
            LS=True)
        utils.plot_ts_panel(ax3, [eralo_ann, jra_anoms, merra_anoms],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC)

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

        # Upper Stratosphere
        #        utils.plot_ts_panel(ax4, [ssu2, ncar], "-", "temperature", loc=LEGEND_LOC)

        # sort formatting
        plt.xlim([1957, raobcore.times[-1] + 1])

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

            ax.set_ylim([-1.2, 2.2])

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

        fig.text(0.01,
                 0.45,
                 "Anomaly (" + r'$^\circ$' + "C)",
                 fontsize=settings.FONTSIZE,
                 rotation="vertical")
        fig.subplots_adjust(right=0.98, top=0.98, bottom=0.04, hspace=0.001)

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

        plt.close()

    #************************************************************************
    # Timeseries figures
    if True:

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

        ssu1, ssu1_2, ssu2, ssu2_2, ssu3, ssu3_2 = read_ssu(DATALOC +
                                                            "SSU.dat")

        # SSU3
        utils.plot_ts_panel(ax1, [ssu3, ssu3_2], "-", "temperature", loc="")
        # SSU2
        utils.plot_ts_panel(ax2, [ssu2, ssu2_2], "-", "temperature", loc="")
        # SSU1
        utils.plot_ts_panel(ax3, [ssu1, ssu1_2],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC)

        # sort formatting
        plt.xlim([1957, ssu1.times[-1] + 2])

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

            ax.set_ylim([-1.3, 2.2])

        # sort labelling
        ax1.text(0.02, 0.88, "(a) SSU3", transform=ax1.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)
        ax2.text(0.02, 0.88, "(b) SSU2", transform=ax2.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)
        ax3.text(0.02, 0.88, "(c) SSU1", transform=ax3.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)

        fig.text(0.01,
                 0.45,
                 "Anomaly (" + r'$^\circ$' + "C)",
                 fontsize=settings.FONTSIZE,
                 rotation="vertical")
        fig.subplots_adjust(right=0.98, top=0.98, bottom=0.04, hspace=0.001)

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

        plt.close()

    #************************************************************************
    # Combined Timeseries figures
    if True:

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

        # manually set up the 10 axes
        w = 0.42
        h = 0.31
        c = 0.51
        ax1 = plt.axes([c - w, 0.99 - h, w, h])
        ax2 = plt.axes([c, 0.99 - h, w, h])
        ax3 = plt.axes([c - w, 0.99 - (2 * h), w, h], sharex=ax1)
        ax4 = plt.axes([c, 0.99 - (2 * h), w, h], sharex=ax2)
        ax5 = plt.axes([c - w, 0.99 - (3 * h), w, h], sharex=ax1)
        ax6 = plt.axes([c, 0.99 - (3 * h), w, h], sharex=ax2)

        UAH, rss, ratpac, raobcore, rich, noaa, jra, merra = read_csv(
            DATALOC + "SotC_AnnTemps_2020_0220_LSTGL.csv")
        #        ssu2, ncar = read_ssu_csv(DATALOC + "2018_LTT_LST_SSU_date0401_SSU.csv")

        eral, erao, eralo = read_era5(DATALOC + "ERA5_TLS_GLOBAL")
        eralo_ann = utils.Timeseries("ERA5",
                                     np.reshape(eralo.times, [-1, 12])[:, 0],
                                     utils.annual_average(eralo.data))

        # update to ERA5.1 during revisions for SotC2019
        era51 = np.genfromtxt(DATALOC + "ERA5_1_update.dat")
        eralo_ann = utils.Timeseries("ERA5", era51[:, 0], era51[:, 1])

        # Sondes [no RATPAC for 2019]
        utils.plot_ts_panel(ax2, [raobcore, rich, ratpac],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC)

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

        # reanalyses
        jra_actuals, jra_anoms = utils.read_jra55(
            settings.REANALYSISLOC + "JRA-55_MSUch4_global_ts.txt",
            "temperature")
        merra_actuals, merra_anoms = utils.read_merra_LT_LS(
            settings.REANALYSISLOC +
            "MERRA2_MSU_Tanom_ann_{}.dat".format(settings.YEAR),
            LS=True)
        utils.plot_ts_panel(ax6, [eralo_ann, jra_anoms, merra_anoms],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC)

        ssu1, ssu1_2, ssu2, ssu2_2, ssu3, ssu3_2 = read_ssu(DATALOC +
                                                            "SSU.dat")

        # SSU3
        utils.plot_ts_panel(ax1, [ssu3, ssu3_2], "-", "temperature", loc="")
        # SSU2
        utils.plot_ts_panel(ax3, [ssu2, ssu2_2], "-", "temperature", loc="")
        # SSU1
        utils.plot_ts_panel(ax5, [ssu1, ssu1_2],
                            "-",
                            "temperature",
                            loc=LEGEND_LOC)

        # sort labelling
        for ax in [ax2, ax4, ax6]:
            ax.yaxis.tick_right()
            for tick in ax.yaxis.get_major_ticks():
                tick.label2.set_fontsize(settings.FONTSIZE)
        for ax in [ax1, ax3, ax5]:
            ax.yaxis.tick_right()
            ax.yaxis.set_ticks_position('left')

        ax2.text(0.02, 0.88, "(d) Radiosondes", transform=ax2.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)
        ax4.text(0.02, 0.88, "(e) Satellites", transform=ax4.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)
        ax6.text(0.02, 0.88, "(f) Reanalyses", transform=ax6.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)

        ax1.text(0.02, 0.88, "(a) SSU3", transform=ax1.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)
        ax3.text(0.02, 0.88, "(b) SSU2", transform=ax3.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)
        ax5.text(0.02, 0.88, "(c) SSU1", transform=ax5.transAxes, \
                     fontsize=settings.LABEL_FONTSIZE)

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

        # sort formatting
        ax1.set_xlim([1957, raobcore.times[-1] + 3])
        ax2.set_xlim([1957, raobcore.times[-1] + 3])

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

            ax.set_ylim([-1.2, 2.2])

        fig.text(0.01,
                 0.55,
                 "Anomaly (" + r'$^\circ$' + "C)",
                 fontsize=settings.FONTSIZE,
                 rotation="vertical")
        fig.subplots_adjust(right=0.98, top=0.98, bottom=0.04, hspace=0.001)

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

        plt.close()

    #************************************************************************
    # Polar Figure
    if False:
        fig, ax1 = plt.subplots(figsize=(8, 5))

        north, south = read_polar(DATALOC +
                                  "polar_data_{}.dat".format(settings.YEAR))

        ax1.plot(north.times, north.data, c="b", ls="-", label=north.name)
        ax1.plot(south.times, south.data, c="r", ls="-", label=south.name)

        ax1.legend(loc=LEGEND_LOC,
                   frameon=False,
                   prop={'size': settings.FONTSIZE})
        ax1.set_xlim([1978, 2018 + 2])
        ax1.set_ylabel("Anomaly (" + r'$^\circ$' + "C)",
                       fontsize=settings.FONTSIZE)

        utils.thicken_panel_border(ax1)

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

        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)

        plt.close()

    #************************************************************************
    # Polar and QBO Timeseries figures

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

    # north, south, qbo = read_qbo_csv(DATALOC + "SOC_Strat_Data_QBO.csv")

    # noaa_qbo = read_qbo_ncdf(DATALOC + "qbo_noaa.nc", "NOAA v4.0")
    # uah_qbo = read_qbo_ncdf(DATALOC + "qbo_uah.nc", "UAH v6.0")
    # rss_qbo = read_qbo_ncdf(DATALOC + "qbo_rss.nc", "RSS v3.3")

    # utils.plot_ts_panel(ax1, [north], "-", "temperature", loc="")
    # utils.plot_ts_panel(ax2, [south], "-", "temperature", loc="")
    # utils.plot_ts_panel(ax3, [noaa_qbo, uah_qbo, rss_qbo], "-", "temperature", loc="", lw=1)

    # lines3, labels3 = ax3.get_legend_handles_labels()

    # plt.figlegend(lines3, labels3, "lower center", frameon=False, ncol=3, fontsize=settings.FONTSIZE)

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

    # ax1.text(0.02, 0.88, "(a) North Polar Pentad Anomalies", transform=ax1.transAxes, \
    #              fontsize=settings.LABEL_FONTSIZE)
    # ax2.text(0.02, 0.88, "(b) South Polar Pentad Anomalies", transform=ax2.transAxes, \
    #              fontsize=settings.LABEL_FONTSIZE)
    # ax3.text(0.02, 0.88, "(c) QBO from Lower Stratospheric Temperature", transform=ax3.transAxes, \
    #              fontsize=settings.LABEL_FONTSIZE)

    # ax3.text(-0.15, 0.88, "West", transform=ax3.transAxes, fontsize=settings.LABEL_FONTSIZE)
    # ax3.text(-0.15, 0.01, "East", transform=ax3.transAxes, fontsize=settings.LABEL_FONTSIZE)

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

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

    # ax1.set_ylim([-10, 19])
    # ax2.set_ylim([-10, 23])
    # ax3.set_ylim([-1.1, 1.4])

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

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

    # plt.close()

    #************************************************************************
    # MERRA Trop and Strat Timeseries figures

    # fourh, threeh, twofiveh, twoh, onefiveh, fourtwoav, oneh, seventy, fifty, thirty, twenty, ten, seventytwentyav = read_merra_monthly(DATALOC + "MERRA2_400_20_temp_anom_1980-{}.txt".format(settings.YEAR))

    # fourtwoav.data = np.ma.masked_where(fourtwoav.times < 1994, fourtwoav.data)
    # seventytwentyav.data = np.ma.masked_where(seventytwentyav.times < 1994, seventytwentyav.data)
    # fourtwoav.times = np.ma.masked_where(fourtwoav.times < 1994, fourtwoav.times)
    # seventytwentyav.times = np.ma.masked_where(seventytwentyav.times < 1994, seventytwentyav.times)

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

    # # trop
    # fit = utils.fit_plot_points(0.025, -50.01, fourtwoav.times)
    # ax1.plot(fourh.times, fit, c="0.5", lw = 2, ls = "-", label = "fit", zorder = 10)
    # utils.plot_ts_panel(ax1, [fourh, threeh, twofiveh, twoh, fourtwoav], "-", "lst", loc = LEGEND_LOC)
    # # strat
    # fit = utils.fit_plot_points(-0.0014, 2.4527, seventytwentyav.times)
    # ax2.plot(fourh.times, fit, c="0.5", lw = 2, ls = "-", label = "fit", zorder = 10)
    # utils.plot_ts_panel(ax2, [seventy, fifty, thirty, twenty, seventytwentyav], "-", "lst", loc = LEGEND_LOC)

    # # sort formatting
    # plt.xlim([1978, fourh.times[-1]+1])
    # ax1.set_ylim([-1.7,1.5])
    # ax2.set_ylim([-2.0,2.7])

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

    # # sort labelling
    # ax1.text(0.02, 0.9, "(a) MERRA-2 Troposphere", transform = ax1.transAxes, fontsize = settings.LABEL_FONTSIZE)
    # ax2.text(0.02, 0.9, "(b) MERRA-2 Stratosphere", transform = ax2.transAxes, fontsize = settings.LABEL_FONTSIZE)

    # ax1.text(0.7, 0.9, "y=0.025x - 50.01", transform = ax1.transAxes, fontsize = settings.LABEL_FONTSIZE*0.8)
    # ax2.text(0.7, 0.9, "y=-0.0014x + 2.4527", transform = ax2.transAxes, fontsize = settings.LABEL_FONTSIZE*0.8)

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

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

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

    # plt.close()

    #************************************************************************
    # Zonal figures

    # fig, (ax1, ax2) = plt.subplots(1, 2, figsize = (8, 6.5), sharey=True)

    # cfsr, merra, era, jra = read_zonal(DATALOC + "TLS_Reanal_zonal_trends_1994-{}.txt".format(settings.YEAR), "R")
    # star, uah, rss = read_zonal(DATALOC + "TLS_Satellite_zonal_trends_1994-{}.txt".format(settings.YEAR), "S")

    # # Reanalyses
    # utils.plot_ts_panel(ax1, [cfsr, merra, era, jra], "--", "temperature", loc = "lower left", ncol = 1)

    # # Satellite
    # utils.plot_ts_panel(ax2, [star, uah, rss], "--", "temperature", loc = "center right", ncol = 1)

    # ax1.axvline(0,color = "0.5", ls = "--")
    # ax2.axvline(0,color = "0.5", ls = "--")

    # # sort formatting
    # plt.ylim([-90,90])
    # ax1.set_ylabel("Latitude", fontsize = settings.LABEL_FONTSIZE)
    # ax1.set_xlabel("Trend ("+r'$^\circ$'+"C decade"+r'$^{-1}$'+")", fontsize = settings.FONTSIZE)
    # ax2.set_xlabel("Trend ("+r'$^\circ$'+"C decade"+r'$^{-1}$'+")", fontsize = settings.FONTSIZE)

    # for tick in ax1.yaxis.get_major_ticks():
    #     tick.label.set_fontsize(settings.FONTSIZE)
    # for ax in [ax1, ax2]:
    #     ax.set_xlim([-0.3,0.6])
    #     ax.set_xticks(np.arange(-0.2,0.8,0.2))
    #     ax.set_yticks(np.arange(-90,120,30))
    #     for tick in ax.xaxis.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)

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

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

    # plt.close()

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

        cube_list = iris.load(settings.REANALYSISLOC +
                              "era5_tls_{}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 + "LST_{}_anoms_era5".format(settings.YEAR), cube[0], \
                                   settings.COLOURMAP_DICT["temperature"], bounds, "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", title="ERA5")
        utils.plot_smooth_map_iris(settings.IMAGELOC + "p2.1_LST_{}_anoms_era5".format(settings.YEAR), cube[0], \
                                   settings.COLOURMAP_DICT["temperature"], bounds, "Anomalies from 1981-2010 ("+r'$^{\circ}$'+"C)", \
                                   figtext="(f) Lower Stratosphere Temperature")

    #************************************************************************
    # merra Anomaly figure
    if False:
        import netCDF4 as ncdf

        ncfile = ncdf.Dataset(settings.REANALYSISLOC +
                              "merra2_tls_ANNUAL_anom.nc")

        var = ncfile.variables["TLS ANOM"][:]  # this is a masked array
        nlons = ncfile.variables["LONGITUDES"][:]
        nlats = ncfile.variables["LATITUDES"][:]

        cube = utils.make_iris_cube_2d(var, nlats, nlons, "LST", "C")

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

    #************************************************************************
    # 2015 MERRA seasonal figure

    # import netCDF4 as ncdf

    # month_list = []

    # for month in MONTHS:
    #     print month

    #     # IRIS doesn't like the whitespace in the "TLS ANOM"
    #     ncfile=ncdf.Dataset(settings.REANALYSISLOC + "merra2_tls_{}_anom.nc".format(month.upper()),'r')

    #     var=ncfile.variables["TLS ANOM"][:] # this is a masked array
    #     lons = ncfile.variables["LONGITUDES"][:]
    #     lats = ncfile.variables["LATITUDES"][:]

    #     ncfile.close()

    #     cube = utils.make_iris_cube_2d(var, lats, lons, "TLS_ANOM", "C")

    #     month_list += [cube]

    # # pass to plotting routine
    # utils.plot_smooth_map_iris_multipanel(settings.IMAGELOC + "LST_{}_monthly_merra".format(settings.YEAR), month_list, \
    #                                           settings.COLOURMAP_DICT["temperature"], bounds, \
    #                                           "Anomaly ("+r'$^{\circ}$'+"C)", shape = (6,2), \
    #                                           title = MONTHS, \
    #                                           figtext = ["(a)","(b)","(c)","(d)", "(e)","(f)","(g)","(h)","(i)","(j)","(k)","(l)"])

    return  # run_all_plots