本文整理汇总了Python中scipy.fftpack.irfft函数的典型用法代码示例。如果您正苦于以下问题:Python irfft函数的具体用法?Python irfft怎么用?Python irfft使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了irfft函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: sanity
def sanity(wavobj):
transformed = wavobj['transformed']
transformed_raw = wavobj['raw']
rate = wavobj['rate']
output = irfft(transformed)
san_output = irfft(transformed)* transformed_raw.max(axis=0)
write('sanity.wav', rate, np.array(san_output, dtype=np.int16))
print("Sanity.wav written")
开发者ID:255BITS,项目名称:DCGAN-tensorflow,代码行数:9,代码来源:wav.py
示例2: test_random_real
def test_random_real(self):
for size in [1, 51, 111, 100, 200, 64, 128, 256, 1024]:
x = random([size]).astype(self.rdt)
y1 = irfft(rfft(x))
y2 = rfft(irfft(x))
assert_equal(y1.dtype, self.rdt)
assert_equal(y2.dtype, self.rdt)
assert_array_almost_equal(y1, x, decimal=self.ndec, err_msg="size=%d" % size)
assert_array_almost_equal(y2, x, decimal=self.ndec, err_msg="size=%d" % size)
开发者ID:shantanusharma,项目名称:scipy,代码行数:9,代码来源:test_basic.py
示例3: test_random_real
def test_random_real(self):
for size in [1,51,111,100,200,64,128,256,1024]:
x = random([size]).astype(self.rdt)
y1 = irfft(rfft(x))
y2 = rfft(irfft(x))
self.failUnless(y1.dtype == self.rdt,
"Output dtype is %s, expected %s" % (y1.dtype, self.rdt))
self.failUnless(y2.dtype == self.rdt,
"Output dtype is %s, expected %s" % (y2.dtype, self.rdt))
assert_array_almost_equal (y1, x, decimal=self.ndec)
assert_array_almost_equal (y2, x, decimal=self.ndec)
开发者ID:donaldson-lab,项目名称:Gene-Designer,代码行数:11,代码来源:test_basic.py
示例4: test_definition
def test_definition(self):
x = [1,2,3,4,1,2,3,4]
x1 = [1,2+3j,4+1j,2+3j,4,2-3j,4-1j,2-3j]
y = irfft(x)
y1 = direct_irdft(x)
assert_array_almost_equal(y,y1)
assert_array_almost_equal(y,ifft(x1))
x = [1,2,3,4,1,2,3,4,5]
x1 = [1,2+3j,4+1j,2+3j,4+5j,4-5j,2-3j,4-1j,2-3j]
y = irfft(x)
y1 = direct_irdft(x)
assert_array_almost_equal(y,y1)
assert_array_almost_equal(y,ifft(x1))
开发者ID:mullens,项目名称:khk-lights,代码行数:13,代码来源:test_basic.py
示例5: test_size_accuracy
def test_size_accuracy(self):
# Sanity check for the accuracy for prime and non-prime sized inputs
if self.rdt == np.float32:
rtol = 1e-5
elif self.rdt == np.float64:
rtol = 1e-10
for size in LARGE_COMPOSITE_SIZES + LARGE_PRIME_SIZES:
np.random.seed(1234)
x = np.random.rand(size).astype(self.rdt)
y = irfft(rfft(x))
_assert_close_in_norm(x, y, rtol, size, self.rdt)
y = rfft(irfft(x))
_assert_close_in_norm(x, y, rtol, size, self.rdt)
开发者ID:shantanusharma,项目名称:scipy,代码行数:14,代码来源:test_basic.py
示例6: test_size_accuracy
def test_size_accuracy(self):
# Sanity check for the accuracy for prime and non-prime sized inputs
if self.rdt == np.float32:
rtol = 1e-5
elif self.rdt == np.float64:
rtol = 1e-10
for size in LARGE_COMPOSITE_SIZES + LARGE_PRIME_SIZES:
np.random.seed(1234)
x = np.random.rand(size).astype(self.rdt)
y = irfft(rfft(x))
self.failUnless(np.linalg.norm(x - y) < rtol*np.linalg.norm(x),
(size, self.rdt))
y = rfft(irfft(x))
self.failUnless(np.linalg.norm(x - y) < rtol*np.linalg.norm(x),
(size, self.rdt))
开发者ID:wrbrooks,项目名称:VB3,代码行数:16,代码来源:test_basic.py
示例7: savefft
def savefft(wavfile, wavobj, filtered):
transformed = wavobj['transformed']
transformed_raw = wavobj['raw']
rate = wavobj['rate']
data = filtered * transformed_raw.max(axis=0)
output = irfft(data)
write(wavfile, rate, np.array(output, dtype=np.int16))
开发者ID:wavelets,项目名称:vocal-autoencoder,代码行数:7,代码来源:wav.py
示例8: fft_filter
def fft_filter(x, fs, band=(9, 14)):
w = fftpack.rfftfreq(x.shape[0], d=1. / fs)
f_signal = fftpack.rfft(x, axis=0)
cut_f_signal = f_signal.copy()
cut_f_signal[(w < band[0]) | (w > band[1])] = 0
cut_signal = fftpack.irfft(cut_f_signal, axis=0)
return cut_signal
开发者ID:nikolaims,项目名称:nfb,代码行数:7,代码来源:__init__.py
示例9: fftresample
def fftresample(S, npoints, reflect=False, axis=0):
"""
Resample a signal using discrete fourier transform. The signal
is transformed in the fourier domain and then padded or truncated
to the correct sampling frequency. This should be equivalent to
a sinc resampling.
"""
from scipy.fftpack import rfft, irfft
from dlab.datautils import flipaxis
# this may be considerably faster if we do the memory operations in C
# reflect at the boundaries
if reflect:
S = nx.concatenate([flipaxis(S,axis), S, flipaxis(S,axis)],
axis=axis)
npoints *= 3
newshape = list(S.shape)
newshape[axis] = int(npoints)
Sf = rfft(S, axis=axis)
Sr = (1. * npoints / S.shape[axis]) * irfft(Sf, npoints, axis=axis, overwrite_x=1)
if reflect:
return nx.split(Sr,3)[1]
else:
return Sr
开发者ID:melizalab,项目名称:dlab,代码行数:26,代码来源:dlab-attic.py
示例10: fft_filter
def fft_filter(x, fs, band=(9, 14)):
w = fftfreq(x.shape[0], d=1. / fs * 2)
f_signal = rfft(x)
cut_f_signal = f_signal.copy()
cut_f_signal[(w < band[0]) | (w > band[1])] = 0
cut_signal = irfft(cut_f_signal)
return cut_signal
开发者ID:nikolaims,项目名称:nfb,代码行数:7,代码来源:mu_5days.py
示例11: _test
def _test(x, xr):
y = irfft(np.array(x, dtype=self.rdt))
y1 = direct_irdft(x)
self.assertTrue(y.dtype == self.rdt,
"Output dtype is %s, expected %s" % (y.dtype, self.rdt))
assert_array_almost_equal(y,y1, decimal=self.ndec)
assert_array_almost_equal(y,ifft(xr), decimal=self.ndec)
开发者ID:wrbrooks,项目名称:VB3,代码行数:7,代码来源:test_basic.py
示例12: do_gen_random
def do_gen_random(peakAmpl, durationInMSec, samplingRate, fHigh, stereo=True):
samples = durationInMSec * samplingRate / 1000
result = np.zeros(samples * 2 if stereo else samples, dtype=np.int16)
randomSignal = np.random.normal(scale = peakAmpl * 2 / 3, size=samples)
fftData = fft.rfft(randomSignal)
freqSamples = samples/2
iHigh = freqSamples * fHigh * 2 / samplingRate + 1
#print len(randomSignal), len(fftData), fLow, fHigh, iHigh
if iHigh > freqSamples - 1:
iHigh = freqSamples - 1
fftData[0] = 0 # DC
for i in range(iHigh, freqSamples - 1):
fftData[ 2 * i + 1 ] = 0
fftData[ 2 * i + 2 ] = 0
if (samples - 2 *freqSamples) != 0:
fftData[samples - 1] = 0
filteredData = fft.irfft(fftData)
#freq = np.linspace(0.0, samplingRate, num=len(fftData), endpoint=False)
#plt.plot(freq, abs(fft.fft(filteredData)))
#plt.plot(filteredData)
#plt.show()
if stereo:
for i in range(len(filteredData)):
result[2 * i] = filteredData[i]
result[2 * i + 1] = filteredData[i]
else:
for i in range(len(filteredData)):
result[i] = filteredData[i]
return result
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:30,代码来源:gen_random.py
示例13: bandpass
def bandpass(x, sampling_rate, f_min, f_max, verbose=0):
"""
xf = bandpass(x, sampling_rate, f_min, f_max)
Description
--------------
Phasen-treue mit der rueckwaerts-vorwaerts methode!
Function bandpass-filters a signal without roleoff. The cutoff frequencies,
f_min and f_max, are sharp.
Arguements
--------------
x: input timeseries
sampling_rate: equidistant sampling with sampling frequency sampling_rate
f_min, f_max: filter constants for lower and higher frequency
Returns
--------------
xf: the filtered signal
"""
x, N = np.asarray(x, dtype=float), len(x)
t = np.arange(N)/np.float(sampling_rate)
xn = detrend_linear(x)
del t
yn = np.concatenate((xn[::-1], xn)) # backwards forwards array
f = np.float(sampling_rate)*np.asarray(np.arange(2*N)/2, dtype=int)/float(2*N)
s = rfft(yn)*(f>f_min)*(f<f_max) # filtering
yf = irfft(s) # backtransformation
xf = (yf[:N][::-1]+yf[N:])/2. # phase average
return xf
开发者ID:jusjusjus,项目名称:KHT_PRL2016,代码行数:34,代码来源:kht.py
示例14: subtract_original_signal_from_picked_signal
def subtract_original_signal_from_picked_signal(self, original_signal, picked_signal):
# Note this function assumes that the signals are aligned for the starting point!
fft_length = max(len(original_signal), len(picked_signal))
original_f_domain = rfft(original_signal, n= fft_length)
picked_f_domain = rfft(picked_signal, n= fft_length)
assert len(original_f_domain) == len(picked_f_domain)
difference_signal = picked_f_domain - original_f_domain
return irfft(difference_signal)
开发者ID:asafazaria,项目名称:AudioIdentificatoin,代码行数:8,代码来源:AudioFilesPreprocessor.py
示例15: testFFTComp
def testFFTComp(self):
data = np.array([1, 0, 0, 1, 1, 0, 0, 1], dtype=np.float32)
self.stft.performStft(data)
dfts = self.stft.getDFTs()
transformed = mat.to_numpy_format(dfts)
ifftout = fftp.irfft(transformed[:, 0] / 2)
print ifftout
self.assertListFloatEqual(data, ifftout)
开发者ID:amill676,项目名称:realtime_audio,代码行数:8,代码来源:mattoolstest.py
示例16: applyParameter
def applyParameter(self, data):
#low pass filter
fftdata = rfft(data)
fftdata[int(float(self._variables["FREQUENCY"])*np.pi*2):] = 0
##removes negative values
filtered_data = irfft(fftdata).clip(0)
return filtered_data
开发者ID:dvdmrn,项目名称:AV-study,代码行数:10,代码来源:lpf.py
示例17: irfft
def irfft(self, X):
"""
Apply real FFT to X
Parameters
----------
X : list of lists or ndArrays
"""
X = np.array([irfft(x) for x in X])
return X
开发者ID:lipengyu,项目名称:cle,代码行数:10,代码来源:prep.py
示例18: bandpass
def bandpass(data_list, min_hz, max_hz):
fft_list = rfft(data_list)
# Filter
for i in range(len(fft_list)):
if not (min_hz < i/2+1 < max_hz): fft_list[i] = 0
result_vals = irfft(fft_list)
return result_vals
开发者ID:neurotechuoft,项目名称:Wall-EEG,代码行数:11,代码来源:fft_tingz.py
示例19: remove_freq_range
def remove_freq_range(data_list, min_hz, max_hz):
fft_list = rfft(data_list)
# Filter
for i in range(len(fft_list)):
if (min_hz < i / 2 + 1 < max_hz): fft_list[i] = 0
result_vals = irfft(fft_list)
return result_vals
开发者ID:neurotechuoft,项目名称:Wall-EEG,代码行数:11,代码来源:fft_tingz.py
示例20: ourFFT2
def ourFFT2(signal,ffTtime):
W = fftfreq(len(signal), d=ffTtime[1]-ffTtime[0])
f_signal = rfft(signal)
# If our original signal time was in seconds, this is now in Hz
cut_f_signal = f_signal.copy()
#cut_f_signal[(W>0.004)] = 0
cut_f_signal[(W<=0)] = 0
cut_f_signal[(W>0.001)] = 0
cut_signal = irfft(cut_f_signal)
return W, ffTtime, cut_signal, cut_f_signal, f_signal
开发者ID:auracapstone,项目名称:Prototyping-Code,代码行数:12,代码来源:2_19_plotAll.py
注:本文中的scipy.fftpack.irfft函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论