Exemplo n.º 1
0
def pts_clim(index_pts, nm, clev_bar=10, clev_std=np.arange(0, 21, 1),
             axlims=(5, 32, 60, 100), cmap='spectral', res='c',
             label_locs=None, inline_spacing=2):
    """Plot climatological mean and standard deviation of grid point indices."""
    varbar = index_pts[nm].mean(dim='year')
    varstd = index_pts[nm].std(dim='year')
    lat1, lat2, lon1, lon2 = axlims
    m = atm.init_latlon(lat1, lat2, lon1, lon2, resolution=res)
    m = atm.contourf_latlon(varstd, m=m, clev=clev_std, axlims=axlims, cmap=cmap,
                            symmetric=False, colorbar=False, extend='max')
    m.colorbar(ticks=np.arange(0, 21, 2))
    _, cs = atm.contour_latlon(varbar, clev=clev_bar, axlims=axlims, colors='k',
                               linewidths=2)
    cs_opts = {'fmt' : '%.0f', 'fontsize' : 9,
               'inline_spacing' : inline_spacing}
    if label_locs is not None:
        cs_opts['manual'] = label_locs
    plt.clabel(cs, **cs_opts)
    fix_axes(axlims)
Exemplo n.º 2
0
def plot_maps(var, days, grp, cmin=0, cmax=20, cint=1, axlims=(5, 35, 60, 100),
                cmap='PuBuGn', res='c', extend='max', cticks=None,
                daypos=(0.05, 0.85)):
    """Lat-lon maps of precip on selected days."""
    clev = np.arange(cmin, cmax + cint/2.0, cint)
    if cticks is None:
        cticks = np.arange(cmin, clev.max() + 1, 2)
    lat1, lat2, lon1, lon2 = axlims
    for day in days:
        grp.next()
        pcp = var.sel(dayrel=day)
        m = atm.init_latlon(lat1, lat2, lon1, lon2, resolution=res)
        m = atm.contourf_latlon(pcp, m=m, clev=clev, axlims=axlims, cmap=cmap,
                                colorbar=False, extend=extend)
        atm.text(day, daypos, fontsize=12, fontweight='bold')
    # plt.colorbar(ax=grp.axes.ravel().tolist(), orientation='vertical',
    #              shrink=0.8, ticks=cticks)
    atm.colorbar_multiplot(orientation='vertical', shrink=0.8, ticks=cticks)
    fix_axes(axlims)
exts = ['png', 'eps']
isave = True

howi, ds = onset_HOWI(uq_int, vq_int, npts)

# ----------------------------------------------------------------------
# MAPS
# ----------------------------------------------------------------------
# Plot climatological VIMT composites
lat = atm.get_coord(ds, 'lat')
lon = atm.get_coord(ds, 'lon')
x, y = np.meshgrid(lon, lat)
axlims = (lat1, lat2, lon1, lon2)
plt.figure(figsize=(12,10))
plt.subplot(221)
m = atm.init_latlon(lat1, lat2, lon1, lon2)
m.quiver(x, y, ds['uq_bar_pre'], ds['vq_bar_pre'])
plt.title(pre_days + ' VIMT Climatology')
plt.subplot(223)
m = atm.init_latlon(lat1, lat2, lon1, lon2)
m.quiver(x, y, ds['uq_bar_post'], ds['vq_bar_post'])
plt.title(post_days + ' VIMT Climatology')

# Plot difference between pre- and post- composites
plt.subplot(222)
m = atm.init_latlon(lat1, lat2, lon1, lon2)
#m, _ = atm.pcolor_latlon(ds['vimt_bar_diff'], axlims=axlims, cmap='hot_r')
m.quiver(x, y, ds['uq_bar_diff'], ds['vq_bar_diff'])
plt.title(post_days + ' minus ' + pre_days + ' VIMT Climatology')

# Top N difference vectors