candl.io#

IO module that handles reading in data and providing feedback to the user.

Overview:#

candl.io.expand_transformation_block(data_set_dict, block_file)#

Read a .yaml file containing a list of transformation entries.

Parameters:
data_set_dictdict

The data set dictionary containing all the information from the input yaml file.

block_filestr

Full path of the .yaml block file containing the transformations to be read.

Returns:
list

List of transformations form the block file.

candl.io.like_init_output(like)#

Print details after successful initialisation of the likelihood.

Parameters:
like:

candl.Like or candl.LensLike

Returns:
None
candl.io.load_info_yaml(yaml_file, variant='default')#

Read the data set yaml file that contains all the information needed to instantiate the likelihood. Navigates through index files if necessary.

Parameters:
yaml_filestr

Path of the data set yaml file or index file

variantstr

Optional, to be used for index files. Indicates the variant of the data set to be read in.

Returns:
dict

Data set dictionary.

str

Path of the data set yaml file.

candl.io.read_effective_frequencies_from_yaml(data_set_dict)#

Read in effective frequency information from data set dictionary.

Parameters:
data_set_dictdict

The data set dictionary containing all the information from the input yaml file.

Returns:
dict

Dictionary containing keys for all source types given in the effective frequency yaml file. Each entry is a dictionary with frequency identifiers as keys and effective frequencies as values.

candl.io.read_file_from_path(full_path)#

Read in a file (array) from a path. Method used to read in band powers and covariance matrix. Can read four types: (1) Text files. Ending must be “.txt” or “.dat”. (2) Binary files. These must end in “.bin” and be stored as float64s. Will be turned into a square array if possible. (3) Numpy files. These must end in “.npy” and will be read in as a numpy array. (4) FITS files. These must end in “.fits”.

Parameters:
full_pathstr

The absolute path of the file.

Returns:
array

File read into array format.

candl.io.read_file_from_yaml(data_set_dict, file_kw)#

Read in a file from the data_set dict.

Parameters:
data_set_dictdict

The data set dictionary containing all the information from the input yaml file.

file_kwstr

A string that corresponds to a keyword in data_set_dict that specifies the file location relative to the base path.

Returns:
array

File read into array format.

candl.io.read_lensing_M_matrices_from_yaml(full_path, Mtype='pp')#

Read lensing M matrices. This function assumes that window functions are saved in a specific format: window{n}.dat, where n runs over the bin numbers. Each file specifies the response function at all L values. All bins are read in, any cropping is performed later.

Parameters:
full_pathstr

The absolute path of the folder.

Mtypestr

Which M matrices to load, “TT”, “TE”, “EE”, “BB”, “pp”, or “kk”.

Returns:
array

M matrices as a (number_of_ells, N_files_total) array.

candl.io.read_meta_info_from_yaml(data_set_dict)#

Read any meta information.

Parameters:
data_set_dictdict

The data set dictionary containing all the information from the input yaml file.

Returns:
str

Name of the likelihood.

candl.io.read_spectrum_info_from_yaml(data_set_dict, lensing=False)#

Read spectrum info. If lensing == True only returns first, second, and fourth item from usual returns.

Parameters:
data_set_dictdict

The data set dictionary containing all the information from the input yaml file.

Returns:
list

List of strings of spectrum identifiers.

list

List of strings of spectrum types.

list

List of lists with two entries giving frequencies for each spectrum.

int

Number of total spectra.

list

List of ints giving number of bins for each spectrum.

candl.io.read_transformation_info_from_yaml(data_set_dict, i_tr)#

Read in information about a specific transformation from data set yaml file.

Parameters:
data_set_dictdict

The data set dictionary containing all the information from the input yaml file.

i_trint

Index of the transformation to be read.

Returns:
str

Name of the transformation class.

dict

Dictionary of information passed by the user, required as instantiation Parameters for the specified class.

candl.io.read_window_functions_from_yaml(data_set_dict, spec_order, N_bins)#

Read band power window functions using data set dictionary. There are two allowed formats:

  1. Window functions are saved by spectrum as “{spec}_window_functions.txt” The files are arrays of (ell, N_bins+1) size, where the first column gives the theory ell.

  2. Window functions are saved by bin as “window_{i}.txt” starting at i=0. The files are arrays of (ell, N_specs+1) size, where the first column gives the theory ell.

Generally, the first format is preferred as it allows for spectra of different length.

Parameters:
data_set_dictdict

The data set dictionary containing all the information from the input yaml file.

spec_orderlist

List specifying the order of spectra.

N_binslist (int)

Number of bins for each spectrum.

Returns:
list

Band power window functions as a list of N_spectra with (N_ell_theory, N_bins) arrays. Start at ell=2.