def maskoceans(lonsin,latsin,datain,inlands=True,resolution='l',grid=5):
"""
mask data (``datain``), defined on a grid with latitudes ``latsin``
longitudes ``lonsin`` so that points over water will not be plotted.
.. tabularcolumns:: |l|L|
============== ====================================================
Arguments Description
============== ====================================================
lonsin, latsin rank-2 arrays containing longitudes and latitudes of
grid.
datain rank-2 input array on grid defined by ``lonsin`` and
``latsin``.
inlands if False, masked only ocean points and not inland
lakes (Default True).
resolution gshhs coastline resolution used to define land/sea
mask (default 'l', available 'c','l','i','h' or 'f')
grid land/sea mask grid spacing in minutes (Default 5;
10, 2.5 and 1.25 are also available).
============== ====================================================
returns a masked array the same shape as datain with "wet" points masked.
"""
# read in land/sea mask.
lsmask_lons, lsmask_lats, lsmask =\
_readlsmask(lakes=inlands,resolution=resolution,grid=grid)
# nearest-neighbor interpolation to output grid.
lsmasko = interp(lsmask,lsmask_lons,lsmask_lats,lonsin,latsin,masked=True,order=0)
# mask input data.
mask = lsmasko == 0
return ma.masked_array(datain,mask=mask)
评论列表
文章目录