Esempio n. 1
0
def plot_grid(lon, lat, dhdt, cell=None, plot_cell=False, contourf=True):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    plon, plat = lon[GRID_CELL[1]], lat[GRID_CELL[0]]
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    x, y = m(plon, plat)
    print 'point cell (lon lat x y):', plon, plat, x, y
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)

    #plt.colorbar().set_label(LABEL)
    viz.colorbar(fig, CMAP, (-ABS_VAL, ABS_VAL))
    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    return fig
Esempio n. 2
0
def plot_grid(lon, lat, dhdt, cell=None, plot_cell=False, contourf=True):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    plon, plat = lon[GRID_CELL[1]], lat[GRID_CELL[0]]
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    x, y = m(plon, plat)
    print 'point cell (lon lat x y):', plon, plat, x, y
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)

    #plt.colorbar().set_label(LABEL)
    viz.colorbar(fig, CMAP, (-ABS_VAL,ABS_VAL))

    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    return fig
Esempio n. 3
0
def plot_grid(lon,
              lat,
              dhdt,
              cell=None,
              plot_cell=False,
              contourf=True,
              savefig=None):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    plon, plat = lon[GRID_CELL[1]], lat[GRID_CELL[0]]
    # shift grid half degree
    lon -= (lon[1] - lon[0]) / 2.
    lat -= (lat[1] - lat[0]) / 2.
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    x, y = m(plon, plat)
    print 'point cell (lon lat x y):', plon, plat, x, y
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    p_ = m.drawparallels(np.arange(-90., -60, 6),
                         labels=[0, 0, 0, 1],
                         color='0.8')
    m_ = m.drawmeridians(np.arange(-180, 180., 12),
                         labels=[1, 0, 0, 0],
                         color='0.8')
    #m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)
    ###
    '''
    x2, y2 = np.loadtxt('/Users/fpaolo/data/masks/scripps/scripps_iceshelves_v1_geod.txt', 
                        usecols=(0,1), unpack=True, comments='%')
    x2, y2 = m(x2, y2)
    m.plot(x2, y2, 'o', markersize=0.8)
    '''
    ###
    #plt.colorbar().set_label(LABEL)
    #viz.colorbar(fig, CMAP, (-ABS_VAL,ABS_VAL), title='m/yr')
    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    if savefig is not None:
        plt.savefig(savefig + '_map.png')
    return fig
Esempio n. 4
0
def plot_map(lon, lat, RR, bbox, mfile, mres=1):
    fig1 = plt.figure()
    ax = fig1.add_subplot(111)
    m = viz.make_proj_stere(bbox)
    m = viz.plot_grid_proj(m, lon, lat, RR, contourf=False, shift=True)
    plt.colorbar(orientation='vertical', shrink=.7)
    x, y, mask = viz.get_gtif_subreg(m, mfile, mres)
    mask = np.ma.masked_values(mask, 4)
    m.imshow(mask, zorder=1, cmap=plt.cm.gray_r)
    #m = plot_boundaries(m, (lon.min(),lon.max(),lat.min()-10,lat.max()+3))
    p_ = m.drawparallels(np.arange(-90.,-70.,3), labels=[0,0,1,0], color='0.6')
    m_ = m.drawmeridians(np.arange(-80.,-20.,5), labels=[1,0,0,0], color='0.6')
    return fig1 
Esempio n. 5
0
def plot_map(lon, lat, grid, bbox, mfile, mres=1, **kw):
    fig1 = plt.figure()
    ax = fig1.add_subplot(111)
    m = viz.make_proj_stere(bbox)
    m = viz.plot_grid_proj(m, lon, lat, grid, contourf=False, shift=True, **kw)
    #plt.colorbar(orientation='vertical', shrink=.7)
    #x, y, mask = viz.get_gtif_subreg(m, mfile, mres)
    #mask = np.ma.masked_values(mask, 4)
    #m.imshow(mask, zorder=0, cmap=plt.cm.gray_r)
    #m = plot_boundaries(m, (lon.min(),lon.max(),lat.min()-10,lat.max()+3))
    #p_ = m.drawparallels(np.arange(-90.,-70.,3), labels=[0,0,0,1], color='0.6')
    #m_ = m.drawmeridians(np.arange(-80.,-20.,5), labels=[1,0,0,0], color='0.6')
    #viz.colorbar(fig1, CMAP, (-ABS_VAL,ABS_VAL))
    return fig1
Esempio n. 6
0
def plot_grid(lon, lat, dhdt, cell=None, plot_cell=False, contourf=True, savefig=None):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    plon, plat = lon[GRID_CELL[1]], lat[GRID_CELL[0]]
    # shift grid half degree
    lon -= (lon[1] - lon[0])/2.
    lat -= (lat[1] - lat[0])/2.
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    x, y = m(plon, plat)
    print 'point cell (lon lat x y):', plon, plat, x, y
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    p_ = m.drawparallels(np.arange(-90.,-60, 2), labels=[1,0,0,0], color='0.3')
    m_ = m.drawmeridians(np.arange(-180,180., 15), labels=[0,0,1,0], color='0.3')
    #m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)
    ###
    '''
    x2, y2 = np.loadtxt('/Users/fpaolo/data/masks/scripps/scripps_iceshelves_v1_geod.txt', 
                        usecols=(0,1), unpack=True, comments='%')
    x2, y2 = m(x2, y2)
    m.plot(x2, y2, 'o', markersize=1.2)
    '''
    ###
    #plt.colorbar().set_label(LABEL)
    rect = 0.25, 0.11, 0.5, 0.02
    viz.colorbar(fig, CMAP, (-ABS_VAL,ABS_VAL), title='Elevation change rate (m/yr)',
                 rect=rect)
    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    if savefig is not None:
        plt.savefig(savefig+'_map.png')
    return fig
Esempio n. 7
0
def plot_map(lon, lat, grid, bbox, mfile, mres=1, **kw):
    """
    **kw : keyword args
        contourf=[True/False]
        vmin=int
        vmax=int
    """
    fig1 = plt.figure()
    ax = fig1.add_subplot(111)
    m = viz.make_proj_stere(bbox)
    m = viz.plot_grid_proj(m, lon, lat, grid, shift=True, **kw)
    plt.colorbar(orientation='vertical', shrink=.65)
    x, y, mask = viz.get_gtif_subreg(m, mfile, mres)
    mask = np.ma.masked_values(mask, 4)
    m.imshow(mask, zorder=1, cmap=plt.cm.gray_r)
    #m = plot_boundaries(m, (lon.min(),lon.max(),lat.min()-10,lat.max()+3))
    p_ = m.drawparallels(np.arange(-90.,-60,3), labels=[0,0,0,1], color='0.2')
    m_ = m.drawmeridians(np.arange(-180,180.,5), labels=[1,0,0,0], color='0.2')
    return fig1 
Esempio n. 8
0
def plot_grid(lon, lat, dhdt, cell=None, plot_cell=False, contourf=True):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    p_ = m.drawparallels(np.arange(-90.,-60, 5), labels=[0,0,0,1], color='0.8')
    m_ = m.drawmeridians(np.arange(-180,180., 10), labels=[1,0,0,0], color='0.8')
    ###
    '''
    xx, yy = np.loadtxt('/Users/fpaolo/data/masks/scripps/scripps_iceshelves_v1_geod.txt', usecols=(0,1), unpack=True, comments='%')
    xx, yy = m(xx, yy)
    m.plot(xx, yy, 'o', markersize=0.1)
    '''
    ###
    #m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)

    #plt.colorbar().set_label(LABEL)
    viz.colorbar(fig, CMAP, (-ABS_VAL,ABS_VAL))

    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    return fig
Esempio n. 9
0
def plot_map(lon, lat, grid, bbox, mfile, mres=1, **kw):
    """
    **kw : keyword args
        contourf=[True/False]
        vmin=int
        vmax=int
    """
    fig1 = plt.figure()
    ax = fig1.add_subplot(111)
    m = viz.make_proj_stere(bbox)
    m = viz.plot_grid_proj(m, lon, lat, grid, shift=True, **kw)
    plt.colorbar(orientation='vertical', shrink=.65)
    x, y, mask = viz.get_gtif_subreg(m, mfile, mres)
    mask = np.ma.masked_values(mask, 4)
    m.imshow(mask, zorder=1, cmap=plt.cm.gray_r)
    #m = plot_boundaries(m, (lon.min(),lon.max(),lat.min()-10,lat.max()+3))
    p_ = m.drawparallels(np.arange(-90., -60, 3),
                         labels=[0, 0, 0, 1],
                         color='0.2')
    m_ = m.drawmeridians(np.arange(-180, 180., 5),
                         labels=[1, 0, 0, 0],
                         color='0.2')
    return fig1