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


Python scipy.absolute方法代码示例

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


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

示例1: get_stft_bin_freqs

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def get_stft_bin_freqs(self, stft, framerate):
        fft_length = self.HAN_WINDOW * framerate
        binResolution = float(framerate) / float(fft_length)
        stft_binFrequencies = []
        stft_magnitudes = []
        for i in range(len(stft)):
            binFreqs = []
            magnitudes = []
            for k in range(len(stft[i])):
                binFreq = k * binResolution
                if binFreq > self.minFreqConsidered and binFreq < self.maxFreqConsidered:
                    power_spectrum = scipy.absolute(stft[i][k]) * scipy.absolute(stft[i][k])
                    if power_spectrum > self.THRESHOLD:
                        binFreqs.append(binFreq)
                        magnitudes.append(power_spectrum)
                    stft_binFrequencies.append(binFreqs)
                    stft_magnitudes.append(magnitudes)
        return (stft_binFrequencies, stft_magnitudes) 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:20,代码来源:least_squares_first_peaks_2.py

示例2: getAlgebraicConnectivity

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def getAlgebraicConnectivity(self, lanczosVecs = 15, maxiter = 20):
        """
        Returns the algebraic connectivity of the higher-order network.    
        
        @param lanczosVecs: number of Lanczos vectors to be used in the approximate
            calculation of eigenvectors and eigenvalues. This maps to the ncv parameter 
            of scipy's underlying function eigs. 
        @param maxiter: scaling factor for the number of iterations to be used in the 
            approximate calculation of eigenvectors and eigenvalues. The number of iterations 
            passed to scipy's underlying eigs function will be n*maxiter where n is the
            number of rows/columns of the Laplacian matrix.         
        """
    
        Log.add('Calculating algebraic connectivity ... ', Severity.INFO)

        L = self.getLaplacianMatrix()
        # NOTE: ncv sets additional auxiliary eigenvectors that are computed
        # NOTE: in order to be more confident to find the one with the largest
        # NOTE: magnitude, see https://github.com/scipy/scipy/issues/4987
        w = _sla.eigs( L, which="SM", k=2, ncv=lanczosVecs, return_eigenvectors=False, maxiter = maxiter )
        evals_sorted = _np.sort(_np.absolute(w))

        Log.add('finished.', Severity.INFO)

        return _np.abs(evals_sorted[1]) 
开发者ID:IngoScholtes,项目名称:pathpy,代码行数:27,代码来源:HigherOrderNetwork.py

示例3: get_FFT_of_noise

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def get_FFT_of_noise(self, x, rnorm):
        sum_of_singles = x[0] * self.get_FFT(self.first_single) + x[1] * self.get_FFT(self.second_single) + x[2] * self.get_FFT(self.third_single)
        fft = scipy.absolute(self.get_FFT(self.chord) - sum_of_singles)
        return fft 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:6,代码来源:threshold_finder.py

示例4: get_sum_of_squares

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def get_sum_of_squares(self, fft):
        sum_of_squares = 0.0
        for i in range(len(fft)):
            sum_of_squares += scipy.absolute(fft[i]) * sscipy.absolute(fft[i])
        return sum_of_squares 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:7,代码来源:threshold_finder.py

示例5: plot_power_spectrum

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def plot_power_spectrum(self, fft):
        T = int(600)

        pylab.figure('Power spectrum')
        pylab.plot(scipy.absolute(fft[:T]) * scipy.absolute(fft[:T]),)
        pylab.xlabel('Frequency [Hz]')
        pylab.ylabel('Power spectrum []')
        pylab.show() 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:10,代码来源:threshold_finder.py

示例6: plotPowerSpectrum

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def plotPowerSpectrum(FFT, binFrequencies, maxFreq):
    """
        Calculates and plots the power spectrum of a given sound wave.
    """

    T = int(maxFreq)
    pylab.figure('Power spectrum')
    pylab.plot(binFrequencies[:T], scipy.absolute(FFT[:T]) * scipy.absolute(FFT[:T]),)
    pylab.xlabel('Frequency (Hz)')
    pylab.ylabel('Power spectrum (|X[k]|^2)')
    pylab.show() 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:13,代码来源:first_peaks_method.py

示例7: plotMagnitudeSpectrogram

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def plotMagnitudeSpectrogram(self, rate, sample, framesz, hop):
        """
            Calculates and plots the magnitude spectrum of a given sound wave.
        """

        X = self.STFT(sample, rate, framesz, hop)

        # Plot the magnitude spectrogram.
        pylab.figure('Magnitude spectrogram')
        pylab.imshow(scipy.absolute(X.T), origin='lower', aspect='auto',
                     interpolation='nearest')
        pylab.xlabel('Time')
        pylab.ylabel('Frequency')
        pylab.show() 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:16,代码来源:first_peaks_method.py

示例8: getFilteredFFT

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def getFilteredFFT(self, FFT, duration, threshold):
        """
            Returns a list of frequencies with the magnitudes higher than a given threshold.
        """

        significantFreqs = []
        for i in range(len(FFT)):
            power_spectrum = scipy.absolute(FFT[i]) * scipy.absolute(FFT[i])
            if power_spectrum > threshold:
                significantFreqs.append(i / duration)

        return significantFreqs 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:14,代码来源:least_squares_first_peaks_2.py

示例9: calculateFFT

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def calculateFFT(self, duration, framerate, sample):
        """
            Calculates FFT for a given sound wave.
            Considers only frequencies with the magnitudes higher than
            a given threshold.
        """

        fft_length = int(duration * framerate)

        fft_length = get_next_power_2(fft_length)
        FFT = numpy.fft.fft(sample, n=fft_length)

        ''' ADJUSTING THRESHOLD '''
        threshold = 0
        power_spectra = []
        for i in range(len(FFT) / 2):
            power_spectrum = scipy.absolute(FFT[i]) * scipy.absolute(FFT[i])
            if power_spectrum > threshold:
                threshold = power_spectrum
            power_spectra.append(power_spectrum)
        threshold *= 0.1

        binResolution = float(framerate) / float(fft_length)
        frequency_power = []
        # For each bin calculate the corresponding frequency.
        for k in range(len(FFT) / 2):
            binFreq = k * binResolution

            if binFreq > self.minFreqConsidered and binFreq < self.maxFreqConsidered:
                power_spectrum = power_spectra[k]
                #dB = 10*math.log10(power_spectrum)
                if power_spectrum > threshold:
                    frequency_power.append((binFreq, power_spectrum))

        return frequency_power 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:37,代码来源:highest_peak_method.py

示例10: getEigenValueGap

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def getEigenValueGap(self, includeSubPaths=True, lanczosVecs = 15, maxiter = 20):
        """
        Returns the eigenvalue gap of the transition matrix.

        @param includeSubPaths: whether or not to include subpath statistics in the 
            calculation of transition probabilities.
        """
    
        #NOTE to myself: most of the time goes for construction of the 2nd order
        #NOTE            null graph, then for the 2nd order null transition matrix   
    
        Log.add('Calculating eigenvalue gap ... ', Severity.INFO)

        # Build transition matrices
        T = self.getTransitionMatrix(includeSubPaths)
    
        # Compute the two largest eigenvalues
        # NOTE: ncv sets additional auxiliary eigenvectors that are computed
        # NOTE: in order to be more confident to actually find the one with the largest
        # NOTE: magnitude, see https://github.com/scipy/scipy/issues/4987
        w2 = _sla.eigs(T, which="LM", k=2, ncv=lanczosVecs, return_eigenvectors=False, maxiter = maxiter)
        evals2_sorted = _np.sort(-_np.absolute(w2))
        
        Log.add('finished.', Severity.INFO)
    
        return _np.abs(evals2_sorted[1]) 
开发者ID:IngoScholtes,项目名称:pathpy,代码行数:28,代码来源:HigherOrderNetwork.py

示例11: getFiedlerVectorDense

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def getFiedlerVectorDense(self):
        """
         Returns the (dense)Fiedler vector of the higher-order network. The Fiedler 
         vector can be used for a spectral bisectioning of the network.             
        """
    
        # NOTE: The Laplacian is transposed for the sparse case to get the left
        # NOTE: eigenvalue.
        L = self.getLaplacianMatrix()
        # convert to dense matrix and transpose again to have the untransposed
        # laplacian again.
        w, v = _la.eig(L.todense().transpose(), right=False, left=True)

        return v[:,_np.argsort(_np.absolute(w))][:,1] 
开发者ID:IngoScholtes,项目名称:pathpy,代码行数:16,代码来源:HigherOrderNetwork.py

示例12: get_amplitude

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def get_amplitude(self,signal,l):
        if self.amplitude.has_key(l):
            return self.amplitude[l]
        else:
            amp = sp.absolute(sp.fft(get_frame(signal, self.winsize,l) * self.window))
            self.amplitude[l] = amp
            return amp 
开发者ID:kastnerkyle,项目名称:tools,代码行数:9,代码来源:audio_tools.py

示例13: compute_noise_avg_spectrum

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def compute_noise_avg_spectrum(self, nsignal):
        windownum = int(len(nsignal)//(self.winsize//2) - 1)
        avgamp = np.zeros(self.winsize)
        for l in range(windownum):
            avgamp += sp.absolute(sp.fft(get_frame(nsignal, self.winsize,l) * self.window))
        return avgamp/float(windownum) 
开发者ID:kastnerkyle,项目名称:tools,代码行数:8,代码来源:audio_tools.py

示例14: __minowski_low_positive_integer_p

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def __minowski_low_positive_integer_p(h1, h2, p = 2): # 11..43 us for p = 1..24 \w 100 bins
    """
    A faster implementation of the Minowski distance for positive integer < 25.
    @note do not use this function directly, but the general @link minowski() method.
    @note the passed histograms must be scipy arrays.
    """
    mult = scipy.absolute(h1 - h2)
    dif = mult
    for _ in range(p - 1): dif = scipy.multiply(dif, mult)
    return math.pow(scipy.sum(dif), 1./p) 
开发者ID:doublechenching,项目名称:brats_segmentation-pytorch,代码行数:12,代码来源:histogram.py

示例15: __minowski_low_negative_integer_p

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import absolute [as 别名]
def __minowski_low_negative_integer_p(h1, h2, p = 2): # 14..46 us for p = -1..-24 \w 100 bins
    """
    A faster implementation of the Minowski distance for negative integer > -25.
    @note do not use this function directly, but the general @link minowski() method.
    @note the passed histograms must be scipy arrays.
    """
    mult = scipy.absolute(h1 - h2)
    dif = mult
    for _ in range(-p + 1): dif = scipy.multiply(dif, mult)
    return math.pow(scipy.sum(1./dif), 1./p) 
开发者ID:doublechenching,项目名称:brats_segmentation-pytorch,代码行数:12,代码来源:histogram.py


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