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


Python fftpack.fftfreq方法代码示例

本文整理汇总了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 
开发者ID:pySTEPS,项目名称:pysteps,代码行数:19,代码来源:fft.py

示例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 
开发者ID:pySTEPS,项目名称:pysteps,代码行数:22,代码来源:fft.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:10,代码来源:test_spectral.py

示例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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:bench_pseudo_diffs.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:bench_pseudo_diffs.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:bench_pseudo_diffs.py

示例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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:bench_pseudo_diffs.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_helper.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_spectral.py

示例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])) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_spectral.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:10,代码来源:test_spectral.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:10,代码来源:test_spectral.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:test_spectral.py

示例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)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:13,代码来源:test_spectral.py

示例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) 
开发者ID:habom2310,项目名称:Heart-rate-measurement-using-camera,代码行数:12,代码来源:amplify_color.py


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