pystella/fourier/spectra.py
def polarization(self, vector, projector, queue=None, k_power=3, allocator=None):
        """
        Computes the power spectra of the plus and minus polarizations of a vector
        field.

        :arg vector: The array containing the position-space vector field
            whose power spectrum is to be computed.
            If ``vector`` has more than four axes, all the outer axes are
            looped over.
            As an example, if ``vector`` has shape ``(2, 3, 3, 130, 130, 130)``
            (where the fourth-to-last axis is the vector-component axis),
            this method loops over the outermost two axes with shape ``(2, 3)``, and
            the resulting output data would have the shape ``(2, 3, 2, num_bins)``
            (where the second-to-last axis is the polarization axis).

        :arg projector: A :class:`Projector`.

        The remaining arguments are the same as those to :meth:`__call__`.

        :returns: A :class:`numpy.ndarray` containing the polarization spectra
            with shape ``vector.shape[:-4]+(2, num_bins)``.
        """

        queue = queue or vector.queue

        vec_k = cla.empty(queue, (3,)+self.kshape, self.cdtype, allocator=None)
        # overwrite vec_k
        plus = vec_k[0]
        minus = vec_k[1]

        outer_shape = vector.shape[:-4]
        from itertools import product
        slices = list(product(*[range(n) for n in outer_shape]))

        result = np.zeros(outer_shape+(2, self.num_bins,), self.rdtype)
        for s in slices:
            for mu in range(3):
                self.fft.dft(vector[s][mu], vec_k[mu])

            projector.vec_to_pol(queue, plus, minus, vec_k)
            result[s][0] = self.bin_power(plus, queue, k_power, allocator=allocator)
            result[s][1] = self.bin_power(minus, queue, k_power, allocator=allocator)

        return self.norm * result

        Computes the power spectra of the plus and minus polarizations of a vector
        field.

        :arg vector: The array containing the position-space vector field
            whose power spectrum is to be computed.
            If ``vector`` has more than four axes, all the outer axes are
            looped over.
            As an example, if ``vector`` has shape ``(2, 3, 3, 130, 130, 130)``
            (where the fourth-to-last axis is the vector-component axis),
            this method loops over the outermost two axes with shape ``(2, 3)``, and
            the resulting output data would have the shape ``(2, 3, 2, num_bins)``
            (where the second-to-last axis is the polarization axis).

        :arg projector: A :class:`Projector`.

        The remaining arguments are the same as those to :meth:`__call__`.

        :returns: A :class:`numpy.ndarray` containing the polarization spectra
            with shape ``vector.shape[:-4]+(2, num_bins)``.
        
Computes the power spectra of the plus and minus polarizations of a vector
field.
Computes the power spectra of the plus and minus polarizations of a vector field .
def polarization(self, vector, projector, queue=None, k_power=3, allocator=None):
        queue = queue or vector.queue
        vec_k = cla.empty(queue, (3,)+self.kshape, self.cdtype, allocator=None)
        plus = vec_k[0]
        minus = vec_k[1]
        outer_shape = vector.shape[:-4]
        from itertools import product
        slices = list(product(*[range(n) for n in outer_shape]))
        result = np.zeros(outer_shape+(2, self.num_bins,), self.rdtype)
        for s in slices:
            for mu in range(3):
                self.fft.dft(vector[s][mu], vec_k[mu])
            projector.vec_to_pol(queue, plus, minus, vec_k)
            result[s][0] = self.bin_power(plus, queue, k_power, allocator=allocator)
            result[s][1] = self.bin_power(minus, queue, k_power, allocator=allocator)
        return self.norm * result
def polarization ( self , vector , projector , queue = None , k_power = 3 , allocator = None ) : queue = queue or vector . queue vec_k = cla . empty ( queue , ( 3 , ) + self . kshape , self . cdtype , allocator = None ) plus = vec_k [ 0 ] minus = vec_k [ 1 ] outer_shape = vector . shape [ : - 4 ] from itertools import product slices = list ( product ( * [ range ( n ) for n in outer_shape ] ) ) result = np . zeros ( outer_shape + ( 2 , self . num_bins , ) , self . rdtype ) for s in slices : for mu in range ( 3 ) : self . fft . dft ( vector [ s ] [ mu ] , vec_k [ mu ] ) projector . vec_to_pol ( queue , plus , minus , vec_k ) result [ s ] [ 0 ] = self . bin_power ( plus , queue , k_power , allocator = allocator ) result [ s ] [ 1 ] = self . bin_power ( minus , queue , k_power , allocator = allocator ) return self . norm * result
Computes the power spectra of the plus and minus polarizations of a vector
field.
Computes the power spectra of the plus and minus polarizations of a vector field .
"""
        Computes the power spectra of the plus and minus polarizations of a vector
        field.

        :arg vector: The array containing the position-space vector field
            whose power spectrum is to be computed.
            If ``vector`` has more than four axes, all the outer axes are
            looped over.
            As an example, if ``vector`` has shape ``(2, 3, 3, 130, 130, 130)``
            (where the fourth-to-last axis is the vector-component axis),
            this method loops over the outermost two axes with shape ``(2, 3)``, and
            the resulting output data would have the shape ``(2, 3, 2, num_bins)``
            (where the second-to-last axis is the polarization axis).

        :arg projector: A :class:`Projector`.

        The remaining arguments are the same as those to :meth:`__call__`.

        :returns: A :class:`numpy.ndarray` containing the polarization spectra
            with shape ``vector.shape[:-4]+(2, num_bins)``.
        """ # overwrite vec_k

A :class:`numpy.ndarray` containing the polarization spectra
with shape ``vector.shape[:-4]+(2, num_bins)``.
A : class : ` numpy . ndarray ` containing the polarization spectra with shape ` ` vector . shape [ : - 4 ] + ( 2 num_bins ) ` ` .
self
vector
The array containing the position-space vector field
whose power spectrum is to be computed.
If ``vector`` has more than four axes, all the outer axes are
looped over.
As an example, if ``vector`` has shape ``(2, 3, 3, 130, 130, 130)``
(where the fourth-to-last axis is the vector-component axis),
this method loops over the outermost two axes with shape ``(2, 3)``, and
the resulting output data would have the shape ``(2, 3, 2, num_bins)``
(where the second-to-last axis is the polarization axis).
The array containing the position - space vector field whose power spectrum is to be computed . If ` ` vector ` ` has more than four axes all the outer axes are looped over . As an example if ` ` vector ` ` has shape ` ` ( 2 3 3 130 130 130 ) ` ` ( where the fourth - to - last axis is the vector - component axis ) this method loops over the outermost two axes with shape ` ` ( 2 3 ) ` ` and the resulting output data would have the shape ` ` ( 2 3 2 num_bins ) ` ` ( where the second - to - last axis is the polarization axis ) .
projector
A :class:`Projector`.
The remaining arguments are the same as those to :meth:`__call__`.
A : class : ` Projector ` . The remaining arguments are the same as those to : meth : ` __call__ ` .
queue
k_power
allocator