本文整理汇总了Python中numpy.fft.irfftn方法的典型用法代码示例。如果您正苦于以下问题:Python fft.irfftn方法的具体用法?Python fft.irfftn怎么用?Python fft.irfftn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.fft
的用法示例。
在下文中一共展示了fft.irfftn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_test_c2r_impl
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import irfftn [as 别名]
def run_test_c2r_impl(self, shape, axes, fftshift=False):
ishape = list(shape)
oshape = list(shape)
ishape[axes[-1]] = shape[axes[-1]] // 2 + 1
oshape[axes[-1]] = (ishape[axes[-1]] - 1) * 2
ishape[-1] *= 2 # For complex
known_data = np.random.normal(size=ishape).astype(np.float32).view(np.complex64)
idata = bf.ndarray(known_data, space='cuda')
odata = bf.ndarray(shape=oshape, dtype='f32', space='cuda')
fft = Fft()
fft.init(idata, odata, axes=axes, apply_fftshift=fftshift)
fft.execute(idata, odata)
# Note: Numpy applies normalization while CUFFT does not
norm = reduce(lambda a, b: a * b, [shape[d] for d in axes])
if fftshift:
known_data = np.fft.ifftshift(known_data, axes=axes)
known_result = gold_irfftn(known_data, axes=axes) * norm
compare(odata.copy('system'), known_result)
示例2: test_not_last_axis_success
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import irfftn [as 别名]
def test_not_last_axis_success(self):
ar, ai = np.random.random((2, 16, 8, 32))
a = ar + 1j*ai
axes = (-2,)
# Should not raise error
fft.irfftn(a, axes=axes)
示例3: rfftn_empty_aligned
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import irfftn [as 别名]
def rfftn_empty_aligned(shape, axes, dtype, order='C', n=None):
"""Construct an empty byte-aligned array for real FFTs.
Construct an empty byte-aligned array for efficient use by :mod:`pyfftw`
functions :func:`pyfftw.interfaces.numpy_fft.rfftn` and
:func:`pyfftw.interfaces.numpy_fft.irfftn`. The shape of the
empty array is appropriate for the output of
:func:`pyfftw.interfaces.numpy_fft.rfftn` applied
to an array of the shape specified by parameter `shape`, and for the
input of the corresponding :func:`pyfftw.interfaces.numpy_fft.irfftn`
call that reverses this operation.
Parameters
----------
shape : sequence of ints
Output array shape
axes : sequence of ints
Axes on which the FFT will be computed
dtype : dtype
Real dtype from which the complex dtype of the output array is derived
order : {'C', 'F'}, optional (default 'C')
Specify whether arrays should be stored in row-major (C-style) or
column-major (Fortran-style) order
n : int, optional (default None)
Output array should be aligned to n-byte boundary
Returns
-------
a : ndarray
Empty array with required byte-alignment
"""
ashp = list(shape)
raxis = axes[-1]
ashp[raxis] = ashp[raxis] // 2 + 1
cdtype = complex_dtype(dtype)
return pyfftw.empty_aligned(ashp, cdtype, order, n)
示例4: irfftn
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import irfftn [as 别名]
def irfftn(a, s, axes=None):
"""Multi-dimensional inverse discrete Fourier transform for real input.
Compute the inverse of the multi-dimensional discrete Fourier
transform for real input. This function is a wrapper for
:func:`pyfftw.interfaces.numpy_fft.irfftn`, with an interface similar
to that of :func:`numpy.fft.irfftn`.
Parameters
----------
a : array_like
Input array
s : sequence of ints
Shape of the output along each transformed axis (input is cropped
or zero-padded to match). This parameter is not optional because,
unlike :func:`ifftn`, the output shape cannot be uniquely
determined from the input shape.
axes : sequence of ints, optional (default None)
Axes over which to compute the inverse DFT.
Returns
-------
af : ndarray
Inverse DFT of input array
"""
return pyfftw.interfaces.numpy_fft.irfftn(
a, s=s, axes=axes, overwrite_input=False,
planner_effort=pyfftw_planner_effort, threads=pyfftw_threads)
示例5: fftconv
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import irfftn [as 别名]
def fftconv(a, b, axes=(0, 1), origin=None):
"""Multi-dimensional convolution via the Discrete Fourier Transform.
Compute a multi-dimensional convolution via the Discrete Fourier
Transform. Note that the output has a phase shift relative to the
output of :func:`scipy.ndimage.convolve` with the default `origin`
parameter.
Parameters
----------
a : array_like
Input array
b : array_like
Input array
axes : sequence of ints, optional (default (0, 1))
Axes on which to perform convolution
origin : sequence of ints or None optional (default None)
Indices of centre of `a` filter. The default of None corresponds
to a centre at 0 on all axes of `a`
Returns
-------
ab : ndarray
Convolution of input arrays, `a` and `b`, along specified `axes`
"""
if np.isrealobj(a) and np.isrealobj(b):
fft = rfftn
ifft = irfftn
else:
fft = fftn
ifft = ifftn
dims = np.maximum([a.shape[i] for i in axes], [b.shape[i] for i in axes])
af = fft(a, dims, axes)
bf = fft(b, dims, axes)
ab = ifft(af * bf, dims, axes)
if origin is not None:
ab = np.roll(ab, -np.array(origin), axis=axes)
return ab
示例6: _irfftn
# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import irfftn [as 别名]
def _irfftn(a, s=None, axes=None):
return npfft.irfftn(a, s, axes).astype(real_dtype(a.dtype))