Python scipy.fftpack.fftfreq() Examples
The following are 26
code examples of scipy.fftpack.fftfreq().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy.fftpack
, or try the search function
.
Example #1
Source File: fft.py From pysteps with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #2
Source File: fft.py From pysteps with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #3
Source File: test_spectral.py From Computable with MIT License | 6 votes |
def test_complex(self): x = np.zeros(16, np.complex128) x[0] = 1.0 + 2.0j x[8] = 1.0 + 2.0j f, p = welch(x, nperseg=8) assert_allclose(f, fftpack.fftfreq(8, 1.0)) assert_allclose(p, np.array([0.41666667, 0.38194444, 0.55555556, 0.55555556, 0.55555556, 0.55555556, 0.55555556, 0.38194444]))
Example #4
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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)) q = np.array([0.08333333, 0.07638889, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.07638889]) assert_allclose(p, q, atol=1e-7, rtol=1e-7)
Example #5
Source File: amplify_color.py From Heart-rate-measurement-using-camera with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_complex_32(self): x = np.zeros(16, 'F') x[0] = 1.0 + 2.0j x[8] = 1.0 + 2.0j f, p = csd(x, 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))
Example #7
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_real_twosided_32(self): x = np.zeros(16, 'f') x[0] = 1 x[8] = 1 f, p = csd(x, x, nperseg=8, return_onesided=False) assert_allclose(f, fftpack.fftfreq(8, 1.0)) q = np.array([0.08333333, 0.07638889, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.07638889], 'f') assert_allclose(p, q, atol=1e-7, rtol=1e-7) assert_(p.dtype == q.dtype)
Example #8
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_complex(self): x = np.zeros(16, np.complex128) x[0] = 1.0 + 2.0j x[8] = 1.0 + 2.0j f, p = csd(x, x, nperseg=8, return_onesided=False) assert_allclose(f, fftpack.fftfreq(8, 1.0)) q = np.array([0.41666667, 0.38194444, 0.55555556, 0.55555556, 0.55555556, 0.55555556, 0.55555556, 0.38194444]) assert_allclose(p, q, atol=1e-7, rtol=1e-7)
Example #9
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_integer_twosided(self): x = np.zeros(16, dtype=int) x[0] = 1 x[8] = 1 f, p = csd(x, x, nperseg=8, return_onesided=False) assert_allclose(f, fftpack.fftfreq(8, 1.0)) q = np.array([0.08333333, 0.07638889, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.07638889]) assert_allclose(p, q, atol=1e-7, rtol=1e-7)
Example #10
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_real_twosided(self): x = np.zeros(16) x[0] = 1 x[8] = 1 f, p = csd(x, x, nperseg=8, return_onesided=False) assert_allclose(f, fftpack.fftfreq(8, 1.0)) q = np.array([0.08333333, 0.07638889, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.07638889]) assert_allclose(p, q, atol=1e-7, rtol=1e-7)
Example #11
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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))
Example #12
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_real_twosided_32(self): x = np.zeros(16, 'f') x[0] = 1 x[8] = 1 f, p = welch(x, nperseg=8, return_onesided=False) assert_allclose(f, fftpack.fftfreq(8, 1.0)) q = np.array([0.08333333, 0.07638889, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.07638889], 'f') assert_allclose(p, q, atol=1e-7, rtol=1e-7) assert_(p.dtype == q.dtype)
Example #13
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_complex(self): x = np.zeros(16, np.complex128) 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.41666667, 0.38194444, 0.55555556, 0.55555556, 0.55555556, 0.55555556, 0.55555556, 0.38194444]) assert_allclose(p, q, atol=1e-7, rtol=1e-7)
Example #14
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_integer_twosided(self): x = np.zeros(16, dtype=int) x[0] = 1 x[8] = 1 f, p = welch(x, nperseg=8, return_onesided=False) assert_allclose(f, fftpack.fftfreq(8, 1.0)) q = np.array([0.08333333, 0.07638889, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.07638889]) assert_allclose(p, q, atol=1e-7, rtol=1e-7)
Example #15
Source File: bench_pseudo_diffs.py From Computable with MIT License | 5 votes |
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
Example #16
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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)
Example #17
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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)
Example #18
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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)
Example #19
Source File: test_spectral.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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)
Example #20
Source File: test_helper.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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)
Example #21
Source File: test_spectral.py From Computable with MIT License | 5 votes |
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]))
Example #22
Source File: test_spectral.py From Computable with MIT License | 5 votes |
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)
Example #23
Source File: test_helper.py From Computable with MIT License | 5 votes |
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)
Example #24
Source File: bench_pseudo_diffs.py From Computable with MIT License | 5 votes |
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
Example #25
Source File: bench_pseudo_diffs.py From Computable with MIT License | 5 votes |
def direct_hilbert(x): fx = fft(x) n = len(fx) w = fftfreq(n)*n w = 1j*sign(w) return ifft(w*fx)
Example #26
Source File: bench_pseudo_diffs.py From Computable with MIT License | 5 votes |
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)