cosmicfishpie.analysis package
Submodules
cosmicfishpie.analysis.colors module
- synopsis:
A collection of color utilities.
- class cosmicfishpie.analysis.colors.bash_colors[source]
Bases:
objectThis class contains the necessary definitions to print to bash screen with colors. Sometimes it can be useful and nice! :ivar HEADER: ANSI color for light purple. :ivar OKBLUE: ANSI color for blue. :ivar OKGREEN: ANSI color for green. :ivar WARNING: ANSI color for yellow. :ivar FAIL: ANSI color for red. :ivar BOLD: ANSI code for bold text. :ivar UNDERLINE: ANSI code for underlined text. :ivar ENDC: ANSI code to restore the bash default.
- blue(string)[source]
Function that returns a string that can be printed to bash in
cosmicfish_pylib.colors.bash_colors.OKBLUEcolor.- Parameters:
string (string) – input string.
- Returns:
the input string with the relevant ANSI code at the beginning and at the end.
- Return type:
string
- bold(string)[source]
Function that returns a string that can be printed to bash in
cosmicfish_pylib.colors.bash_colors.BOLDcolor.- Parameters:
string (string) – input string.
- Returns:
the input string with the relevant ANSI code at the beginning and at the end.
- Return type:
string
- fail(string)[source]
Function that returns a string that can be printed to bash in
cosmicfish_pylib.colors.bash_colors.FAILcolor.- Parameters:
string (string) – input string.
- Returns:
the input string with the relevant ANSI code at the beginning and at the end.
- Return type:
string
- green(string)[source]
Function that returns a string that can be printed to bash in
cosmicfish_pylib.colors.bash_colors.OKGREENcolor.- Parameters:
string (string) – input string.
- Returns:
the input string with the relevant ANSI code at the beginning and at the end.
- Return type:
string
- header(string)[source]
Function that returns a string that can be printed to bash in
cosmicfish_pylib.colors.bash_colors.HEADERcolor.- Parameters:
string (string) – input string.
- Returns:
the input string with the relevant ANSI code at the beginning and at the end.
- Return type:
string
- underline(string)[source]
Function that returns a string that can be printed to bash in
cosmicfish_pylib.colors.bash_colors.UNDERLINEcolor.- Parameters:
string (string) – input string.
- Returns:
the input string with the relevant ANSI code at the beginning and at the end.
- Return type:
string
- warning(string)[source]
Function that returns a string that can be printed to bash in
cosmicfish_pylib.colors.bash_colors.WARNINGcolor.- Parameters:
string (string) – input string.
- Returns:
the input string with the relevant ANSI code at the beginning and at the end.
- Return type:
string
- BOLD = '\x1b[1m'
ANSI code for bold text.
- ENDC = '\x1b[0m'
ANSI code to restore the bash default.
- FAIL = '\x1b[91m'
ANSI color for red.
- HEADER = '\x1b[95m'
ANSI color for light purple.
- OKBLUE = '\x1b[94m'
ANSI color for blue.
- OKGREEN = '\x1b[92m'
ANSI color for green.
- UNDERLINE = '\x1b[4m'
ANSI code for underlined text.
- WARNING = '\x1b[93m'
ANSI color for yellow.
- cosmicfishpie.analysis.colors.nice_colors(num)[source]
This function returns a color from a colormap defined below according to the number entered.
- Parameters:
num (
intorfloat) – input number. Can be an integer or float. Notice that the colormap contains only a small numbers of colors. Even if the input is a float the output will still be one of the few colors in the colormap.- Returns:
tuple of
floatcontaining the three RGB coordinates of the color.- Return type:
cosmicfishpie.analysis.fisher_derived module
- class cosmicfishpie.analysis.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]
Bases:
objectThis 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. :ivar 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. :ivar path: Absolute path of the input Jacobian matrix. Computed at initialization if passing a file. :ivar name: Name of the input Jacobian matrix. Computed at initialization if passing a file. :ivar indir: Absolute path of the directory containing the input Jacobian matrix. Computed at initialization if passing a file. :ivar num_params: Number of base parameters of the Jacobian matrix. :ivar num_derived: Number of derived parameters. :ivar param_names: Names of the base parameters. Used as the identifier of the parameters. Initialized, if possible, through a .paramnames file. :ivar param_names_latex: LaTeX names of the base parameters. :ivar param_fiducial: Numpy array with the values of the fiducial of the base parameters. Passed to the constructor or by file. :ivar derived_param_names: Names of the derived parameters. Used as the identifier of the parameters. Initialized, if possible, through a .paramnames file. :ivar derived_param_names_latex: LaTeX names of the derived parameters. :ivar derived_param_fiducial: Numpy array with the values of the fiducial of the derived parameters. Passed to the constructor or by file.
- 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
cosmicfishpie.analysis.fisher_matrix module
- synopsis:
Module that contains the fisher_matrix class and the operations defined on it. The idea is that of creating a Fisher matrix safely, with all operations being well defined and safe-guarded once the input matrix is accepted as a Fisher matrix.
- class cosmicfishpie.analysis.fisher_matrix.fisher_matrix(fisher_matrix=None, param_names=None, param_names_latex=None, fiducial=None, file_name=None, name='')[source]
Bases:
objectThis class contains the relevant code to define a fisher matrix and basic operations on it.
- Variables:
fisher_cutoff – cutoff for the spectrum of the Fisher matrix. Parameter of the class. Starts at 10**(-9) but, if needed, is fixed during computations.
fisher_spectrum – maximum condition number allowed for the Fisher matrix. Worse constrained modes that go above this value will be flattened to this value.
fisher_matrix – numpy array with the fisher matrix. Passed to the constructor of by file.
path – absolute path of the input Fisher matrix. Computed at initialization if passing a file or just an empty string.
name – name of the input Fisher matrix. Computed at initialization if passing a file or just an empty string.
indir – absoulte path of the directory of the input Fisher matrix. Computed at initialization if passing a file or just an empty string.
num_params – number of parameters of the input Fisher matrix. Computed at initialization.
fisher_eigenvalues – eigenvalues of the input Fisher matrix. Computed at initialization or by the PCA function.
fisher_eigenvectors – eigenvectors of the input Fisher matrix. Computed at initialization or by the PCA function.
fisher_matrix_inv – inverse of the input Fisher matrix. Computed at initialization or by inverse_fisher_matrix.
param_names – name of the parameters of the input Fisher matrix. Passed to the constructor of by file.
param_names_latex – LaTeX name of the parameters of the Fisher matrix. Passed to the constructor of by file.
param_fiducial – numpy array with the values of the fiducial parameters. Passed to the constructor of by file.
param_names_dict – a dictionary that maps parameter names to numbers and vice versa.
- __add__(other)[source]
Addition operator (+). Safeguarded agains adding Fisher matrices with different parameters and different fiducials. The addition will add parameters with the same name and append parameters with different names. Notice that if a parameter is in one of the two Fisher matrices but not in the other it will be assumed independent from the other.
- __eq__(other)[source]
Equality check operator (==). Ensures equality in all properties of the Fisher matrix. Notice that also name, path and indir are checked.
- __ne__(other)[source]
Non-equality operator (!=). Simply implemented as the inverse of the equality operator.
- PCA()[source]
This function performs the principal component analysis of the Fisher matrix returning its eigenvalues and its eigenvectors. As of now it just works just as a wrapper for numpy.
- check_symmetric()[source]
Assert if the Fisher matrix is symmetric or not :returns: a
bool:rtype:bool
- determinant()[source]
This function returns the determinant of the Fisher matrix.
- Returns:
a
floatwith the determinant of the Fisher matrix.
- get_confidence_bounds(confidence_level=0.6827, marginal=True, cache=False)[source]
Computes the marginal 1D confidence bounds on the Fisher parameters
- get_param_index(name)[source]
Returns the index of a parameter as specified by his name. Notice that indices starts at 0.
- get_param_name(number)[source]
Returns the name of the parameter corresponding to the given number.
- get_param_names_fiducial_dict()[source]
- Returns:
a dictionary with parameter names as keys and fiducial values as values.
- get_param_names_latex()[source]
- Returns:
the parameter names, in LaTeX format of the Fisher matrix.
- get_param_number(name)[source]
Returns the number of a parameter as specified by his name. Notice this differs from get_param_index becasue number = index+1.
- inverse_fisher_matrix()[source]
Invert the Fisher matrix.
- Returns:
a matrix containing the inverse of the Fisher matrix.
- Return type:
numpy.array
- load_paramnames_from_file(file_name=None)[source]
Loads the paramnames array from a file.
- Parameters:
file_name (default:
None) – (optional) file name and path of the parameter names file. If file_name is None this reads the file self.name+.paramnames.
- protect_degenerate(cache=True)[source]
Protects the Fisher matrix against degeneracies. Modifies the spectrum to ensure that the absolute value of the eigenvalues is bounded. This will make the Fisher matrix strictly positive definite. It will modify the magnitude of the worst constrained parameter combinations without modifying the degeneracies directions.
- Parameters:
cache (bool) – (optional) wether to use cached results or compute everything again
- save_paramnames_to_file(file_name=None)[source]
Saves the paramnames to a file.
- Parameters:
file_name (default:
None) – (optional) file name and path of the parameter names file. If file_name is None this saves the file self.name+.paramnames.
- save_to_file(file_name, simple_header=False, file_format='.txt')[source]
Saves the fisher matrix to a file. Notice that the file name has to be specified to avoid overwriting an existing fisher matrix.
- Parameters:
file_name – file name and path of the output fisher matrix. The file extension gets automatically added as is not needed.
- set_fiducial(fiducial)[source]
Function sets a new fiducial substituting the old one.
- Parameters:
fiducial – list containing the new fiducial.
- set_fisher_matrix(fisher_matrix)[source]
Function sets a new fisher matrix substituting the old one. Notice that this will reset parameter names, latex parameter names and fiducial values.
- Parameters:
fisher_matrix (
numpy.array) –numpy.arraycontaining the input Fisher matrix.
- set_param_names(param_names)[source]
Function sets a new list of param names substituting the old one. Notice that latex parameter names will be reset.
- Parameters:
param_names (
listofstring) – list containing the new parameter names.
cosmicfishpie.analysis.fisher_operations module
- synopsis:
Module that contains operations that can be performed on Fisher matrices. All of them are safeguarded against non-Fisher input.
- cosmicfishpie.analysis.fisher_operations.eliminate_columns_rows(fisher_matrix, indexes)[source]
This function eliminates the row and columns corresponding to the given indexes from the Fisher matrix. It also deletes all the other informations like the names of the parameters. Notice that the index corresponding to the first parameter is zero.
- Parameters:
- Returns:
A Fisher matrix with the columns and rows deleted
- Return type:
cosmicfish_pylib.fisher_matrix.fisher_matrix
- cosmicfishpie.analysis.fisher_operations.eliminate_parameters(fisher_matrix, names)[source]
This function eliminates the row and columns corresponding to the given parameter name from the Fisher matrix. It also deletes all the other informations like the names of the parameters.
- Parameters:
fisher_matrix (
cosmicfish_pylib.fisher_matrix.fisher_matrix) – input Fisher matrixnames (
listofstring) – list of names of the parameters to delete from the Fisher matrix
- Returns:
A Fisher matrix with the parameters deleted
- Return type:
cosmicfish_pylib.fisher_matrix.fisher_matrix
- cosmicfishpie.analysis.fisher_operations.information_gain(fisher_1, fisher_2, fisher_prior, units=0.6931471805599453, stat=True)[source]
This function computes the Fisher approximation of Kullback-Leibler information gain. For the details of the formula we refer to the CosmicFish notes.
- Parameters:
fisher_1 (
cosmicfish_pylib.fisher_matrix.fisher_matrix) – first input Fisher matrixfisher_2 (
cosmicfish_pylib.fisher_matrix.fisher_matrix) – second input Fisher matrixfisher_prior (
cosmicfish_pylib.fisher_matrix.fisher_matrix) – input Fisher matrix with the prior information.units (
float) – Units of information gain. Optional by default in Bits.stat (
logical) – wether to output the expected value and variance
- Returns:
a
floatwith the information gain.- Return type:
- cosmicfishpie.analysis.fisher_operations.marginalise(fisher_matrix, names, update_names=True)[source]
This function marginalises a Fisher matrix over all parameters but the ones in names. The new Fisher matrix will have the parameters specified in names, in the order specified by names. The calculation is performed in the numerically stable way.
- Parameters:
fisher_matrix (
cosmicfish_pylib.fisher_matrix.fisher_matrix) – input Fisher matrixnames (
listofstring) – list of names of the parameters of the output Fisher matrix, in the order that will appear in the output Fisher matrix. All other parameters will be marginalized over.
- Returns:
A Fisher matrix with the marginalized parameters
- Return type:
cosmicfish_pylib.fisher_matrix.fisher_matrix
- cosmicfishpie.analysis.fisher_operations.marginalise_over(fisher_matrix, names)[source]
This function marginalises a Fisher matrix over the parameters in names. The new Fisher matrix will not have the parameters specified in names. The calculation is performed in the numerically stable way.
- Parameters:
fisher_matrix (
cosmicfish_pylib.fisher_matrix.fisher_matrix) – input Fisher matrixnames (
listofstring) – list of names of the parameters over which the Fisher will be marginalised.
- Returns:
A Fisher matrix with the names parameters marginalized.
- Return type:
cosmicfish_pylib.fisher_matrix.fisher_matrix
- cosmicfishpie.analysis.fisher_operations.reshuffle(fisher_matrix, names, update_names=True)[source]
This function reshuffles a Fisher matrix. The new Fisher matrix will have the parameters specified in names, in the order specified by names. Can be used to delete parameters, change their order or extract the Fisher for some parameters without marginalizing over the others.
- Parameters:
fisher_matrix (
cosmicfish_pylib.fisher_matrix.fisher_matrix) – input Fisher matrixnames (
listofstring) – list of names of the parameters that are desired in the output Fisher matrix, in the desired order.
- Returns:
A Fisher matrix with the new parameters
- Return type:
cosmicfish_pylib.fisher_matrix.fisher_matrix
cosmicfishpie.analysis.fisher_plot_analysis module
- synopsis:
Module that contains a set of tools to perform the analysis of a set of Fisher matrices.
- class cosmicfishpie.analysis.fisher_plot_analysis.CosmicFish_FisherAnalysis(fisher_list=None, fisher_path=None, search_fisher_guess=False, with_derived=True)[source]
Bases:
objectThis class takes care of handeling a set of Fisher matrices with plotting in mind. This class is meant to hold a list of Fisher matrices and have defined on this list a set of vectorized operations. For now no caching is implemented.
- Variables:
fisher_list – list of Fisher matrices
cosmicfish_pylib.fisher_matrix.fisher_matrixfisher_name_list – list of names of the Fisher matrices. The names are used as the unique identifier of the Fisher matrix. No double name is enforced.
- add_fisher_matrix(fisher)[source]
Add a set of Fisher matrices to the already existing set. Rejects Fisher matrices if the name is double i.e. the name is the unique identifier of the Fisher matrix. Checks wether the elements that are passed are really Fisher matrices.
- Parameters:
fisher_list (
cosmicfish_pylib.fisher_matrix.fisher_matrixorlistofcosmicfish_pylib.fisher_matrix.fisher_matrix) – Fisher matrix or list of Fisher matrices.
- compare_fisher_results(parstomarg=None, fisher_list=None, export_json_path=None, append=False, overwrite=False, extra_metadata=None)[source]
Compare and print results from Fisher matrices.
This method analyzes each Fisher matrix in the list, calculating and printing various statistics including the Figure of Merit (FoM) and parameter constraints.
- Parameters:
parstomarg (
listofstr, optional) – List of parameter names to marginalize over when computing the FoM. If None, the first two parameters of each Fisher matrix are used (independently per matrix).fisher_list (
listofFisherMatrix objects, optional) – List of Fisher matrices to analyze. If None, uses the instance’s fisher_list.export_json_path (
str, optional) – If provided, a JSON file with the collected statistics is written here.append (
bool, defaultFalse) – If True and export_json_path exists, merge/append current run results to the existing JSON (keyed by Fisher name, overwriting duplicates for that name only).overwrite (
bool, defaultFalse) – If True and export_json_path exists, the file is overwritten (takes precedence over append). Ignored if append=True.extra_metadata (
dict, optional) – Additional metadata to store at top-level of JSON output.
Notes
This method modifies the instance’s fisher_list if a new list is provided. Returns the structured results list (same objects written to JSON when requested).
Prints
Fisher matrix name
Figure of Merit (FoM) for chosen marginalized parameters
Per-parameter: fiducial, 1-sigma error, percent error
JSON Schema (export_json_path)
The JSON output has the following structure:
{ "metadata": { "timestamp": "ISO-8601 str", "parstomarg_user_provided": true, "n_fishers": 3, ...extra_metadata }, "results": [ { "name": "FisherName", "FoM": { "parameters": ["p1", "p2", ...], "value": 123.45 }, "parameters": [ { "name": "param1", "fiducial": 1.0, "sigma": 0.1, "percent_error": 10.0 }, ... ] }, ... ] }
- compute_ellipse(params1=None, params2=None, confidence_level=0.6827, names=None, num_points=100)[source]
Function that computes the (2D) ellipses for a given parameters combination. Returns a dictionary with all the meaningul information about the ellipses.
- Parameters:
params1 (a
stringor alistofstring) – name of the first parameter or list of names of parameters.params2 (default:
None) – name of the second parameter or list of names of parameters.confidence_level (
float) – (optional) Confidence Level of the bounds. Default 68%.names (a
stringor alistofstring) – names of the Fisher matrices.num_points (
int) – number of (x,y) points.
- Returns:
a dictionary mapping name and parameters to a tuple of: [x, y, [fiducial_x, fiducial_y, coeff_a, coeff_b, theta_0]]
- Return type:
- compute_gaussian(params=None, confidence_level=0.6827, names=None, num_points=100, normalized=False, nice_bounds=True)[source]
Function that computes the (1D) gaussian distribution of a given parameter. Returns a dictionary with all the meaningul information about the gaussian.
- Parameters:
params (a
stringor alistofstring) – name of the parameter or list of names of parameters.confidence_level (
float) – (optional) Confidence Level of the bounds. Default 68%.names (a
stringor alistofstring) – names of the Fisher matrices.num_points (
int) – number of (x,y) points.normalized (
bool) – wether the distribution is normalized or not.nice_bounds (
bool) – wether the x range is properly rounded to be nice or not.
- Returns:
a dictionary mapping name and parameter to a tuple of: [x, y, [fiducial,sigma]]
- Return type:
- compute_plot_range(params=None, confidence_level=0.6827, range_factors={'default': 1.0}, names=None, nice=True, dimensions=1)[source]
Function that computes a meaningfull plot range for the plots involving the specified parameters and the specified Fisher names.
- Parameters:
params (a
stringor alistofstring) – name of the parameter or list of names of parameters.confidence_level (
float) – (optional) Confidence Level of the bounds. Default 68%.names (a
stringor alistofstring) – names of the Fisher matrices.nice (
bool) – wether the number is properly rounded to be nice.
- Returns:
a dictionary of name and bounds
- Return type:
- delete_fisher_matrix(names=None)[source]
Delete the fisher matrix or the fisher matrices in names from the Fisher list.
- Parameters:
names (a
stringor alistofstring) – names of the Fisher matrices to delete.
- get_fisher_matrix(names=None)[source]
Returns the list of Fisher matrices corresponding to the given names.
- Parameters:
names (a
stringor alistofstring) – names of the Fisher matrices.- Returns:
a list containing the desired Fisher matrices. Notice if the name is not found in the list no error is risen and and the entrance is just ignored.
- Return type:
a
listofcosmicfish_pylib.fisher_matrix.fisher_matrix
- get_fisher_name_list()[source]
- Returns:
the list fisher matrices names. These are the unique identifiers of the list.
- get_parameter_latex_names(names=None)[source]
Returns a dictionary mapping parameter names and latex parameter names.
- get_parameter_list(names=None)[source]
Returns the list of parameter names of all the matrices identified in names.
- marginalise(params, names=None, update_names=True)[source]
Marginalise all the Fisher matrices over all the parameters that are not in params.
- Parameters:
- Returns:
a new Fisher list with the reshuffled Fishers
- Return type:
a
cosmicfish_pylib.fisher_plot_analysis.CosmicFish_FisherAnalysis
- search_fisher_path(fisher_path, search_fisher_guess=False, with_derived=True)[source]
Searches a path for fisher matrices. Will detect wether fisher_path contains directly the paths to the Fisher files or folder. If a list of folders is passed all the folders will be searched, first for Fisher matrices then for derived Fisher matrices.
- Parameters:
fisher_path (
stringorlistofstring) – path or list of paths to search for Fisher matrices. If this contains Fisher matrices files those are imported as well.search_fisher_guess (
bool) – wether to guess the Fisher matrix name or not. Guessing assumes that the Fisher matrices have ‘fisher_matrix’ and ‘.dat’ in the name as happens with Fisher matrices produced with CosmicFish.with_derived (
bool) – wether to search for derived Fisher matrices to add to the base Fisher that are found.
cosmicfishpie.analysis.fisher_plotting module
- synopsis:
Module that contains the fisher_plotting class and related functions for generating contour plots and visualizing Fisher matrix results using getdist.
- class cosmicfishpie.analysis.fisher_plotting.fisher_plotting(**options)[source]
Bases:
objectThis class uses the cosmicfish_pylib classes to generate contour plots using getdist
- matrix_ratio(r_fishers_list=None, tick_labels=None, plot_title=None, ratio_mat=None, filename=None, savefig=True)[source]
- plot_fisher(**kwargs)[source]
Generates a triangle plot based on loaded gaussian data and specified parameters.
- Parameters:
**kwargs – Keyword arguments for customizing the plot. axis_custom_factors (optional): Custom factors for axis limits. Default is None. filled (optional): Boolean value indicating whether contour plots should be filled or not. Default is True. contour_args (optional): List of dictionaries specifying contour plot arguments. Default is [{‘alpha’:0.9}]. legend_loc (optional): Location of the legend in the plot. Default is ‘upper right’. dpi (optional): Dots per inch for saving the plot to a file. Default is 300. file_format (optional): File format for saving the plot. Default is ‘.pdf’. marker_color (optional): Color of the axis markers. Default is ‘black’. axes_fontsize (optional): Font size for the axes labels. Default is 20. legend_fontsize (optional): Font size for the legend labels. Default is 20. figure_legend_frame (optional): Frame thickness for the figure legend. Default is 20. axes_labelsize (optional): Font size for the axes tick labels. Default is 20. figure_facecolor (optional): Facecolor of the figure. Default is ‘white’.
- Returns:
None
- Raises:
None –
- Usage:
- instance_name.plot_fisher(axis_custom_factors=create_factors(),
filled=True, contour_args=[{‘alpha’:0.7}], legend_loc=’lower left’, dpi=150, file_format=’.png’, marker_color=’red’, axes_fontsize=16, legend_fontsize=18, figure_legend_frame=10, axes_labelsize=14)
cosmicfishpie.analysis.plot_comparison module
- synopsis:
Module for creating comparison plots of Fisher Matrix entries and related visualizations.
- module author:
Dida Markovic, Santiago Casas, and other contributors to the CosmicFishPie project.
- cosmicfishpie.analysis.plot_comparison.add_colorbar(im, aspect=30, pad_fraction=0.5, **kwargs)[source]
Add a vertical color bar to an image plot.
- cosmicfishpie.analysis.plot_comparison.matrix_plot(matrix, xlabel='Ratio', ticklabels=None, filename='matrixplot.png', figsize=(9, 9), colormap=<matplotlib.colors.ListedColormap object>, savefig=True, dpi=200)[source]
- cosmicfishpie.analysis.plot_comparison.og_plot_shades(ax, x_arr, x_names, lighty_arr=None, darky_arr=None, mats_labels=None, lightdark_names=['marg.', 'unmarg.'], cols=[], plotdark=True, plotlight=True, yrang=None, x_limpad=0.2, fish_leg_loc='upper left', LW=2, colordark='darkgrey', colorlight='lightgrey', alpha=0.7, light_hatch='/', patches_legend_loc='upper right', patches_legend_fontsize=16, dots_legend_fontsize=20, ylabelfontsize=20, ncol_legend=None, colors=None, color_palette='colorblind', legend_title_fontsize=None, legend_title=None, y_label='Differences', yticklabsize=18, xticklabsize=18, xtickfontsize=15, xticksrotation=0)[source]
- cosmicfishpie.analysis.plot_comparison.plot_shades(ax, x_arr, x_names, lighty_arr=None, darky_arr=None, mats_labels=None, lightdark_names=['marg.', 'unmarg.'], plotdark=True, plotlight=True, yrang=None, x_limpad=0.2, fish_leg_loc='upper left', LW=2, colordark='darkgrey', colorlight='lightgrey', alpha=0.7, light_hatch='/', patches_legend_loc='upper right', patches_legend_fontsize=16, dots_legend_fontsize=20, ylabelfontsize=20, ncol_legend=None, colors=None, color_palette='colorblind', legend_title_fontsize=None, legend_title=None, y_label='Differences', yticklabsize=18, xticklabsize=18, xtickfontsize=15, xticksrotation=0)[source]
- cosmicfishpie.analysis.plot_comparison.ploterrs(fishers_list, fishers_name, parstoplot=None, parsnames_latex=None, marginalize_pars=True, plot_style='original', outpathfile='/home/docs/checkouts/readthedocs.org/user_builds/cosmicfishpie/checkouts/latest/docs/source', plot_marg=True, plot_unmarg=True, yrang=None, figsize=(10, 6), fish_leg_loc='lower left', dpi=400, savefig=True, y_label='Errors', ncol_legend=None, colors=None, legend_title_fontsize=None, legend_title=None, yticklabsize=20, xticklabsize=15, patches_legend_fontsize=20, dots_legend_fontsize=20, xtickfontsize=18, ylabelfontsize=20, compare_to_index=False, xticksrotation=0, save_error=False, transform_latex_dict={}, figure_title='')[source]
cosmicfishpie.analysis.utilities module
- synopsis:
A collection of small utilities.
- cosmicfishpie.analysis.utilities.CosmicFish_write_header(name)[source]
This function prints to screen the CosmicFish header. To be called at the beginning of the applications.
- Parameters:
name – string that contains the name of the program. This will be printed along the CosmicFish header.
- cosmicfishpie.analysis.utilities.confidence_coefficient(confidence_level, dimensions=1)[source]
This function returns the number of sigmas given a confidence level. See page 815 of Numerical Recipes, Press et al., 2007 Uses the inverse CDF of the chi squared distribution :type confidence_level: :param confidence_level: desired confidence level. Between 0 and 1. :type confidence_level:
float:return: the coefficient (number of sigmas) for the desired confidence level. :rtype:float
- cosmicfishpie.analysis.utilities.find_nearest(array, value)[source]
This function finds the index of the element in array which is nearest to ValueError :type array: :param array: an array of numbers :type value: :param value: a number :return: the index in array nearest to value :rtype: int
- cosmicfishpie.analysis.utilities.grouper(n, iterable, fillvalue=None)[source]
This small function regroups a list in sub lists of n elements
- Parameters:
n – an element or a list of elements
iterable – input list
fillvalue (default:
None) – value to put to fill if no element is present
- Returns:
a list of list containing grouped elements
- Return type:
- cosmicfishpie.analysis.utilities.make_list(elements)[source]
Checks if elements is a list. If yes returns elements without modifying it. If not creates and return a list with elements inside.
- Parameters:
elements – an element or a list of elements
- Returns:
a list containing elements if elements is not a list, elements otherwise.
- Return type:
- cosmicfishpie.analysis.utilities.mant_exp_to_num(mant_exp)[source]
This function returns a float built with the given (base 10) mantissa and exponent.
- cosmicfishpie.analysis.utilities.mkdirp(dirpath)[source]
This function creates the directory dirpath if it is not found :type dirpath: :param dirpath: string with the path of the directory to be created :return: None :rtype: NoneType
- cosmicfishpie.analysis.utilities.nice_number(num, mode=1, digits=1)[source]
This function returns a nice number built with num. This is useful to build the axes of a plot. The nice number is built by taking the first digit of the number.
- cosmicfishpie.analysis.utilities.num_to_mant_exp(num)[source]
This function returns the (base 10) exponent and mantissa of a number.
- cosmicfishpie.analysis.utilities.print_table(table)[source]
This function prints on the screen a nicely formatted table.
- Parameters:
table – a 2D list that should be printed on the screen.
- cosmicfishpie.analysis.utilities.rel_error_to_index(index, array, percentage=True)[source]
This function returns the percentage difference compared to median of an array for each element :type array: :param array: numpy array of numbers :optional_param percentage: if set to True, returns percentage difference. Default: True :return: difference of each element compared to median of array :rtype: Numpy array
- cosmicfishpie.analysis.utilities.rel_median_error(array, percentage=True)[source]
This function returns the percentage difference compared to median of an array for each element :type array: :param array: numpy array of numbers :optional_param percentage: if set to True, returns percentage difference. Default: True :return: difference of each element compared to median of array :rtype: Numpy array