pystella/fourier/rayleigh.py
def generate(self, queue, random=True, field_ps=lambda kmag: 1/2/kmag,
                 norm=1, window=lambda kmag: 1.):
        """
        Generate a 3-D array of Fourier modes with a given power spectrum and
        random phases.

        :arg queue: A :class:`pyopencl.CommandQueue`.

        :arg random: Whether to randomly sample the Rayleigh distribution
            of mode amplitudes.
            Defaults to *True*.

        :arg field_ps: A :class:`~collections.abc.Callable` returning the desired
            power spectrum of the field as a function of momentum ``kmag``.
            Defaults to the Bunch-Davies vacuum,
            ``lambda kmag: 1/2/kmag``.

        :arg norm: A constant normalization factor by which to multiply all
            power spectra.
            Defaults to ``1``.

        :arg window: A :class:`~collections.abc.Callable` window function
            filtering initial mode amplitudes.
            Defaults to ``lambda kmag: 1``, i.e., no filter.

        :returns: An :class:`numpy.ndarray` containing the generated Fourier modes
            of the field.
        """

        amplitude_sq = norm / self.volume

        rands = self.rng.uniform(queue, (2,)+self.kmags.shape, self.rdtype)
        if not random:
            rands[0] = np.exp(-1)

        f_power = (amplitude_sq * window(self.kmags)**2
                   * self._ps_wrapper(field_ps, self.kmags, self.kmags))

        evt, (fk,) = self.non_wkb_knl(queue, rands=rands, f_power=f_power,
                                      out_host=True)

        return self._post_process(fk)

        Generate a 3-D array of Fourier modes with a given power spectrum and
        random phases.

        :arg queue: A :class:`pyopencl.CommandQueue`.

        :arg random: Whether to randomly sample the Rayleigh distribution
            of mode amplitudes.
            Defaults to *True*.

        :arg field_ps: A :class:`~collections.abc.Callable` returning the desired
            power spectrum of the field as a function of momentum ``kmag``.
            Defaults to the Bunch-Davies vacuum,
            ``lambda kmag: 1/2/kmag``.

        :arg norm: A constant normalization factor by which to multiply all
            power spectra.
            Defaults to ``1``.

        :arg window: A :class:`~collections.abc.Callable` window function
            filtering initial mode amplitudes.
            Defaults to ``lambda kmag: 1``, i.e., no filter.

        :returns: An :class:`numpy.ndarray` containing the generated Fourier modes
            of the field.
        
Generate a 3-D array of Fourier modes with a given power spectrum and
random phases.
Generate a 3 - D array of Fourier modes with a given power spectrum and random phases .
def generate(self, queue, random=True, field_ps=lambda kmag: 1/2/kmag,
                 norm=1, window=lambda kmag: 1.):
        amplitude_sq = norm / self.volume
        rands = self.rng.uniform(queue, (2,)+self.kmags.shape, self.rdtype)
        if not random:
            rands[0] = np.exp(-1)
        f_power = (amplitude_sq * window(self.kmags)**2
                   * self._ps_wrapper(field_ps, self.kmags, self.kmags))
        evt, (fk,) = self.non_wkb_knl(queue, rands=rands, f_power=f_power,
                                      out_host=True)
        return self._post_process(fk)
def generate ( self , queue , random = True , field_ps = lambda kmag : 1 / 2 / kmag , norm = 1 , window = lambda kmag : 1. ) : amplitude_sq = norm / self . volume rands = self . rng . uniform ( queue , ( 2 , ) + self . kmags . shape , self . rdtype ) if not random : rands [ 0 ] = np . exp ( - 1 ) f_power = ( amplitude_sq * window ( self . kmags ) ** 2 * self . _ps_wrapper ( field_ps , self . kmags , self . kmags ) ) evt , ( fk , ) = self . non_wkb_knl ( queue , rands = rands , f_power = f_power , out_host = True ) return self . _post_process ( fk )
Generate a 3-D array of Fourier modes with a given power spectrum and
random phases.
Generate a 3 - D array of Fourier modes with a given power spectrum and random phases .
"""
        Generate a 3-D array of Fourier modes with a given power spectrum and
        random phases.

        :arg queue: A :class:`pyopencl.CommandQueue`.

        :arg random: Whether to randomly sample the Rayleigh distribution
            of mode amplitudes.
            Defaults to *True*.

        :arg field_ps: A :class:`~collections.abc.Callable` returning the desired
            power spectrum of the field as a function of momentum ``kmag``.
            Defaults to the Bunch-Davies vacuum,
            ``lambda kmag: 1/2/kmag``.

        :arg norm: A constant normalization factor by which to multiply all
            power spectra.
            Defaults to ``1``.

        :arg window: A :class:`~collections.abc.Callable` window function
            filtering initial mode amplitudes.
            Defaults to ``lambda kmag: 1``, i.e., no filter.

        :returns: An :class:`numpy.ndarray` containing the generated Fourier modes
            of the field.
        """
An :class:`numpy.ndarray` containing the generated Fourier modes
of the field.
An : class : ` numpy . ndarray ` containing the generated Fourier modes of the field .
self
queue
None
random
Whether to randomly sample the Rayleigh distribution
of mode amplitudes.
Defaults to *True*.
Whether to randomly sample the Rayleigh distribution of mode amplitudes . Defaults to * True * .
field_ps
A :class:`~collections.abc.Callable` returning the desired
power spectrum of the field as a function of momentum ``kmag``.
Defaults to the Bunch-Davies vacuum,
``lambda kmag: 1/2/kmag``.
A : class : ` ~collections . abc . Callable ` returning the desired power spectrum of the field as a function of momentum ` ` kmag ` ` . Defaults to the Bunch - Davies vacuum ` ` lambda kmag : 1 / 2 / kmag ` ` .
norm
A constant normalization factor by which to multiply all
power spectra.
A constant normalization factor by which to multiply all power spectra .
window
A :class:`~collections.abc.Callable` window function
filtering initial mode amplitudes.
Defaults to ``lambda kmag: 1``, i.e., no filter.
A : class : ` ~collections . abc . Callable ` window function filtering initial mode amplitudes . Defaults to ` ` lambda kmag : 1 ` ` i . e . no filter .