tjpcov.covariance_builder
#
Module Contents#
Classes#
Base class in charge of building the full covariance. |
|
Parent class for Cell x Cell covariances in Fourier space. |
|
Parent class for xi x xi covariances in Real space. |
|
Parent class for xi x xi covariances in Real space. |
- class tjpcov.covariance_builder.CovarianceBuilder(config)[source]#
Bases:
abc.ABC
Base class in charge of building the full covariance.
Class in charge of building the full covariance needed for the sacc file from individual covariance blocks. This is meant to be used as a parent class and the child classes would actually implement the actual computation of the blocks.
Init the base class with a config file or dictionary.
- Parameters:
config (dict or str) – If dict, it returns the configuration dictionary directly. If string, it asumes a YAML file and parses it.
- property covariance_block_data_type: str[source]#
The covariance block data type for your builder.
- Returns:
Covariance block sacc data type
- Return type:
- property _tracer_types[source]#
Tuple with the tracer types (e.g. (“cl”, “cl”)).
This is used to decide if the block covariance should be computed or is zero. For instance, if the class is meant to produce the covariance for Cells and the tracer types are clusters, the class should return 0.
- _split_tasks_by_rank(tasks)[source]#
Yield the tasks corresponding to the given process.
Iterate through a list of items, yielding the ones this process is responsible for. The tasks are allocated in a round-robin way.
- Parameters:
tasks (iterable) – Tasks to split up
- Returns:
Tasks associated to this process
- Return type:
generator
- _compute_all_blocks(**kwargs)[source]#
Compute all the independent covariance blocks.
- Parameters:
**kwargs – Arguments to pass to the get_covariance_block method. These will depend on the covariance type requested.
- Returns:
blocks (list): List of all the independent super sample covariance blocks.
tracer_blocks (list): List of all tracer combinations in order as the blocks.
- Return type:
- get_cosmology()[source]#
Return a CCL Cosmology instance.
The Cosmology is generated with the information passed in the configuration file in the “cosmo” section of “tjpcov”. This can be a file path to a yaml, pickle object or “set” to read the parameters from the “parameters” section.
- Returns:
pyccl.Cosmology
instance
- abstract get_covariance_block(tracer_comb1, tracer_comb2, **kwargs)[source]#
Return the covariance block for the two pair of tracers.
This is what you would get from an external code and could contain data types not present in the sacc file. For Fourier space covariances, we assume the same order as in NaMaster.
- abstract _get_covariance_block_for_sacc(tracer_comb1, tracer_comb2, **kwargs)[source]#
Return the covariance block as needed for the sacc file.
For instance, if the sacc file does not contain B-modes, the covariance block would only have the EE-EE component). Furthermore, the ordering must be the same as in the sacc file.
- get_covariance_block_for_sacc(tracer_comb1, tracer_comb2, **kwargs)[source]#
Return the covariance block as needed for the sacc file.
For instance, if the sacc file does not contain B-modes, the covariance block would only have the EE-EE component). Furthermore, the ordering must be the same as in the sacc file.
This function returns 0 if the covariance class is not meant to produce covariances for the given tracer combination.
- get_covariance(**kwargs)[source]#
Return the full covariance.
- Parameters:
**kwargs – Arguments to pass to _compute_all_blocks.
- Returns:
Full covariance
- Return type:
array
- get_mask_names_dict(tracer_names)[source]#
Return a dictionary with the mask names for the given tracers.
- Parameters:
tracer_names (dict) – Dictionary of the tracer names of the same form as mask_name. It has to be given as {1: name1, 2: name2, 3: name3, 4: name4}, where 12 and 34 are the pair of tracers that go into the first and second Cell you are computing the covariance for; i.e. <Cell^12 Cell^34>.
- Returns:
Dictionary with the mask names assotiated to the fields to be correlated.
- Return type:
- get_masks_dict(tracer_names, cache=None)[source]#
Return a dictionary with the masks assotiated to the given tracers.
- Parameters:
tracer_names (dict) – Dictionary of the tracer names of the same form as mask_name. It has to be given as {1: name1, 2: name2, 3: name3, 4: name4}, where 12 and 34 are the pair of tracers that go into the first and second Cell you are computing the covariance for; i.e. <Cell^12 Cell^34>.
cache (dict, optional) – Dictionary with cached variables. It will use the cached masks if found. The keys must be ‘m1’, ‘m2’, ‘m3’ or ‘m4’ and the values the loaded maps.
- Returns:
Dictionary with the masks assotiated to the fields to be correlated.
- Return type:
- get_nbpw()[source]#
Return the number of bandpowers in which the data has been binned.
- Returns:
Number of bandpowers; i.e. ell_effective.size
- Return type:
- get_tracers_spin_dict(tracer_names)[source]#
Return a dictionary with the spins assotiated to the given tracers.
- Parameters:
tracer_names (dict) – Dictionary of the tracer names of the same form as mask_name. It has to be given as {1: name1, 2: name2, 3: name3, 4: name4}, where 12 and 34 are the pair of tracers that go into the first and second Cell you are computing the covariance for; i.e. <Cell^12 Cell^34>.
- Returns:
Dictionary with the spins assotiated to the fields to be correlated.
- Return type:
- class tjpcov.covariance_builder.CovarianceFourier(config)[source]#
Bases:
CovarianceBuilder
Parent class for Cell x Cell covariances in Fourier space.
This has all the methods common to all the Fourier covariance calculations. The child classes will actually implement the actual computation of the blocks.
Init the base class with a config file or dictionary.
- Parameters:
config (dict or str) – If dict, it returns the configuration dictionary directly. If string, it asumes a YAML file and parses it.
- _get_covariance_block_for_sacc(tracer_comb1, tracer_comb2, **kwargs)[source]#
Return the covariance block as needed for the sacc file.
For instance, if the sacc file does not contain B-modes, the covariance block would only have the EE-EE component). Furthermore, the ordering must be the same as in the sacc file.
- Parameters:
1 (tracer_comb) – List of the pair of tracer names of C_ell^1
2 (tracer_comb) – List of the pair of tracer names of C_ell^2
**kwargs – Arguments accepted by get_covariance_block
- Returns:
Covariance matrix for a pair of C_ell for the data types considered in the sacc file.
- Return type:
array
- get_datatypes_from_ncell(ncell)[source]#
Return the datatypes (e.g cl_00) for a the number of cells.
- get_ell_eff()[source]#
Return the effective ell in the sacc file.
It assume that all of them have the same effective ell (true with current TXPipe implementation).
- Parameters:
sacc_data (
sacc.sacc.Sacc
) – Data Sacc instance- Returns:
Array with the effective ell in the sacc file.
- Return type:
array
- get_sacc_with_concise_dtypes()[source]#
Return a copy of the sacc file with concise data types.
- Returns:
Data Sacc instance with concise data types
- Return type:
- get_tracer_comb_ncell(tracer_comb, independent=False)[source]#
Return the number of Cell for a pair of tracers.
For instance, for shear-shear, ncell = 4: EE, EB, BE, BB.
- get_tracer_info(return_noise_coupled=False)[source]#
Returns CCL tracer objects and the noise for all the tracers.
This is done based on the specifications given in the configuration file.
- Parameters:
return_noise_coupled (bool, optional) – If True, also return tracers_Noise_coupled. Default False.
- Returns:
ccl_tracers (
pyccl.tracers.Tracer
): CCL tracers used to compute the theory vectortracer_Noise (
dict
): shot (shape) noise for lens (sources) tracerstracer_Noise_coupled (
dict
): coupled shot (shape) noise for lens (sources). Returned if retrun_noise_coupled is True.
- Return type:
- class tjpcov.covariance_builder.CovarianceReal(config)[source]#
Bases:
CovarianceBuilder
Parent class for xi x xi covariances in Real space.
This has all the methods common to all the Real covariance calculations. The child classes will actually implement the actual computation of the blocks.
Init the base class with a config file or dictionary.
- Parameters:
config (dict or str) – If dict, it returns the configuration dictionary directly. If string, it asumes a YAML file and parses it.
- get_theta_eff()[source]#
Return the effective theta in the sacc file.
It assume that all of them have the same effective theta (true with current TXPipe implementation).
- Parameters:
sacc_data (
sacc.sacc.Sacc
) – Data Sacc instance- Returns:
Array with the effective theta in the sacc file.
- Return type:
array
- class tjpcov.covariance_builder.CovarianceProjectedReal(config)[source]#
Bases:
CovarianceReal
Parent class for xi x xi covariances in Real space.
This has all the methods common to all the Real covariance calculations that are computed by projecting the Fourier space ones. The child classes will only have to call a CovarianceFourier child to get the covariance in Fourier space.
Init the base class with a config file or dictionary.
- Parameters:
config (dict or str) – If dict, it returns the configuration dictionary directly. If string, it asumes a YAML file and parses it.
- get_binning_info(binning='log', in_radians=True)[source]#
Get the theta for bins given the sacc object.
- get_cov_WT_spin(tracer_comb)[source]#
Get the Wigner transform factors.
- Parameters:
tracer_comb (list of two str) – tracer combination in sacc format
- Returns:
WT_factors
- get_Wigner_transform()[source]#
Return an instance of the wigner_transform class.
- Returns:
WignerTransform
instance
- get_covariance_block(tracer_comb1, tracer_comb2, xi_plus_minus1='plus', xi_plus_minus2='plus', binned=True)[source]#
Compute a single covariance matrix for a given pair of xi.
- Parameters:
tracer_comb1 (list) – List of the pair of tracer names of C_ell^1
tracer_comb2 (list) – List of the pair of tracer names of C_ell^2
xi_plus_minus1 (str) – ‘plus’ if one wants the covariance for the xi+ component or ‘minus’ for the xi-. This is ignored if tracer_comb1 is not a spin 2 (e.g. shear) field.
xi_plus_minus2 (str) – As xi_plus_minus1 for tracer_comb2.
- Returns:
Covariance matrix
- Return type:
array