Skip to content

Commit

Permalink
Merge pull request #401 from LSSTDESC/sigma8_fix
Browse files Browse the repository at this point in the history
replaced sigma_8 -> sigma8
  • Loading branch information
damonge committed Jul 4, 2018
2 parents ab6129c + 2205f1d commit b4e676e
Show file tree
Hide file tree
Showing 24 changed files with 195 additions and 249 deletions.
42 changes: 20 additions & 22 deletions examples/Distance Calculations Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
Expand Down Expand Up @@ -55,18 +53,20 @@
" Omega_b: 0.045\n",
" Omega_m: 0.315\n",
" Omega_k: 0.0\n",
" Omega_l: 0.684927855904\n",
" Omega_l: 0.684906869231\n",
" w0: -1.0\n",
" wa: 0.0\n",
" H0: 67.0\n",
" h: 0.67\n",
" A_s: 2.1e-09\n",
" n_s: 0.96\n",
" N_nu_rel: 3.046\n",
" N_nu_mass: 0.0\n",
" mnu: 0.0\n",
" bcm_log10Mc: 14.079181246\n",
" bcm_etab: 0.5\n",
" bcm_ks: 55.0\n",
" Neff: 3.046\n",
" mnu: <Swig Object of type 'double *' at 0x7fe2c4abecc0>\n",
" Omega_n_mass: 0.0\n",
" Omega_n_rel: 1.70947512533e-05\n",
" Omega_n_rel: 3.80814240441e-05\n",
" T_CMB: 2.725\n",
" Omega_g: 5.50493446829e-05\n",
" z_star: nan\n",
Expand All @@ -81,7 +81,7 @@
"\n",
"Status\n",
"------\n",
"status(0): C\n"
"status(0): \n"
]
}
],
Expand All @@ -93,7 +93,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As you can see, a number of cosmological parameters have been set to default values, or derived from the input parameters. Some, like `sigma_8`, have been left undefined; this is because calculating them from the input parameters is non-trivial, so this will only be done if needed (or if the user explicitly requests it)."
"As you can see, a number of cosmological parameters have been set to default values, or derived from the input parameters. Some, like `sigma8`, have been left undefined; this is because calculating them from the input parameters is non-trivial, so this will only be done if needed (or if the user explicitly requests it)."
]
},
{
Expand Down Expand Up @@ -139,7 +139,7 @@
{
"data": {
"text/plain": [
"1962.9612048132053"
"1962.9391106362025"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -167,9 +167,9 @@
{
"data": {
"text/plain": [
"array([ 0. , 436.69947016, 851.39817459, 1243.79753712,\n",
" 1614.11360802, 1962.96120481, 2291.23813831, 2600.02282463,\n",
" 2890.49121176, 3163.8538544 ])"
"array([ 0. , 436.6985085 , 851.39441823, 1243.7892696 ,\n",
" 1614.09913239, 1962.93911064, 2291.20727173, 2599.98206626,\n",
" 2890.43969486, 3163.7908473 ])"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -197,7 +197,7 @@
{
"data": {
"text/plain": [
"1962.9612048132053"
"1962.9391106362025"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -225,7 +225,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Radial Dist. = 1992.55 Mpc \t Angular Dist. = 1999.14 Mpc\n"
"Radial Dist. = 1992.53 Mpc \t Angular Dist. = 1999.12 Mpc\n"
]
}
],
Expand Down Expand Up @@ -254,7 +254,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Luminosity Dist = 2944.44 Mpc \t Distance Modulus = 42.35 \n"
"Luminosity Dist = 2944.41 Mpc \t Distance Modulus = 42.34 \n"
]
}
],
Expand All @@ -279,7 +279,7 @@
{
"data": {
"text/plain": [
"0.6666668249534857"
"0.6666639271123571"
]
},
"execution_count": 10,
Expand All @@ -294,9 +294,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
Expand All @@ -317,7 +315,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.12"
}
},
"nbformat": 4,
Expand Down
6 changes: 2 additions & 4 deletions examples/MCMC Likelihood Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"z = np.linspace(0., 3., 200)\n",
Expand Down Expand Up @@ -440,7 +438,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.12"
}
},
"nbformat": 4,
Expand Down
32 changes: 16 additions & 16 deletions examples/Power spectrum example.ipynb

Large diffs are not rendered by default.

166 changes: 58 additions & 108 deletions examples/SLAC Feb2018 Demo.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/ccl_sample_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ int main(int argc, char * argv[])
return NAN;
}
}
printf("sigma_8 = %.6lE\n", ccl_sigmaR(cosmo,8./h,&status));
printf("Consistency check: sigma_8 = %.6lE\n", ccl_sigma8(cosmo,&status));
printf("sigma8 = %.6lE\n", ccl_sigmaR(cosmo,8./h,&status));
printf("Consistency check: sigma8 = %.6lE\n", ccl_sigma8(cosmo,&status));
printf("Completed. Status = %d\n",status);

ccl_cosmology_free(cosmo);
Expand Down
4 changes: 2 additions & 2 deletions examples/ccl_sample_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ int main(int argc,char **argv)
rhom = ccl_rho_x(cosmo, 1., ccl_species_m_label, isco, &status);
printf("%i\t%.3f\t%.3f\t%.3f\t%.3e\t%.3e\t%.3e\n", 0, Om, OL, Or, rhoc, rhom, RHO_CRITICAL);

// Compute sigma_8
// Compute sigma8
printf("Initializing power spectrum...\n");
printf("sigma_8 = %.3lf\n\n", ccl_sigma8(cosmo, &status));
printf("sigma8 = %.3lf\n\n", ccl_sigma8(cosmo, &status));

//Create tracers for angular power spectra
double z_arr_gc[NZ],z_arr_sh[NZ],nz_arr_gc[NZ],nz_arr_sh[NZ],bz_arr[NZ];
Expand Down
14 changes: 7 additions & 7 deletions include/ccl_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef struct ccl_parameters {
double bcm_ks;

// Derived parameters
double sigma_8;
double sigma8;
double Omega_l;
double z_star;

Expand Down Expand Up @@ -183,7 +183,7 @@ ccl_cosmology * ccl_cosmology_create_with_lcdm_params(
* @param w0 Dark energy EoS parameter
* @param wa Dark energy EoS parameter
* @param h Hubble constant in units of 100 km/s/Mpc
* @param norm_pk the normalization of the power spectrum, either A_s or sigma_8
* @param norm_pk the normalization of the power spectrum, either A_s or sigma8
* @param n_s the power-law index of the power spectrum
* @param bcm_log10Mc log10 cluster mass, one of the parameters of the BCM model
* @param bcm_etab ejection radius parameter, one of the parameters of the BCM model
Expand All @@ -210,7 +210,7 @@ ccl_parameters ccl_parameters_create(double Omega_c, double Omega_b, double Omeg
* @param Omega_c Omega_c
* @param Omega_b Omega_b
* @param h Hubble constant in units of 100 km/s/Mpc
* @param norm_pk the normalization of the power spectrum, either A_s or sigma_8
* @param norm_pk the normalization of the power spectrum, either A_s or sigma8
* @param n_s the power-law index of the power spectrum
* @param status Status flag. 0 if there are no errors, nonzero otherwise.
* For specific cases see documentation for ccl_error.c
Expand All @@ -223,7 +223,7 @@ ccl_parameters ccl_parameters_create_flat_lcdm(double Omega_c, double Omega_b, d
* @param Omega_c Omega_c
* @param Omega_b Omega_b
* @param h Hubble constant in units of 100 km/s/Mpc
* @param norm_pk the normalization of the power spectrum, either A_s or sigma_8
* @param norm_pk the normalization of the power spectrum, either A_s or sigma8
* @param n_s the power-law index of the power spectrum
* @param bcm_log10Mc log10 cluster mass, one of the parameters of the BCM model
* @param bcm_etab ejection radius parameter, one of the parameters of the BCM model
Expand All @@ -242,7 +242,7 @@ ccl_parameters ccl_parameters_create_flat_lcdm_bar(double Omega_c, double Omega_
* @param Omega_b Omega_b
* @param w0 Dark energy EoS parameter
* @param h Hubble constant in units of 100 km/s/Mpc
* @param norm_pk the normalization of the power spectrum, either A_s or sigma_8
* @param norm_pk the normalization of the power spectrum, either A_s or sigma8
* @param n_s the power-law index of the power spectrum
* @param status Status flag. 0 if there are no errors, nonzero otherwise.
* For specific cases see documentation for ccl_error.c
Expand All @@ -257,7 +257,7 @@ ccl_parameters ccl_parameters_create_flat_wcdm(double Omega_c, double Omega_b, d
* @param w0 Dark energy EoS parameter
* @param wa Dark energy EoS parameter
* @param h Hubble constant in units of 100 km/s/Mpc
* @param norm_pk the normalization of the power spectrum, either A_s or sigma_8
* @param norm_pk the normalization of the power spectrum, either A_s or sigma8
* @param n_s the power-law index of the power spectrum
* @param status Status flag. 0 if there are no errors, nonzero otherwise.
* For specific cases see documentation for ccl_error.c
Expand All @@ -273,7 +273,7 @@ ccl_parameters ccl_parameters_create_flat_wacdm(double Omega_c, double Omega_b,
* @param w0 Dark energy EoS parameter
* @param wa Dark energy EoS parameter
* @param h Hubble constant in units of 100 km/s/Mpc
* @param norm_pk the normalization of the power spectrum, either A_s or sigma_8
* @param norm_pk the normalization of the power spectrum, either A_s or sigma8
* @param n_s the power-law index of the power spectrum
* @param status Status flag. 0 if there are no errors, nonzero otherwise.
* For specific cases see documentation for ccl_error.c
Expand Down
6 changes: 3 additions & 3 deletions include/ccl_power.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ double ccl_nonlin_matter_power(ccl_cosmology * cosmo, double k, double a,int * s
double ccl_sigmaR(ccl_cosmology *cosmo, double R, int * status);

/**
* Computes sigma_8, variance of the matter density field with (top-hat) smoothing scale R = 8 Mpc/h, from linear power spectrum.
* Returns sigma_8 for specified cosmology.
* Computes sigma8, variance of the matter density field with (top-hat) smoothing scale R = 8 Mpc/h, from linear power spectrum.
* Returns sigma8 for specified cosmology.
* @param cosmo Cosmology parameters and configurations
* @param status Status flag. 0 if there are no errors, nonzero otherwise.
* For specific cases see documentation for ccl_error.c
* @return sigma_8.
* @return sigma8.
*/
double ccl_sigma8(ccl_cosmology *cosmo, int * status);

Expand Down
18 changes: 9 additions & 9 deletions src/ccl_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const ccl_gsl_params default_gsl_params = {GSL_EPSREL,
The following are the relevant global variables:
*/

ccl_spline_params * ccl_splines; // Global variable
ccl_gsl_params * ccl_gsl; // Global variable
ccl_spline_params * ccl_splines=NULL; // Global variable
ccl_gsl_params * ccl_gsl=NULL; // Global variable

void ccl_cosmology_read_config(void)
{
Expand Down Expand Up @@ -208,7 +208,7 @@ mnu_type: how the neutrino mass(es) should be treated
w0: Dark energy eqn. of state parameter
wa: Dark energy eqn. of state parameter, time variation
h: Hubble's constant divided by (100 km/s/Mpc).
norm_pk: amplitude of the primordial PS (either A_s or sigma_8)
norm_pk: amplitude of the primordial PS (either A_s or sigma8)
n_s: index of the primordial PS
*/
ccl_cosmology * ccl_cosmology_create_with_params(double Omega_c, double Omega_b, double Omega_k,
Expand Down Expand Up @@ -247,7 +247,7 @@ Omega_c: cold dark matter
Omega_b: baryons
Omega_k: curvature
h: Hubble's constant divided by (100 km/s/Mpc).
norm_pk: amplitude of the primordial PS (either A_s or sigma_8)
norm_pk: amplitude of the primordial PS (either A_s or sigma8)
n_s: index of the primordial PS
*/
ccl_cosmology * ccl_cosmology_create_with_lcdm_params(double Omega_c, double Omega_b, double Omega_k,
Expand All @@ -274,7 +274,7 @@ Omega_g = (Omega_g*h^2)/h^2 is the radiation parameter; "g" is for photons, as i
T_CMB: CMB temperature in Kelvin
Omega_l: Lambda
A_s: amplitude of the primordial PS, enforced here to initially set to NaN
sigma_8: variance in 8 Mpc/h spheres for normalization of matter PS, enforced here to initially set to NaN
sigma8: variance in 8 Mpc/h spheres for normalization of matter PS, enforced here to initially set to NaN
z_star: recombination redshift
*/
void ccl_parameters_fill_initial(ccl_parameters * params, int *status)
Expand Down Expand Up @@ -311,8 +311,8 @@ void ccl_parameters_fill_initial(ccl_parameters * params, int *status)
params->Omega_l = 1.0 - params->Omega_m - params->Omega_g - params->Omega_n_rel -params->Omega_n_mass- params->Omega_k;
// Initially undetermined parameters - set to nan to trigger
// problems if they are mistakenly used.
if (isfinite(params->A_s)) {params->sigma_8 = NAN;}
if (isfinite(params->sigma_8)) {params->A_s = NAN;}
if (isfinite(params->A_s)) {params->sigma8 = NAN;}
if (isfinite(params->sigma8)) {params->A_s = NAN;}
params->z_star = NAN;

if(fabs(params->Omega_k)<1E-6)
Expand Down Expand Up @@ -362,7 +362,7 @@ ccl_parameters ccl_parameters_create(
params.mnu = NULL;
params.z_mgrowth=NULL;
params.df_mgrowth=NULL;
params.sigma_8 = NAN;
params.sigma8 = NAN;
params.A_s = NAN;
params.Omega_c = Omega_c;
params.Omega_b = Omega_b;
Expand Down Expand Up @@ -485,7 +485,7 @@ ccl_parameters ccl_parameters_create(
if(norm_pk<1E-5)
params.A_s=norm_pk;
else
params.sigma_8=norm_pk;
params.sigma8=norm_pk;
params.n_s = n_s;

//Baryonic params
Expand Down
2 changes: 1 addition & 1 deletion src/ccl_emu17.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static void emu(double *xstar, double **ystar, int* status, ccl_cosmology* cosmo
break;
case 2:
sprintf(cosmo->status_message,
"ccl_pkemu(): sigma_8 must be between %f and %f.\n",
"ccl_pkemu(): sigma8 must be between %f and %f.\n",
xmin[i], xmax[i]);
break;
case 3:
Expand Down

0 comments on commit b4e676e

Please sign in to comment.