예제 #1
0
def get_bestres(gg):
    """Get the best shoreline resolution as letter, for my grid or (lon,lat)"""
    lon, lat = get_xy(gg, num=True)
    testresol = ((lon.max()-lon.min())+(lat.max()-lat.min()))/2.0
    if testresol <1. and Histolitt.avail() and Histolitt.embed(lon, lat):
        return 's'
    return gshhs_autores(lon.min(), lon.max(), lat.min(), lat.max())
예제 #2
0
파일: bathy.py 프로젝트: acoat/vacumm
    def togrid(self, grid=None, mask=None, cgrid=False,  proj=None, **kwargs):


        # Shoreline for masking
        if mask is not None and mask is not False and mask is not MV2.nomask and grid is not None:

            # Clip for polygons
            kwmask = kwfilter(kwargs, 'mask')
            clip = kwmask.pop('clip', .1)
            if isinstance(clip, float):
                xx, yy = get_xy(grid)
                xmin = xx[:].min() ; xmax = xx[:].max()
                ymin = yy[:].min() ; ymax = yy[:].max()
                dx = (xmax-xmin)*clip
                dy = (ymax-ymin)*clip
                clip = [xmin-dx, ymin-dy, xmax+dx, ymax+dy]

            # Auto resolution
            if mask=='auto' and False:
                if grid is None:
                    grid = self.get_grid(**kwfilter(kwargs, 'grid'))
                mask = get_best(grid)

            # Direct handling
            if isinstance(mask, (str, Shapes)):
                # Get mask
                mask = get_shoreline(mask, clip=clip)

        # Normal case
        return XYZ.togrid(self, grid=grid, mask=mask, cgrid=cgrid,  proj=proj, **kwargs)
예제 #3
0
파일: showgrid.py 프로젝트: acoat/vacumm
# VACUMM path
here = os.path.dirname(__file__)
for rpath in [os.path.join(here, '../lib/python')]:
    path = os.path.abspath(rpath)
    sys.path.append(path)
try:
    from vacumm.misc.grid import resol, get_xy, create_grid
    from vacumm.misc import lonlab, latlab, scalebox
    from vacumm.misc.plot import map2, add_grid
    import cdms2
except:
    sys.exit('Error when loading vacumm')

# Dimension
gg = (lon, lat)
lonn, latn = get_xy(gg, num=True)
grid = create_grid(*gg)
print 'Dimensions           : nx=%i ny=%i' % grid.shape[::-1]
print 'Axes                 : lon="%s" lat="%s" (%iD)' % (lon.id, lat.id,
                                                          lonn.ndim)

# Extension
print 'Zonal extent         : %s -> %s  [%s -> %s]' % (
    lonn.min(), lonn.max(), lonlab(
        lonn.min(), decimal=False), lonlab(lonn.max(), decimal=False))
print 'Meridional extent    : %s -> %s  [%s -> %s]' % (
    latn.min(), latn.max(), latlab(
        latn.min(), decimal=False), latlab(latn.max(), decimal=False))

# Resolution
lonres, latres = resol(gg, proj=False)
예제 #4
0
파일: showgrid.py 프로젝트: jfleroux/vacumm
# VACUMM path
here = os.path.dirname(__file__)
for rpath in [os.path.join(here, '../lib/python')]:
    path = os.path.abspath(rpath)
    sys.path.append(path)
try:
    from vacumm.misc.grid import resol, get_xy, create_grid
    from vacumm.misc import lonlab, latlab, scalebox
    from vacumm.misc.plot import map2, add_grid
    import cdms2
except:
    sys.exit('Error when loading vacumm')

# Dimension
gg = (lon, lat)
lonn, latn = get_xy(gg, num=True)
grid = create_grid(*gg)
print 'Dimensions           : nx=%i ny=%i'%grid.shape[::-1]
print 'Axes                 : lon="%s" lat="%s" (%iD)'%(lon.id, lat.id, lonn.ndim)


# Extension
print 'Zonal extent         : %s -> %s  [%s -> %s]'%(
    lonn.min(), lonn.max(), lonlab(lonn.min(), decimal=False), lonlab(lonn.max(), decimal=False))
print 'Meridional extent    : %s -> %s  [%s -> %s]'%(
    latn.min(), latn.max(), latlab(latn.min(), decimal=False), latlab(latn.max(), decimal=False))

# Resolution
lonres, latres = resol(gg, proj=False)
xres, yres = resol(gg, proj=True)
xres /= 1000.