45 return exp(- (z_ph-z_s)*(z_ph-z_s) / (2.*sigma_z*sigma_z)) / (
pow(2.*
M_PI,0.5)*
sigma_z);
82 ccl_parameters params =
ccl_parameters_create(
OC,
OB,
OK,
NEFF, MNU, MNUTYPE,
W0,
WA,
HH,
NORMPS,
NS,-1,-1,-1,-1,NULL,NULL, &status);
89 printf(
"Comoving distance to z = %.3lf is chi = %.3lf Mpc\n",
91 printf(
"Luminosity distance to z = %.3lf is chi = %.3lf Mpc\n",
93 printf(
"Distance modulus to z = %.3lf is mu = %.3lf Mpc\n",
98 printf(
"Scale factor is a=%.3lf \n",1./(1+
ZD));
99 printf(
"Consistency: Scale factor at chi=%.3lf Mpc is a=%.3lf\n",
104 printf(
"Growth factor and growth rate at z = %.3lf are D = %.3lf and f = %.3lf\n",
108 printf(
"z\tOmega_m\tOmega_L\tOmega_r\trho_crit\trho_m\tRHO_CRITICAL\n");
109 double Om, OL, Or, rhoc, rhom;
110 for (
int z=10000;
z!=0;
z/=3){
116 printf(
"%i\t%.3f\t%.3f\t%.3f\t%.3e\t%.3e\t%.3e\n",
z, Om, OL, Or, rhoc, rhom,
RHO_CRITICAL);
123 printf(
"%i\t%.3f\t%.3f\t%.3f\t%.3e\t%.3e\t%.3e\n", 0, Om, OL, Or, rhoc, rhom,
RHO_CRITICAL);
126 printf(
"Initializing power spectrum...\n");
127 printf(
"sigma8 = %.3lf\n\n",
ccl_sigma8(cosmo, &status));
130 double z_arr_gc[
NZ],z_arr_sh[
NZ],nz_arr_gc[
NZ],nz_arr_sh[
NZ],bz_arr[
NZ];
131 for(
int i=0;i<
NZ;i++) {
134 bz_arr[i]=1+z_arr_gc[i];
138 double *a_arr_resample=(
double *)malloc(2*NZ*
sizeof(
double));
139 double *nz_resampled=(
double *)malloc(2*NZ*
sizeof(
double));
140 for(
int i=0;i<2*
NZ;i++) {
142 a_arr_resample[i]=1./(1+
z);
153 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");
159 double cells_cc_limber[
NL];
160 double cells_cg_limber[
NL];
161 double cells_cl_limber[
NL];
162 double cells_ll_limber[
NL];
163 double cells_gl_limber[
NL];
164 double cells_gg_limber[
NL];
165 for(
int ii=0;ii<
NL;ii++)
169 double logstep = 1.15;
173 CCL_ClWorkspace *
w=ccl_cl_workspace_default(NL+1,-1,CCL_NONLIMBER_METHOD_NATIVE,logstep,linstep,dchi,dlk,zmin,&status);
182 for(
int l=2;
l<=
NL;
l*=2)
183 printf(
"%d %.3lE %.3lE %.3lE %.3lE %.3lE %.3lE | %.3lE\n",
l,cells_cc_limber[
l],cells_cg_limber[l],cells_cl_limber[l],cells_gg_limber[l],cells_gl_limber[l],cells_ll_limber[l],cells_gl_limber[l]/
sqrt(cells_gg_limber[l]*cells_ll_limber[l]));
192 free(a_arr_resample);
196 printf(
"M\tdN/dlog10M(z = 0, 0.5, 1))\n");
197 for(
int logM=9;logM<=15;logM+=1) {
198 printf(
"%.1e\t",
pow(10,logM));
199 for(
double z=0;
z<=1;
z+=0.5) {
200 printf(
"%e\t",
ccl_massfunc(cosmo,
pow(10,logM),1.0/(1.0+
z), 200., &status));
207 printf(
"Halo bias: z, M, b1(M,z)\n");
208 for(
int logM=9;logM<=15;logM+=1) {
209 for(
double z=0;
z<=1;
z+=0.5) {
210 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));
222 my_dN_params_example.
alpha = 1.24;
223 my_dN_params_example.
beta = 1.01;
224 my_dN_params_example.
z0 = 0.51;
234 double sigma_z0 = 0.05;
258 double tmp1,tmp2,tmp3,tmp4,tmp5;
259 printf(
"Trying splitting dNdz (lensing) into 5 redshift bins. " 260 "Output written into file tests/example_tomographic_bins.out\n");
261 output = fopen(
"./tests/example_tomographic_bins.out",
"w");
264 fprintf(stderr,
"Could not write to 'tests' subdirectory" 265 " - please run this program from the main CCL directory\n");
269 for (z=0; z<100; z=z+1) {
271 ccl_dNdz_tomog(z_test, 0.,6., pz_info_example, dN_info_example, &dNdz_tomo,&status);
272 ccl_dNdz_tomog(z_test, 0.,0.6, pz_info_example,dN_info_example, &tmp1,&status);
273 ccl_dNdz_tomog(z_test, 0.6,1.2, pz_info_example,dN_info_example, &tmp2,&status);
274 ccl_dNdz_tomog(z_test, 1.2,1.8, pz_info_example,dN_info_example, &tmp3,&status);
275 ccl_dNdz_tomog(z_test, 1.8,2.4, pz_info_example,dN_info_example, &tmp4,&status);
276 ccl_dNdz_tomog(z_test, 2.4,3.0, pz_info_example,dN_info_example, &tmp5,&status);
277 fprintf(output,
"%f %f %f %f %f %f %f\n", z_test,tmp1,tmp2,tmp3,tmp4,tmp5,dNdz_tomo);
double ccl_scale_factor_of_chi(ccl_cosmology *cosmo, double chi, int *status)
double user_dNdz(double z, void *user_par, int *status)
int main(int argc, char **argv)
double ccl_omega_x(ccl_cosmology *cosmo, double a, ccl_species_x_label label, int *status)
double ccl_growth_factor(ccl_cosmology *cosmo, double a, int *status)
double ccl_massfunc(ccl_cosmology *cosmo, double smooth_mass, double a, double odelta, int *status)
double ccl_luminosity_distance(ccl_cosmology *cosmo, double a, int *status)
double ccl_growth_rate(ccl_cosmology *cosmo, double a, int *status)
void ccl_cl_tracer_free(CCL_ClTracer *clt)
dNdz_info * ccl_create_dNdz_info(void *params, double(*dNdz_func)(double, void *, int *))
int ccl_get_tracer_fas(ccl_cosmology *cosmo, CCL_ClTracer *clt, int na, double *a, double *fa, int func_code, int *status)
transfer_function_t transfer_function_method
void ccl_angular_cls(ccl_cosmology *cosmo, CCL_ClWorkspace *w, CCL_ClTracer *clt1, CCL_ClTracer *clt2, int nl_out, int *l, double *cl, int *status)
dNdz_info * ccl_create_Smail_dNdz_info(double alpha, double beta, double z0)
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
ccl_cosmology * ccl_cosmology_create(ccl_parameters params, ccl_configuration config)
static double beta[2][28][8]
pz_info * ccl_create_gaussian_photoz_info(double sigma_z0)
CCL_ClTracer * ccl_cl_tracer_number_counts_simple(ccl_cosmology *cosmo, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int *status)
void ccl_cosmology_free(ccl_cosmology *cosmo)
double user_pz_probability(double z_ph, double z_s, void *user_par, int *status)
double ccl_rho_x(ccl_cosmology *cosmo, double a, ccl_species_x_label label, int is_comoving, int *status)
double ccl_halo_bias(ccl_cosmology *cosmo, double smooth_mass, double a, double odelta, int *status)
double sigmaz_sources(double z)
double(* sigma_z)(double)
double ccl_sigma8(ccl_cosmology *cosmo, int *status)
const ccl_configuration default_config
float pow(float base, unsigned long int exp)
CCL_ClTracer * ccl_cl_tracer_cmblens(ccl_cosmology *cosmo, double z_source, int *status)
pz_info * ccl_create_photoz_info(void *params, double(*pz_func)(double, double, void *, int *))
void ccl_free_photoz_info(pz_info *my_photoz_info)
void ccl_dNdz_tomog(double z, double bin_zmin, double bin_zmax, pz_info *photo_info, dNdz_info *dN_info, double *tomoout, int *status)
double ccl_distance_modulus(ccl_cosmology *cosmo, double a, int *status)
ccl_parameters ccl_parameters_create(double Omega_c, double Omega_b, double Omega_k, double Neff, double *mnu, ccl_mnu_convention mnu_type, double w0, double wa, double h, double norm_pk, double n_s, double bcm_log10Mc, double bcm_etab, double bcm_ks, int nz_mgrowth, double *zarr_mgrowth, double *dfarr_mgrowth, int *status)
double ccl_comoving_radial_distance(ccl_cosmology *cosmo, double a, int *status)
static double w[2][28][111]
void ccl_free_dNdz_info(dNdz_info *dN_info)
CCL_ClTracer * ccl_cl_tracer_lensing_simple(ccl_cosmology *cosmo, int nz_n, double *z_n, double *n, int *status)