API References

Conceal Data Vector (smokescreen.datavector)

The smokescreen.datavector module provides functionalities to conceal data vectors in the context of cosmological analysis.

Conceal Data Vector Class

class smokescreen.datavector.ConcealDataVector(cosmo, systm_dict, likelihood, shifts_dict, sacc_data, seed='2112', **kwargs)

Class for calling a smokescreen on the measured data-vector.

FIXME: Only cosmological parameters are supported for now for the shifts

Parameters:
  • cosmo (pyccl.Cosmology) – Cosmology object from CCL with a fiducial cosmology.

  • systm_dict (dict) – Dictionary of systematics names and corresponding fiducial values.

  • likelihood (str or module) – path to the likelihood or a module containing the likelihood must contain both build_likelihood and compute_theory_vector methods

  • shifts_dict (dict) – Dictionary of parameter names and corresponding shift widths. If the shifts are single values, the dictionary values should be the shift widths. If the shifts are tuples of values, the dictionary values should be the (lower, upper) bounds of the shift widths.

  • sacc_data (sacc.sacc.Sacc) – Data-vector to be concealed (blinded). If None, the data-vector will be loaded from the likelihood.

  • seed (int or str) – Random seed.

Keyword Arguments:
  • shift_type (str) – Type of shift to be applied. Default is “flat”. FIXME: Only flat shifts are implemented for now.

  • debug (bool) – If True, prints debug information. Default is False.

apply_concealing_to_likelihood_datavec()

Applies the concealing (blinding) factor to the data-vector.

calculate_concealing_factor(factor_type='add')
Calculates the concealing (blinding) factor for the data-vector,

according to Muir et al. 2019:

Parameters:

factor_type (str) – Type of concealing (blinding) factor to be calculated. Default is add.

Returns:

.__concealing_factor – Concealing factor.

Return type:

np.ndarray

Notes

type=”add”:
\[f^{\rm add} = d(\theta_{\rm blind}) - d(\theta_{\rm fid})\]
type=”mult”:
\[f^{\rm mult} = d(\theta_{\rm blind}) / d(\theta_{\rm fid})\]
save_concealed_datavector(path_to_save, file_root, return_sacc=False)

Saves the concealed (blinded) data-vector to a file.

Saves the blinded data-vector to a file with the name: {path_to_save}/{file_root}_blinded_data_vector.fits

Parameters:
  • path_to_save (str) – Path to save the blinded data-vector.

  • file_root (str) – Root of the file name.

  • return_sacc (bool) – If True, returns the sacc object with the blinded data-vector.

Parameter Shifts (smokescreen.param_shifts)

The smokescreen.param_shifts module provides modules to perform shifts in the cosmological parameters.

Parameter Shifts

smokescreen.param_shifts.draw_flat_param_shifts(shift_dict, seed)

Draw flat parameter shifts from a dictionary of parameter names and corresponding shift widths.

Parameters:
  • shift_dict (dict) – Dictionary of parameter names and corresponding shift widths. If the shifts are single values, the dictionary values should be the shift widths. If the shifts are tuples of values, the dictionary values should be the (lower, upper) bounds of the shift widths.

  • seed (int or str) – Random seed.

Returns:

Dictionary of parameter names and corresponding flat parameter shifts.

Return type:

dict

smokescreen.param_shifts.draw_flat_or_deterministic_param_shifts(cosmo, shifts_dict, seed)

Draw flat or deterministic parameter shifts from a dictionary of parameter names and corresponding shift widths.

Parameters:
  • cosmo (pyccl.Cosmology) – Cosmology object.

  • shift_dict (dict) – Dictionary of parameter names and corresponding shift. If the shifts are single values, it does a deterministic shift: PARAM = FIDUCIAL + SHIFT If the shifts are tuples of values, the dictionary values should be the (lower, upper) bounds of the shift widths: PARAM = U(a, b)

  • seed (int or str) – Random seed.

Returns:

Dictionary of parameter names and corresponding flat or deterministic parameter shifts.

Return type:

dict

Utils (smokescreen.utils)

The smokescreen.utils module provides utility functions for the smokescreen package.

Smokescreen Utils

smokescreen.utils.load_cosmology_from_partial_dict(cosmo_dict)

Given a partial dictionary with cosmological parameters, return a Cosmology object setting the unspecified parameters to their default values.

Parameters:

cosmo_dict (dict) – Dictionary with the cosmological parameters.

Returns:

Cosmology object with the specified parameters.

Return type:

Cosmology

smokescreen.utils.load_module_from_path(path)

Load a module from a given path.

Parameters:

path (str) – Path to the module to load.

Returns:

Module loaded from the given path.

Return type:

module

smokescreen.utils.string_to_seed(seedstring)

Convert a string to a random seed.

Parameters:

string (str) – String to convert to a random seed.

Returns:

Random seed.

Return type:

int