Python numpy.fft 模块,irfftn() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用numpy.fft.irfftn()

项目:bifrost    作者:ledatelescope    | 项目源码 | 文件源码
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)
项目:radar    作者:amoose136    | 项目源码 | 文件源码
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)
项目:thunder-registration    作者:thunder-project    | 项目源码 | 文件源码
def compute(a, b):
        """
        Compute an optimal displacement between two ndarrays.

        Finds the displacement between two ndimensional arrays. Arrays must be
        of the same size. Algorithm uses a cross correlation, computed efficiently
        through an n-dimensional fft.

        Parameters
        ----------
        a : ndarray
            The first array

        b : ndarray
            The second array
        """
        from numpy.fft import rfftn, irfftn
        from numpy import unravel_index, argmax

        # compute real-valued cross-correlation in fourier domain
        s = a.shape
        f = rfftn(a)
        f *= rfftn(b).conjugate()
        c = abs(irfftn(f, s))

        # find location of maximum
        inds = unravel_index(argmax(c), s)

        # fix displacements that are greater than half the total size
        pairs = zip(inds, a.shape)
        # cast to basic python int for serialization
        adjusted = [int(d - n) if d > n // 2 else int(d) for (d, n) in pairs]

        return Displacement(adjusted)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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)
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
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)
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
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)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
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)