def plot_all_WLH(wlh, y=0, axlims=(0,50,50,180), cmap='jet', clines=True):
    onset = wlh['onset']
    Rsq = wlh['Rsq']
    lat = wlh['lat']
    lon = wlh['lon']
    kmax = wlh['smoothing_kmax']
    years=wlh['years']
    if wlh['climatology']:
        titlestr = 'CMAP %d-%d Climatology' % (years.min(), years.max())
    else:
        onset = onset[y]
        Rsq = Rsq[y]
        titlestr = 'CMAP %d' % years[y]

    # Note:  add 1 to pentad indices to index from 1-73 for comparison
    # with Wang & LinHo
    onset = onset + 1

    # Calculate onset dates from pentads
    nlat, nlon = onset.shape
    onset_date = np.nan * np.ones((nlat, nlon))
    for i in range(nlat):
        for j in range(nlon):
            jday = atm.pentad_to_jday(onset[i, j], pmin=1)
            mon, day = atm.jday_to_mmdd(jday)
            onset_date[i, j] = 100*mon + day
    # -- Smooth with cubic spline
    # lat_i = np.arange(-89.5, 90, 0.5)
    # lon_i = np.arange(0, 360, 0.5)
    lat_i = np.arange(-90, 90, 4.)
    lon_i = np.arange(0, 360, 4.)
    onset_date = atm.interp_latlon(onset_date, lat_i, lon_i, lat, lon, order=3)
    clev_date = [501, 511, 521, 601, 611, 621, 701, 711]
    clev_label = {}
    for d in clev_date:
        clev_label[d] = '%02d-%02d' % (d//100, d%100)

    # Plot maps
    manual = False
    plt.figure(figsize=(14,10))
    cmin, cmax = 20, 55
    plt.subplot(211)
    _, pc = atm.pcolor_latlon(onset, lat, lon, cmap=cmap, axlims=axlims)
    pc.set_clim(cmin, cmax)
    if clines:
        _, cs = atm.contour_latlon(onset_date, lat_i, lon_i, clev=clev_date,
                                   axlims=axlims)
        plt.clabel(cs, clev_date, fmt=clev_label, manual=manual)
        plt.title(titlestr + ' Onset Pentad & Day')
    else:
        plt.title(titlestr + ' Onset Pentad')

    plt.subplot(212)
    clev = np.arange(0, 1.1, 0.025)
    _, pc = atm.pcolor_latlon(Rsq, lat, lon, cmap=cmap, axlims=axlims)
    pc.set_clim(0., 1.)
    plt.title('$R^2$ for kmax = %d' % kmax)
Ejemplo n.º 2
0
 def daystr(day):
     day = round(day)
     mm, dd = atm.jday_to_mmdd(day)
     mon = atm.month_str(mm)
     return '%.0f (%s-%.0f)' % (day, mon, dd)