當前位置: 首頁>>代碼示例>>Python>>正文


Python ma.masked_less_equal方法代碼示例

本文整理匯總了Python中numpy.ma.masked_less_equal方法的典型用法代碼示例。如果您正苦於以下問題:Python ma.masked_less_equal方法的具體用法?Python ma.masked_less_equal怎麽用?Python ma.masked_less_equal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy.ma的用法示例。


在下文中一共展示了ma.masked_less_equal方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __call__

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def __call__(self, value, clip=None):
        if clip is None:
            clip = self.clip

        result, is_scalar = self.process_value(value)

        result = ma.masked_less_equal(result, 0, copy=False)

        self.autoscale_None(result)
        vmin, vmax = self.vmin, self.vmax
        if vmin > vmax:
            raise ValueError("minvalue must be less than or equal to maxvalue")
        elif vmin <= 0:
            raise ValueError("values must all be positive")
        elif vmin == vmax:
            result.fill(0)
        else:
            if clip:
                mask = ma.getmask(result)
                result = ma.array(np.clip(result.filled(vmax), vmin, vmax),
                                  mask=mask)
            # in-place equivalent of above can be much faster
            resdat = result.data
            mask = result.mask
            if mask is np.ma.nomask:
                mask = (resdat <= 0)
            else:
                mask |= resdat <= 0
            cbook._putmask(resdat, mask, 1)
            np.log(resdat, resdat)
            resdat -= np.log(vmin)
            resdat /= (np.log(vmax) - np.log(vmin))
            result = np.ma.array(resdat, mask=mask, copy=False)
        if is_scalar:
            result = result[0]
        return result 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:38,代碼來源:colors.py

示例2: autoscale

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def autoscale(self, A):
        '''
        Set *vmin*, *vmax* to min, max of *A*.
        '''
        A = ma.masked_less_equal(A, 0, copy=False)
        self.vmin = ma.min(A)
        self.vmax = ma.max(A) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:9,代碼來源:colors.py

示例3: autoscale_None

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def autoscale_None(self, A):
        ' autoscale only None-valued vmin or vmax'
        if self.vmin is not None and self.vmax is not None:
            return
        A = ma.masked_less_equal(A, 0, copy=False)
        if self.vmin is None:
            self.vmin = ma.min(A)
        if self.vmax is None:
            self.vmax = ma.max(A) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:11,代碼來源:colors.py

示例4: mask_to_limits

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def mask_to_limits(a, limits, inclusive):
    """Mask an array for values outside of given limits.

    This is primarily a utility function.

    Parameters
    ----------
    a : array
    limits : (float or None, float or None)
        A tuple consisting of the (lower limit, upper limit).  Values in the
        input array less than the lower limit or greater than the upper limit
        will be masked out. None implies no limit.
    inclusive : (bool, bool)
        A tuple consisting of the (lower flag, upper flag).  These flags
        determine whether values exactly equal to lower or upper are allowed.

    Returns
    -------
    A MaskedArray.

    Raises
    ------
    A ValueError if there are no values within the given limits.
    """
    lower_limit, upper_limit = limits
    lower_include, upper_include = inclusive
    am = ma.MaskedArray(a)
    if lower_limit is not None:
        if lower_include:
            am = ma.masked_less(am, lower_limit)
        else:
            am = ma.masked_less_equal(am, lower_limit)
    if upper_limit is not None:
        if upper_include:
            am = ma.masked_greater(am, upper_limit)
        else:
            am = ma.masked_greater_equal(am, upper_limit)
    if am.count() == 0:
        raise ValueError("No array values within given limits")
    return am 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:42,代碼來源:stats.py

示例5: autoscale

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def autoscale(self, A):
        """
        Set *vmin*, *vmax* to min, max of *A*.
        """
        A = ma.masked_less_equal(A, 0, copy=False)
        self.vmin = ma.min(A)
        self.vmax = ma.max(A) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:9,代碼來源:colors.py

示例6: operation

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def operation(self, opname, value):
        """Do operation on map values.

        Do operations on the current map values. Valid operations are:

        * 'elilt' or 'eliminatelessthan': Eliminate less than <value>

        * 'elile' or 'eliminatelessequal': Eliminate less or equal than <value>

        Args:
            opname (str): Name of operation. See list above.
            values (*): A scalar number (float) or a tuple of two floats,
                dependent on operation opname.

        Examples::

            surf.operation('elilt', 200)  # set all values < 200 as undef
        """

        if opname in ("elilt", "eliminatelessthan"):
            self._values = ma.masked_less(self._values, value)
        elif opname in ("elile", "eliminatelessequal"):
            self._values = ma.masked_less_equal(self._values, value)
        else:
            raise ValueError("Invalid operation name")

    # ==================================================================================
    # Operations restricted to inside/outside polygons
    # ================================================================================== 
開發者ID:equinor,項目名稱:xtgeo,代碼行數:31,代碼來源:regular_surface.py

示例7: _mask_to_limits

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def _mask_to_limits(a, limits, inclusive):
    """Mask an array for values outside of given limits.

    This is primarily a utility function.

    Parameters
    ----------
    a : array
    limits : (float or None, float or None)
        A tuple consisting of the (lower limit, upper limit).  Values in the
        input array less than the lower limit or greater than the upper limit
        will be masked out. None implies no limit.
    inclusive : (bool, bool)
        A tuple consisting of the (lower flag, upper flag).  These flags
        determine whether values exactly equal to lower or upper are allowed.

    Returns
    -------
    A MaskedArray.

    Raises
    ------
    A ValueError if there are no values within the given limits.
    """
    lower_limit, upper_limit = limits
    lower_include, upper_include = inclusive
    am = ma.MaskedArray(a)
    if lower_limit is not None:
        if lower_include:
            am = ma.masked_less(am, lower_limit)
        else:
            am = ma.masked_less_equal(am, lower_limit)

    if upper_limit is not None:
        if upper_include:
            am = ma.masked_greater(am, upper_limit)
        else:
            am = ma.masked_greater_equal(am, upper_limit)

    if am.count() == 0:
        raise ValueError("No array values within given limits")

    return am 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:45,代碼來源:stats.py

示例8: _mask_to_limits

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import masked_less_equal [as 別名]
def _mask_to_limits(a, limits, inclusive):
    """Mask an array for values outside of given limits.

    This is primarily a utility function.

    Parameters
    ----------
    a : array
    limits : (float or None, float or None)
    A tuple consisting of the (lower limit, upper limit).  Values in the
    input array less than the lower limit or greater than the upper limit
    will be masked out. None implies no limit.
    inclusive : (bool, bool)
    A tuple consisting of the (lower flag, upper flag).  These flags
    determine whether values exactly equal to lower or upper are allowed.

    Returns
    -------
    A MaskedArray.

    Raises
    ------
    A ValueError if there are no values within the given limits.
    """
    lower_limit, upper_limit = limits
    lower_include, upper_include = inclusive
    am = ma.MaskedArray(a)
    if lower_limit is not None:
        if lower_include:
            am = ma.masked_less(am, lower_limit)
        else:
            am = ma.masked_less_equal(am, lower_limit)

    if upper_limit is not None:
        if upper_include:
            am = ma.masked_greater(am, upper_limit)
        else:
            am = ma.masked_greater_equal(am, upper_limit)

    if am.count() == 0:
        raise ValueError("No array values within given limits")

    return am 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:45,代碼來源:mstats_basic.py


注:本文中的numpy.ma.masked_less_equal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。