flip.covariance.symbolic
========================

.. py:module:: flip.covariance.symbolic


Attributes
----------

.. autoapisummary::

   flip.covariance.symbolic.log


Functions
---------

.. autoapisummary::

   flip.covariance.symbolic.simplify_term
   flip.covariance.symbolic.generate_MN_ab_i_l_function_wide_angle
   flip.covariance.symbolic.generate_MN_ab_i_l_function_parallel_plane
   flip.covariance.symbolic.write_output
   flip.covariance.symbolic.write_M_N_functions
   flip.covariance.symbolic.generate_generalized_adamsblake17plane_functions
   flip.covariance.symbolic.generate_generalized_adamsblake17_functions
   flip.covariance.symbolic.generate_generalized_adamsblake20_functions
   flip.covariance.symbolic.generate_generalized_lai22_functions
   flip.covariance.symbolic.generate_generalized_carreres23_functions
   flip.covariance.symbolic.generate_generalized_ravouxcarreres_functions
   flip.covariance.symbolic.generate_generalized_rcrk24_functions
   flip.covariance.symbolic.compute_partial_derivative_dictionnary
   flip.covariance.symbolic.write_partial_derivatives
   flip.covariance.symbolic.write_one_function
   flip.covariance.symbolic.generate_fisher_coefficients_dictionnary_carreres23
   flip.covariance.symbolic.generate_fisher_coefficients_dictionnary_adamsblake17
   flip.covariance.symbolic.generate_fisher_coefficients_dictionnary_adamsblake17plane
   flip.covariance.symbolic.generate_fisher_coefficients_dictionnary_full_nosigmag
   flip.covariance.symbolic.generate_fisher_coefficients_dictionnary_lai22
   flip.covariance.symbolic.generate_files
   flip.covariance.symbolic.generate_fisher_files


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

.. py:data:: log

.. py:function:: simplify_term(term, simplification_method='simplify_iteration', max_simplification=20)

   The simplify_term function takes a sympy expression and simplifies it.
   It does so by applying the TR8 function to the term, then checks if this is different from the original term.
   If it is, then it applies TR8 again to this new simplified term and compares that with the previous one.
   This process continues until either no further simplification can be achieved or max_simplification iterations have been reached.

   :param term: Pass the term to be simplified
   :param simplification_method: Choose between two different methods of simplification
   :param max_simplification: Limit the number of iterations
   :param : Set the method of simplification

   :returns: The simplified term


.. py:function:: generate_MN_ab_i_l_function_wide_angle(term_B, l, l1, l2)

   The generate_MN_ab_i_l_function_wide_angle function generates the M and N terms for a given l, l', and l'' value.

   :param term_B: Define the integrand of the integral over mu_2
   :param l: Determine the order of the legendre polynomial
   :param l1: Define the first legendre polynomial in the integral
   :param l2: Determine the order of the legendre polynomial in the second integral
   :param : Determine the number of terms in the sum

   :returns: The terms m_l,l',l'' and n_l, l', l''


.. py:function:: generate_MN_ab_i_l_function_parallel_plane(term_B, l)

   The generate_MN_ab_i_l_function_parallel_plane function takes in a term_B and an l value.
   It then generates the M_l and N_l functions for that particular term B, which is used to calculate the parallel plane integral.
   The function returns both M_l and N_l as sympy expressions.

   :param term_B: Define the term b in the equation for m_l and n_l
   :param l: Determine the order of the legendre polynomial

   :returns: A tuple of


.. py:function:: write_output(filename, type_list, term_index_list, lmax_list, output_pool, index_pool, wide_angle, additional_parameters=None, l1max_list=None, l2max_list=None, multi_index_model=False, redshift_dependent_model=False, regularize_M_terms='None')

   The write_output function takes the following arguments:
       filename (str): The name of the file to be written.
       type_list (list): A list of strings that are used as keys for each term in the model. For example, if you have a model with two terms, one called 'A' and one called 'B', then type_list = ['A','B'] would be appropriate.
       term_index_list (nested list): A nested list containing integers that correspond to each term in your model. For example, if you have a three-term model where terms 1 and 2 are both linear functions

   :param filename: Specify the name of the output file
   :param type_list: Specify the type of term
   :param term_index_list: Determine the order of the terms in
   :param lmax_list: Specify the maximum l value for each term
   :param output_pool: Store the output of the function
   :param index_pool: Store the index of each term in the output_pool
   :param wide_angle: Determine if the wide angle approximation should be used
   :param additional_parameters: Pass additional parameters to the functions
   :param l1max_list: Specify the maximum l value for the first index of a wide-angle term
   :param l2max_list: Specify the maximum l2 value for each term in the wide-angle case
   :param multi_index_model: Distinguish between the two models
   :param : Determine whether the model is a multi-index model or not

   :returns: A python file with the functions m_ab_i_l and n_ab_i


.. py:function:: write_M_N_functions(filename, type_list, term_index_list, lmax_list, dict_B, additional_parameters=None, number_worker=1, wide_angle=False, l1max_list=None, l2max_list=None, multi_index_model=False, redshift_dependent_model=False, regularize_M_terms='None')

   The write_M_N_functions function is used to generate the M_N functions for a given model.
   The function takes in the following arguments:
       filename (str): The name of the file that will be generated. This should end with .py, and should not include any path information. If no path information is included, then this file will be saved in your current working directory.

   :param filename: Specify the name of the file to which the output is written
   :param type_list: Specify the type of terms that are to be included in the calculation
   :param term_index_list: Specify the index of each term in a given type
   :param lmax_list: Determine the maximum value of l for each term in the model
   :param dict_B: Store the b_ab_i values
   :param additional_parameters: Add additional parameters to the output file
   :param number_worker: Specify the number of processes to be used
   :param wide_angle: Determine if the function should be written for wide angle or not
   :param l1max_list: Define the maximum value of l_i in the wide angle approximation
   :param l2max_list: Specify the maximum l2 value for each term in the model
   :param multi_index_model: Tell the function whether to use a multi-index model or not
   :param : Write the output to a file

   :returns: The output_pool and index_pool


.. py:function:: generate_generalized_adamsblake17plane_functions(filename='./adamsblake17plane/flip_terms.py', number_worker=8)

.. py:function:: generate_generalized_adamsblake17_functions(filename='./adamsblake17/flip_terms.py', number_worker=8)

.. py:function:: generate_generalized_adamsblake20_functions(filename='./adamsblake20/flip_terms.py', number_worker=8)

   The generate_generalized_adamsblake20_functions function generates the functions needed to compute the M and N matrices for a generalized version of Adams, Blake &amp; Kitching (2020).

   :param filename: Specify the name of the file where the functions will be written
   :param number_worker: Parallelize the computation of the m and n functions

   :returns: A dictionary of functions


.. py:function:: generate_generalized_lai22_functions(filename='./lai22/flip_terms.py', number_worker=8)

   The generate_generalized_lai22_functions function generates the functions for calculating the M and N terms in
   the generalized Lai22 model. The function is called by running:

   :param filename: Specify the name of the file where all functions will be written
   :param number_worker: Determine the number of processes that will be used to generate the functions

   :returns: A set of functions that are used in the calculation of the scattering matrix


.. py:function:: generate_generalized_carreres23_functions(filename='./carreres23/flip_terms.py', number_worker=8)

   The generate_generalized_carreres23_functions function generates the flip_terms.py file in the carreres23 directory, which contains functions that calculate M and N terms for a generalized version of Carreres' (2012) model 2 and 3.

   :param filename: Specify the name of the file that will be generated
   :param number_worker: Determine the number of processes to use for multiprocessing

   :returns: A list of functions,


.. py:function:: generate_generalized_ravouxcarreres_functions(filename='./ravouxcarreres/flip_terms.py', number_worker=8)

   The generate_generalized_ravouxcarreres_functions function generates the functions needed to compute the generalized Ravoux-Carreres model.

   :param filename: Specify the name of the file where you want to write your functions
   :param number_worker: Specify the number of cores to use for multiprocessing

   :returns: A dictionary of functions


.. py:function:: generate_generalized_rcrk24_functions(filename='./rcrk24/flip_terms.py', number_worker=8)

   The generate_generalized_rcrk24_functions function generates the flip_terms.py file in the carreres23 directory, which contains functions that calculate M and N terms for a generalized version of Carreres' (2012) model 2 and 3.

   :param filename: Specify the name of the file that will be generated
   :param number_worker: Determine the number of processes to use for multiprocessing

   :returns: A list of functions,


.. py:function:: compute_partial_derivative_dictionnary(name_models, components, parameter_models, all_parameters, coefficient_models)

   The compute_partial_derivatiove_dictionnary function computes the partial derivatives of each component of the model with respect to each parameter.
   The output is a list containing dictionnaries, one for each model. Each dictionnary contains as keys all parameters and as values another dictionnary which contains as keys all components and as values lists containing the partial derivatives.

   :param name_models: Name the models
   :param parameter_models: Get the parameters of each model
   :param components: Create the keys of the dictionnaries in compute_partial_derivatiove_dictionnary
   :param coefficient_models: Compute the partial derivatives of each component with respect to each parameter
   :param : Create the keys of the dictionnaries in compute_partial_derivatiove_dictionnary

   :returns: A list containing dictionnaries, one for each model

   Doc Author:
       Trelent


.. py:function:: write_partial_derivatives(filename, name_models, components, parameter_models, all_parameters, coefficient_models)

.. py:function:: write_one_function(f, name_models, components, parameter_models, partial_derivative_dictionnary_list)

.. py:function:: generate_fisher_coefficients_dictionnary_carreres23(filename='./carreres23/fisher_terms.py')

.. py:function:: generate_fisher_coefficients_dictionnary_adamsblake17(filename='./adamsblake17/fisher_terms.py')

.. py:function:: generate_fisher_coefficients_dictionnary_adamsblake17plane(filename='./adamsblake17plane/fisher_terms.py')

.. py:function:: generate_fisher_coefficients_dictionnary_full_nosigmag(filename)

.. py:function:: generate_fisher_coefficients_dictionnary_lai22(filename='./lai22/fisher_terms.py')

.. py:function:: generate_files()

   The generate_files function generates the following files:
       - generalized_carreres23.py
       - generalized_adamsblake20.py
       - generalized_lai22.py
       - generalized_ravouxcarreres.py

   Args:

   :returns: A list of all the functions that have been generated


.. py:function:: generate_fisher_files()

