当前位置: 首页>>代码示例>>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;未经允许,请勿转载。