cosmicfish_pylib.fisher_derived

Module that contains the fisher_derived class and the operations defined on it. This is meant to handle efficiently and safely Jacobian matrices transforming a Fisher matrix for some parameters to a Fisher matrix for some other parameters.

class cosmicfish_pylib.fisher_derived.fisher_derived(derived_matrix=None, param_names=None, derived_param_names=None, param_names_latex=None, derived_param_names_latex=None, fiducial=None, fiducial_derived=None, file_name=None)[source]

This class contains the relevant code to define a matrix that contains the relevant information to reparametrize a Fisher matrix. Generally this is a rectangular matrix containing the Jacobian of the transformation from the original Fisher to the derived one.

Variables:
  • derived_matrix – Numpy array containing the Jacobian of the transformation between the Fisher matrix and the derived Fisher matrix. Passed to the constructor of by file.
  • path – Absolute path of the input Jacobian matrix. Computed at initialization if passing a file.
  • name – Name of the input Jacobian matrix. Computed at initialization if passing a file.
  • indir – Absolute path of the directory containing the input Jacobian matrix. Computed at initialization if passing a file.
  • num_params – Number of base parameters of the Jacobian matrix.
  • num_derived – Number of derived parameters.
  • param_names – Names of the base parameters. Used as the identifier of the parameters. Initialized, if possible, through a .paramnames file.
  • param_names_latex – LaTeX names of the base parameters.
  • param_fiducial – Numpy array with the values of the fiducial of the base parameters. Passed to the constructor or by file.
  • derived_param_names – Names of the derived parameters. Used as the identifier of the parameters. Initialized, if possible, through a .paramnames file.
  • derived_param_names_latex – LaTeX names of the derived parameters.
  • derived_param_fiducial – Numpy array with the values of the fiducial of the derived parameters. Passed to the constructor or by file.

fisher_derived class constructor. The class constructor will read from file the Fisher derived matrix if it is initialized with the name of a file (and the file exists). Otherwise it will read the matrix and the parameter names as passed by the user.

Parameters:
  • derived_matrix (2D list or numpy.array) – array containing the input Jacobian matrix.
  • param_names (list of string) – names of the parameters of the derived parameters. If initialized from file it will read them if a file file_name.paramnames is found. If it is none when itialized from python it will just use some defaults names (p1, p2,...).
  • derived_param_names (list of string) – names of the derived parameters. If initialized from file it will read them if a file file_name.paramnames and expects them to have a * appened. If it is none when itialized from python it will just use some defaults names.
  • param_names_latex (list of string) – LaTeX names of the parameters of the Jacobian matrix also appearing in the Fisher matrix.
  • derived_param_names_latex (list of string) – LaTeX names of the parameters of the Jacobian matrix that are derived parameters.
  • fiducial (list of float or numpy.array) – values of the fiducial parameters of the Fisher matrix. If initialized from file it will have the value found in .paramnames. If not found on a file it will be zero. Passing it to the constructor overwrites the values.
  • fiducial_derived (list of float or numpy.array) – values of the fiducial derived parameters. If initialized from file it will have the value found in .paramnames. If not found on a file it will be zero. Passing it to the constructor overwrites the values.
  • file_name (string) – name of the file (and path) of the input Jacobian matrix.
add_derived(fisher_matrix, preserve_input=False)[source]

This function computes the derived fisher_matrix given an input Fisher matrix based on the Jacobian contained in derived_matrix.

Parameters:
  • fisher_matrix (cosmicfish_pylib.fisher_matrix.fisher_matrix) – input Fisher matrix that will be used as a base for the derived Fisher matrix.
  • preserve_input (bool) – wether to preserve input parameters in the output Fisher. Default to false because it might lead to strage results if not used properly.
Returns:

output Fisher matrix with derived parameters.

Return type:

cosmicfish_pylib.fisher_matrix.fisher_matrix

get_derived_matrix()[source]
Returns:the derived Jacobian matrix.
get_derived_param_fiducial()[source]
Returns:the derived parameter fiducial values.
get_derived_param_names()[source]
Returns:the derived parameters names.
get_derived_param_names_latex()[source]
Returns:the LaTeX version of the derived parameters names.
get_param_fiducial()[source]
Returns:the base parameter fiducial values.
get_param_names()[source]
Returns:the base parameter names.
get_param_names_latex()[source]
Returns:the LaTeX version of the base parameter names.
load_paramnames_from_file(file_name=None)[source]

Loads the paramnames array, of a derived Fisher matrix, from a file

Parameters:file_name (string) – (optional) file name and path of the parameter names file. If file_name is None this reads the file self.name+.paramnames.