flip.covariance.generator#

Attributes#

Functions#

correlation_integration(l, r, k, integrand)

The correlation_integration function is used to calculate the correlation function for a given multipole.

correlation_hankel(l, r, k, integrand[, ...])

The correlation_hankel function is a wrapper for the cosmoprimo.fftlog.PowerToCorrelation function,

coefficient_hankel(model_name, covariance_type, ...[, ...])

The coefficient_hankel function computes the covariance between two terms of a given model.

coefficient_trapz(model_name, covariance_type, ...[, ...])

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

regularize_M(M_function, wavenumber, ...[, ...])

compute_coordinates(covariance_type[, ...])

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

compute_coeficient(parameters, model_name, ...[, ...])

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

compute_cov(model_name, covariance_type, ...[, ...])

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

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.

generate_covariance(model_name, model_kind, ...[, ...])

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

Module Contents#

flip.covariance.generator.log#
flip.covariance.generator._avail_models = ['adamsblake17plane', 'adamsblake17', 'adamsblake20', 'lai22', 'carreres23', 'ravouxcarreres',...#
flip.covariance.generator._avail_regularization_option = [None, 'mpmath', 'savgol', 'lowk_asymptote']#
flip.covariance.generator.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

Parameters:
  • l – Determine the order of the spherical bessel function

  • r – Calculate the spherical bessel function

  • k – Calculate the spherical bessel function

  • integrand – Calculate the integrand of the correlation function

Returns:

The integral of the integrand

flip.covariance.generator.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 "n

Parameters:
  • l – Determine the parity of the integrand, and therefore whether to add a 1j term

  • r – Set the radius of the sphere

  • k – Set the kmin and kmax values in the powertocorrelation function

  • integrand – Pass the integrand to the correlation_hankel function

  • 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

flip.covariance.generator.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

Parameters:
  • model_name – Call the dictionary_subterms function from the flip_terms file

  • type – Determine which subterms to use

  • term_index – Select the term in the dictionary_subterms

  • lmax – Determine the number of terms in the sum

  • wavenumber – Calculate the hankel transform

  • power_spectrum – Calculate the correlation function

  • coord – Pass the coordinates of the point where we want to evaluate

  • 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

flip.covariance.generator.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.

Parameters:
  • model_name – Call the dictionary_subterms function from the flip_terms file

  • type – Distinguish between the different terms in the covariance matrix

  • term_index – Specify which term of the model is being used

  • lmax – Specify the maximum order of spherical harmonics

  • wavenumber – Calculate the integrand

  • power_spectrum – Multiply the integrand

  • coord – Pass in the coordinates of the point at which we want to evaluate

  • additional_parameters_values – Pass the values of the additional parameters

:param : Determine the model to be used

Returns:

A matrix

flip.covariance.generator.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)#
flip.covariance.generator.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.

Parameters:
  • covariance_type – Determine whether the covariance is a cross-covariance or an auto-covariance

  • coordinates_density – Store the coordinates of the density field

  • coordinates_velocity – Pass the coordinates of the velocity field

  • size_batch – Control the size of the batches

:param : Compute the angle separation between two objects

Returns:

A list of parameters

flip.covariance.generator.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.

Parameters:
  • parameters – Compute the covariance matrix for each parameter

  • model_name – Select the model to be used

  • covariance_type – Select the type of covariance we want to compute

  • power_spectrum_list – Compute the power spectrum of each term in the covariance matrix

  • additional_parameters_values – Pass the values of additional parameters, such as the redshift

  • number_worker – Specify the number of cores to use for multiprocessing

  • 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

flip.covariance.generator.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.

Parameters:
  • model_name – Choose the model to be used

  • covariance_type – Determine the type of covariance to be computed

  • power_spectrum_list – Compute the power spectrum of the density field

  • coordinates_density – Set the range of values for the density coordinates

  • coordinates_velocity – Compute the velocity covariance

  • additional_parameters_values – Pass the values of the additional parameters to be used in the model

  • size_batch – Split the computation of the covariance matrix in smaller matrices

  • number_worker – Specify the number of cores to be used

  • 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

flip.covariance.generator.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.

Parameters:

model_name – Determine which model to use

flip.covariance.generator.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.

Parameters:
  • model_name – Select the model to use

  • model_kind – Determine the type of model to generate

  • power_spectrum_dict – Store the power spectra of the different fields

  • coordinates_velocity – Specify the coordinates of the velocity field

  • coordinates_density – Specify the coordinates of the density field

  • additional_parameters_values – Pass the values of the additional parameters to be used in the computation of covariance matrices

  • size_batch – Split the computation of the covariance matrix into smaller batches

  • number_worker – Specify the number of cores to use for computing the covariance matrix

  • 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