本文整理匯總了Python中numpy.ma.min方法的典型用法代碼示例。如果您正苦於以下問題:Python ma.min方法的具體用法?Python ma.min怎麽用?Python ma.min使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.ma
的用法示例。
在下文中一共展示了ma.min方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: shade
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def shade(self, data, cmap, norm=None):
"""
Take the input data array, convert to HSV values in the
given colormap, then adjust those color values
to give the impression of a shaded relief map with a
specified light source.
RGBA values are returned, which can then be used to
plot the shaded image with imshow.
"""
if norm is None:
norm = Normalize(vmin=data.min(), vmax=data.max())
rgb0 = cmap(norm(data))
rgb1 = self.shade_rgb(rgb0, elevation=data)
rgb0[:, :, 0:3] = rgb1
return rgb0
示例2: _contour_args
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def _contour_args(self, args, kwargs):
if self.filled:
fn = 'contourf'
else:
fn = 'contour'
Nargs = len(args)
if Nargs <= 2:
z = ma.asarray(args[0], dtype=np.float64)
x, y = self._initialize_x_y(z)
args = args[1:]
elif Nargs <= 4:
x, y, z = self._check_xyz(args[:3], kwargs)
args = args[3:]
else:
raise TypeError("Too many arguments to %s; see help(%s)" %
(fn, fn))
z = ma.masked_invalid(z, copy=False)
self.zmax = float(z.max())
self.zmin = float(z.min())
if self.logscale and self.zmin <= 0:
z = ma.masked_where(z <= 0, z)
warnings.warn('Log scale: values of z <= 0 have been masked')
self.zmin = float(z.min())
self._contour_level_args(z, args)
return (x, y, z)
示例3: regridToCoarse
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def regridToCoarse(fine,fac,mode,missValue):
nr,nc = np.shape(fine)
coarse = np.zeros(nr/fac * nc / fac).reshape(nr/fac,nc/fac) + MV
nr,nc = np.shape(coarse)
for r in range(0,nr):
for c in range(0,nc):
ar = fine[r * fac : fac * (r+1),c * fac: fac * (c+1)]
m = np.ma.masked_values(ar,missValue)
if ma.count(m) == 0:
coarse[r,c] = MV
else:
if mode == 'average':
coarse [r,c] = ma.average(m)
elif mode == 'median':
coarse [r,c] = ma.median(m)
elif mode == 'sum':
coarse [r,c] = ma.sum(m)
elif mode =='min':
coarse [r,c] = ma.min(m)
elif mode == 'max':
coarse [r,c] = ma.max(m)
return coarse
示例4: autoscale
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def autoscale(self, A):
'''
Set *vmin*, *vmax* to min, max of *A*.
'''
self.vmin = ma.min(A)
self.vmax = ma.max(A)
示例5: autoscale_None
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def autoscale_None(self, A):
' autoscale only None-valued vmin or vmax'
if self.vmin is None and np.size(A) > 0:
self.vmin = ma.min(A)
if self.vmax is None and np.size(A) > 0:
self.vmax = ma.max(A)
示例6: shade
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def shade(self, data, cmap):
"""
Take the input data array, convert to HSV values in the
given colormap, then adjust those color values
to given the impression of a shaded relief map with a
specified light source.
RGBA values are returned, which can then be used to
plot the shaded image with imshow.
"""
rgb0 = cmap((data - data.min()) / (data.max() - data.min()))
rgb1 = self.shade_rgb(rgb0, elevation=data)
rgb0[:, :, 0:3] = rgb1
return rgb0
示例7: autoscale
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def autoscale(self, A):
"""
Set *vmin*, *vmax* to min, max of *A*.
"""
self.vmin = ma.min(A)
self.vmax = ma.max(A)
示例8: _process_args
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def _process_args(self, *args, **kwargs):
"""
Process *args* and *kwargs*; override in derived classes.
Must set self.levels, self.zmin and self.zmax, and update axes
limits.
"""
self.levels = args[0]
self.allsegs = args[1]
self.allkinds = len(args) > 2 and args[2] or None
self.zmax = np.max(self.levels)
self.zmin = np.min(self.levels)
self._auto = False
# Check lengths of levels and allsegs.
if self.filled:
if len(self.allsegs) != len(self.levels) - 1:
raise ValueError('must be one less number of segments as '
'levels')
else:
if len(self.allsegs) != len(self.levels):
raise ValueError('must be same number of segments as levels')
# Check length of allkinds.
if (self.allkinds is not None and
len(self.allkinds) != len(self.allsegs)):
raise ValueError('allkinds has different length to allsegs')
# Determine x,y bounds and update axes data limits.
flatseglist = [s for seg in self.allsegs for s in seg]
points = np.concatenate(flatseglist, axis=0)
self._mins = points.min(axis=0)
self._maxs = points.max(axis=0)
return kwargs
示例9: _contour_level_args
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def _contour_level_args(self, z, args):
"""
Determine the contour levels and store in self.levels.
"""
if self.filled:
fn = 'contourf'
else:
fn = 'contour'
self._auto = False
if self.levels is None:
if len(args) == 0:
levels_arg = 7 # Default, hard-wired.
else:
levels_arg = args[0]
else:
levels_arg = self.levels
if isinstance(levels_arg, Integral):
self.levels = self._autolev(levels_arg)
else:
self.levels = np.asarray(levels_arg).astype(np.float64)
if not self.filled:
inside = (self.levels > self.zmin) & (self.levels < self.zmax)
levels_in = self.levels[inside]
if len(levels_in) == 0:
self.levels = [self.zmin]
warnings.warn("No contour levels were found"
" within the data range.")
if self.filled and len(self.levels) < 2:
raise ValueError("Filled contours require at least 2 levels.")
if len(self.levels) > 1 and np.min(np.diff(self.levels)) <= 0.0:
raise ValueError("Contour levels must be increasing")
示例10: _process_levels
# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import min [as 別名]
def _process_levels(self):
"""
Assign values to :attr:`layers` based on :attr:`levels`,
adding extended layers as needed if contours are filled.
For line contours, layers simply coincide with levels;
a line is a thin layer. No extended levels are needed
with line contours.
"""
# Make a private _levels to include extended regions; we
# want to leave the original levels attribute unchanged.
# (Colorbar needs this even for line contours.)
self._levels = list(self.levels)
if self.logscale:
lower, upper = 1e-250, 1e250
else:
lower, upper = -1e250, 1e250
if self.extend in ('both', 'min'):
self._levels.insert(0, lower)
if self.extend in ('both', 'max'):
self._levels.append(upper)
self._levels = np.asarray(self._levels)
if not self.filled:
self.layers = self.levels
return
# Layer values are mid-way between levels in screen space.
if self.logscale:
# Avoid overflow by taking sqrt before multiplying.
self.layers = (np.sqrt(self._levels[:-1])
* np.sqrt(self._levels[1:]))
else:
self.layers = 0.5 * (self._levels[:-1] + self._levels[1:])