• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyfftw.empty_aligned函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyfftw.empty_aligned函数的典型用法代码示例。如果您正苦于以下问题:Python empty_aligned函数的具体用法?Python empty_aligned怎么用?Python empty_aligned使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了empty_aligned函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_flags

    def test_flags(self):
        '''Test to see if the flags are correct
        '''
        fft = FFTW(self.input_array, self.output_array)
        self.assertEqual(fft.flags, ('FFTW_MEASURE',))

        fft = FFTW(self.input_array, self.output_array,
                flags=('FFTW_DESTROY_INPUT', 'FFTW_UNALIGNED'))
        self.assertEqual(fft.flags, ('FFTW_DESTROY_INPUT', 'FFTW_UNALIGNED'))

        # Test an implicit flag
        _input_array = empty_aligned(256, dtype='complex64', n=16)
        _output_array = empty_aligned(256, dtype='complex64', n=16)

        # These are guaranteed to be misaligned (due to dtype size == 8)
        input_array = _input_array[:-1]
        output_array = _output_array[:-1]
        u_input_array = _input_array[1:]
        u_output_array = _output_array[1:]

        fft = FFTW(input_array, u_output_array)
        self.assertEqual(fft.flags, ('FFTW_MEASURE', 'FFTW_UNALIGNED'))

        fft = FFTW(u_input_array, output_array)
        self.assertEqual(fft.flags, ('FFTW_MEASURE', 'FFTW_UNALIGNED'))

        fft = FFTW(u_input_array, u_output_array)
        self.assertEqual(fft.flags, ('FFTW_MEASURE', 'FFTW_UNALIGNED'))
开发者ID:carterbox,项目名称:pyFFTW,代码行数:28,代码来源:test_pyfftw_class_misc.py


示例2: generate_wisdom

    def generate_wisdom(self):
        for each_dtype in (numpy.complex128, numpy.complex64, 
                numpy.clongdouble):

            a = empty_aligned((1,1024), each_dtype, n=16)
            b = empty_aligned(a.shape, dtype=a.dtype, n=16)
            fft = FFTW(a,b)
开发者ID:PierreBizouard,项目名称:pyFFTW,代码行数:7,代码来源:test_pyfftw_wisdom.py


示例3: test_update_data_with_unaligned_original

    def test_update_data_with_unaligned_original(self):
        in_shape = self.input_shapes['2d']
        out_shape = self.output_shapes['2d']

        input_dtype_alignment = self.get_input_dtype_alignment()
        
        axes=(-1,)
        a, b = self.create_test_arrays(in_shape, out_shape)

        # Offset from 16 byte aligned to guarantee it's not
        # 16 byte aligned
        a__ = empty_aligned(
                numpy.prod(in_shape)*a.itemsize + input_dtype_alignment,
                dtype='int8', n=16)

        a_ = a__[input_dtype_alignment:].view(dtype=self.input_dtype).reshape(*in_shape)
        a_[:] = a

        b__ = empty_aligned(
                numpy.prod(out_shape)*b.itemsize + input_dtype_alignment,
                dtype='int8', n=16)

        b_ = b__[input_dtype_alignment:].view(dtype=self.output_dtype).reshape(*out_shape)
        b_[:] = b
        
        fft, ifft = self.run_validate_fft(a_, b_, axes, 
                force_unaligned_data=True)
        
        self.run_validate_fft(a, b_, axes, fft=fft, ifft=ifft)
        self.run_validate_fft(a_, b, axes, fft=fft, ifft=ifft)
        self.run_validate_fft(a_, b_, axes, fft=fft, ifft=ifft)
开发者ID:PierreBizouard,项目名称:pyFFTW,代码行数:31,代码来源:test_pyfftw_complex.py


示例4: test_call_with_normalisation_precision

    def test_call_with_normalisation_precision(self):
        '''The normalisation should use a double precision scaling.
        '''
        # Should be the case for double inputs...
        _input_array = empty_aligned((256, 512), dtype='complex128', n=16)

        self.fft()
        ifft = FFTW(self.output_array, _input_array,
                direction='FFTW_BACKWARD')

        ref_output = ifft(normalise_idft=False).copy()/numpy.float64(ifft.N)
        test_output = ifft(normalise_idft=True).copy()

        self.assertTrue(numpy.alltrue(ref_output == test_output))

        # ... and single inputs.
        _input_array = empty_aligned((256, 512), dtype='complex64', n=16)

        ifft = FFTW(numpy.array(self.output_array, _input_array.dtype),
                    _input_array,
                    direction='FFTW_BACKWARD')

        ref_output = ifft(normalise_idft=False).copy()/numpy.float64(ifft.N)
        test_output = ifft(normalise_idft=True).copy()

        self.assertTrue(numpy.alltrue(ref_output == test_output))
开发者ID:grlee77,项目名称:pyFFTW,代码行数:26,代码来源:test_pyfftw_call.py


示例5: test_incorrect_byte_alignment_fails

    def test_incorrect_byte_alignment_fails(self):
        in_shape = self.input_shapes["2d"]
        out_shape = self.output_shapes["2d"]

        input_dtype_alignment = self.get_input_dtype_alignment()

        axes = (-1,)
        a, b = self.create_test_arrays(in_shape, out_shape)

        a = byte_align(a, n=16)
        b = byte_align(b, n=16)

        fft, ifft = self.run_validate_fft(a, b, axes, force_unaligned_data=True)

        a, b = self.create_test_arrays(in_shape, out_shape)

        # Offset from 16 byte aligned to guarantee it's not
        # 16 byte aligned
        a__ = empty_aligned(numpy.prod(in_shape) * a.itemsize + 1, dtype="int8", n=16)

        a_ = a__[1:].view(dtype=self.input_dtype).reshape(*in_shape)
        a_[:] = a

        b__ = empty_aligned(numpy.prod(out_shape) * b.itemsize + 1, dtype="int8", n=16)

        b_ = b__[1:].view(dtype=self.output_dtype).reshape(*out_shape)
        b_[:] = b

        self.assertRaisesRegex(ValueError, "Invalid output alignment", FFTW, *(a, b_))

        self.assertRaisesRegex(ValueError, "Invalid input alignment", FFTW, *(a_, b))

        self.assertRaisesRegex(ValueError, "Invalid input alignment", FFTW, *(a_, b_))
开发者ID:rajath,项目名称:pyFFTW,代码行数:33,代码来源:test_pyfftw_complex.py


示例6: __init__

    def __init__(self,mask, tccList):
        self.mask = mask
        self.tcc = tccList
        self.order = tccList.order
        self.kernelList = tccList.kernelList
        self.coefList = tccList.coefList
        self.focusList = tccList.focusList
        self.focusCoef = tccList.focusCoef
        self.doseList = [1.0]
        self.doseCoef = [1.0]
        self.AIList = []
        self.RIList = []
        self.resist_a = 80
        self.resist_tRef = 0.5

        self.norm = self.mask.y_gridnum*self.mask.x_gridnum
        self.x1 = np.floor(self.mask.x_gridnum/2) - self.tcc.s.fnum
        self.x2 = np.floor(self.mask.x_gridnum/2) + self.tcc.s.fnum  + 1
        self.y1 = np.floor(self.mask.y_gridnum/2) - self.tcc.s.gnum 
        self.y2 = np.floor(self.mask.y_gridnum/2) + self.tcc.s.gnum  + 1

        self.spat_part = pyfftw.empty_aligned((self.mask.y_gridnum,self.mask.x_gridnum),\
                                               dtype='complex128')
        self.freq_part = pyfftw.empty_aligned((self.mask.y_gridnum,self.mask.x_gridnum),\
                                               dtype='complex128')
        self.ifft_image = pyfftw.FFTW(self.freq_part,self.spat_part,axes=(0,1),\
                                     direction='FFTW_BACKWARD')  
开发者ID:vincentlv,项目名称:DimmiLitho,代码行数:27,代码来源:image.py


示例7: test_misaligned_data_doesnt_clobber_cache

    def test_misaligned_data_doesnt_clobber_cache(self):
        '''A bug was highlighted in #197 in which misaligned data causes
        an overwrite of an FFTW internal array which is also the same as
        an output array. The correct behaviour is for the cache to have
        alignment as a key to stop this happening.
        '''
        interfaces.cache.enable()

        N = 64
        pyfftw.interfaces.cache.enable()
        np.random.seed(12345)

        Um = pyfftw.empty_aligned((N, N+1), dtype=np.float32, order='C')
        Vm = pyfftw.empty_aligned((N, N+1), dtype=np.float32, order='C')
        U = np.ndarray((N, N), dtype=Um.dtype, buffer=Um.data, offset=0)
        V = np.ndarray(
            (N, N), dtype=Vm.dtype, buffer=Vm.data, offset=Vm.itemsize)

        U[:] = np.random.randn(N, N).astype(np.float32)
        V[:] = np.random.randn(N, N).astype(np.float32)

        uh = hashlib.md5(U).hexdigest()
        vh = hashlib.md5(V).hexdigest()
        x = interfaces.numpy_fft.rfftn(
            U, None, axes=(0, 1), overwrite_input=False)
        y = interfaces.numpy_fft.rfftn(
            V, None, axes=(0, 1), overwrite_input=False)

        self.assertTrue(uh == hashlib.md5(U).hexdigest())
        self.assertTrue(vh == hashlib.md5(V).hexdigest())

        interfaces.cache.disable()
开发者ID:grlee77,项目名称:pyFFTW,代码行数:32,代码来源:test_pyfftw_interfaces_cache.py


示例8: __init__

 def __init__(self, size):
     self.size = size
     self._time = pyfftw.empty_aligned(size, 'float64')
     self._freq = pyfftw.empty_aligned(size//2 + 1, 'complex128')
     self.fft = pyfftw.FFTW(self._time, self._freq, threads=os.cpu_count(),
                            direction='FFTW_FORWARD')
     self.ifft = pyfftw.FFTW(self._freq, self._time, threads=os.cpu_count(),
                             direction='FFTW_BACKWARD')
开发者ID:crowsonkb,项目名称:fragments,代码行数:8,代码来源:fftw.py


示例9: setUp

    def setUp(self):

        self.input_array = empty_aligned((256, 512), dtype='complex128', n=16)
        self.output_array = empty_aligned((256, 512), dtype='complex128', n=16)

        self.fft = FFTW(self.input_array, self.output_array)

        self.input_array[:] = (numpy.random.randn(*self.input_array.shape)
                + 1j*numpy.random.randn(*self.input_array.shape))
开发者ID:grlee77,项目名称:pyFFTW,代码行数:9,代码来源:test_pyfftw_call.py


示例10: test_call_with_unaligned

    def test_call_with_unaligned(self):
        '''Make sure the right thing happens with unaligned data.
        '''
        input_array = (numpy.random.randn(*self.input_array.shape)
                + 1j*numpy.random.randn(*self.input_array.shape))

        output_array = self.fft(
                input_array=byte_align(input_array.copy(), n=16)).copy()

        input_array = byte_align(input_array, n=16)
        output_array = byte_align(output_array, n=16)

        # Offset by one from 16 byte aligned to guarantee it's not
        # 16 byte aligned
        a = byte_align(input_array.copy(), n=16)
        a__ = empty_aligned(numpy.prod(a.shape)*a.itemsize+1, dtype='int8',
                            n=16)

        a_ = a__[1:].view(dtype=a.dtype).reshape(*a.shape)
        a_[:] = a

        # Create a different second array the same way
        b = byte_align(output_array.copy(), n=16)
        b__ = empty_aligned(numpy.prod(b.shape)*a.itemsize+1, dtype='int8',
                            n=16)

        b_ = b__[1:].view(dtype=b.dtype).reshape(*b.shape)
        b_[:] = a

        # Set up for the first array
        fft = FFTW(input_array, output_array)
        a_[:] = a
        output_array = fft().copy()

        # Check a_ is not aligned...
        self.assertRaisesRegex(ValueError, 'Invalid input alignment',
                self.fft.update_arrays, *(a_, output_array))

        # and b_ too
        self.assertRaisesRegex(ValueError, 'Invalid output alignment',
                self.fft.update_arrays, *(input_array, b_))

        # But it should still work with the a_
        fft(a_)

        # However, trying to update the output will raise an error
        self.assertRaisesRegex(ValueError, 'Invalid output alignment',
                self.fft.update_arrays, *(input_array, b_))

        # Same with SIMD off
        fft = FFTW(input_array, output_array, flags=('FFTW_UNALIGNED',))
        fft(a_)
        self.assertRaisesRegex(ValueError, 'Invalid output alignment',
                self.fft.update_arrays, *(input_array, b_))
开发者ID:grlee77,项目名称:pyFFTW,代码行数:54,代码来源:test_pyfftw_call.py


示例11: pyfftw_container

def pyfftw_container(ny, nx, bwd = False):
    '''
    construct a fftw container to perform fftw.
    '''
    a = pyfftw.empty_aligned((ny,nx),dtype = 'complex128')
    b = pyfftw.empty_aligned((ny,nx),dtype = 'complex128')
    if bwd:
        container = pyfftw.FFTW(a,b,axes = (0,1),direction = 'FFTW_BACKWARD')
    else:
        container = pyfftw.FFTW(a,b,axes = (0,1),direction = 'FFTW_FORWARD')
    return container
开发者ID:danustc,项目名称:Image_toolbox,代码行数:11,代码来源:correlation.py


示例12: test_failure

 def test_failure(self):
     for dtype, npdtype in zip(['32', '64', 'ld'], [np.complex64, np.complex128, np.clongdouble]):
         if dtype == 'ld' and np.dtype(np.clongdouble) == np.dtype(np.complex128):
             # skip this test on systems where clongdouble is complex128
             continue
         if dtype not in _supported_types:
             a = empty_aligned((1,1024), npdtype, n=16)
             b = empty_aligned(a.shape, dtype=a.dtype, n=16)
             msg = "Rebuild pyFFTW with support for %s precision!" % _all_types_human_readable[dtype]
             with self.assertRaisesRegex(NotImplementedError, msg):
                 FFTW(a,b)
开发者ID:grlee77,项目名称:pyFFTW,代码行数:11,代码来源:test_pyfftw_partial.py


示例13: test_update_data_with_alignment_error

    def test_update_data_with_alignment_error(self):
        in_shape = self.input_shapes['2d']
        out_shape = self.output_shapes['2d']

        byte_error = 1
        
        axes=(-1,)
        a, b = self.create_test_arrays(in_shape, out_shape)

        a = byte_align(a, n=16)
        b = byte_align(b, n=16)

        fft, ifft = self.run_validate_fft(a, b, axes)
        
        a, b = self.create_test_arrays(in_shape, out_shape)

        # Offset from 16 byte aligned to guarantee it's not
        # 16 byte aligned
        a__ = empty_aligned(
                numpy.prod(in_shape)*a.itemsize+byte_error,
                dtype='int8', n=16)

        a_ = (a__[byte_error:]
                .view(dtype=self.input_dtype).reshape(*in_shape))
        a_[:] = a

        b__ = empty_aligned(
                numpy.prod(out_shape)*b.itemsize+byte_error,
                dtype='int8', n=16)

        b_ = (b__[byte_error:]
                .view(dtype=self.output_dtype).reshape(*out_shape))
        b_[:] = b
     
        with self.assertRaisesRegex(ValueError, 'Invalid output alignment'):
            self.run_validate_fft(a, b_, axes, fft=fft, ifft=ifft, 
                    create_array_copies=False)

        with self.assertRaisesRegex(ValueError, 'Invalid input alignment'):
            self.run_validate_fft(a_, b, axes, fft=fft, ifft=ifft, 
                    create_array_copies=False)

        # Should also be true for the unaligned case
        fft, ifft = self.run_validate_fft(a, b, axes, 
                force_unaligned_data=True)

        with self.assertRaisesRegex(ValueError, 'Invalid output alignment'):
            self.run_validate_fft(a, b_, axes, fft=fft, ifft=ifft, 
                    create_array_copies=False)

        with self.assertRaisesRegex(ValueError, 'Invalid input alignment'):
            self.run_validate_fft(a_, b, axes, fft=fft, ifft=ifft, 
                    create_array_copies=False)
开发者ID:PierreBizouard,项目名称:pyFFTW,代码行数:53,代码来源:test_pyfftw_complex.py


示例14: test_is_byte_aligned

    def test_is_byte_aligned(self):
        a = empty_aligned(100)
        self.assertTrue(is_byte_aligned(a, get_expected_alignment(None)))

        a = empty_aligned(100, n=16)
        self.assertTrue(is_byte_aligned(a, n=16))

        a = empty_aligned(100, n=5)
        self.assertTrue(is_byte_aligned(a, n=5))

        a = empty_aligned(100, dtype="float32", n=16)[1:]
        self.assertFalse(is_byte_aligned(a, n=16))
        self.assertTrue(is_byte_aligned(a, n=4))
开发者ID:rajath,项目名称:pyFFTW,代码行数:13,代码来源:test_pyfftw_nbyte_align.py


示例15: get_fft

 def get_fft(self):
     try:
         import pyfftw
         if not hasattr(self,'__fftw_ffts'):
             a = pyfftw.empty_aligned((self._nx, self._ny), dtype='complex128')
             b = pyfftw.empty_aligned((self._nx, self._ny), dtype='complex128')
             fft2 = pyfftw.FFTW(a, b, axes=(0,1), threads=self._thread_count, direction = 'FFTW_FORWARD')
             ifft2 = pyfftw.FFTW(b, a, axes=(0,1), threads=self._thread_count, direction = 'FFTW_BACKWARD')
             self.__fftw_ffts = fft2,ifft2
         return self.__fftw_ffts
     except ImportError:
         from numpy.fft import fft2,ifft2
         return fft2,ifft2
开发者ID:TheLartians,项目名称:PyPropagate,代码行数:13,代码来源:fresnel.py


示例16: test_call_with_ortho_on

    def test_call_with_ortho_on(self):
        _input_array = empty_aligned((256, 512), dtype='complex128', n=16)

        ifft = FFTW(self.output_array, _input_array,
                    direction='FFTW_BACKWARD')

        self.fft(ortho=True, normalise_idft=False)

        # ortho case preserves the norm in forward direction
        self.assertTrue(
            numpy.allclose(numpy.linalg.norm(self.input_array),
                           numpy.linalg.norm(self.output_array)))

        ifft(ortho=True, normalise_idft=False)

        # ortho case preserves the norm in backward direction
        self.assertTrue(
            numpy.allclose(numpy.linalg.norm(_input_array),
                           numpy.linalg.norm(self.output_array)))

        self.assertTrue(numpy.allclose(self.input_array, _input_array))

        # cant select both ortho and normalise_idft
        self.assertRaisesRegex(ValueError, 'Invalid options',
                               self.fft, normalise_idft=True, ortho=True)
        # cant specify orth=True with default normalise_idft=True
        self.assertRaisesRegex(ValueError, 'Invalid options',
                               self.fft, ortho=True)
开发者ID:grlee77,项目名称:pyFFTW,代码行数:28,代码来源:test_pyfftw_call.py


示例17: test_call_with_different_striding

    def test_call_with_different_striding(self):
        '''Test the input update with different strides to internal array.
        '''
        input_array_shape = self.input_array.shape + (2,)
        internal_array_shape = self.internal_array.shape

        internal_array = byte_align(
                numpy.random.randn(*internal_array_shape)
                + 1j*numpy.random.randn(*internal_array_shape))

        fft =  utils._FFTWWrapper(internal_array, self.output_array,
                input_array_slicer=self.input_array_slicer,
                FFTW_array_slicer=self.FFTW_array_slicer)

        test_output_array = fft().copy()

        new_input_array = empty_aligned(input_array_shape,
                                        dtype=internal_array.dtype)
        new_input_array[:] = 0

        new_input_array[:,:,0][self.input_array_slicer] = (
                internal_array[self.FFTW_array_slicer])

        new_output = fft(new_input_array[:,:,0]).copy()

        # Test the test!
        self.assertTrue(
                new_input_array[:,:,0].strides != internal_array.strides)

        self.assertTrue(numpy.alltrue(test_output_array == new_output))
开发者ID:ng110,项目名称:pyFFTW,代码行数:30,代码来源:test_pyfftw_builders.py


示例18: conversion

    def conversion(self, missing, alt1, alt2):
        '''If the ``missing`` precision is not available, the builder should convert to
           ``alt1`` precision. If that isn't available either, it should fall back to
           ``alt2``. If input precision is lost, a warning should be emitted.

        '''

        missing, alt1, alt2 = [np.dtype(x) for x in (missing, alt1, alt2)]
        if _all_types_np[missing]  in _supported_types:
            return

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")

            itemsize = alt1.itemsize
            a = empty_aligned((1, 512), dtype=missing)
            b = interfaces.numpy_fft.fft(a)
            res = _rc_dtype_pairs.get(alt1.char, None)
            if res is not None:
                self.assertEqual(b.dtype, res)
            else:
                itemsize = alt2.itemsize
                self.assertEqual(b.dtype, _rc_dtype_pairs[alt2.char])

            if itemsize < missing.itemsize:
                print(itemsize, missing.itemsize)
                assert len(w) == 1
                assert "Narrowing conversion" in str(w[-1].message)
                print("Found narrowing conversion from %d to %d bytes" % (missing.itemsize, itemsize))
            else:
                assert len(w) == 0
开发者ID:grlee77,项目名称:pyFFTW,代码行数:31,代码来源:test_pyfftw_partial.py


示例19: test_avoid_copy

    def test_avoid_copy(self):
        '''Test the avoid_copy flag
        '''
        dtype_tuple = input_dtypes[functions[self.func]]
        
        for dtype in dtype_tuple[0]:
            for test_shape, s, kwargs in self.test_data:
                _kwargs = kwargs.copy()

                _kwargs['avoid_copy'] = True

                s2 = copy.copy(s)
                try:
                    for each_axis, length in enumerate(s):
                        s2[each_axis] += 2
                except TypeError:
                    s2 += 2

                input_array = dtype_tuple[1](test_shape, dtype)

                self.assertRaisesRegex(ValueError, 
                        'Cannot avoid copy.*transform shape.*',
                        getattr(builders, self.func),
                        input_array, s2, **_kwargs)

                non_contiguous_shape = [
                        each_dim * 2 for each_dim in test_shape]
                non_contiguous_slices = (
                        [slice(None, None, 2)] * len(test_shape))

                misaligned_input_array = dtype_tuple[1](
                        non_contiguous_shape, dtype)[non_contiguous_slices]

                self.assertRaisesRegex(ValueError, 
                        'Cannot avoid copy.*not contiguous.*',
                        getattr(builders, self.func),
                        misaligned_input_array, s, **_kwargs)

                # Offset by one from 16 byte aligned to guarantee it's not
                # 16 byte aligned
                _input_array = empty_aligned(
                        numpy.prod(test_shape)*input_array.itemsize+1,
                        dtype='int8', n=16)

                misaligned_input_array = _input_array[1:].view(
                         dtype=input_array.dtype).reshape(*test_shape)

                self.assertRaisesRegex(ValueError, 
                        'Cannot avoid copy.*not aligned.*',
                        getattr(builders, self.func),
                        misaligned_input_array, s, **_kwargs)

                _input_array = byte_align(input_array.copy())
                FFTW_object = getattr(builders, self.func)(
                        _input_array, s, **_kwargs)

                # A catch all to make sure the internal array
                # is not a copy
                self.assertTrue(FFTW_object.input_array is
                        _input_array)
开发者ID:ng110,项目名称:pyFFTW,代码行数:60,代码来源:test_pyfftw_builders.py


示例20: readCoherent

    def readCoherent(self, size=2**25):
        """Return coherently dedispersed timestream

        Read size number of samples, coherently dedisperse, take first
        step samples to chop off wraparound
        """

        if size != self.size or not 'dd' in self.__dict__ :
            # Only compute dedispersion phases and fft plans once for given size
            print("Calculating de-dispersion phase factors for size {0}".format(size))
            self.f = self.fedge + self.forder*np.fft.rfftfreq(size, self.dt1)[:, np.newaxis]
            self.dd = self.dm.phase_factor(self.f, self.fref)
            for j in range(len(self.forder)):
                if self.forder[j] == 1:
                    self.dd[...,j] = np.conj(self.dd[...,j])
            self.size = size
            self.step = int(size -  2**(np.ceil(np.log2(self.samploss))))
            a = pyfftw.empty_aligned((self.size, self.npol), dtype='float32', n=16)
            b = pyfftw.empty_aligned((self.size//2+1, self.npol), dtype='complex64', n=16)
            print("planning FFTs for coherent dedispersion...")
            self.fft_ts = pyfftw.FFTW(a,b, axes=(0,), direction='FFTW_FORWARD',
                           planning_timelimit=1.0, threads=8 )
            print("...")
            self.ifft_ts = pyfftw.FFTW(b,a, axes=(0,), direction='FFTW_BACKWARD',
                           planning_timelimit=1.0, threads=8 )


        d = pyfftw.empty_aligned((size,self.npol), dtype='float32')
        #d = self.fh.read(size)

        # need better solution...
        if self.dtype == 'vdif':
            d[:] = self.fh.read(size)[self.thread_ids]
        else:
            d[:] = self.fh.read(size)

        #ft = np.fft.rfft(d, axis=0)
        ft = self.fft_ts(d)
        ft *= self.dd

        dift = pyfftw.empty_aligned((size//2+1,self.npol), dtype='complex64')
        dift[:] = ft
        d = self.ifft_ts(dift)
        #d = np.fft.irfft(ft, axis=0)[:self.step]
        return d
开发者ID:ramain,项目名称:scint_analysis,代码行数:45,代码来源:ReadDD.py



注:本文中的pyfftw.empty_aligned函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyfftw.n_byte_align函数代码示例发布时间:2022-05-25
下一篇:
Python pyfftw.byte_align函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap