tjpcov.covariance_fourier_gaussian_nmt#

Module Contents#

Classes#

FourierGaussianNmt

Class to compute the Gaussian CellxCell covariance with NaMaster.

class tjpcov.covariance_fourier_gaussian_nmt.FourierGaussianNmt(config)[source]#

Bases: tjpcov.covariance_builder.CovarianceFourier

Class to compute the Gaussian CellxCell covariance with NaMaster.

This class uses the Narrow Kernel Approximation. It can also use the Toeplitz approximation.

Initialize the 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.

cov_type = 'gauss'[source]#
_compute_all_blocks(**kwargs)[source]#

Compute all the independent covariance blocks.

Parameters:

**kwargs – The arguments to pass to get_covariance_block. See its documentation.

Returns:

List of all the independent covariance blocks.

Return type:

list

get_cl_for_cov(clab, nlab, ma, mb, w, nl_is_cp)[source]#

Computes the coupled Cell that goes into the covariance matrix.

Parameters:
  • clab (array) – Fiducial Cell for the tracers a and b, used in the covariance estimation

  • nlab (array) – Coupled noise for the tracers a and b

  • ma (array) – Mask of the field a

  • mb (array) – Mask of the field b

  • w (pymaster.workspaces.NmtWorkspace) – NmtWorkspace of the

  • nl_is_cp (fields a and b) – True if nlab is coupled. False

  • otherwise.

Returns:

Coupled Cell with signal and noise

Return type:

array

get_covariance_block(tracer_comb1, tracer_comb2, use_coupled_noise=True, coupled=False, cache=None, clobber=False)[source]#

Compute a single covariance matrix for a given pair of C_ell.

If outdir is set, it will save the covariance to a file called cov_tr1_tr2_tr3_tr4.npz. This file will be read and its output returned if found.

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

  • use_coupled_noise (bool, optional) – If True, use the coupled noise. Note that if noise is provided via the cache arg, this will be used and assumed to be coupled if this option is True. Defaults to True.

  • coupled (bool, optional) – True to return the coupled Gaussian covariance (default False)

  • cache (dict) – Dictionary with the corresponding noise, masks, fields, workspaces and covariance workspaces. It accepts noise (keys: ‘SN13’, ‘SN23’, ‘SN14’, ‘SN24’), masks (keys: ‘m1’, ‘m2’, ‘m3’, ‘m4’), fields (keys: ‘f1’, ‘f2’, ‘f3’, ‘f4’), workspaces (keys: ‘w13’, ‘w23’, ‘w14’, ‘w24’, ‘w12’, ‘w34’), the covariance workspace (key: ‘cw’) and a NmtBin (key: ‘bins’).

  • clobber (bool, optional) – True to recalculate covariance and overwrite cached covariance (default False). Note this does not erase the cache, or ignore the provided cache.

Returns:

Gaussian covariance matrix for a pair of C_ell.

Return type:

array

get_covariance_workspace(f1, f2, f3, f4, m1, m2, m3, m4, **kwargs)[source]#

Return the covariance workspace of the fields f1, f2, f3, f4.

Parameters:
  • f1 (pymaster.field.NmtField) – Field 1

  • f2 (pymaster.field.NmtField) – Field 2

  • f3 (pymaster.field.NmtField) – Field 3

  • f4 (pymaster.field.NmtField) – Field 4

  • m1 (str) – Mask name assotiated to the field 1

  • m2 (str) – Mask name assotiated to the field 2

  • m3 (str) – Mask name assotiated to the field 3

  • m4 (str) – Mask name assotiated to the field 4

  • **kwargs – Extra arguments to pass to pymaster.compute_coupling_coefficients. In addition, if recompute=True is passed, the cw will be recomputed even if found in the disk.

Returns:

Covariance Workspace of the fields f1, f2, f3, f4

Return type:

pymaster.covariance.NmtCovarianceWorkspace

get_fields_dict(tracer_names, cache=None, masks=None, **kwargs)[source]#

Return a dictionary with the fields 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) – Dictionary with cached variables. It will use the cached field if found. The keys must be ‘f1’, ‘f2’, ‘f3’ or ‘f4’ and the values the corresponding NmtFields.

  • masks (dict) – Dictionary of the masks of the fields correlated with keys 1, 2, 3 or 4 and values the loaded masks.

  • **kwargs – Arguments to pass to NaMaster when computing the field. They will override the ones passed in the configuration file through nmt_conf[‘f’].

Returns:

Dictionary with the masks assotiated to the fields to be correlated.

Return type:

dict

get_list_of_tracers_for_wsp()[source]#

Return the tracers needed to compute the independent workspaces.

Returns:

List of tracers needed to compute the independent workspaces.

Return type:

list of str

get_list_of_tracers_for_cov_wsp(remove_trs_wsp=False)[source]#

Return the tracers to compute the independent covariance workspaces.

Parameters:

remove_trs_wsp (bool, optional) – If True, remove the tracer combinations from used to generate the workspaces independently (i.e the output of get_list_of_tracers_for_wsp). Defaults to False.

Returns:

List of tracers needed to compute the independent covariance workspaces.

Return type:

list of str

get_list_of_tracers_for_cov_without_trs_wsp_cwsp()[source]#

Return the remaining covariance tracers combinations.

It will remove the tracer combinations used to compute the workspaces and covariance workspaces.

Returns:

List of independent tracers combinations.

Return type:

list of str

get_nell(bins=None, nside=None, cache=None)[source]#

Return the number of ells for the fiducial Cells.

If the sacc file stored bandpowers are wrong. You will need to pass one of the other arguments.

Parameters:
  • bins (pymaster.NmtBin) – NmtBin instance with the desired binning.

  • nside (int) – Healpy map nside.

  • cache (dict) – Dictionary with cached variables. It will use the cached workspaces to read the bandpower windows.

Returns:

Number of ells for the fidicual Cells points; i.e. lmax or 3*nside

Return type:

int

get_workspace(f1, f2, m1, m2, bins, **kwargs)[source]#

Return the workspace of the fields f1, f2.

Parameters:
  • f1 (pymaster.field.NmtField) – Field 1

  • f2 (pymaster.field.NmtField) – Field 2

  • m1 (str) – Mask name assotiated to the field 1

  • m2 (str) – Mask name assotiated to the field 2

  • bins (pymaster.bins.NmtBin) – NmtBin instance

  • mask_names (dict) – Dictionary with tracer names as key and maks names as values.

  • **kwargs – Extra arguments to pass to w.compute_coupling_matrix. In addition, if recompute=True is passed, the cw will be recomputed even if found in the disk.

Returns:

Covariance Workspace of the fields f1, f2, f3, f4

Return type:

pymaster.covariance.NmtCovarianceWorkspace

get_workspaces_dict(tracer_names, bins, cache=None, fields=None, masks=None, **kwargs)[source]#

Return a dictionary with the workspaces for the given tracers.

Parameters:
  • tracer_names (dict) – Dictionary of the masks names assotiated to the fields to be correlated. 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>.

  • bins (pymaster.bins.NmtBin) – NmtBin instance with the

  • binning. (desired) –

  • cache (dict) – Dictionary with cached variables. It will use the cached field if found. The keys must be ‘w12’, ‘w34’, ‘w13’, ‘w23’, ‘w14’ or ‘w24’ and the values the corresponding NmtWorkspaces. Alternatively, you can pass a dictionary with keys as (mask_name1, mask_name2).

  • field (dict) – Dictionary of the NmtFields of the fields correlated with keys 1, 2, 3 or 4 and values the NmtFields. masks (dict): Dictionary of the masks of the fields correlated with keys 1, 2, 3 or 4 and values the loaded masks.

  • **kwargs – Arguments to pass to NaMaster when computing the workspace. They will override the ones passed in the configuration file through nmt_conf[‘w’].

Returns:

Dictionary with the workspaces assotiated to the different field combinations needed for the covariance. Its keys are 13, 23, 14, 24, 12, 34; with values the corresponding pymaster.workspaces.NmtWorkspaces.

Return type:

dict