Skip to content

Commit

Permalink
Merge pull request #329 from LSSTDESC/README_addcmb
Browse files Browse the repository at this point in the history
Update README to reflect current ccl_sample_run
  • Loading branch information
elisachisari committed Feb 13, 2018
2 parents 75b72bc + bd78f83 commit c58d0ad
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 deletions.
67 changes: 41 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ where `smooth_mass` is mass smoothing scale (in units of *M_sun*) and `odelta` i
### LSST Specifications
`CCL` includes LSST specifications for the expected galaxy distributions of the full galaxy clustering sample and the lensing source galaxy sample. Start by defining a flexible photometric redshift model given by function
````c
double (* your_pz_func)(double z_ph, double z_spec, void *param, int * status);
double (* your_pz_func)(double z_ph, double z_s, void *param, int * status);
````
which returns the likelihood of measuring a particular photometric redshift `z_ph` given a spectroscopic redshift `z_spec`, with a pointer to additional arguments `param` and a status flag. Then you call function **`ccl_specs_create_photoz_info`**
which returns the likelihood of measuring a particular photometric redshift `z_ph` given a spectroscopic redshift `z_s`, with a pointer to additional arguments `param` and a status flag. Then you call function **`ccl_specs_create_photoz_info`**
````c
user_pz_info* ccl_specs_create_photoz_info(void * user_params,
double(*user_pz_func)(double, double, void*, int*));
Expand Down Expand Up @@ -372,32 +372,34 @@ where `/path/to/install/` is the path to the location where the library has been
#define MNU 0.0
// The user defines a structure of parameters
// The user defines a structure of parameters
// to the user-defined function for the photo-z probability
struct user_func_params
{
double (* sigma_z) (double);
};
// The user defines a function of the form double function ( z_ph, z_spec, void * user_pz_params)
// where user_pz_params is a pointer to the parameters of the user-defined function.
// This returns the probability of obtaining a given photo-z given a particular spec_z.
double user_pz_probability(double z_ph, double z_spec, void * user_par, int * status)
// The user defines a function of the form double function ( z_ph, z_s, void * user_pz_params)
// where user_pz_params is a pointer to the parameters of the user-defined function.
// This returns the probabilty of obtaining a given photo-z given a particular spec_z.
double user_pz_probability(double z_ph, double z_s, void * user_par, int * status)
{
double sigma_z = ((struct user_func_params *) user_par)->sigma_z(z_spec);
return exp(- (z_ph-z_spec)*(z_ph-z_spec) / (2.*sigma_z*sigma_z)) / (pow(2.*M_PI,0.5)*sigma_z);
double sigma_z = ((struct user_func_params *) user_par)->sigma_z(z_s);
return exp(- (z_ph-z_s)*(z_ph-z_s) / (2.*sigma_z*sigma_z)) / (pow(2.*M_PI,0.5)*sigma_z);
}
int main(int argc,char **argv)
{
//status flag
int status = 0;
int status =0;
// Initialize cosmological parameters
ccl_configuration config = default_config;
config.transfer_function_method = ccl_boltzmann_class;
ccl_configuration config=default_config;
config.transfer_function_method=ccl_boltzmann_class;
ccl_parameters params = ccl_parameters_create(OC, OB, OK, NREL, NMAS, MNU, W0, WA, HH,
NORMPS, NS,0,NULL,NULL, &status);
NORMPS, NS,-1,-1,-1,-1,NULL,NULL, &status);
//printf("in sample run w0=%1.12f, wa=%1.12f\n", W0, WA);
// Initialize cosmology object given cosmo params
ccl_cosmology *cosmo=ccl_cosmology_create(params,config);
Expand All @@ -410,6 +412,7 @@ int main(int argc,char **argv)
printf("Distance modulus to z = %.3lf is mu = %.3lf Mpc\n",
ZD,ccl_distance_modulus(cosmo,1./(1+ZD), &status));
//Consistency check
printf("Scale factor is a=%.3lf \n",1./(1+ZD));
printf("Consistency: Scale factor at chi=%.3lf Mpc is a=%.3lf\n",
Expand All @@ -424,14 +427,14 @@ int main(int argc,char **argv)
printf("z\tOmega_m\tOmega_L\tOmega_r\n");
double Om, OL, Or;
for (int z=10000;z!=0;z/=3){
Om = ccl_omega_x(cosmo, 1./(z+1), 0, &status);
OL = ccl_omega_x(cosmo, 1./(z+1), 1, &status);
Or = ccl_omega_x(cosmo, 1./(z+1), 2, &status);
Om = ccl_omega_x(cosmo, 1./(z+1), ccl_omega_m_label, &status);
OL = ccl_omega_x(cosmo, 1./(z+1), ccl_omega_l_label, &status);
Or = ccl_omega_x(cosmo, 1./(z+1), ccl_omega_g_label, &status);
printf("%i\t%.3f\t%.3f\t%.3f\n", z, Om, OL, Or);
}
Om = ccl_omega_x(cosmo, 1., 0, &status);
OL = ccl_omega_x(cosmo, 1., 1, &status);
Or = ccl_omega_x(cosmo, 1., 2, &status);
Om = ccl_omega_x(cosmo, 1., ccl_omega_m_label, &status);
OL = ccl_omega_x(cosmo, 1., ccl_omega_l_label, &status);
Or = ccl_omega_x(cosmo, 1., ccl_omega_g_label, &status);
printf("%i\t%.3f\t%.3f\t%.3f\n", 0, Om, OL, Or);
// Compute sigma_8
Expand All @@ -448,23 +451,30 @@ int main(int argc,char **argv)
nz_arr_sh[i]=exp(-0.5*pow((z_arr_sh[i]-Z0_SH)/SZ_SH,2));
}
//CMB lensing tracer
CCL_ClTracer *ct_cl=ccl_cl_tracer_cmblens_new(cosmo,1100.,&status);
//Galaxy clustering tracer
CCL_ClTracer *ct_gc=ccl_cl_tracer_number_counts_simple_new(cosmo,NZ,z_arr_gc,nz_arr_gc,NZ,
z_arr_gc,bz_arr, &status);
CCL_ClTracer *ct_gc=ccl_cl_tracer_number_counts_simple_new(cosmo,NZ,
z_arr_gc,nz_arr_gc,NZ,z_arr_gc,bz_arr, &status);
//Cosmic shear tracer
CCL_ClTracer *ct_wl=ccl_cl_tracer_lensing_simple_new(cosmo,NZ,z_arr_sh,nz_arr_sh, &status);
printf("ell C_ell(g,g) C_ell(g,s) C_ell(s,s) | r(g,s)\n");
printf("ell C_ell(c,c) C_ell(c,g) C_ell(c,s) C_ell(g,g) C_ell(g,s) C_ell(s,s) \n");
for(int l=2;l<=NL;l*=2) {
double cl_cc=ccl_angular_cl(cosmo,l,ct_cl,ct_cl, &status); //CMBLensing-CMBLensing
double cl_cg=ccl_angular_cl(cosmo,l,ct_cl,ct_gc, &status); //CMBLensing-Clustering
double cl_cs=ccl_angular_cl(cosmo,l,ct_wl,ct_cl, &status); //CMBLensing-Galaxy lensing
double cl_gg=ccl_angular_cl(cosmo,l,ct_gc,ct_gc, &status); //Galaxy-galaxy
double cl_gs=ccl_angular_cl(cosmo,l,ct_gc,ct_wl, &status); //Galaxy-lensing
double cl_ss=ccl_angular_cl(cosmo,l,ct_wl,ct_wl, &status); //Lensing-lensing
printf("%d %.3lE %.3lE %.3lE | %.3lE\n",l,cl_gg,cl_gs,cl_ss,cl_gs/sqrt(cl_gg*cl_ss));
printf("%d %.3lE %.3lE %.3lE %.3lE %.3lE %.3lE\n",l,cl_cc,cl_cg,cl_cs,cl_gg,cl_gs,cl_ss);
}
printf("\n");
//Free up tracers
ccl_cl_tracer_free(ct_gc);
ccl_cl_tracer_free(ct_cl);
ccl_cl_tracer_free(ct_wl);
//Halo mass function
Expand All @@ -482,8 +492,7 @@ int main(int argc,char **argv)
printf("Halo bias: z, M, b1(M,z)\n");
for(int logM=9;logM<=15;logM+=1) {
for(double z=0; z<=1; z+=0.5) {
printf("%.1e %.1e %.2e\n",1.0/(1.0+z),pow(10,logM),
ccl_halo_bias(cosmo,pow(10,logM),1.0/(1.0+z), 200., &status));
printf("%.1e %.1e %.2e\n",1.0/(1.0+z),pow(10,logM),ccl_halo_bias(cosmo,pow(10,logM),1.0/(1.0+z), 200., &status));
}
}
printf("\n");
Expand All @@ -497,7 +506,13 @@ int main(int argc,char **argv)
user_pz_info * pz_info_example;
// Create the struct to hold the user information about photo_z's.
pz_info_example = ccl_specs_create_photoz_info(&my_params_example, &user_pz_probability);
pz_info_example = ccl_specs_create_photoz_info(&my_params_example, &user_pz_probability);
// Alternatively, we could have used the built-in Gaussian photo-z pdf,
// which assumes sigma_z = sigma_z0 * (1 + z) (not used in what follows).
double sigma_z0 = 0.05;
user_pz_info *pz_info_gaussian;
pz_info_gaussian = ccl_specs_create_gaussian_photoz_info(sigma_z0);
double z_test;
double dNdz_tomo;
Expand Down
2 changes: 1 addition & 1 deletion tests/ccl_sample_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int main(int argc,char **argv)

//Cosmic shear tracer
CCL_ClTracer *ct_wl=ccl_cl_tracer_lensing_simple_new(cosmo,NZ,z_arr_sh,nz_arr_sh, &status);
printf("ell C_ell(c,c) C_ell(c,g) C_ell(c,s) C_ell(g,g) C_ell(g,s) C_ell(s,s) | r(g,s)\n");
printf("ell C_ell(c,c) C_ell(c,g) C_ell(c,s) C_ell(g,g) C_ell(g,s) C_ell(s,s)\n");
for(int l=2;l<=NL;l*=2) {
double cl_cc=ccl_angular_cl(cosmo,l,ct_cl,ct_cl, &status); //CMBLensing-CMBLensing
double cl_cg=ccl_angular_cl(cosmo,l,ct_cl,ct_gc, &status); //CMBLensing-Clustering
Expand Down

0 comments on commit c58d0ad

Please sign in to comment.