Ejemplo n.º 1
0
def contourf_latday(var, clev=None, title='', nc_pref=40, grp=None,
                    xlims=(-120, 200), xticks=np.arange(-120, 201, 30),
                    ylims=(-60, 60), yticks=np.arange(-60, 61, 20),
                    ssn_length=None):
    vals = var.values.T
    lat = atm.get_coord(var, 'lat')
    days = atm.get_coord(var, 'dayrel')
    if var.name.lower() == 'precip':
        cmap = 'hot_r'
        extend = 'max'
    else:
        cmap = 'RdBu_r'
        extend = 'both'
    if clev == None:
        symmetric = atm.symm_colors(vals)
        cint = atm.cinterval(vals, n_pref=nc_pref, symmetric=symmetric)
        clev = atm.clevels(vals, cint, symmetric=symmetric)
    cticks_dict = {'precip' : np.arange(0, 13, 2),
                   'T200' : np.arange(-208, 227, 2),
                   'U200' : np.arange(-60, 61, 10),
                   'PSI500' : np.arange(-800, 801, 200)}
    cticks = cticks_dict.get(var.name)
    plt.contourf(days, lat, vals, clev, cmap=cmap, extend=extend)
    plt.colorbar(ticks=cticks)
    fmt_axes(xlims, xticks, ylims, yticks)
    plt.grid()
    plt.title(title)
    plt.axvline(0, color='k')
    if ssn_length is not None:
        plt.axvline(ssn_length, color='k')
    if grp is not None and grp.row == grp.ncol - 1:
        plt.xlabel('Rel Day')
    if grp is not None and grp.col == 0:
        plt.ylabel('Latitude')
Ejemplo n.º 2
0
def contourf_lat_time(lat, days, plotdata, clev=None, title='', cmap='RdBu_r',
                      onset_nm='', zero_line=False, ax=None):
    if ax is None:
        ax = plt.gca()
    vals = plotdata.values.T
    vals = np.ma.array(vals, mask=np.isnan(vals))
    ncont = 40
    symmetric = atm.symm_colors(plotdata)
    if clev == None:
        cint = atm.cinterval(vals, n_pref=ncont, symmetric=symmetric)
        clev = atm.clevels(vals, cint, symmetric=symmetric)
    cf = ax.contourf(days, lat, vals, clev, cmap=cmap)
    plt.colorbar(mappable=cf, ax=ax)
    #plot_colorbar(symmetric, ax=ax, mappable=cf)
    if symmetric and zero_line:
        ax.contour(days, lat, vals, [0], colors='k')
    ax.grid(True)
    ax.set_ylabel('Latitude')
    ax.set_xlabel('Day Relative to %s Onset' % onset_nm)
    ax.set_title(title)
    xmin, xmax = ax.get_xlim()
    if xmax > 60:
        ax.set_xticks(range(int(xmin), int(xmax) + 1, 30))
    plt.draw()
Ejemplo n.º 3
0
     cmin = -cmax
 else:
     cmin, cmax = climits[varnm][0], climits[varnm][1]
 # Lat-lon maps of composites
 for j, key in enumerate(keys):
     grp.next()
     if comp_attrs[key]['axis'] == 1:
         cmap = get_colormap(varnm, anom_plot)
     else:
         cmap = 'RdBu_r'
     atm.pcolor_latlon(dat[key], axlims=axlims, cmap=cmap, fancy=False)
     plt.xticks(range(40, 121, 20))
     if comp_attrs[key]['axis'] == 1:
         plt.clim(cmin, cmax)
     else:
         symmetric = atm.symm_colors(dat[key])
         if symmetric:
             cmax = np.nanmax(abs(dat[key]))
             plt.clim(-cmax, cmax)
     plt.title(varstr + ' ' + key.upper(), fontsize=11)
     if grp.col > 0:
         plt.gca().set_yticklabels([])
     if grp.row < nrow - 1:
         plt.gca().set_xticklabels([])
 # Line plots of sector averages
 grp.next()
 if varnm == 'precip':
     legend_opts['loc'] = 'upper center'
 else:
     legend_opts['loc'] = 'lower center'
 title = '%s %d-%dE' % (varstr, lon1, lon2)