本文整理匯總了Python中scipy.fftpack.fftfreq方法的典型用法代碼示例。如果您正苦於以下問題:Python fftpack.fftfreq方法的具體用法?Python fftpack.fftfreq怎麽用?Python fftpack.fftfreq使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scipy.fftpack
的用法示例。
在下文中一共展示了fftpack.fftfreq方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_numpy
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def get_numpy(shape, fftn_shape=None, **kwargs):
import numpy.fft as numpy_fft
f = {
"fft2": numpy_fft.fft2,
"ifft2": numpy_fft.ifft2,
"rfft2": numpy_fft.rfft2,
"irfft2": lambda X: numpy_fft.irfft2(X, s=shape),
"fftshift": numpy_fft.fftshift,
"ifftshift": numpy_fft.ifftshift,
"fftfreq": numpy_fft.fftfreq,
}
if fftn_shape is not None:
f["fftn"] = numpy_fft.fftn
fft = SimpleNamespace(**f)
return fft
示例2: get_scipy
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def get_scipy(shape, fftn_shape=None, **kwargs):
import numpy.fft as numpy_fft
import scipy.fftpack as scipy_fft
# use numpy implementation of rfft2/irfft2 because they have not been
# implemented in scipy.fftpack
f = {
"fft2": scipy_fft.fft2,
"ifft2": scipy_fft.ifft2,
"rfft2": numpy_fft.rfft2,
"irfft2": lambda X: numpy_fft.irfft2(X, s=shape),
"fftshift": scipy_fft.fftshift,
"ifftshift": scipy_fft.ifftshift,
"fftfreq": scipy_fft.fftfreq,
}
if fftn_shape is not None:
f["fftn"] = scipy_fft.fftn
fft = SimpleNamespace(**f)
return fft
示例3: test_real_twosided
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_real_twosided(self):
x = np.zeros(16)
x[0] = 1
f, p = periodogram(x, return_onesided=False)
assert_allclose(f, fftpack.fftfreq(16, 1.0))
q = np.ones(16)/16.0
q[0] = 0
assert_allclose(p, q)
示例4: direct_diff
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def direct_diff(x,k=1,period=None):
fx = fft(x)
n = len(fx)
if period is None:
period = 2*pi
w = fftfreq(n)*2j*pi/period*n
if k < 0:
w = 1 / w**k
w[0] = 0.0
else:
w = w**k
if n > 2000:
w[250:n-250] = 0.0
return ifft(w*fx).real
示例5: direct_tilbert
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def direct_tilbert(x,h=1,period=None):
fx = fft(x)
n = len(fx)
if period is None:
period = 2*pi
w = fftfreq(n)*h*2*pi/period*n
w[0] = 1
w = 1j/tanh(w)
w[0] = 0j
return ifft(w*fx)
示例6: direct_hilbert
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def direct_hilbert(x):
fx = fft(x)
n = len(fx)
w = fftfreq(n)*n
w = 1j*sign(w)
return ifft(w*fx)
示例7: direct_shift
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def direct_shift(x,a,period=None):
n = len(x)
if period is None:
k = fftfreq(n)*1j*n
else:
k = fftfreq(n)*2j*pi/period*n
return ifft(fft(x)*exp(k*a)).real
示例8: test_definition
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_definition(self):
x = [0,1,2,3,4,-4,-3,-2,-1]
assert_array_almost_equal(9*fftfreq(9),x)
assert_array_almost_equal(9*pi*fftfreq(9,pi),x)
x = [0,1,2,3,4,-5,-4,-3,-2,-1]
assert_array_almost_equal(10*fftfreq(10),x)
assert_array_almost_equal(10*pi*fftfreq(10,pi),x)
示例9: test_complex
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_complex(self):
x = np.zeros(16, np.complex128)
x[0] = 1.0 + 2.0j
f, p = periodogram(x)
assert_allclose(f, fftpack.fftfreq(16, 1.0))
q = 5.0*np.ones(16)/16.0
q[0] = 0
assert_allclose(p, q)
示例10: test_real_twosided
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_real_twosided(self):
x = np.zeros(16)
x[0] = 1
x[8] = 1
f, p = welch(x, nperseg=8, return_onesided=False)
assert_allclose(f, fftpack.fftfreq(8, 1.0))
assert_allclose(p, np.array([0.08333333, 0.07638889, 0.11111111,
0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.07638889]))
示例11: test_integer_twosided
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_integer_twosided(self):
x = np.zeros(16, dtype=int)
x[0] = 1
f, p = periodogram(x, return_onesided=False)
assert_allclose(f, fftpack.fftfreq(16, 1.0))
q = np.ones(16)/16.0
q[0] = 0
assert_allclose(p, q)
示例12: test_complex
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_complex(self):
x = np.zeros(16, np.complex128)
x[0] = 1.0 + 2.0j
f, p = periodogram(x, return_onesided=False)
assert_allclose(f, fftpack.fftfreq(16, 1.0))
q = 5.0*np.ones(16)/16.0
q[0] = 0
assert_allclose(p, q)
示例13: test_real_twosided_32
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_real_twosided_32(self):
x = np.zeros(16, 'f')
x[0] = 1
f, p = periodogram(x, return_onesided=False)
assert_allclose(f, fftpack.fftfreq(16, 1.0))
q = np.ones(16, 'f')/16.0
q[0] = 0
assert_allclose(p, q)
assert_(p.dtype == q.dtype)
示例14: test_complex_32
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def test_complex_32(self):
x = np.zeros(16, 'F')
x[0] = 1.0 + 2.0j
x[8] = 1.0 + 2.0j
f, p = welch(x, nperseg=8, return_onesided=False)
assert_allclose(f, fftpack.fftfreq(8, 1.0))
q = np.array([0.41666666, 0.38194442, 0.55555552, 0.55555552,
0.55555558, 0.55555552, 0.55555552, 0.38194442], 'f')
assert_allclose(p, q, atol=1e-7, rtol=1e-7)
assert_(p.dtype == q.dtype,
'dtype mismatch, %s, %s' % (p.dtype, q.dtype))
示例15: temporal_ideal_filter
# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import fftfreq [as 別名]
def temporal_ideal_filter(self,tensor,low,high,fps,axis=0):
fft=fftpack.fft(tensor,axis=axis)
frequencies = fftpack.fftfreq(tensor.shape[0], d=1.0 / fps)
bound_low = (np.abs(frequencies - low)).argmin()
bound_high = (np.abs(frequencies - high)).argmin()
fft[:bound_low] = 0
fft[bound_high:-bound_high] = 0
fft[-bound_low:] = 0
iff=fftpack.ifft(fft, axis=axis)
return np.abs(iff)