コード例 #1
0
def latlon_plot(varnm, reg, day_or_season, coeff='m', stipple_kw={},
                axlims=(-60, 60, 40, 120)):
    regdata = reg[varnm + '_latlon']
    keys = [key for key in regdata if key.endswith('_' + coeff)]
    clim = atm.climits(regdata[keys].to_array(), symmetric=True,
                        percentile=99.9)
    xname, yname = 'lon', 'lat'
    lat = atm.get_coord(regdata, 'lat')
    if max(np.diff(lat)) > 1:
        xsample, ysample = 1, 1
    else:
        xsample, ysample = 2, 2
    if isinstance(day_or_season, int):
        key = varnm + '_DAILY_'
        var = regdata[key + coeff].sel(dayrel=day_or_season)
        p = regdata[key + 'p'].sel(dayrel=day_or_season)
        titlestr = varnm + ' Day %d' % day_or_season
    else:
        key = varnm + '_' + day_or_season + '_'
        var = regdata[key + coeff]
        p = regdata[key + 'p']
        titlestr = varnm + ' ' + day_or_season
    pts_mask = stipple_mask(p)
    atm.pcolor_latlon(var, axlims=axlims, fancy=False)
    plt.clim(clim)
    atm.stipple_pts(pts_mask, xname, yname, xsample, ysample, **stipple_kw)
    plt.title(titlestr)
コード例 #2
0
ファイル: pub-figs-grl.py プロジェクト: jenfly/monsoon-onset
def plot_reg(pts_reg, nm, clev=0.2, xsample=1, ysample=1,
             axlims=(5, 32, 60, 100), cline=None, color='0.3', alpha=1.0,
             markersize=2):
    """Plot regression of grid point indices onto large-scale index."""
    var = pts_reg[nm]['m']
    mask = pts_reg[nm]['pts_mask']
    xname = atm.get_coord(mask, 'lon', 'name')
    yname = atm.get_coord(mask, 'lat', 'name')
    atm.contourf_latlon(var, clev=clev, axlims=axlims, extend='both')
    atm.stipple_pts(mask, xname=xname, yname=yname, xsample=xsample,
                    ysample=ysample, color=color, alpha=alpha,
                    markersize=markersize)
    if cline is not None:
        atm.contour_latlon(var, clev=[cline], axlims=axlims, colors='b',
                           linewidths=2)
    fix_axes(axlims)
コード例 #3
0
def sector_plot(var, p, stipple_kw={}, grp=None, ylim=None,
                yticks=None, clim=None):
    xname, yname = 'dayrel', 'lat'
    pts_mask = stipple_mask(p)
    lat = atm.get_coord(var, 'lat')
    days = atm.get_coord(var, 'dayrel')
    xsample = 3
    if max(np.diff(lat)) > 1:
        ysample = 1
    else:
        ysample = 2
    #utils.contourf_lat_time(lat, days, var)
    vals = np.ma.masked_array(var.T.values, mask=np.isnan(var.T))
    plt.pcolormesh(days, lat, vals, cmap='RdBu_r')
    cb = plt.colorbar()
    atm.stipple_pts(pts_mask, xname, yname, xsample, ysample, **stipple_kw)
    plt.title(varnm)
    plt.xlabel('Relative Day')
    plt.ylabel('Latitude')
    plt.grid(True)
    xticks = np.arange(-120, 201, 30)
    xlims = (-120, 200)
    plt.xlim(xlims)
    plt.xticks(xticks)
    if grp is not None:
        if grp.col > 0:
            plt.ylabel('')
        if grp.row < grp.nrow - 1:
            plt.xlabel('')
    if ylim is not None:
        plt.ylim(ylim)
    if yticks is not None:
        plt.yticks(yticks)
    if clim is not None:
        plt.clim(clim)
    else:
        clim = atm.climits(var, symmetric=True, percentile=99.9)
        plt.clim(clim)