cosmicfishpie.fishermatrix package
Submodules
cosmicfishpie.configs.config module
- cosmicfishpie.configs.config.init(options={}, specifications={}, observables=None, freepars=None, extfiles=None, fiducialpars=None, photobiaspars=None, photopars=None, IApars=None, PShotpars=None, spectrobiaspars=None, spectrononlinearpars=None, IMbiaspars=None, surveyName='Euclid', cosmoModel='w0waCDM', latexnames=None)[source]
This class is to handle the configuration for the fishermatrix computation as well as the fiducial parameters. It then gives access to all global variables
- Parameters:
options (
dict, optional) – A dictionary that contains the global options for the calculation of the fishermatrix. A list of all possible keys are found belowspecifications (
dict, optional) – A dictionary containing the survey specifications. Defaults to the specifications in the .yaml of the survey specificationsobservables (
list, optional) – A list of strings for the different observablesfreepars (
dict, optional) – A dictionary containing all cosmological parameters to be varied and their corresponding rel. step sizesextfiles (
dict, optional) – A dictionary containing the path to the external files as well as how all the names of the files in the folder correspond to the cosmological quantities, units etc.fiducialpars (
dict, optional) – A dictionary containing the fiducial cosmological parametersphotobiaspars (
dict, optional) – A dictionary containing the specifications for the galaxy biases of the photometric probephotopars (
dict, optional) – A dictionary containing specifications for the window function’s galaxy distributionIApars (
dict, optional) – A dictionary containing the specifications for the intrinsic alignment effect in cosmic shearPShotpars (
dict, optional) – A dictionary containing the values of additional shotnoise of the spectroscopic probesspectrobiaspars (
dict, optional) – A dictionary containing the specifications for the galaxy biases of the spectroscopic probespectrononlinearpars (
dict, optional) – A dictionary containing the values of the non linear modeling parameters of the spectroscopic probeIMbiaspars (
dict, optional) – A dictionary containing the specifications for the galaxy biases of the spectroscopic intensity mapping probesurveyName (
str, optional) – String of the name of the survey for which the forecast is done. Defaults to Euclid with optimistic specificationscosmoModel (
str, optional) – A string of the name of the cosmological model used in the calculations. Defaults to flat “w0waCDM” cosmologylatexnames (
dict, optional) – A dictionary that contains the Latex names of the cosmological parametersOptions
-------
camb_path (
str) – Path to camb. Defaults to the camb in your current environmentspecs_dir (
str) – Path to the survey specifications. Defaults to the specs_dir_defaultspecs_dir_default (
str) – Path to the default survey specifications. Defaults to the survey_specifications folder in the config directory of cosmicfishpiesurvey_name (
str) – String of the names of the survey. Defaults to the name passed in the parameter surveyNamesurvey_name_photo (
str) – Name of the survey specifications file for a photometric probesurvey_name_spectro (
str) – Name of the survey specifications file for a spectrocopic probesurvey_name_radio_IM (
str) – Name of the survey specifications file for a line intensity mapping probederivatives (
str) – String of the name of the derivative method. Either 3PT, 4PT_FWD, STEM or POLY. Defaults to 3PTnonlinear (
bool) – If True will do nonlinear corrections in the computation of the different observables. Defaults to Truenonlinear_photo (
bool) – If True will use the nonlinear power spectrum when calculation the angular power spectrum of the photometric probe. Defaults to Truebfs8terms (
bool) – If True will expand the observed power spectrum with \(\sigma_8\) to match the IST:F recipe. Defaults to Truevary_bias_str (
str) – The root of the name of the bias parameters that should be varied in the spectroscopic probe. Defaults to ‘lnb’AP_effect (
bool) – If True the Alcock-Paczynsk effect will be considered in the spectroscopic probe. Defaults to TrueFoG_switch (
bool) – If True the finger of god effect will be modelled in the observed power spectrum of the spectroscopic probe. Defaults to TrueGCsp_linear (
bool) – If True there will be no nonlinear modelling used in the spectroscopic probe. Defaults to Falsefix_cosmo_nl (
bool) – If True and the nonlinear modeling parameters are not varied, then they will be fixed to the values computed in the fiducial cosmology. Else they will be recomputed in each sample cosmology. Defaults to TruePshot_nuisance_fiducial (
float) – Value of the fiducial additional shotnoise of the spectroscopic probe. Defaults to 0.0pivot_z_IA (
float) – Redshift on which the power law dependance in the eNLA model of intrinsic alignment should be normalized to. Defaults to 0.0accuracy (
int) – Global rescaling of the amount of points that are used in internal calculations or interpolations for the probes. Defaults to 1feedback (
int) – Number indicating the verbosity of the output. Higher numbers generally mean more output. Defaults to 2activateMG (
bool) – If True will also consider modified gravity in the calculations of the observables. Defaults to Falseexternal_activateMG (
bool) – If True while reading the external Files will also look for files specific to modified gravity modelscosmo_model (
str) – A string of the name of the cosmological model used in the calculations. Defaults to what was passed in the parameter cosmoModeloutroot (
str) – The name of the output files are always starting with CosmicFish_Version number_outroot. Defaults to ‘default_run’code (
str) – String of the method to obtain the cosmological functions such as the power spectrum. Either ‘camb’, ‘class’ or ‘external’. Defaults to ‘camb’memorize_cosmo (
bool) – If True will save and load cosmologies that have already been computed in the cache. Defaults to Falseresults_dir (
str) – Name of the folder in which the results should be saved. If the folder does not exist will create a new one. Defaults to ‘./results’boltzmann_yaml_path (
str) – Path to the configurations for the Einstein-Boltzmann solvers. Defaults to the boltzmann_yaml_files folder in the home directory of cosmicfishpieclass_config_yaml (
str) – Path to the configurations for class. Defaults to ‘boltzmann_yaml_path/class/default.yaml’camb_config_yaml (
str) – Path to the configurations for camb. Defaults to ‘boltzmann_yaml_path/camb/default.yaml’fishermatrix_file_extension (
str) – Specifies in what kind of file the result Fisher matrix should be saved. Defaults to ‘.txt’savgol_polyorder (
float) – Order of the Savitzky-Golay filter. Defaults to 3 matching the IST:F recipesavgol_width (
float) – Width of the Savitzky-Golay filter. Defaults to ~1.359savgol_internalsamples (
float) – How many points on a logarithmic k axis should be taken to apply the Savitzky-Golay filter to. Defaults to 800savgol_internalkmin (
float) – Lowest wavenumber that should be used when calculating when applying the Savitzky-Golay filter. Defaults to 1e-3. Together with the other defaults this is matching the IST:F recipeeps_cosmopars (
float) – The default rel. step size of the cosmological parameters if none have been passed. Defaults to 1e-2eps_gal_nuispars (
float) – The default rel. step size of the bias parameters if none have been passed. Defaults to 1e-4GCsp_Tracer (
str) – What power spectrum should be used as the underlying power spectrum the spectroscopic probe’s galaxy clustering traces. Either ‘matter’ for the total matter spectrum or ‘clustering’ for CDM+baryons. Defaults to ‘matter’GCph_Tracer (
str) – What power spectrum should be used as the underlying power spectrum the photometric probe’s galaxy clustering traces. Either ‘matter’ for the total matter spectrum or ‘clustering’ for CDM+baryons. Defaults to ‘matter’ShareDeltaNeff (
bool) – If True, the variation of the cosmological parameter Neff is understood as a rescaling of the decoupling temperature of neutrinos. If False any additional Neff is accounted for as additional massless relics.kh_rescaling_bug (
bool) – If true, the internal wavenumber in the computation of the spectroscopic probe’s power spectrum computation will be rescaled by an adtional factor h/hfid. Default Falsekh_rescaling_beforespecerr_bug (
bool) – If True, the internal scales in the computation of the spectroscopic probe’s resolution error will be rescaled by an adtional factor h/hfid. Default False
- cosmicfishpie.configs.config.settings
A dictionary containing all the global options passed as well as the default values of the ones not passed
- Type:
dict,global
- cosmicfishpie.configs.config.external
A dictionary containing all paths to the external files, how all the names of the files in the folder correspond to the cosmological quantities, the units etc. Will be None if no external files are given
- Type:
dict,global
- cosmicfishpie.configs.config.input_type
String of the method to obtain the cosmological functions such as the power spectrum. Either ‘camb’, ‘class’ or ‘external’
- Type:
str,global
- cosmicfishpie.configs.config.specs
A dictionary containing the survey specifications
- Type:
dict,global
- cosmicfishpie.configs.config.boltzmann_classpars
A dictionary containing the configuration, precision parameters, and fixed cosmological parameters for class
- Type:
dict,global
- cosmicfishpie.configs.config.boltzmann_cambpars
A dictionary containing the configuration, precision parameters, and fixed cosmological parameters for camb
- Type:
dict,global
- cosmicfishpie.configs.config.survey_equivalence
Part of the Parser, will correspond the passed survey to the name of a specifications file
- Type:
callable,global
- cosmicfishpie.configs.config.obs
A list of strings for the different observables
- Type:
list,global
- cosmicfishpie.configs.config.freeparams
A dictionary containing all names and the corresponding rel. step size for all parameters
- Type:
dict,global
- cosmicfishpie.configs.config.fiducialparams
A dictionary containing all fiducial values for the cosmological parameters
- Type:
dict,global
- cosmicfishpie.configs.config.fiducialcosmo
An instance of cosmo_functions of the fiducial cosmology, this contains all the cosmological functions and quantities computed from them
- Type:
- cosmicfishpie.configs.config.biasparams
a dictionary containing the specifications for the galaxy biases of the photometric probe
- Type:
dict,global
- cosmicfishpie.configs.config.photoparams
A dictionary containing specifications for the window function’s galaxy distribution of the photometric probe
- Type:
dict,global
- cosmicfishpie.configs.config.IAparams
A dictionary containing the specifications for the intrinsic alignment effect in cosmic shear of the photometric probe
- Type:
dict,global
- cosmicfishpie.configs.config.PShotparams
A dictionary containing the values of the additional shot noise per bin dictionary containing the values of the additional shot noise per bin for the spectroscopic probe
- Type:
dict,global
- cosmicfishpie.configs.config.Spectrobiasparams
A dictionary containing the specifications for the galaxy biases of the spectroscopic probe
- Type:
dict,global
- cosmicfishpie.configs.config.Spectrononlinearparams
A dictionary containing the values of the non linear modeling parameters entering FOG and the dewiggling weight per bin for the spectroscopic probe
- Type:
dict,global
cosmicfishpie.fishermatrix.cosmicfish module
MAIN
This is the main engine of CosmicFish.
- class cosmicfishpie.fishermatrix.cosmicfish.FisherMatrix(options={}, specifications={}, observables=None, freepars=None, extfiles=None, fiducialpars=None, photobiaspars=None, photopars=None, spectrononlinearpars=None, spectrobiaspars=None, IApars=None, IMbiaspars=None, PShotpars=None, surveyName='Euclid', cosmoModel='w0waCDM', latexnames=None, parallel=False, parallel_cpus=4)[source]
Bases:
object- compute(max_z_bins=None)[source]
This function will compute the Fisher information matrix and export using the specified settings.
- Parameters:
max_z_bins (
int) – For the spectroscopic probe what the highest redshift bin that should be considered in the computation of the Fisher- Returns:
A instance of fisher_matrix containing the calculated Fisher matrix as well as parameter names, settings, etc
- Return type:
- compute_binned_derivs(z_arr)[source]
This computes the derivatives of the observed power spectrum for all redshift bins
- Parameters:
z_arr (
list,numpy.ndarray) – List of the redshift bin centers of the probe- Returns:
A dictionary containing lists of derivatives of the observed power spectrum for each redshift bin and varied parameter
- Return type:
- eliminate_zbinned_freepars(nmax)[source]
This helper function is there to find any parameters passed that correspond to no zbin. It will then remove them from the varied parameters list
- Parameters:
nmax (
int) – Index of the highest redshift bin that should be considered
- export_fisher(fishmat, totaltime=None)[source]
Will print the fisher matrix as well as specifications and the parameter names to files. To change location and filenames for this check the settings dictionary of cosmicfishpie.configs.config
- Parameters:
fishmat (
numpy.ndarray) – Computed Fisher matrixtotaltime (
float, optional) – Total time needed to compute the fisher. Will print time information if passed
- Returns:
A instance of fisher_matrix containing the calculated Fisher matrix as well as parameter names, settings, etc
- Return type:
- fish_integrand(zi, k, mu, pi, pj)[source]
Helper function to calculate the integrand that enters the computation of the Fisher elements.
- Parameters:
zi (
int) – index of the redshift bink (
numpy.ndarray) – grid of wavenumbers used in the calculation. Has to be the internal kmeshmu (
numpy.ndarray) – grid of observation angles used in the calculation. Has to be the internal mumeshpi (
str) – name of the first parameterpj (
str) – name of the second parameter
- Returns:
Integrant that enters the Fisher matrix element computation. The shape matches ( shape of the kmesh ) x ( shape of mumesh)
- Return type:
- fisher_calculation(zi, p_i, p_j)[source]
This helper function calculates a singular element of the fisher matrix
- fisher_integral(integrand)[source]
Function to calculate the integral that enters the computation of the Fisher elements. Uses a simpson integration on the mu and k grid
- Parameters:
integrand (
numpy.ndarray) – Integrant that enters the Fisher matrix element computation. The shape needs to match ( shape of the kmesh ) x ( shape of mumesh)- Returns:
The Fisher matrix element computed from the derivative with respect to two parameters at a given redshift bin for a spectroscopic probe
- Return type:
- fisher_per_bin(ibin)[source]
This helper function contains the Fisher matrix of a spectroscopic probe for a single redshift bin
- Parameters:
ibin (
int) – index of the redshift bin- Returns:
Fisher matrix of a spectroscopic probe for a single redshift bin
- Return type:
- photo_LSS_fishermatrix(noisy_cls=None, covmat=None, derivs=None, lss_obj=None)[source]
Compute the Fisher matrix of a photometric probe.
- Parameters:
noisy_cls (
dict, optional) – a dictionary with all the auto and cross correlation fiducial angular power spectra with noise added to it. Will recompute from lss_obj when not passedcovmat (
list, optional) – A list of pandas.DataFrame objects that store the covariance matrix for each multipole. Will recompute from lss_obj when not passedderivs (
dict, optional) – A dictionary containing the derivatives of the angular power spectrum at the fiducial for all free parameters. Will recompute from lss_obj when not passedlss_obj (
cosmicfishpie.LSSsurvey.photo_cov.PhotoCov, optional) – This object is used to compute the ingredients of the Fisher matrix if they were not passed
- Returns:
The full fisher matrix for the photometric probe
- Return type:
- photo_LSS_fishermatrix_einsum(noisy_cls=None, covmat=None, derivs=None, lss_obj=None)[source]
Compute the Fisher matrix of a photometric probe.
- Parameters:
noisy_cls (
dict, optional) – a dictionary with all the auto and cross correlation fiducial angular power spectra with noise added to it. Will recompute from lss_obj when not passedcovmat (
list, optional) – A list of pandas.DataFrame objects that store the covariance matrix for each multipole. Will recompute from lss_obj when not passedderivs (
dict, optional) – A dictionary containing the derivatives of the angular power spectrum at the fiducial for all free parameters. Will recompute from lss_obj when not passedlss_obj (
cosmicfishpie.LSSsurvey.photo_cov.PhotoCov, optional) – This object is used to compute the ingredients of the Fisher matrix if they were not passed
- Returns:
The full fisher matrix for the photometric probe
- Return type:
- pk_LSS_Fisher(nbins)[source]
This computes the Fisher matrix of a spectroscopic probe for all redshift bins
- Parameters:
nbins (
int) – number of redshift bins the spectroscopic probe has- Returns:
A list of Fisher matrices for each redshift bin
- Return type:
- set_pk_settings()[source]
Function to define grids of the internal wavenumber and observation angle
Note
This is not a setter function. Rather the internal grids are constructed from the passed options and then they are stored in the attributes Pk_kgrid and Pk_mugrid as well as the combined meshes Pk_kmesh and Pk_mumesh.
- cf_version = 'CosmicFish_v1.3.0'
cosmicfishpie.fishermatrix.derivatives module
DERIVATIVES
This is the derivatives engine of CosmicFish.
- class cosmicfishpie.fishermatrix.derivatives.derivatives(observable, fiducial, special_deriv_function=None, derivatives_type='3PT', freeparams={}, observables_type=None, external_settings=None, feed_lvl=None)[source]
Bases:
object- der_3pt_stencil(fwd, bwd, step)[source]
Helper function to compute the 3PT symmetrical finite step size derivative
- Parameters:
fwd (
float,numpy.ndarray) – Observable computed at the forward stepfwd – Observable computed at the backwards step
step (
float) – Absolute step size of the numerical derivative
- Returns:
Numerical derivative using the a 3 point stencil
- Return type:
- der_fwd_4pt(fwdi, step)[source]
Helper function to compute the 4PT forward finite step size derivative
- Parameters:
fwdi (
list,numpy.ndarray) – Observable computed at the fiducial and at equally spaced points in the forward directionstep (
float) – Absolute distance between the size of the numerical derivative
- Returns:
Numerical derivative using the a 4 point forward stencil
- Return type:
- derivative_3pt()[source]
One of the possible derivative methods. Computes the numerical derivative using a finite differences 3 point symmetrical derivative
- Returns:
A dictionary containing the derivative of the observable for each varied parameter.
- Return type:
Note
Implements the following equation:
\[\frac{\mathrm{d} \mathcal{O}}{\mathrm{d} \theta} = \frac{\mathcal{O}(\theta+h)-\mathcal{O}(\theta-h)}{2\,h}\]
- derivative_forward_4pt()[source]
One of the possible derivative methods. Computes the numerical derivative using a finite differences one-sided 4 point forward derivative. Taken from: https://web.media.mit.edu/~crtaylor/calculator.html @misc{fdcc, title={Finite Difference Coefficients Calculator}, author={Taylor, Cameron R.}, year={2016}, howpublished=”url{https://web.media.mit.edu/~crtaylor/calculator.html}” }
- Returns:
A dictionary containing the derivative of the observable for each varied parameter.
- Return type:
Note
Implements the following equation:
\[\begin{split}\\frac{\\mathrm{d} \\mathcal{O}}{\\mathrm{d} \\theta} = \\frac{-11\\,\\mathcal{O}(\\theta)+18\\,\\mathcal{O}(\\theta+h)-9\\,\\mathcal{O}(\\theta+2\\,)+2\\,\\mathcal{O}(\\theta+3\\,h)}{6\\,h}\end{split}\]