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


Python numpy.nanmin方法代码示例

本文整理汇总了Python中numpy.nanmin方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.nanmin方法的具体用法?Python numpy.nanmin怎么用?Python numpy.nanmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.nanmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: apply_cmap

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def apply_cmap(zs, cmap, vmin=None, vmax=None, unit=None, logrescale=False):
    '''
    apply_cmap(z, cmap) applies the given cmap to the values in z; if vmin and/or vmax are passed,
      they are used to scale z.

    Note that this function can automatically rescale data into log-space if the colormap is a
    neuropythy log-space colormap such as log_eccentricity. To enable this behaviour use the
    optional argument logrescale=True.
    '''
    zs = pimms.mag(zs) if unit is None else pimms.mag(zs, unit)
    zs = np.asarray(zs, dtype='float')
    if pimms.is_str(cmap): cmap = matplotlib.cm.get_cmap(cmap)
    if logrescale:
        if vmin is None: vmin = np.log(np.nanmin(zs))
        if vmax is None: vmax = np.log(np.nanmax(zs))
        mn = np.exp(vmin)
        u = zdivide(nanlog(zs + mn) - vmin, vmax - vmin, null=np.nan)
    else:        
        if vmin is None: vmin = np.nanmin(zs)
        if vmax is None: vmax = np.nanmax(zs)
        u = zdivide(zs - vmin, vmax - vmin, null=np.nan)
    u[np.isnan(u)] = -np.inf
    return cmap(u) 
开发者ID:noahbenson,项目名称:neuropythy,代码行数:25,代码来源:core.py

示例2: __call__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def __call__(self, transform_xy, x1, y1, x2, y2):
        x_, y_ = np.linspace(x1, x2, self.nx), np.linspace(y1, y2, self.ny)
        x, y = np.meshgrid(x_, y_)
        lon, lat = transform_xy(np.ravel(x), np.ravel(y))

        with np.errstate(invalid='ignore'):
            if self.lon_cycle is not None:
                lon0 = np.nanmin(lon)
                # Changed from 180 to 360 to be able to span only
                # 90-270 (left hand side)
                lon -= 360. * ((lon - lon0) > 360.)
            if self.lat_cycle is not None:
                lat0 = np.nanmin(lat)
                # Changed from 180 to 360 to be able to span only
                # 90-270 (left hand side)
                lat -= 360. * ((lat - lat0) > 360.)

        lon_min, lon_max = np.nanmin(lon), np.nanmax(lon)
        lat_min, lat_max = np.nanmin(lat), np.nanmax(lat)

        lon_min, lon_max, lat_min, lat_max = \
            self._adjust_extremes(lon_min, lon_max, lat_min, lat_max)

        return lon_min, lon_max, lat_min, lat_max 
开发者ID:python-control,项目名称:python-control,代码行数:26,代码来源:grid.py

示例3: test_calc_f107a_daily_missing

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def test_calc_f107a_daily_missing(self):
        """ Test the calc_f107a routine with some daily data missing"""

        self.testInst.data = pds.DataFrame({'f107': np.linspace(70, 200, 160)},
                                           index=[pysat.datetime(2009, 1, 1)
                                                  + pds.DateOffset(days=2*i+1)
                                                  for i in range(160)])
        sw_f107.calc_f107a(self.testInst, f107_name='f107', f107a_name='f107a')

        # Assert that new data and metadata exist
        assert 'f107a' in self.testInst.data.columns
        assert 'f107a' in self.testInst.meta.keys()

        # Assert the finite values have realistic means
        assert(np.nanmin(self.testInst['f107a'])
               > np.nanmin(self.testInst['f107']))
        assert(np.nanmax(self.testInst['f107a'])
               < np.nanmax(self.testInst['f107']))

        # Assert the expected number of fill values
        assert(len(self.testInst['f107a'][np.isnan(self.testInst['f107a'])])
               == 40) 
开发者ID:pysat,项目名称:pysat,代码行数:24,代码来源:test_sw.py

示例4: test_unsorted_index_lims

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def test_unsorted_index_lims(self):
        df = DataFrame({'y': [0., 1., 2., 3.]}, index=[1., 0., 3., 2.])
        ax = df.plot()
        xmin, xmax = ax.get_xlim()
        lines = ax.get_lines()
        assert xmin <= np.nanmin(lines[0].get_data()[0])
        assert xmax >= np.nanmax(lines[0].get_data()[0])

        df = DataFrame({'y': [0., 1., np.nan, 3., 4., 5., 6.]},
                       index=[1., 0., 3., 2., np.nan, 3., 2.])
        ax = df.plot()
        xmin, xmax = ax.get_xlim()
        lines = ax.get_lines()
        assert xmin <= np.nanmin(lines[0].get_data()[0])
        assert xmax >= np.nanmax(lines[0].get_data()[0])

        df = DataFrame({'y': [0., 1., 2., 3.], 'z': [91., 90., 93., 92.]})
        ax = df.plot(x='z', y='y')
        xmin, xmax = ax.get_xlim()
        lines = ax.get_lines()
        assert xmin <= np.nanmin(lines[0].get_data()[0])
        assert xmax >= np.nanmax(lines[0].get_data()[0]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,代码来源:test_frame.py

示例5: scatter_lims

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def scatter_lims(vals1, vals2=None, buffer=.05):
  if vals2 is not None:
    vals = np.concatenate((vals1, vals2))
  else:
    vals = vals1
  vmin = np.nanmin(vals)
  vmax = np.nanmax(vals)

  buf = .05 * (vmax - vmin)

  if vmin == 0:
    vmin -= buf / 2
  else:
    vmin -= buf
  vmax += buf

  return vmin, vmax

################################################################################
# __main__
################################################################################ 
开发者ID:calico,项目名称:basenji,代码行数:23,代码来源:bam_cov.py

示例6: scatter_lims

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def scatter_lims(vals1, vals2=None, buffer=.05):
  if vals2 is not None:
    vals = np.concatenate((vals1, vals2))
  else:
    vals = vals1
  vmin = np.nanmin(vals)
  vmax = np.nanmax(vals)

  buf = .05 * (vmax - vmin)

  if vmin == 0:
    vmin -= buf / 2
  else:
    vmin -= buf
  vmax += buf

  return vmin, vmax


################################################################################
# nucleotides

# Thanks to Anshul Kundaje, Avanti Shrikumar
# https://github.com/kundajelab/deeplift/tree/master/deeplift/visualization 
开发者ID:calico,项目名称:basenji,代码行数:26,代码来源:plots.py

示例7: findminval_multirasters

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def findminval_multirasters(FileList):
    """
    Loops through a list or array of rasters (np arrays)
    and finds the minimum single value in the set of arrays.
    """
    overall_min_val = 0

    for i in range (len(FileList)):

        raster_as_array = LSDMap_IO.ReadRasterArrayBlocks(FileList[i])
        this_min_val = np.nanmin(raster_as_array)

        if this_min_val > overall_min_val:
            overall_min_val = this_min_val
            print(overall_min_val)

    return overall_min_val 
开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:19,代码来源:LSDMap_Subplots.py

示例8: quickMinMax

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def quickMinMax(self, data):
        """
        Estimate the min/max values of *data* by subsampling.
        Returns [(min, max), ...] with one item per channel
        """
        while data.size > 1e6:
            ax = np.argmax(data.shape)
            sl = [slice(None)] * data.ndim
            sl[ax] = slice(None, None, 2)
            data = data[sl]
            
        cax = self.axes['c']
        if cax is None:
            return [(float(nanmin(data)), float(nanmax(data)))]
        else:
            return [(float(nanmin(data.take(i, axis=cax))), 
                     float(nanmax(data.take(i, axis=cax)))) for i in range(data.shape[-1])] 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:19,代码来源:ImageView.py

示例9: netcdf_to_geojson

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def netcdf_to_geojson(ncfile, var, fourth_dim=None):
    realpath = os.path.realpath(ncfile)
    name, ext = os.path.splitext(realpath)
    X, Y, Z, levels, unit = setup(ncfile, var)
    figure = plt.figure()
    ax = figure.add_subplot(111)
    for t in range(len(Z.time)):
        third = Z.isel(time=t)
        position = 0
        if len(third.dims) == 3:
            position = len(getattr(third, third.dims[0]))-1
            third = third[position, ]
        # local min max
        levels = np.linspace(start=np.nanmin(third),
                             stop=np.nanmax(third), num=20)
        contourf = ax.contourf(X, Y, third, levels=levels, cmap=plt.cm.viridis)
        geojsoncontour.contourf_to_geojson(
            contourf=contourf,
            geojson_filepath='{}_{}_t{}_{}.geojson'.format(name, var,
                                                           t, position),
            ndigits=3,
            min_angle_deg=None,
            unit=unit
        ) 
开发者ID:bartromgens,项目名称:geojsoncontour,代码行数:26,代码来源:netcdfhelper.py

示例10: return_normalized_distance_matrix

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def return_normalized_distance_matrix(self, input_vector):
        """Return the min-max normalized euclidean-distance matrix between the input vector and the SOM weights.

        A value of 0.0 means that the input/weights are equal.
        @param input_vector the vector to use for the comparison.
        """
        output_matrix = np.zeros((self._matrix_size, self._matrix_size))
        it = np.nditer(output_matrix, flags=['multi_index'])
        while not it.finished:
            #print "%d <%s>" % (it[0], it.multi_index),
            dist = self.return_euclidean_distance(input_vector, self._weights_matrix[it.multi_index[0], it.multi_index[1], :])
            output_matrix[it.multi_index[0], it.multi_index[1]] = dist
            it.iternext()
        #min-max normalization
        max_value = np.nanmax(output_matrix)
        min_value = np.nanmin(output_matrix)
        output_matrix = (output_matrix - min_value) / (max_value - min_value)
        return output_matrix 
开发者ID:mpatacchiola,项目名称:pyERA,代码行数:20,代码来源:som.py

示例11: return_similarity_matrix

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def return_similarity_matrix(self, input_vector):
        """Return a similarity matrix where a value is 1.0 if the distance input/weight is zero.

        @param input_vector the vector to use for the comparison.
        """
        output_matrix = np.zeros((self._matrix_size, self._matrix_size))
        it = np.nditer(output_matrix, flags=['multi_index'])
        while not it.finished:
            #print "%d <%s>" % (it[0], it.multi_index),
            dist = self.return_euclidean_distance(input_vector, self._weights_matrix[it.multi_index[0], it.multi_index[1], :])
            output_matrix[it.multi_index[0], it.multi_index[1]] = dist
            it.iternext()
        #min-max normalization
        max_value = np.nanmax(output_matrix)
        min_value = np.nanmin(output_matrix)
        output_matrix = (output_matrix - min_value) / (max_value - min_value)
        output_matrix = 1.0 - output_matrix
        return output_matrix 
开发者ID:mpatacchiola,项目名称:pyERA,代码行数:20,代码来源:som.py

示例12: fuzzify_partitions

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def fuzzify_partitions(p):
    def fuzzify_p(A):
        R = np.zeros((A.shape[0], A.shape[1] * p))

        cmin, cmax = np.nanmin(A, 0), np.nanmax(A, 0)
        psize = (cmax - cmin) / (p - 1)

        mus = []
        # iterate features
        for i in range(A.shape[1]):
            # iterate partitions
            mu_i = []
            offset = cmin[i]
            for j in range(p):
                f = fl.TriangularSet(offset - psize[i], offset, offset + psize[i])
                R[:, (i * p) + j] = f(A[:, i])
                mu_i.append(f)
                offset += psize[i]
            mus.append(mu_i)
        return p, R, mus
    return fuzzify_p 
开发者ID:sorend,项目名称:fylearn,代码行数:23,代码来源:rafpc.py

示例13: fuzzify_mean

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def fuzzify_mean(A):
    # output for fuzzified values
    R = np.zeros((A.shape[0], A.shape[1] * 3))

    cmin, cmax, cmean = np.nanmin(A, 0), np.nanmax(A, 0), np.nanmean(A, 0)
        
    left = np.array([cmin - (cmax - cmin), cmin, cmax]).T
    middle = np.array([cmin, cmean, cmax]).T
    right = np.array([cmin, cmax, cmax + (cmax - cmin)]).T

    mus = []

    for i in range(A.shape[1]):
        f_l = fl.TriangularSet(*left[i])
        f_m = fl.TriangularSet(*middle[i])
        f_r = fl.TriangularSet(*right[i])
        R[:,(i*3)] = f_l(A[:,i])
        R[:,(i*3)+1] = f_m(A[:,i])
        R[:,(i*3)+2] = f_r(A[:,i])
        mus.extend([(i, f_l), (i, f_m), (i, f_r)])

    return 3, R, mus 
开发者ID:sorend,项目名称:fylearn,代码行数:24,代码来源:rafpc.py

示例14: scale_for_cmap

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def scale_for_cmap(cmap, x, vmin=Ellipsis, vmax=Ellipsis, unit=Ellipsis):
    '''
    scale_for_cmap(cmap, x) yields the values in x rescaled to be appropriate for the given
      colormap cmap. The cmap must be the name of a colormap or a colormap object.

    For a given cmap argument, if the object is a colormap itself, it is treated as cmap.name.
    If the cmap names a colormap known to neuropythy, neuropythy will rescale the values in x
    according to a heuristic.
    '''
    import matplotlib as mpl
    if isinstance(cmap, mpl.colors.Colormap): cmap = cmap.name
    (name, cm) = (None, None)
    if cmap not in colormaps:
        for (k,v) in six.iteritems(colormaps):
            if cmap in k:
                (name, cm) = (k, v)
                break
    else: (name, cm) = (cmap, colormaps[cmap])
    if cm is not None:
        cm = cm if len(cm) == 3 else (cm + (None,))
        (cm, (mn,mx), uu) = cm
        if vmin is Ellipsis: vmin = mn
        if vmax is Ellipsis: vmax = mx
        if unit is Ellipsis: unit = uu
    if vmin is Ellipsis: vmin = None
    if vmax is Ellipsis: vmax = None
    if unit is Ellipsis: unit = None
    x = pimms.mag(x) if unit is None else pimms.mag(x, unit)
    if name is not None and name.startswith('log_'):
        emn = np.exp(vmin)
        x = np.log(x + emn)
    vmin = np.nanmin(x) if vmin is None else vmin
    vmax = np.nanmax(x) if vmax is None else vmax
    return zdivide(x - vmin, vmax - vmin, null=np.nan) 
开发者ID:noahbenson,项目名称:neuropythy,代码行数:36,代码来源:core.py

示例15: _do

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmin [as 别名]
def _do(self, F, **kwargs):
        n, m = F.shape

        if self.normalize:
            F = normalize(F, self.ideal_point, self.nadir_point, estimate_bounds_if_none=True)

        neighbors_finder = NeighborFinder(F, epsilon=0.125, n_min_neigbors="auto", consider_2d=False)

        mu = np.full(n, - np.inf)

        # for each solution in the set calculate the least amount of improvement per unit deterioration
        for i in range(n):

            # for each neighbour in a specific radius of that solution
            neighbors = neighbors_finder.find(i)

            # calculate the trade-off to all neighbours
            diff = F[neighbors] - F[i]

            # calculate sacrifice and gain
            sacrifice = np.maximum(0, diff).sum(axis=1)
            gain = np.maximum(0, -diff).sum(axis=1)

            np.warnings.filterwarnings('ignore')
            tradeoff = sacrifice / gain

            # otherwise find the one with the smalled one
            mu[i] = np.nanmin(tradeoff)

        return find_outliers_upper_tail(mu) 
开发者ID:msu-coinlab,项目名称:pymoo,代码行数:32,代码来源:high_tradeoff.py


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