param_grids module

Functions for pre- and post-processing CosmoSIS grids.

param_grids.get_diagonal_params(grid_dir, varied_params, save_path)

From a two-parameter CosmoSIS grid, export a list of parameters from one corner of the grid (min values of the two parameters) to the opposite corner (max values of the two parameters).

Parameters
  • grid_dir (str) – Path to CosmoSIS grid.

  • varied_params (list) – List of the two CosmoSIS parameter names whose values are varied across the grid.

  • save_path (str) – Path to save list of parameter values as a text file.

param_grids.load_diagonal_3x2pt_cl(grid_dir, diag_params_path, save_path, lmax, lmin_in, n_zbin)

Load all 3x2pt power spectra for each point in parameter space output by get_diagonal_params, and save into a single file.

Parameters
  • grid_dir (str) – Path to CosmoSIS grid.

  • diag_params_path (str) – Path to text file listing parameters across the diagonal of the grid, as output by get_diagonal_params.

  • save_path (str) – Path to save output as a numpy .npz file.

  • lmax (int) – Maximum to load.

  • lmin_in (int) – Minimum l in input.

  • n_zbin (int) – Number of redshift bins, assuming 1 position and 1 shear field per redshift bin.

param_grids.load_diagonal_3x2pt_cl_with_b(grid_dir, diag_params_path, save_path, lmax, lmin_in, n_zbin)

Load all 3x2pt power spectra, inserting zero B-modes, for each point in parameter space output by get_diagonal_params, and save into a single file.

Parameters
  • grid_dir (str) – Path to CosmoSIS grid.

  • diag_params_path (str) – Path to text file listing parameters across the diagonal of the grid, as output by get_diagonal_params.

  • save_path (str) – Path to save output as a numpy .npz file.

  • lmax (int) – Maximum to load.

  • lmin_in (int) – Minimum l in input.

  • n_zbin (int) – Number of redshift bins, assuming 1 position and 1 shear field per redshift bin.

param_grids.load_diagonal_shear_cl(grid_dir, diag_params_path, save_path)

Load the first shear power spectrum for each point in parameter space output by get_diagonal_params, and save into a single file.

Parameters
  • grid_dir (str) – Path to CosmoSIS grid.

  • diag_params_path (str) – Path to text file listing parameters across the diagonal of the grid, as output by get_diagonal_params.

  • save_path (str) – Path to save output as a numpy .npz file.

param_grids.reduced_grid_chains(params, upper_diag, lower_diag, n_chains, output_dir=None, plot=False)

Generate a custom number of chain text files for input to the list sampler in CosmoSIS, covering a two-dimensional grid but only including the range within two specified diagonals for efficiency.

Parameters
  • params (dict) – Dictionary containing one sub-dictionary for each parameter to be varied. Each subdirectory should contain three items: min (minimum value), max (maximum value) and steps (number of steps including endpoints) - see example below.

  • upper_diag (list of tuples) – The upper limit of the parameter space to include. Upper and lower diagonal limits are defined by their endpoints, in order of increasing value of the first parameter (the parameter appearing first in the argument to params). E.g. [(-1.0, -0.5), (1.0, 0.0)]. It can be useful to use the plot option to visualise this.

  • lower_diag (list of tuples) – The lower limit of the parameter space to include. See upper_diag.

  • n_chains (int) – Number of chains to output.

  • output_dir (str, optional) – Path to output directory where the text files will be saved. If not supplied, no output is produced, which can be useful when wanting only to visualise the grid using the plot option.

  • plot (bool, optional) – Display the grid points to be included.

Example for params:

params = {
    'cosmological_parameters--w': {
        'min': -1.5,
        'max': -0.5,
        'steps': 41
    },
    'cosmological_parameters--wa': {
        'min': -1.0,
        'max': 1.0,
        'steps': 51
    }
}
param_grids.single_param_chains(fid_params, param_to_vary, half_range, steps, n_chains, output_dir)

Generate a custom number of chain text files for input to the list sampler in CosmoSIS, varying a single parameter with other parameters held fixed at their fiducial values.

Parameters
  • fid_params (dict) – Dictionary containing fiducial values for each parameter, using parameter names as used in CosmoSIS, excluding the ‘cosmological_parameters–’ prefix, e.g. {'w': -1.0, 'wa': 0.0, ...}.

  • param_to_vary (str) – Name of the parameter to vary.

  • half_range (float) – Parameter will be varied from its fiducial value +/- half_range.

  • steps (int) – Number of steps with which to vary the parameter, from (fiducial - half_range) to (fiducial + half_range), including the endpoints.

  • n_chains (int) – Number of chains to output.

  • output_dir (str) – Path to output directory where the text files will be saved.