flip.covariance.generator
=========================

.. py:module:: flip.covariance.generator


Attributes
----------

.. autoapisummary::

   flip.covariance.generator.log
   flip.covariance.generator._avail_models
   flip.covariance.generator._avail_regularization_option


Functions
---------

.. autoapisummary::

   flip.covariance.generator.correlation_integration
   flip.covariance.generator.correlation_hankel
   flip.covariance.generator.coefficient_hankel
   flip.covariance.generator.coefficient_trapz
   flip.covariance.generator.regularize_M
   flip.covariance.generator.compute_coordinates
   flip.covariance.generator.compute_coeficient
   flip.covariance.generator.compute_cov
   flip.covariance.generator.get_redshift_dependent_model_flag
   flip.covariance.generator.generate_covariance


Module Contents
---------------

.. py:data:: log

.. py:data:: _avail_models
   :value: ['adamsblake17plane', 'adamsblake17', 'adamsblake20', 'lai22', 'carreres23', 'ravouxcarreres',...


.. py:data:: _avail_regularization_option
   :value: [None, 'mpmath', 'savgol', 'lowk_asymptote']


.. py:function:: correlation_integration(l, r, k, integrand)

   The correlation_integration function is used to calculate the correlation function for a given multipole.
   It does this by integrating over k, which is the magnitude of the wavevector. The integration is performed using
   the Simpson's rule (integrate.simps). This function takes in four arguments: l, r, k and integrand. l represents
   the multipole that we are calculating for; it can be 0 (monopole), 2 (quadrupole) or 4 (hexadecapole). r represents
   the radial distance at which we want to evaluate our correlation function at; it can be any value between 0 and 200 M

   :param l: Determine the order of the spherical bessel function
   :param r: Calculate the spherical bessel function
   :param k: Calculate the spherical bessel function
   :param integrand: Calculate the integrand of the correlation function

   :returns: The integral of the integrand


.. py:function:: correlation_hankel(l, r, k, integrand, hankel_overhead_coefficient=2, kmin=None)

   The correlation_hankel function is a wrapper for the cosmoprimo.fftlog.PowerToCorrelation function,
   which computes the correlation function from power spectrum using FFTLog (Hamilton 2000).
   The PowerToCorrelation class takes in an array of k values and an array of P(k) values, and returns
   an array of r values and an array of xi(r) values. The PowerToCorrelation class has two methods: set_fft_engine()
   and __call__(). The set_fft_engine() method sets which fft engine to use; it can be either &quot;n

   :param l: Determine the parity of the integrand, and therefore whether to add a 1j term
   :param r: Set the radius of the sphere
   :param k: Set the kmin and kmax values in the powertocorrelation function
   :param integrand: Pass the integrand to the correlation_hankel function
   :param hankel_overhead_coefficient: Determine the minimum r value for which to use the hankel transform

   :returns: The correlation function

   .. note:: If l is odd, count a 1j term in the integrand, without the need for adding it


.. py:function:: coefficient_hankel(model_name, covariance_type, term_index, lmax, wavenumber, power_spectrum, coord, additional_parameters_values=None, **kwargs)

   The coefficient_hankel function computes the covariance between two terms of a given model.
   The function takes as input:
       - The name of the model (e.g., adamsblake20, lai22, carreres23 or ravouxcarreres)
       - The type of term (i.e., either 'delta' or 'v')
       - The index i for the first term in question (i = 1 corresponds to delta_0 and v_0; i = 2 corresponds to delta_2 and v_2; etc.)
       - lmax: maximum multipole moment

   :param model_name: Call the dictionary_subterms function from the flip_terms file
   :param type: Determine which subterms to use
   :param term_index: Select the term in the dictionary_subterms
   :param lmax: Determine the number of terms in the sum
   :param wavenumber: Calculate the hankel transform
   :param power_spectrum: Calculate the correlation function
   :param coord: Pass the coordinates of the point where we want to evaluate
   :param additional_parameters_values: Pass the values of additional parameters to the functions that
   :param : Define the model name

   :returns: The covariance of the a-th and b-th terms


.. py:function:: coefficient_trapz(model_name, covariance_type, term_index, lmax, wavenumber, power_spectrum, coord, additional_parameters_values=None, **kwargs)

   The coefficient_trapz function computes the covariance matrix element for a given term.

   :param model_name: Call the dictionary_subterms function from the flip_terms file
   :param type: Distinguish between the different terms in the covariance matrix
   :param term_index: Specify which term of the model is being used
   :param lmax: Specify the maximum order of spherical harmonics
   :param wavenumber: Calculate the integrand
   :param power_spectrum: Multiply the integrand
   :param coord: Pass in the coordinates of the point at which we want to evaluate
   :param additional_parameters_values: Pass the values of the additional parameters
   :param : Determine the model to be used

   :returns: A matrix


.. py:function:: regularize_M(M_function, wavenumber, regularize_M_terms, covariance_type, flip_terms, additional_parameters_values, savgol_window=50, savgol_polynomial=3, lowk_unstable_threshold=0.1, lowk_unstable_mean_filtering=10, mpmmath_decimal_precision=50)

.. py:function:: compute_coordinates(covariance_type, coordinates_density=None, coordinates_velocity=None, redshift_dict=None, size_batch=10000, los_definition='bisector')

   The compute_coordinates function computes the spherical coordinates of all pairs of objects in a given catalog.

   :param covariance_type: Determine whether the covariance is a cross-covariance or an auto-covariance
   :param coordinates_density: Store the coordinates of the density field
   :param coordinates_velocity: Pass the coordinates of the velocity field
   :param size_batch: Control the size of the batches
   :param : Compute the angle separation between two objects

   :returns: A list of parameters


.. py:function:: compute_coeficient(parameters, model_name, covariance_type, power_spectrum_list, additional_parameters_values=None, number_worker=8, hankel=True, kmin=None)

   The compute_coeficient function computes the covariance matrix for a given model.

   :param parameters: Compute the covariance matrix for each parameter
   :param model_name: Select the model to be used
   :param covariance_type: Select the type of covariance we want to compute
   :param power_spectrum_list: Compute the power spectrum of each term in the covariance matrix
   :param additional_parameters_values: Pass the values of additional parameters, such as the redshift
   :param number_worker: Specify the number of cores to use for multiprocessing
   :param hankel: Choose between the trapezoidal rule and the hankel transform
   :param : Define the number of threads used to compute the covariance matrix

   :returns: A list of arrays


.. py:function:: compute_cov(model_name, covariance_type, power_spectrum_list, coordinates_density=None, coordinates_velocity=None, redshift_dict=None, additional_parameters_values=None, size_batch=10000, number_worker=8, hankel=True, los_definition='bisector', kmin=None)

   The compute_cov function computes the covariance matrix for a given model.

   :param model_name: Choose the model to be used
   :param covariance_type: Determine the type of covariance to be computed
   :param power_spectrum_list: Compute the power spectrum of the density field
   :param coordinates_density: Set the range of values for the density coordinates
   :param coordinates_velocity: Compute the velocity covariance
   :param additional_parameters_values: Pass the values of the additional parameters to be used in the model
   :param size_batch: Split the computation of the covariance matrix in smaller matrices
   :param number_worker: Specify the number of cores to be used
   :param hankel: Choose between the hankel transform or the fourier transform
   :param : Compute the covariance matrix for a given model

   :returns: The covariance matrix for a given model and set of parameters


.. py:function:: get_redshift_dependent_model_flag(model_name)

   The get_redshift_dependent_model_flag function returns a boolean indicating whether the model is redshift dependent or not.

   :param model_name: Determine which model to use


.. py:function:: generate_covariance(model_name, model_kind, power_spectrum_dict, coordinates_velocity=None, coordinates_density=None, additional_parameters_values=None, size_batch=10000, number_worker=8, hankel=True, los_definition='bisector', kmin=None)

   The generate_flip function computes the covariance matrix for a given model.

   :param model_name: Select the model to use
   :param model_kind: Determine the type of model to generate
   :param power_spectrum_dict: Store the power spectra of the different fields
   :param coordinates_velocity: Specify the coordinates of the velocity field
   :param coordinates_density: Specify the coordinates of the density field
   :param additional_parameters_values: Pass the values of the additional parameters to be used in the computation of covariance matrices
   :param size_batch: Split the computation of the covariance matrix into smaller batches
   :param number_worker: Specify the number of cores to use for computing the covariance matrix
   :param hankel: Decide whether to use the hankel transform or not
   :param : Define the number of workers to use for the computation

   :returns: A dictionary with the covariance matrices and their dimensions


