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


Python fftpack.ifftn方法代碼示例

本文整理匯總了Python中scipy.fftpack.ifftn方法的典型用法代碼示例。如果您正苦於以下問題:Python fftpack.ifftn方法的具體用法?Python fftpack.ifftn怎麽用?Python fftpack.ifftn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.fftpack的用法示例。


在下文中一共展示了fftpack.ifftn方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: vhartree_pbc

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def vhartree_pbc(self, dens, **kw): 
  """  Compute Hartree potential for the density given in an equidistant grid  """
  from scipy.fftpack import fftn, ifftn
  sh = self.mesh3d.shape
  dens = dens.reshape(sh)
  vh = fftn(dens)    
  umom = self.ucell_mom()
  ii = [np.array([i-sh[j] if i>sh[j]//2 else i for i in range(sh[j])]) for j in range(3)]
  gg = [np.array([umom[j]*i for i in ii[j]]) for j in range(3)]
  vh = apply_inv_G2(vh, gg[0], gg[1], gg[2])
  vh = ifftn(vh).real*(4*np.pi)
  return vh 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:14,代碼來源:m_vhartree_pbc.py

示例2: _irfftn

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def _irfftn(a, s=None, axes=None):
    return fft.ifftn(a, shape = s, axes = axes).real; 
開發者ID:ChristophKirst,項目名稱:ClearMap,代碼行數:4,代碼來源:Convolution.py

示例3: _pad_nans

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def _pad_nans(x, head=None, tail=None):
    if np.ndim(x) == 1:
        if head is None and tail is None:
            return x
        elif head and tail:
            return np.r_[[np.nan] * head, x, [np.nan] * tail]
        elif tail is None:
            return np.r_[[np.nan] * head, x]
        elif head is None:
            return np.r_[x, [np.nan] * tail]
    elif np.ndim(x) == 2:
        if head is None and tail is None:
            return x
        elif head and tail:
            return np.r_[[[np.nan] * x.shape[1]] * head, x,
                         [[np.nan] * x.shape[1]] * tail]
        elif tail is None:
            return np.r_[[[np.nan] * x.shape[1]] * head, x]
        elif head is None:
            return np.r_[x, [[np.nan] * x.shape[1]] * tail]
    else:
        raise ValueError("Nan-padding for ndim > 2 not implemented")

#original changes and examples in sandbox.tsa.try_var_convolve

# don't do these imports, here just for copied fftconvolve
#get rid of these imports
#from scipy.fftpack import fft, ifft, ifftshift, fft2, ifft2, fftn, \
#     ifftn, fftfreq
#from numpy import product,array 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:32,代碼來源:filtertools.py

示例4: test_definition

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def test_definition(self):
        x = np.array([[1,2,3],[4,5,6],[7,8,9]], dtype=self.dtype)
        y = ifftn(x)
        assert_(y.dtype == self.cdtype)
        assert_array_almost_equal_nulp(y,direct_idftn(x),self.maxnlp)
        x = random((20,26))
        assert_array_almost_equal_nulp(ifftn(x),direct_idftn(x),self.maxnlp)
        x = random((5,4,3,20))
        assert_array_almost_equal_nulp(ifftn(x),direct_idftn(x),self.maxnlp) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:11,代碼來源:test_basic.py

示例5: test_random_complex

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def test_random_complex(self):
        for size in [1,2,51,32,64,92]:
            x = random([size,size]) + 1j*random([size,size])
            assert_array_almost_equal_nulp(ifftn(fftn(x)),x,self.maxnlp)
            assert_array_almost_equal_nulp(fftn(ifftn(x)),x,self.maxnlp) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:7,代碼來源:test_basic.py

示例6: test_ifftn

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def test_ifftn(self):
        overwritable = (np.complex128, np.complex64)
        for dtype in self.dtypes:
            self._check_nd(ifftn, dtype, overwritable) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:test_basic.py

示例7: test_definition

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def test_definition(self):
        x = np.array([[1,2,3],[4,5,6],[7,8,9]], dtype=self.dtype)
        y = ifftn(x)
        assert_equal(y.dtype, self.cdtype)
        assert_array_almost_equal_nulp(y,direct_idftn(x),self.maxnlp)
        x = random((20,26))
        assert_array_almost_equal_nulp(ifftn(x),direct_idftn(x),self.maxnlp)
        x = random((5,4,3,20))
        assert_array_almost_equal_nulp(ifftn(x),direct_idftn(x),self.maxnlp) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:11,代碼來源:test_basic.py

示例8: test_invalid_sizes

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def test_invalid_sizes(self):
        assert_raises(ValueError, ifftn, [[]])
        assert_raises(ValueError, ifftn, [[1,1],[2,2]], (4, -3)) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:5,代碼來源:test_basic.py

示例9: generate_fractal_surface

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def generate_fractal_surface(self, G):
        """Generate a 2D array with a fractal distribution.

        Args:
            G (class): Grid class instance - holds essential parameters describing the model.
        """

        if self.xs == self.xf:
            surfacedims = (self.ny, self.nz)
        elif self.ys == self.yf:
            surfacedims = (self.nx, self.nz)
        elif self.zs == self.zf:
            surfacedims = (self.nx, self.ny)

        self.fractalsurface = np.zeros(surfacedims, dtype=complextype)

        # Positional vector at centre of array, scaled by weighting
        v1 = np.array([self.weighting[0] * (surfacedims[0]) / 2, self.weighting[1] * (surfacedims[1]) / 2])

        # 2D array of random numbers to be convolved with the fractal function
        R = np.random.RandomState(self.seed)
        A = R.randn(surfacedims[0], surfacedims[1])

        # 2D FFT
        A = fftpack.fftn(A)
        # Shift the zero frequency component to the centre of the array
        A = fftpack.fftshift(A)

        # Generate fractal
        generate_fractal2D(surfacedims[0], surfacedims[1], G.nthreads, self.b, self.weighting, v1, A, self.fractalsurface)

        # Shift the zero frequency component to start of the array
        self.fractalsurface = fftpack.ifftshift(self.fractalsurface)
        # Take the real part (numerical errors can give rise to an imaginary part) of the IFFT
        self.fractalsurface = np.real(fftpack.ifftn(self.fractalsurface))
        # Scale the fractal volume according to requested range
        fractalmin = np.amin(self.fractalsurface)
        fractalmax = np.amax(self.fractalsurface)
        fractalrange = fractalmax - fractalmin
        self.fractalsurface = self.fractalsurface * ((self.fractalrange[1] - self.fractalrange[0]) / fractalrange) \
            + self.fractalrange[0] - ((self.fractalrange[1] - self.fractalrange[0]) / fractalrange) * fractalmin 
開發者ID:gprMax,項目名稱:gprMax,代碼行數:43,代碼來源:fractals.py

示例10: read_fft_volume

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def read_fft_volume(data4D, harmonic=1):
    zslices = data4D.shape[2]
    tframes = data4D.shape[3]
    data3d_fft = np.empty((data4D.shape[:2]+(0,)))
    for slice in range(zslices):
        ff1 = fftn([data4D[:,:,slice, t] for t in range(tframes)])
        fh = np.absolute(ifftn(ff1[harmonic, :, :]))
        fh[fh < 0.1 * np.max(fh)] = 0.0
        image = 1. * fh / np.max(fh)
        # plt.imshow(image, cmap = 'gray')
        # plt.show()
        image = np.expand_dims(image, axis=2)
        data3d_fft = np.append(data3d_fft, image, axis=2)
    return data3d_fft 
開發者ID:mahendrakhened,項目名稱:Automated-Cardiac-Segmentation-and-Disease-Diagnosis,代碼行數:16,代碼來源:utils.py

示例11: fft

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def fft(x, direction='C2C', inverse=False):
    """
        Interface with torch FFT routines for 2D signals.

        Example
        -------
        x = torch.randn(128, 32, 32, 2)
        x_fft = fft(x, inverse=True)

        Parameters
        ----------
        input : tensor
            complex input for the FFT
        direction : string
            'C2R' for complex to real, 'C2C' for complex to complex
        inverse : bool
            True for computing the inverse FFT.
            NB : if direction is equal to 'C2R', then an error is raised.

    """
    if direction == 'C2R':
        if not inverse:
            raise RuntimeError('C2R mode can only be done with an inverse FFT.')

    if direction == 'C2R':
        output = np.real(ifftn(x, axes=(-3, -2, -1)))
    elif direction == 'C2C':
        if inverse:
            output = ifftn(x, axes=(-3, -2, -1))
        else:
            output = fftn(x, axes=(-3, -2, -1))

    return output 
開發者ID:kymatio,項目名稱:kymatio,代碼行數:35,代碼來源:numpy_backend.py

示例12: bgtensor

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def bgtensor(img, lsigma, rho=0.2):
    eps = 1e-12
    fimg = fftn(img, overwrite_x=True)

    for s in lsigma:
        jvbuffer = bgkern3(kerlen=math.ceil(s)*6+1, sigma=s, rho=rho)
        jvbuffer = fftn(jvbuffer, shape=fimg.shape, overwrite_x=True) * fimg
        fimg = ifftn(jvbuffer, overwrite_x=True)
        yield hessian3(np.real(fimg)) 
開發者ID:RivuletStudio,項目名稱:rivuletpy,代碼行數:11,代碼來源:anisotropic.py

示例13: plan_ifft

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def plan_ifft(A, n=None, axis=None, norm=None, **_):
        """
        Plans an ifft for repeated use. Parameters are the same as for `pyfftw`'s `ifftn`
        which are, where possible, the same as the `numpy` equivalents.
        Note that some functionality is only possible when using the `pyfftw` backend.

        Parameters
        ----------
        A : `numpy.ndarray`, of dimension `d`
            Array of same shape to be input for the ifft
        n : iterable or `None`, `len(n) == d`, optional
            The output shape of ifft (default=`None` is same as `A.shape`)
        axis : `int`, iterable length `d`, or `None`, optional
            The axis (or axes) to transform (default=`None` is all axes)
        overwrite : `bool`, optional
            Whether the input array can be overwritten during computation
            (default=False)
        planner : {0, 1, 2, 3}, optional
            Amount of effort put into optimising Fourier transform where 0 is low
            and 3 is high (default=`1`).
        threads : `int`, `None`
            Number of threads to use (default=`None` is all threads)
        auto_align_input : `bool`, optional
            If `True` then may re-align input (default=`True`)
        auto_contiguous : `bool`, optional
            If `True` then may re-order input (default=`True`)
        avoid_copy : `bool`, optional
            If `True` then may over-write initial input (default=`False`)
        norm : {None, 'ortho'}, optional
            Indicate whether ifft is normalised (default=`None`)

        Returns
        -------
        plan : function
            Returns the inverse Fourier transform of `B`, `plan() == ifftn(B)`
        B : `numpy.ndarray`, `A.shape`
            Array which should be modified inplace for ifft to be computed. If
            possible, `B is A`.
        """
        return lambda: ifftn(A, n, axis, norm), A 
開發者ID:pyxem,項目名稱:diffsims,代碼行數:42,代碼來源:fourier_transform.py

示例14: ifftn

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def ifftn(a, s=None, axes=None, norm=None, **_):
        return _ifftn(a, s, axes, norm) 
開發者ID:pyxem,項目名稱:diffsims,代碼行數:4,代碼來源:fourier_transform.py

示例15: convolve

# 需要導入模塊: from scipy import fftpack [as 別名]
# 或者: from scipy.fftpack import ifftn [as 別名]
def convolve(arr1, arr2, dx=None, axes=None):
    """
    Performs a centred convolution of input arrays

    Parameters
    ----------
    arr1, arr2 : `numpy.ndarray`
        Arrays to be convolved. If dimensions are not equal then 1s are appended
        to the lower dimensional array. Otherwise, arrays must be broadcastable.
    dx : float > 0, list of float, or `None` , optional
        Grid spacing of input arrays. Output is scaled by
        `dx**max(arr1.ndim, arr2.ndim)`. default=`None` applies no scaling
    axes : tuple of ints or `None`, optional
        Choice of axes to convolve. default=`None` convolves all axes

    """
    if arr2.ndim > arr1.ndim:
        arr1, arr2 = arr2, arr1
        if axes is None:
            axes = range(arr2.ndim)
    arr2 = arr2.reshape(arr2.shape + (1,) * (arr1.ndim - arr2.ndim))

    if dx is None:
        dx = 1
    elif isscalar(dx):
        dx = dx ** (len(axes) if axes is not None else arr1.ndim)
    else:
        dx = prod(dx)

    arr1 = fftn(arr1, axes=axes)
    arr2 = fftn(ifftshift(arr2), axes=axes)
    out = ifftn(arr1 * arr2, axes=axes) * dx
    return require(out, requirements="CA") 
開發者ID:pyxem,項目名稱:diffsims,代碼行數:35,代碼來源:fourier_transform.py


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