當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。