Inference utilities

unified_utils.utils.data_loader(redshift, split, use_mock=False, pole_selection=[True, False, True, False, False], norm_cov=1.0, kmin=0.01, kmax=0.2, pybird_mock=False, path_to_repo='/mnt/lustre/jdonaldm/unified_analysis/', mock_type='P18')

Utility function for loading data.

Parameters:
  • redshift (float) – Redshift of data to load. Can be on of [0.096, 0.38, 0.61, 1.52].

  • split (str) – Hemisphere. Can be either NGC or SGC.

  • use_mock (bool) – If True will load mock data. Default is False. Note this cannot be True if pybird_mock is True.

  • pole_selection (list) – List of boolean elements that selects the desired multipoles. Default is [True, False, True, False, True], this selects the even multipoles P0, P2, and P4. Note that is pybird_mock=True only the even multipoles can be selected.

  • norm_cov (float) – Normalisation factor for the covariance matrix. Default is 1..

  • kmin (float) – Set minimum scale. Default is 0.01.

  • kmin – Set maximum scale. Default is 0.2.

  • pybird_mock (bool) – If True will load the appropriate PyBird mock produced in arXiv:2307.07475.

  • path_to_repo (str) – Path to repo. Note that all data must be stored in a directory with name data.

  • mock_type (str) – Tag for the PyBird mocks. The mocks produced in arXiv:2307.07475 all have the tag P18.

Returns:
  • kbins_fit (array) – The k-bins. Has shape (nki,).

  • pk_data_fit (array) – The selected multipoles. Has shape (3*nki,).

  • cov_fit (array) – Covariance matrix. Has shape (3*nki, 3*nki).

  • window (array) – Window function matrix. Has shape (200, 2000).

  • M (array) – Wide angle matrix. Has shape (1200, 2000).

  • range_selection (array) – Array of boolean elements that cut the origonal data. Has shape (nkj,).

  • Nmocks (int) – The number of mocks used to calculate the covariance.

unified_utils.utils.check_emu_bounds(param_dict, emu_bounds)

Function for checking Parameters nested dictionary as read from config. file.

Parameters:
  • param_dict (dict) – Nested dictionary for parameters of model. Each element should have the form {'pi': {'prior': {'type':'uniform', 'min':a, 'max':b}}} or they will be ignored by the function. a and b can be either floats or 'emu'.

  • emu_bounds (dict) – Nested dictionary containing the hard bounds of of the emulator training space.

Returns:

param_dict (dict) – Same as param_dict with all appearances of 'emu' replaced with floats and all extremes checked.

unified_utils.utils.import_loglikelihood(path, fn_name, engine_or_like='like')

Modified version of cronus function. See https://github.com/minaskar/cronus. Extracts likelihood function from specified file.

Parameters:
  • path (str) – Path to .py file that contains likelihood function or engine class.

  • fn_name (str) – The name of the function in the .py file.

  • engine_or_like (str) – Are you loading a likelihood function or a predictione engine? Can be either 'like' or 'engine'.

Returns:

fn (object) – Likelihood function or engine class.

unified_utils.utils.make_fname(setup_dict, use_tags=True, overwrite=False)

Make file name from config file. File name will have tags that reflect the setup.

Parameters:
  • setup_dict (dict) – Nested dictionary as read from .yaml file.

  • use_tags (bool) – Use tags that refelect the setup in the name. This can make file names quite long so set False to turn this off. Default is True.

Returns:

fname (string) – The name for a .npy file.

unified_utils.utils.special_treatment(param_dict)

Determine if parameters need spcial treatment, like analytic marginalisation or Jeffreys prior.

Parameters:

param_dict (dict) – Dictionary defining the parameters and priors as expected in the .yaml config file.

Returns:
  • marg_cov (array) – Inverse prior matrix for marginalised parameters. Will have shape (len(marg_names), len(marg_names)).

  • marg_names (list) – List of names of marginalised parameters.

  • jeff_cov (array) – Inverse prior matrix for marginalised parameters to be used in the Jeffreys prior. Will have shape (len(jeff_names), len(jeff_names)). This shape may be different from marg_cov.

  • jeff_names (list) – List of names of parameters with Jeffreys prior.

unified_utils.utils.fix_params(theta, fixed_dict={'As': None, 'b1': None, 'b3': None, 'c2': None, 'c4': 0.0, 'cct': None, 'ce1': None, 'cmono': 0.0, 'cquad': None, 'cr1': None, 'cr2': 0.0, 'h': None, 'w_b': None, 'w_c': None})

Function for fixing certain parameters of the EFTofLSS model. This function already assumes a fixed value of ns.

Parameters:
  • theta (array) – Array of shape (nsamp, nfree) containing nsamp sets of the nfree free parameters.

  • fixed_dict (dict) – Dictionary of fixed nfix parameter values. Default is {‘w_c’:None, ‘w_b’:None, ‘h’:None, ‘As’:None, ‘b1’:None, ‘c2’:None, ‘b3’:None, ‘c4’:0., ‘cct’:None, ‘cr1’:None, ‘cr2’:0., ‘ce1’:None, ‘cmono’:0., ‘cquad’:None}

Returns:

theta_w_fixed (array) – Array of shape (nsamp, nfree+nfix) containing theta and nsamp repeats of the fixed parameters.