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


Python numpy.nanmax方法代码示例

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


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

示例1: apply_cmap

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [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 nanmax [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 nanmax [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 nanmax [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: convert_to_one_hot_matrix

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [as 别名]
def convert_to_one_hot_matrix(self, dense_matrix, value_set=None):
        if value_set is None:
            n = np.nanmax(dense_matrix) + 1
            value_set = np.arange(n)

        n_data = dense_matrix.shape[0]
        n_points = dense_matrix.shape[1]
        n_values = value_set.size

        one_hot_matrix = np.zeros((n_data, n_points, n_values), dtype=bool)
        for i in range(n_data):
            for j in range(n_points):
                # NOTE:
                # Ignore negative values.
                if dense_matrix[i,j] < 0: continue
                k = np.where(value_set == dense_matrix[i,j])[0]
                one_hot_matrix[i,j,k] = True

        return one_hot_matrix 
开发者ID:mhsung,项目名称:deep-functional-dictionaries,代码行数:21,代码来源:dataset_keypoints.py

示例6: scatter_lims

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [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

示例7: plot_seqlogo

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [as 别名]
def plot_seqlogo(ax, seq_align, sat_score_ti, pseudo_pct=0.05):
  """ Plot a sequence logo for the loss/gain scores.

    Args:
        ax (Axis): matplotlib axis to plot to.
        seq_align (L array): Sequence nucleotides, with gaps.
        sat_score_ti (L_sm array): Minimum mutation delta across satmut length.
        pseudo_pct (float): % of the max to add as a pseudocount.
    """
  sat_score_cp = sat_score_ti.copy()
  satmut_len = len(sat_score_ti)

  # add pseudocounts
  sat_score_cp += pseudo_pct * np.nanmax(sat_score_cp)

  # expand
  sat_score_4l = expand_4l(sat_score_cp, seq_align)

  plots.seqlogo(sat_score_4l, ax) 
开发者ID:calico,项目名称:basenji,代码行数:21,代码来源:basenji_sat_plot2.py

示例8: plot_heat

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [as 别名]
def plot_heat(ax, sat_delta_ti, min_limit):
  """ Plot satmut deltas.

    Args:
        ax (Axis): matplotlib axis to plot to.
        sat_delta_ti (4 x L_sm array): Single target delta matrix for saturated mutagenesis region,
        min_limit (float): Minimum heatmap limit.
    """

  vlim = max(min_limit, np.nanmax(np.abs(sat_delta_ti)))
  sns.heatmap(
      sat_delta_ti,
      linewidths=0,
      cmap='RdBu_r',
      vmin=-vlim,
      vmax=vlim,
      xticklabels=False,
      ax=ax)
  ax.yaxis.set_ticklabels('ACGT', rotation='horizontal')  # , size=10) 
开发者ID:calico,项目名称:basenji,代码行数:21,代码来源:basenji_sat_plot.py

示例9: scatter_lims

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [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

示例10: findmaxval_multirasters

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

    for i in range (len(FileList)):

        raster_as_array = LSDMap_IO.ReadRasterArrayBlocks(FileList[i])
        this_max_val = np.nanmax(raster_as_array)

        if this_max_val > overall_max_val:
            overall_max_val = this_max_val
            print(overall_max_val)

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

示例11: quickMinMax

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [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

示例12: updateRealTimeLSandSS

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [as 别名]
def updateRealTimeLSandSS(self, sample):
        """
        Updates the `Weighted Linear Sum` (WLS), the `Weighted Squared Sum` (WSS), the `center` and the `radius` of the micro-cluster when a new sample is merged. 

        :param sample: the `sample` to merge into the micro-cluster.
        """

        sample = np.array(sample.value)

        self.LS = np.multiply(self.LS, self.reductionFactor)
        self.SS = np.multiply(self.SS, self.reductionFactor)
                
        self.LS = self.LS + sample
        self.SS = self.SS + np.power(sample, 2)

        self.center = np.divide(self.LS, float(self.weight))

        LSd = np.power(self.center, 2)
        SSd = np.divide(self.SS, float(self.weight))

        maxRad = np.nanmax(np.sqrt(SSd.astype(float)-LSd.astype(float)))
        # maxRad = np.nanmax(np.lib.scimath.sqrt(SSd-LSd))
        self.radius = maxRad 
开发者ID:anrputina,项目名称:outlierdenstream,代码行数:25,代码来源:outlierdenstream.py

示例13: netcdf_to_geojson

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [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

示例14: subfig_evo_rad_pow_sz

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [as 别名]
def subfig_evo_rad_pow_sz(ax_power_evo, out, legend, norm=1, **kwargs):
    if out.nSlices > 1:
        z = out.z
        s = out.s
        power = out.rad_power
        if norm == 1:
            max_power = np.nanmax(power, 1)[:, np.newaxis]
            max_power[max_power == 0] = 1  # avoid division by zero
            power = power / max_power
            # power[isnan(power)]=0
        ax_power_evo.pcolormesh(z, s * 1e6, power.T)
        ax_power_evo.set_xlabel('z [m]')
        ax_power_evo.set_ylabel('s [$\mu$m]')
        ax_power_evo.axis('tight')
        ax_power_evo.grid(True)
    else:
        pass 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:19,代码来源:genesis4_plot.py

示例15: subfig_evo_rad_spec_sz

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import nanmax [as 别名]
def subfig_evo_rad_spec_sz(ax_spectrum_evo, out, legend, norm=1):
    if out.nSlices > 1:
        z = out.z
        l, spectrum = out.calc_spec()
        #        spectrum = out.spec
        if norm == 1:
            max_spectrum = np.nanmax(spectrum, 1)[:, np.newaxis]
            max_spectrum[max_spectrum == 0] = 1  # avoid division by zero
            spectrum = spectrum / max_spectrum
            # spectrum[isnan(spectrum)]=0
        ax_spectrum_evo.pcolormesh(z, l, spectrum.T)
        ax_spectrum_evo.set_xlabel('z [m]')
        ax_spectrum_evo.set_ylabel('[eV]')
        ax_spectrum_evo.axis('tight')
        ax_spectrum_evo.grid(True)
    else:
        pass 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:19,代码来源:genesis4_plot.py


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