當前位置: 首頁>>代碼示例>>Python>>正文


Python fftpack.ifft2方法代碼示例

本文整理匯總了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) 
開發者ID:GAMPTeam,項目名稱:vampyre,代碼行數:19,代碼來源:fft2.py

示例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 
開發者ID:AMLab-Amsterdam,項目名稱:lie_learn,代碼行數:20,代碼來源:SO3FFT_Naive.py

示例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 
開發者ID:pySTEPS,項目名稱:pysteps,代碼行數:19,代碼來源:fft.py

示例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 
開發者ID:pySTEPS,項目名稱:pysteps,代碼行數:22,代碼來源:fft.py

示例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 
開發者ID:AMLab-Amsterdam,項目名稱:lie_learn,代碼行數:16,代碼來源:SO3FFT_Naive.py

示例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) 
開發者ID:GeoscienceAustralia,項目名稱:PyRate,代碼行數:9,代碼來源:covariance.py

示例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 
開發者ID:GeoscienceAustralia,項目名稱:PyRate,代碼行數:28,代碼來源:aps.py

示例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 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:60,代碼來源:signaltools.py

示例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() 
開發者ID:cgre-aachen,項目名稱:gempy,代碼行數:61,代碼來源:create_topography.py


注:本文中的scipy.fftpack.ifft2方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。