当前位置: 首页>>代码示例>>Python>>正文


Python ma.min方法代码示例

本文整理汇总了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 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:19,代码来源:colors.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:27,代码来源:contour.py

示例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 
开发者ID:UU-Hydro,项目名称:PCR-GLOBWB_model,代码行数:24,代码来源:virtualOS.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:colors.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:colors.py

示例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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:colors.py

示例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) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:8,代码来源:colors.py

示例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 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:37,代码来源:contour.py

示例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") 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:36,代码来源:contour.py

示例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:]) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:38,代码来源:contour.py


注:本文中的numpy.ma.min方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。