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


Python scipy.amin函数代码示例

本文整理汇总了Python中scipy.amin函数的典型用法代码示例。如果您正苦于以下问题:Python amin函数的具体用法?Python amin怎么用?Python amin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: add_boundary_pores

    def add_boundary_pores(self, labels=['top', 'bottom', 'front', 'back',
                                         'left', 'right'], offset=None):
        r"""
        Add boundary pores to the specified faces of the network

        Pores are offset from the faces of the domain.

        Parameters
        ----------
        labels : string or list of strings
            The labels indicating the pores defining each face where boundary
            pores are to be added (e.g. 'left' or ['left', 'right'])

        offset : scalar or array_like
            The spacing of the network (e.g. [1, 1, 1]).  This must be given
            since it can be quite difficult to infer from the network,
            for instance if boundary pores have already added to other faces.

        """
        offset = sp.array(offset)
        if offset.size == 1:
            offset = sp.ones(3)*offset
        for item in labels:
            Ps = self.pores(item)
            coords = sp.absolute(self['pore.coords'][Ps])
            axis = sp.count_nonzero(sp.diff(coords, axis=0), axis=0) == 0
            ax_off = sp.array(axis, dtype=int)*offset
            if sp.amin(coords) == sp.amin(coords[:, sp.where(axis)[0]]):
                ax_off = -1*ax_off
            topotools.add_boundary_pores(network=self, pores=Ps, offset=ax_off,
                                         apply_label=item + '_boundary')
开发者ID:PMEAL,项目名称:OpenPNM,代码行数:31,代码来源:DelaunayVoronoiDual.py

示例2: infer_diag_post

 def infer_diag_post(self,X_ii,D_i):
     
     X_i = dc(X_ii)
     ns = len(D_i)
     
     X_i.resize([ns,self.D])
     [m,V] = self.infer_diag(X_i,D_i)
     if sp.amin(V)<=-0.:
         class MJMError(Exception):
             pass
         print "negative/eq variance"
         print [m,V,X_i,D_i]
         print "_______________"
         #self.printc()
         raise(MJMError)
     if sp.amin(sp.var(m,axis=0))<-0.:
         class MJMError(Exception):
             pass
         print "negativevar of mean"
         print X_i.shape
         print [m,V,sp.var(m,axis=0),X_i,D_i]
         print "_______________"
         #self.printc()
         raise(MJMError)
     
     return [sp.mean(m,axis=0).reshape([1,ns]),(sp.mean(V,axis=0)+sp.var(m,axis=0)).reshape([1,ns])]
开发者ID:markm541374,项目名称:GPc,代码行数:26,代码来源:GPdc.py

示例3: compute

 def compute(i, j):
     if i == j:
         return 1.0
     elif trains[i].size <= 0 or trains[j].size <= 0:
         return 0.0
     else:
         diff_matrix = sp.absolute(trains[i] - sp.atleast_2d(trains[j]).T)
         return 0.5 * (
             sp.sum(kernel(sp.amin(diff_matrix, axis=0))) / trains[i].size +
             sp.sum(kernel(sp.amin(diff_matrix, axis=1))) / trains[j].size)
开发者ID:NeuroArchive,项目名称:spykeutils,代码行数:10,代码来源:spike_train_metrics.py

示例4: __init__

 def __init__(self, evaluator, hof1, hof2, **args):
     if "symmetric" in args:
         M = CiaoPlot.generateData(evaluator, hof1, hof2, symmetric=args["symmetric"])
         del args["symmetric"]
     else:
         M = CiaoPlot.generateData(evaluator, hof1, hof2)
     M *= 1 / (amin(M) - amax(M))
     M -= amin(M)
     self.relData = M
     ColorMap.__init__(self, M, minvalue=0, maxvalue=1, **args)
开发者ID:saber233,项目名称:pybrain,代码行数:10,代码来源:ciaoplot.py

示例5: test_largest_sphere

 def test_largest_sphere(self):
     net = OpenPNM.Network.Cubic(shape=[5, 5, 5], spacing=[0.1, 0.2, 0.3])
     geo = OpenPNM.Geometry.GenericGeometry(network=net, pores=net.Ps,
                                            throats=net.Ts)
     geo.models.add(propname='pore.diameter',
                    model=mods.largest_sphere,
                    iters=1)
     dmin = sp.amin(geo['pore.diameter'])
     assert dmin <= 0.1
     geo.models['pore.diameter']['iters'] = 5
     geo.regenerate()
     assert dmin < sp.amin(geo['pore.diameter'])
开发者ID:MichaelHoeh,项目名称:OpenPNM,代码行数:12,代码来源:PoreDiameterTest.py

示例6: test_neighbor_max

 def test_neighbor_max(self):
     catch = self.geo.pop('pore.seed', None)
     catch = self.geo.models.pop('pore.seed', None)
     catch = self.geo.models.pop('throat.seed', None)
     mod = gm.pore_misc.neighbor
     self.geo['throat.seed'] = sp.rand(self.net.Nt,)
     self.geo.models.add(model=mod,
                         propname='pore.seed',
                         throat_prop='throat.seed',
                         mode='max')
     assert sp.all(sp.in1d(self.geo['pore.seed'], self.geo['throat.seed']))
     pmin = sp.amin(self.geo['pore.seed'])
     tmin = sp.amin(self.geo['throat.seed'])
     assert pmin >= tmin
开发者ID:MichaelHoeh,项目名称:OpenPNM,代码行数:14,代码来源:PoreMiscTest.py

示例7: test_late_pore_and_throat_filling

def test_late_pore_and_throat_filling():
    phys.models.add(propname='pore.fractional_filling',
                    model=OpenPNM.Physics.models.multiphase.late_pore_filling,
                    Pc=0,
                    Swp_star=0.2,
                    eta=1)
    mod = OpenPNM.Physics.models.multiphase.late_throat_filling
    phys.models.add(propname='throat.fractional_filling',
                    model=mod,
                    Pc=0,
                    Swp_star=0.2,
                    eta=1)
    phys.regenerate()
    drainage.setup(invading_phase=water, defending_phase=air,
                   pore_filling='pore.fractional_filling',
                   throat_filling='throat.fractional_filling')
    drainage.set_inlets(pores=pn.pores('boundary_top'))
    drainage.run()
    data = drainage.get_drainage_data()
    assert sp.amin(data['invading_phase_saturation']) == 0.0
    assert sp.amax(data['invading_phase_saturation']) < 1.0

    drainage.return_results(Pc=5000)
    assert 'pore.occupancy' in water.keys()
    assert 'throat.occupancy' in water.keys()
    assert 'pore.partial_occupancy' in water.keys()
    assert 'throat.partial_occupancy' in water.keys()
开发者ID:TomTranter,项目名称:OpenPNM,代码行数:27,代码来源:test_drainage_algorithm.py

示例8: overf_power_spectrum

def overf_power_spectrum(amp, index, f0, dt, n, cut_off=0):
    """Calculates the theoretical f**`index` power spectrum.
    """
    
    if cut_off < 0:
        raise ValueError("Low frequency cut off must not be negative.")
    # Sometimes the fitting routines do something weird that causes
    # an overflow from a ridiculous index.  Limit the index.
    index = max(index, -20)
    # Get the frequencies represented in the FFT.
    df = 1.0/dt/n
    freq = sp.arange(n, dtype=float)
    freq[n//2+1:] -= freq[-1] + 1
    freq = abs(freq)*df
    # 0th (mean) mode is meaningless has IR divergence.  Deal with it later (in
    # the cut off.
    freq[0] = 1
    # Make the power spectrum.
    power = (freq/f0)**index
    power *= amp
    # Restore frequency of mean mode.
    freq[0] = 0
    # Find the power just above the cut off frequency.
    p_cut = power[sp.amin(sp.where(freq > cut_off)[0])]
    # Flatten off the power spectrum.
    power[freq <= cut_off] = p_cut
    return power
开发者ID:OMGitsHongyu,项目名称:analysis_IM,代码行数:27,代码来源:noise_power.py

示例9: run

    def run(self, N=100):
        r'''
        '''
        im = self.image
        # Create a list of N random points to use as box centers
        pad = [0.1,0.1,0.45]  # Ensure points are near middle
        Cx = sp.random.randint(pad[0]*sp.shape(im)[0],(1-pad[0])*sp.shape(im)[0],N)
        Cy = sp.random.randint(pad[1]*sp.shape(im)[1],(1-pad[1])*sp.shape(im)[1],N)
        Cz = sp.random.randint(pad[2]*sp.shape(im)[2],(1-pad[2])*sp.shape(im)[2],N)
        C = sp.vstack((Cx,Cy,Cz)).T

        # Find maximum radius allowable for each point
        Rmax = sp.array(C>sp.array(sp.shape(im))/2)
        Rlim = sp.zeros(sp.shape(Rmax))
        Rlim[Rmax[:,0],0] = sp.shape(im)[0]
        Rlim[Rmax[:,1],1] = sp.shape(im)[1]
        Rlim[Rmax[:,2],2] = sp.shape(im)[2]
        R = sp.absolute(C-Rlim)
        R = R.astype(sp.int_)
        Rmin = sp.amin(R,axis=1)

        vol = []
        size = []
        porosity = []
        for i in range(0,N):
            for r in sp.arange(Rmin[i],1,-10):
                imtemp = im[C[i,0]-150:C[i,0]+150,C[i,1]-150:C[i,1]+150:,C[i,2]-r:C[i,2]+r]
                vol.append(sp.size(imtemp))
                size.append(2*r)
                porosity.append(sp.sum(imtemp==1)/(sp.size(imtemp)))

        vals = namedtuple('REV', ('porosity', 'size'))
        vals.porosity = porosity
        vals.size = size
        return vals
开发者ID:zhangwise,项目名称:porespy,代码行数:35,代码来源:__rev__.py

示例10: neighbor

def neighbor(geometry, pore_prop='pore.seed', mode='min', **kwargs):
    r"""
    Adopt a value based on the values in neighboring pores

    Parameters
    ----------
    geometry : OpenPNM Geometry Object
        The object containing the ``pore_prop`` to be used.

    pore_prop : string
        The dictionary key to the array containing the pore property to be
        used in the calculation.  Default is 'pore.seed'.

    mode : string
        Controls how the throat property is calculated.  Options are 'min',
        'max' and 'mean'.

    """
    network = geometry._net
    throats = network.throats(geometry.name)
    P12 = network.find_connected_pores(throats)
    pvalues = network[pore_prop][P12]
    if mode == 'min':
        value = _sp.amin(pvalues, axis=1)
    if mode == 'max':
        value = _sp.amax(pvalues, axis=1)
    if mode == 'mean':
        value = _sp.mean(pvalues, axis=1)
    return value
开发者ID:MichaelHoeh,项目名称:OpenPNM,代码行数:29,代码来源:throat_misc.py

示例11: neighbor

def neighbor(geometry, network, pore_prop='pore.seed', mode='min', **kwargs):
    r"""
    Adopt a value based on the values in the neighboring pores

    Parameters
    ----------
    mode : string
        Indicates how to select the values from the neighboring pores.  The
        options are:

        - min : (Default) Uses the minimum of the value found in the neighbors
        - max : Uses the maximum of the values found in the neighbors
        - mean : Uses an average of the neighbor values

    pore_prop : string
        The dictionary key containing the pore property to be used.
    """
    throats = network.throats(geometry.name)
    P12 = network.find_connected_pores(throats)
    pvalues = network[pore_prop][P12]
    if mode == 'min':
        value = _sp.amin(pvalues, axis=1)
    if mode == 'max':
        value = _sp.amax(pvalues, axis=1)
    if mode == 'mean':
        value = _sp.mean(pvalues, axis=1)
    return value
开发者ID:MichaelHoeh,项目名称:OpenPNM,代码行数:27,代码来源:throat_seed.py

示例12: scale

def scale(x, M=None, m=None, REVERSE=None):
    """ Function that standardize the data
        Input:
            x: the data
            M: the Max vector
            m: the Min vector
        Output:
            x: the standardize data
            M: the Max vector
            m: the Min vector
    """
    if not sp.issubdtype(x.dtype, float):
        do_convert = 1
    else:
        do_convert = 0
    if REVERSE is None:
        if M is None:
            M = sp.amax(x, axis=0)
            m = sp.amin(x, axis=0)
            if do_convert:
                xs = 2 * (x.astype("float") - m) / (M - m) - 1
            else:
                xs = 2 * (x - m) / (M - m) - 1
            return xs, M, m
        else:
            if do_convert:
                xs = 2 * (x.astype("float") - m) / (M - m) - 1
            else:
                xs = 2 * (x - m) / (M - m) - 1
            return xs
    else:
        return (1 + x) / 2 * (M - m) + m
开发者ID:lennepkade,项目名称:PGPDA,代码行数:32,代码来源:pgpda.py

示例13: _do_one_outer_iteration

 def _do_one_outer_iteration(self, **kwargs):
     r"""
     One iteration of an outer iteration loop for an algorithm
     (e.g. time or parametric study)
     """
     # Checking for the necessary values in Picard algorithm
     nan_tol = sp.isnan(self['pore.source_tol'])
     nan_max = sp.isnan(self['pore.source_maxiter'])
     self._tol_for_all = sp.amin(self['pore.source_tol'][~nan_tol])
     self._maxiter_for_all = sp.amax(self['pore.source_maxiter'][~nan_max])
     if self._guess is None:
         self._guess = sp.zeros(self._coeff_dimension)
     t = 1
     step = 0
     # The main Picard loop
     while t > self._tol_for_all and step <= self._maxiter_for_all:
         X, t, A, b = self._do_inner_iteration_stage(guess=self._guess,
                                                     **kwargs)
         logger.info('tol for Picard source_algorithm in step ' +
                     str(step) + ' : ' + str(t))
         self._guess = X
         step += 1
     # Check for divergence
     self._steps = step
     if t >= self._tol_for_all and step > self._maxiter_for_all:
         raise Exception('Iterative algorithm for the source term reached '
                         'to the maxiter: ' + str(self._maxiter_for_all) +
                         ' without achieving tol: ' +
                         str(self._tol_for_all))
     logger.info('Picard algorithm for source term converged!')
     self.A = A
     self.b = b
     self._tol_reached = t
     return X
开发者ID:TomTranter,项目名称:OpenPNM,代码行数:34,代码来源:__GenericLinearTransport__.py

示例14: test_calculates_frequencies

 def test_calculates_frequencies(self) :
     self.Data.calc_freq()
     self.assertTrue(hasattr(self.Data, 'freq'))
     self.assertEqual(len(self.Data.freq), self.nfreq)
     self.assertAlmostEqual(self.Data.field['BANDWID'], 
                            sp.amax(self.Data.freq) -
                            sp.amin(self.Data.freq), -5)
开发者ID:OMGitsHongyu,项目名称:analysis_IM,代码行数:7,代码来源:test_data_block.py

示例15: plot_pairwise_velocities_r

def plot_pairwise_velocities_r(case,color,all_radial_distances,all_radial_velocities):
    dr = 0.3 # Mpc/h
    rmin, rmax = sp.amin(all_radial_distances), sp.amax(all_radial_distances) 
    rrange = rmax-rmin 
    N = int(sp.ceil(rrange/dr))
    rs = sp.linspace(rmin,rmax,N)
    v12_of_r = [[] for index in range(N)]
    
    for r,v12 in zip(all_radial_distances,all_pairwise_velocities):
    
        index = int(sp.floor((r-rmin)/dr))
        v12_of_r[index].append(v12)
            
    
    sigma_12s = sp.zeros(N)
    v12_means = sp.zeros(N)
    for index in range(len(sigma_12s)):
        v12_of_r_index = sp.array(v12_of_r[index])
        print "number of counts in the", index,"th bin:", len(v12_of_r_index)
        sigma_12 = sp.sqrt(sp.mean(v12_of_r_index**2))
        v12_mean = -sp.mean(v12_of_r_index)
        sigma_12s[index] = sigma_12
        v12_means[index] = v12_mean
    
    
    plt.plot(rs,sigma_12s,color=color,label='$\sigma_{12}$')
    plt.plot(rs,v12_means,color=color,label='$|v_{12}|$')
    plt.xlabel('r [Mpc/h]')
    plt.ylabel('[km/s]')
    plt.xscale('log')
    plt.axis([0.5,100,0,600])
开发者ID:ioodderskov,项目名称:VelocityField,代码行数:31,代码来源:moments_of_pairwise_velocities.py


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