本文整理汇总了Python中scipy.fftpack.ifft2方法的典型用法代码示例。如果您正苦于以下问题:Python fftpack.ifft2方法的具体用法?Python fftpack.ifft2怎么用?Python fftpack.ifft2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.fftpack
的用法示例。
在下文中一共展示了fftpack.ifft2方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dotH
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [as 别名]
def dotH(self,y):
x = ifft2(y, axes=self.fft_axes)
x = np.prod(self.fft_shape) * x
#if forward operation was zero-padded, crop the output back down to
#size. if it was cropped, zero-pad it back to size.
if not np.all(self.shape0 == self.shape1):
slc = slice(None) * len(self.shape0)
pad = np.zeros((2,len(self.shape0)))
for i_ax in self.ft_axes:
if self.shape1[i_ax] > self.shape0[i_ax]:
slc[i_ax] = slice(self.shape0)
elif self.shape1[i_ax] < self.shape0[i_ax]:
pad[1,i_ax] = self.shape0[i_ax] - self.shape1[i_ax]
x = np.pad(x[slc], pad)
return np.array(x, dtype=self.dtype0)
示例2: SO3_ifft
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [as 别名]
def SO3_ifft(f_hat):
"""
"""
b = len(f_hat)
d = setup_d_transform(b)
df_hat = [d[l] * f_hat[l][:, None, :] for l in range(len(d))]
# Note: the frequencies where m=-B or n=-B are set to zero,
# because they are not used in the forward transform either
# (the forward transform is up to m=-l, l<B
F = np.zeros((2 * b, 2 * b, 2 * b), dtype=complex)
for l in range(b):
F[b - l:b + l + 1, :, b - l:b + l + 1] += df_hat[l]
F = fftshift(F, axes=(0, 2))
f = ifft2(F, axes=(0, 2))
return f * 2 * (b ** 2) / np.pi
示例3: get_numpy
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [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 scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [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: SO3_FFT_synthesize
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [as 别名]
def SO3_FFT_synthesize(f_hat):
"""
Perform the inverse (spectral to spatial) SO(3) Fourier transform.
:param f_hat: a list of matrices of with shapes [1x1, 3x3, 5x5, ..., 2 L_max + 1 x 2 L_max + 1]
"""
F = wigner_d_transform_synthesis(f_hat)
# The rest of the SO(3) FFT is just a standard torus FFT
F = fftshift(F, axes=(0, 2))
f = ifft2(F, axes=(0, 2))
b = len(f_hat)
return f * (2 * b) ** 2
示例6: _calc_autoc_grid
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [as 别名]
def _calc_autoc_grid(phase):
"""
Helper function to assist with memory re-allocation during FFT calculation
"""
pspec = _calc_power_spectrum(phase)
autocorr_grid = ifft2(pspec)
return autocorr_grid.astype(dtype=np.complex64)
示例7: _slp_filter
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [as 别名]
def _slp_filter(phase, cutoff, rows, cols, x_size, y_size, params):
"""
Function to perform spatial low pass filter
"""
cx = np.floor(cols/2)
cy = np.floor(rows/2)
# fft for the input image
imf = fftshift(fft2(phase))
# calculate distance
distfact = 1.0e3 # to convert into meters
[xx, yy] = np.meshgrid(range(cols), range(rows))
xx = (xx - cx) * x_size # these are in meters as x_size in meters
yy = (yy - cy) * y_size
dist = np.sqrt(xx ** 2 + yy ** 2)/distfact # km
if params[cf.SLPF_METHOD] == 1: # butterworth low pass filter
H = 1. / (1 + ((dist / cutoff) ** (2 * params[cf.SLPF_ORDER])))
else: # Gaussian low pass filter
H = np.exp(-(dist ** 2) / (2 * cutoff ** 2))
outf = imf * H
out = np.real(ifft2(ifftshift(outf)))
out[np.isnan(phase)] = np.nan
return out # out is units of phase, i.e. mm
# TODO: use tiles here and distribute amongst processes
示例8: hilbert2
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [as 别名]
def hilbert2(x, N=None):
"""
Compute the '2-D' analytic signal of `x`
Parameters
----------
x : array_like
2-D signal data.
N : int or tuple of two ints, optional
Number of Fourier components. Default is ``x.shape``
Returns
-------
xa : ndarray
Analytic signal of `x` taken along axes (0,1).
References
----------
.. [1] Wikipedia, "Analytic signal",
http://en.wikipedia.org/wiki/Analytic_signal
"""
x = atleast_2d(x)
if x.ndim > 2:
raise ValueError("x must be 2-D.")
if iscomplexobj(x):
raise ValueError("x must be real.")
if N is None:
N = x.shape
elif isinstance(N, int):
if N <= 0:
raise ValueError("N must be positive.")
N = (N, N)
elif len(N) != 2 or np.any(np.asarray(N) <= 0):
raise ValueError("When given as a tuple, N must hold exactly "
"two positive integers")
Xf = fftpack.fft2(x, N, axes=(0, 1))
h1 = zeros(N[0], 'd')
h2 = zeros(N[1], 'd')
for p in range(2):
h = eval("h%d" % (p + 1))
N1 = N[p]
if N1 % 2 == 0:
h[0] = h[N1 // 2] = 1
h[1:N1 // 2] = 2
else:
h[0] = 1
h[1:(N1 + 1) // 2] = 2
exec("h%d = h" % (p + 1), globals(), locals())
h = h1[:, newaxis] * h2[newaxis, :]
k = x.ndim
while k > 2:
h = h[:, newaxis]
k -= 1
x = fftpack.ifft2(Xf * h, axes=(0, 1))
return x
示例9: fractalGrid
# 需要导入模块: from scipy import fftpack [as 别名]
# 或者: from scipy.fftpack import ifft2 [as 别名]
def fractalGrid(self, fd, n=256):
"""
Modified after https://github.com/samthiele/pycompass/blob/master/examples/3_Synthetic%20Examples.ipynb
Generate isotropic fractal surface image using
spectral synthesis method [1, p.]
References:
1. Yuval Fisher, Michael McGuire,
The Science of Fractal Images, 1988
(cf. http://shortrecipes.blogspot.com.au/2008/11/python-isotropic-fractal-surface.html)
**Arguments**:
-fd = the fractal dimension
-N = the size of the fractal surface/image
"""
h = 1 - (fd - 2)
# X = np.zeros((N, N), complex)
a = np.zeros((n, n), complex)
powerr = -(h + 1.0) / 2.0
for i in range(int(n / 2) + 1):
for j in range(int(n / 2) + 1):
phase = 2 * np.pi * np.random.rand()
if i is not 0 or j is not 0:
rad = (i * i + j * j) ** powerr * np.random.normal()
else:
rad = 0.0
a[i, j] = complex(rad * np.cos(phase), rad * np.sin(phase))
if i is 0:
i0 = 0
else:
i0 = n - i
if j is 0:
j0 = 0
else:
j0 = n - j
a[i0, j0] = complex(rad * np.cos(phase), -rad * np.sin(phase))
a.imag[int(n / 2)][0] = 0.0
a.imag[0, int(n / 2)] = 0.0
a.imag[int(n / 2)][int(n / 2)] = 0.0
for i in range(1, int(n / 2)):
for j in range(1, int(n / 2)):
phase = 2 * np.pi * np.random.rand()
rad = (i * i + j * j) ** powerr * np.random.normal()
a[i, n - j] = complex(rad * np.cos(phase), rad * np.sin(phase))
a[n - i, j] = complex(rad * np.cos(phase), -rad * np.sin(phase))
itemp = fftpack.ifft2(a)
itemp = itemp - itemp.min()
return itemp.real / itemp.real.max()