本文整理汇总了Python中numpy.fft.ifftshift方法的典型用法代码示例。如果您正苦于以下问题:Python fft.ifftshift方法的具体用法?Python fft.ifftshift怎么用?Python fft.ifftshift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.fft
的用法示例。
在下文中一共展示了fft.ifftshift方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: synthesize
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def synthesize(f_hat, axis=0):
"""
Compute the inverse / synthesis Fourier transform of the function f_hat : Z -> C.
The function f_hat(n) is sampled at points in a limited range -floor(N/2) <= n <= ceil(N/2) - 1
This function returns
f[k] = f(theta_k) = sum_{n=-floor(N/2)}^{ceil(N/2)-1} f_hat(n) exp(i n theta_k)
where theta_k = 2 pi k / N
for k = 0, ..., N - 1
:param f_hat:
:param axis:
:return:
"""
f_hat = ifftshift(f_hat * f_hat.shape[axis], axes=axis)
f = ifft(f_hat, axis=axis)
return f
示例2: ift2
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def ift2(G, delta_f, FFT=None):
"""
Wrapper for inverse fourier transform
Parameters:
G: data to transform
delta_f: pixel seperation
FFT (FFT object, optional): An accelerated FFT object
"""
N = G.shape[0]
if FFT:
g = numpy.fft.fftshift(FFT(numpy.fft.fftshift(G))) * (N * delta_f) ** 2
else:
g = fft.ifftshift(fft.ifft2(fft.fftshift(G))) * (N * delta_f) ** 2
return g
示例3: get_numpy
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [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
示例4: get_scipy
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [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
示例5: test_definition
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
y = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
示例6: test_inverse
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def test_inverse(self):
for n in [1, 4, 9, 100, 211]:
x = np.random.random((n,))
assert_array_almost_equal(fft.ifftshift(fft.fftshift(x)), x)
示例7: test_axes_keyword
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def test_axes_keyword(self):
freqs = [[0, 1, 2], [3, 4, -4], [-3, -2, -1]]
shifted = [[-1, -3, -2], [2, 0, 1], [-4, 3, 4]]
assert_array_almost_equal(fft.fftshift(freqs, axes=(0, 1)), shifted)
assert_array_almost_equal(fft.fftshift(freqs, axes=0),
fft.fftshift(freqs, axes=(0,)))
assert_array_almost_equal(fft.ifftshift(shifted, axes=(0, 1)), freqs)
assert_array_almost_equal(fft.ifftshift(shifted, axes=0),
fft.ifftshift(shifted, axes=(0,)))
assert_array_almost_equal(fft.fftshift(freqs), shifted)
assert_array_almost_equal(fft.ifftshift(shifted), freqs)
示例8: test_axes_keyword
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def test_axes_keyword(self):
freqs = [[0, 1, 2], [3, 4, -4], [-3, -2, -1]]
shifted = [[-1, -3, -2], [2, 0, 1], [-4, 3, 4]]
assert_array_almost_equal(fft.fftshift(freqs, axes=(0, 1)), shifted)
assert_array_almost_equal(fft.fftshift(freqs, axes=0),
fft.fftshift(freqs, axes=(0,)))
assert_array_almost_equal(fft.ifftshift(shifted, axes=(0, 1)), freqs)
assert_array_almost_equal(fft.ifftshift(shifted, axes=0),
fft.ifftshift(shifted, axes=(0,)))
示例9: test_axes_keyword
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def test_axes_keyword(self):
freqs = [[ 0, 1, 2], [ 3, 4, -4], [-3, -2, -1]]
shifted = [[-1, -3, -2], [ 2, 0, 1], [-4, 3, 4]]
assert_array_almost_equal(fft.fftshift(freqs, axes=(0, 1)), shifted)
assert_array_almost_equal(fft.fftshift(freqs, axes=0),
fft.fftshift(freqs, axes=(0,)))
assert_array_almost_equal(fft.ifftshift(shifted, axes=(0, 1)), freqs)
assert_array_almost_equal(fft.ifftshift(shifted, axes=0),
fft.ifftshift(shifted, axes=(0,)))
示例10: synthesize
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftshift [as 别名]
def synthesize(f_hat, axes=(0, 1)):
"""
:param f_hat:
:param axis:
:return:
"""
size = np.prod([f_hat.shape[ax] for ax in axes])
f_hat = ifftshift(f_hat * size, axes=axes)
f = ifft2(f_hat, axes=axes)
return f