-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_LSSxCMB.c
781 lines (687 loc) · 26.2 KB
/
init_LSSxCMB.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
double invcov_read(int READ, int ci, int cj);
double data_read(int READ, int ci);
double bary_read(int READ, int PC, int cj);
void init_data_inv_bary(char *INV_FILE, char *DATA_FILE, char *BARY_FILE);
void init_priors(double M_Prior, double SigZ_source, double DeltaZ_source_Prior, double SigZ_source_Prior, double SigZ_lens, double DeltaZ_lens_Prior, double SigZ_lens_Prior, double A_IA_Prior, double betaIA_Prior, double etaIA_Prior, double etaZIA_Prior, double Q1_Prior, double Q2_Prior, double Q3_Prior);
void init_survey(char *surveyname, double nsource, double nlens, double area);
void init_galaxies(char *SOURCE_ZFILE, char *LENS_ZFILE, char *lensphotoz, char *sourcephotoz, char *tomo_binning_source, char *tomo_binning_lens);
void init_cosmo_runmode(char *runmode);
void init_binning_fourier(int Ncl, double lmin, double lmax, double lmax_shear, double Rmin_bias, int Ntomo_source, int Ntomo_lens);
void init_probes(char *probes);
void init_lens_sample(char *lensphotoz, char *tomo_binning_lens);
void init_source_sample(char *sourcephotoz, char *tomo_binning_source);
void set_galaxies_source();
void set_lens_galaxies_LSSTgoldsample();
void set_galaxies_WFIRST_SN10();
void set_galaxies_lens_as_source();
void set_equal_tomo_bins();
void init_IA(char *model,char *lumfct);
void init_cmb(char * cmbName);
void set_cmb_cmbs4();
void set_cmb_so_Y5();
void set_cmb_so_Y1();
int count_rows(char* filename,const char delimiter){
FILE *file = fopen (filename, "r" );
char line [1000];
if (file != NULL) {
fgets(line,sizeof line,file);
fclose(file);
}
else{
printf("count_rows: file %s not found.\nEXIT\n",filename);
exit(1);
}
int count = 1;
char *p;
p = line;
while (*p != '\0')
{
if (*p == delimiter){
while (*p == delimiter){p++;}
count++;
}
p++;
}
return count;
}
void init_data_inv_bary(char *INV_FILE, char *DATA_FILE, char *BARY_FILE)
{
double init;
printf("\n");
printf("---------------------------------------\n");
printf("Initializing data vector and covariance\n");
printf("---------------------------------------\n");
sprintf(like.INV_FILE,"%s",INV_FILE);
printf("PATH TO INVCOV: %s\n",like.INV_FILE);
sprintf(like.DATA_FILE,"%s",DATA_FILE);
printf("PATH TO DATA: %s\n",like.DATA_FILE);
sprintf(like.BARY_FILE,"%s",BARY_FILE);
printf("PATH TO BARYONS: %s\n",like.BARY_FILE);
init=data_read(0,1);
init=bary_read(0,1,1);
init=invcov_read(0,1,1);
}
double invcov_read(int READ, int ci, int cj)
{
int i,j,intspace;
static double **inv =0;
if(READ==0 || inv == 0){
inv = create_double_matrix(0, like.Ndata-1, 0, like.Ndata-1);
FILE *F;
F=fopen(like.INV_FILE,"r");
for (i=0;i<like.Ndata; i++){
for (j=0;j<like.Ndata; j++){
fscanf(F,"%d %d %le\n",&intspace,&intspace,&inv[i][j]);
}
}
fclose(F);
printf("FINISHED READING COVARIANCE\n");
}
return inv[ci][cj];
}
double data_read(int READ, int ci)
{
int i,intspace;
static double *data = 0;
if(READ==0 || data ==0){
data = create_double_vector(0, like.Ndata-1);
FILE *F;
F=fopen(like.DATA_FILE,"r");
for (i=0;i<like.Ndata; i++){
fscanf(F,"%d %le\n",&intspace,&data[i]);
}
fclose(F);
printf("FINISHED READING DATA VECTOR\n");
}
return data[ci];
}
double bary_read(int READ, int PC, int cj)
{
int i,j,intspace, N_PC=6;
static double **bary =0;
if(READ==0 || bary == 0){
bary = create_double_matrix(0, N_PC-1, 0, like.Ndata-1);
FILE *F;
F=fopen(like.BARY_FILE,"r");
for (i=0;i<like.Ndata; i++){
fscanf(F,"%le %le %le %le %le %le\n",&bary[0][i],&bary[1][i],&bary[2][i],&bary[3][i],&bary[4][i],&bary[5][i]);
}
fclose(F);
printf("FINISHED READING BARYON MATRIX\n");
}
return bary[PC][cj];
}
void init_cosmo_runmode(char *runmode)
{
printf("\n");
printf("-------------------------------------------\n");
printf("Initializing Standard Runmode/Cosmology\n");
printf("-------------------------------------------\n");
set_cosmological_parameters_to_Planck_15_TT_TE_EE_lowP();
sprintf(pdeltaparams.runmode,"%s",runmode);
printf("pdeltaparams.runmode =%s\n",pdeltaparams.runmode);
}
void init_binning_fourier(int Ncl, double lmin, double lmax, double lmax_shear, double Rmin_bias, int Ntomo_source, int Ntomo_lens)
{
printf("-------------------------------------------\n");
printf("Initializing Binning\n");
printf("-------------------------------------------\n");
like.Rmin_bias=Rmin_bias;
like.Ncl=Ncl;
like.lmin= lmin; //std=20
like.lmax= lmax; //15,000
like.lmax_shear = lmax_shear; //5000
tomo.shear_Nbin=Ntomo_source;
tomo.clustering_Nbin=Ntomo_lens;
double ell;
int i,k=0;
double logdl=(log(like.lmax)-log(like.lmin))/like.Ncl;
for(i=0;i<like.Ncl;i++){
ell=exp(log(like.lmin)+(i+0.5)*logdl);
}
printf("number of ell bins Ncl: %d\n",like.Ncl);
printf("minimum ell: %le\n",like.lmin);
printf("maximum ell: %le\n",like.lmax);
}
void init_priors(double M_Prior, double SigZ_source, double DeltaZ_source_Prior, double SigZ_source_Prior, double SigZ_lens, double DeltaZ_lens_Prior, double SigZ_lens_Prior, double A_ia_Prior, double beta_ia_Prior, double eta_ia_Prior, double etaZ_ia_Prior, double Q1_Prior, double Q2_Prior, double Q3_Prior)
{
int i;
printf("\n");
printf("---------------------------------------\n");
printf("Initializing observational priors for marginalization\n");
printf("---------------------------------------\n");
for (i=0;i<tomo.shear_Nbin; i++){
prior.shear_calibration_m[i][0] = 0.0;
prior.shear_calibration_m[i][1] = M_Prior;
}
like.shearcalib=1;
for (i=0;i<tomo.shear_Nbin; i++){
nuisance.bias_zphot_shear[i]=0.0;
nuisance.sigma_zphot_shear[i]=SigZ_source;
// center of Gaussian priors
prior.bias_zphot_shear[i][0]=nuisance.bias_zphot_shear[i];
prior.sigma_zphot_shear[i][0]=nuisance.sigma_zphot_shear[i];
// rms width of Gaussian priors
prior.bias_zphot_shear[i][1] = DeltaZ_source_Prior;
prior.sigma_zphot_shear[i][1]= SigZ_source_Prior;
}
like.wlphotoz=1;
for (i=0;i<tomo.clustering_Nbin; i++){
nuisance.bias_zphot_clustering[i]=0.0;
nuisance.sigma_zphot_clustering[i]=SigZ_lens;
// center of Gaussian priors
prior.bias_zphot_clustering[i][0]=nuisance.bias_zphot_clustering[i];
prior.sigma_zphot_clustering[i][0]=nuisance.sigma_zphot_clustering[i];
// rms width of Gaussian priors
prior.bias_zphot_clustering[i][1] = DeltaZ_lens_Prior;
prior.sigma_zphot_clustering[i][1]= SigZ_lens_Prior;
}
like.clphotoz=1;
prior.A_ia[0]=5.92;
prior.A_ia[1]=A_ia_Prior;
prior.beta_ia[0]=1.1;
prior.beta_ia[1]=beta_ia_Prior;
prior.eta_ia[0]=-0.47;
prior.eta_ia[1]=eta_ia_Prior;
prior.eta_ia_highz[0]=0.0;
prior.eta_ia_highz[1]=etaZ_ia_Prior;
like.IA=1;
prior.bary_Q1[0]=0.0;
prior.bary_Q1[1]=Q1_Prior;
prior.bary_Q2[0]=0.0;
prior.bary_Q2[1]=Q2_Prior;
prior.bary_Q3[0]=0.0;
prior.bary_Q3[1]=Q3_Prior;
like.baryons=1;
#ifdef NOMPP
printf("\n");
printf("---------------------------------------\n");
printf("Shear Calibration Prior\n");
printf("Mean=%le, Sigma=%le\n",prior.shear_calibration_m[0][0],prior.shear_calibration_m[i][1]);
printf("\n");
printf("---------------------------------------\n");
printf("Photo-z priors Weak Lensing\n");
printf("Delta_z=%le, Sigma (Delta_z)=%le\n",prior.bias_zphot_shear[0][0],prior.bias_zphot_shear[0][1]);
printf("Sigma_z=%le, Sigma (Sigma_z)=%le\n",prior.sigma_zphot_shear[0][0],prior.sigma_zphot_shear[0][1]);
printf("\n");
printf("---------------------------------------\n");
printf("Photo-z priors Clustering\n");
printf("Delta_z=%le, Sigma (Delta_z)=%le\n",prior.bias_zphot_clustering[0][0],prior.bias_zphot_clustering[0][1]);
printf("Sigma_z=%le, Sigma (Sigma_z)=%le\n",prior.sigma_zphot_clustering[0][0],prior.sigma_zphot_clustering[0][1]);
printf("\n");
printf("---------------------------------------\n");
printf("IA Priors\n");
printf("A_IA=%le, A_IA_Prior=%le\n",prior.A_ia[0],prior.A_ia[1]);
printf("beta_ia=%le, betaIA_Prior=%le\n",prior.beta_ia[0],prior.beta_ia[1]);
printf("eta_ia=%le, etaIA_Prior=%le\n",prior.eta_ia[0],prior.eta_ia[1]);
printf("eta_ia_highz=%le, etaZIA_Prior=%le\n",prior.eta_ia_highz[0],prior.eta_ia_highz[1]);
printf("\n");
printf("---------------------------------------\n");
printf("Baryon Priors\n");
printf("Q1=%le, Sigma (Q1)=%le\n",prior.bary_Q1[0],prior.bary_Q1[1]);
printf("Q2=%le, Sigma (Q2)=%le\n",prior.bary_Q2[0],prior.bary_Q2[1]);
printf("Q3=%le, Sigma (Q3)=%le\n",prior.bary_Q3[0],prior.bary_Q3[1]);
#endif
}
void init_survey(char *surveyname, double nsource, double nlens, double area)
{
#ifdef NOMPP
printf("\n");
printf("-------------------------------\n");
printf("Initializing Survey Parameters\n");
printf("-------------------------------\n");
#endif
survey.area = area;
survey.n_gal = nsource;
survey.n_lens=nlens;
survey.sigma_e = 0.37;
sprintf(survey.name,"%s",surveyname);
survey.area_conversion_factor = 60.0*60.0*constants.arcmin*constants.arcmin;
survey.n_gal_conversion_factor=1.0/constants.arcmin/constants.arcmin;
survey.m_lim=24.5;
#ifdef NOMPP
printf("Survey set to %s\n",survey.name);
printf("Survey area: %le deg^2\n",survey.area);
printf("Source Galaxy Density: %le galaxies/arcmin^2\n",survey.n_gal);
#endif
}
void init_galaxies(char *SOURCE_ZFILE, char *LENS_ZFILE, char *lensphotoz, char *sourcephotoz, char *tomo_binning_source, char *tomo_binning_lens)
{
#ifdef NOMPP
printf("\n");
printf("-----------------------------------\n");
printf("Initializing galaxy samples\n");
printf("-----------------------------------\n");
#endif
sprintf(redshift.shear_REDSHIFT_FILE,"%s",SOURCE_ZFILE);
#ifdef NOMPP
printf("PATH TO SOURCE_ZFILE: %s\n",redshift.shear_REDSHIFT_FILE);
#endif
init_source_sample(sourcephotoz,tomo_binning_source);
sprintf(redshift.clustering_REDSHIFT_FILE,"%s",LENS_ZFILE);
#ifdef NOMPP
printf("\n");
printf("PATH TO LENS_ZFILE: %s\n",redshift.clustering_REDSHIFT_FILE);
#endif
init_lens_sample(lensphotoz,tomo_binning_lens);
}
void init_probes(char *probes)
{
#ifdef NOMPP
printf("\n");
printf("------------------------------\n");
printf("Initializing Probes\n");
printf("------------------------------\n");
printf("like.Ncl=%d\n",like.Ncl);
printf("tomo.shear_Npowerspectra=%d\n",tomo.shear_Npowerspectra);
printf("tomo.ggl_Npowerspectra=%d\n",tomo.ggl_Npowerspectra);
printf("tomo.clustering_Npowerspectra=%d\n",tomo.clustering_Npowerspectra);
#endif
sprintf(like.probes,"%s",probes);
if(strcmp(probes,"shear_shear")==0){
like.Ndata=like.Ncl*tomo.shear_Npowerspectra;
like.shear_shear=1;
printf("Shear-Shear computation initialized\n");
}
if(strcmp(probes,"pos_pos")==0){
like.Ndata= like.Ncl*tomo.clustering_Npowerspectra;
like.pos_pos=1;
printf("Position-Position computation initialized\n");
}
if(strcmp(probes,"ggl_cl")==0){
like.Ndata=like.Ncl*(tomo.ggl_Npowerspectra+tomo.clustering_Npowerspectra);
like.shear_pos=1;
like.pos_pos=1;
printf("Shear-Position computation initialized\n");
printf("Position-Position computation initialized\n");
}
if(strcmp(probes,"3x2pt")==0){
like.Ndata=like.Ncl*(tomo.shear_Npowerspectra+tomo.ggl_Npowerspectra+tomo.clustering_Npowerspectra);
like.shear_shear=1;
like.shear_pos=1;
like.pos_pos=1;
printf("Shear-Shear computation initialized\n");
printf("Shear-Position computation initialized\n");
printf("Position-Position computation initialized\n");
}
if(strcmp(probes,"5x2pt")==0) {
like.Ndata = like.Ncl * (2*tomo.clustering_Nbin+tomo.ggl_Npowerspectra+tomo.shear_Nbin+tomo.shear_Npowerspectra);
like.pos_pos = 1;
like.gk = 1;
like.shear_pos = 1;
like.ks = 1;
like.shear_shear = 1;
printf("Shear-Shear computation initialized\n");
printf("Shear-Position computation initialized\n");
printf("Position-Position computation initialized\n");
printf("CMBkappa-Shear computation initialized\n");
printf("CMBkappa-Position computation initialized\n");
}
if(strcmp(probes,"6x2pt")==0) {
like.Ndata = like.Ncl * (2*tomo.clustering_Nbin+tomo.ggl_Npowerspectra+1+tomo.shear_Nbin+tomo.shear_Npowerspectra);
like.pos_pos = 1;
like.gk = 1;
like.shear_pos = 1;
like.kk = 1;
like.ks = 1;
like.shear_shear = 1;
printf("Shear-Shear computation initialized\n");
printf("Shear-Position computation initialized\n");
printf("Position-Position computation initialized\n");
printf("CMBkappa-Shear computation initialized\n");
printf("CMBkappa-Position computation initialized\n");
printf("CMBkappa-CMBkappa computation initialized\n");
}
if(strcmp(probes,"gg_gk_gs")==0) {
like.Ndata = like.Ncl * (2*tomo.clustering_Nbin+tomo.ggl_Npowerspectra);
like.pos_pos = 1;
like.gk = 1;
like.shear_pos = 1;
printf("Position-Position computation initialized\n");
printf("Position-Shear computation initialized\n");
printf("Position-CMBkappa computation initialized\n");
}
if(strcmp(probes,"kk_ks_ss")==0) {
like.Ndata = like.Ncl * (1+tomo.shear_Nbin+tomo.shear_Npowerspectra);
like.kk = 1;
like.ks = 1;
like.shear_shear = 1;
printf("Shear-Shear computation initialized\n");
printf("CMBkappa-Shear computation initialized\n");
printf("CMBkappa-CMBkappa computation initialized\n");
}
if(strcmp(probes,"gk_ks_kk")==0) {
like.Ndata = like.Ncl * (1+tomo.shear_Nbin+tomo.clustering_Nbin);
like.kk = 1;
like.ks = 1;
like.gk = 1;
printf("Position-CMBkappa computation initialized\n");
printf("CMBkappa-Shear computation initialized\n");
printf("CMBkappa-CMBkappa computation initialized\n");
}
if(strcmp(probes,"kk")==0) {
like.Ndata = like.Ncl;
like.kk = 1;
printf("CMBkappa-CMBkappa computation initialized\n");
}
printf("Total number of data points like.Ndata=%d\n",like.Ndata);
}
void init_lens_sample(char *lensphotoz, char *tomo_binning_lens)
{
if(strcmp(lensphotoz,"none")==0) redshift.clustering_photoz=0;
if(strcmp(lensphotoz,"voigt")==0) redshift.clustering_photoz=1;
if(strcmp(lensphotoz,"voigt_out")==0) redshift.clustering_photoz=2;
if(strcmp(lensphotoz,"gaussian")==0) redshift.clustering_photoz=3;
if(strcmp(lensphotoz,"multihisto")==0) redshift.clustering_photoz=4;
if(strcmp(lensphotoz,"outlier_sim")==0) redshift.clustering_photoz=5;
if(strcmp(lensphotoz,"outlier_model")==0) redshift.clustering_photoz=6;
if ((redshift.clustering_photoz !=0) && (redshift.clustering_photoz !=1) && (redshift.clustering_photoz !=2) && (redshift.clustering_photoz !=3) && (redshift.clustering_photoz !=5) && (redshift.clustering_photoz !=6))
{
printf("init.c: init_lens_sample: redshift.clustering_photoz = %d not set properly!\nEXIT!\n",redshift.clustering_photoz);
exit(1);
}
printf("Lens Sample Redshift Errors set to %s: redshift.clustering_photoz=%d\n",lensphotoz,redshift.clustering_photoz);
if(strcmp(tomo_binning_lens,"WF_SN10")==0){
set_galaxies_WFIRST_SN10();
}
if(strcmp(tomo_binning_lens,"LSST_gold")==0){
set_lens_galaxies_LSSTgoldsample();
}
if(strcmp(tomo_binning_lens,"lens=src")==0){
set_galaxies_lens_as_source();
}
//call test_kmax once to initialize look-up tables at reference cosmology
test_kmax(1000.,1);
}
void init_source_sample(char *sourcephotoz, char *tomo_binning_source)
{
if(strcmp(sourcephotoz,"none")==0) redshift.shear_photoz=0;
if(strcmp(sourcephotoz,"voigt")==0) redshift.shear_photoz=1;
if(strcmp(sourcephotoz,"voigt_out")==0) redshift.shear_photoz=2;
if(strcmp(sourcephotoz,"gaussian")==0) redshift.shear_photoz=3;
if(strcmp(sourcephotoz,"multihisto")==0) {
printf("redshift.shear_photoz=4 not supported\n");
exit(1);
}
if(strcmp(sourcephotoz,"outlier_sim")==0) redshift.shear_photoz=5;
if(strcmp(sourcephotoz,"outlier_model")==0) redshift.shear_photoz=6;
if ((redshift.shear_photoz !=0) && (redshift.shear_photoz !=1) && (redshift.shear_photoz !=2) && (redshift.shear_photoz !=3) && (redshift.shear_photoz !=5) && (redshift.shear_photoz !=6))
{
printf("init.c: init_source_sample: redshift.shear_photoz = %d not set properly!\nEXIT!\n",redshift.shear_photoz);
exit(1);
}
printf("Source Sample Redshift Errors set to %s: redshift.shear_photoz=%d\n",sourcephotoz,redshift.shear_photoz);
if(strcmp(tomo_binning_source,"source_std")==0)set_galaxies_source();
}
void set_galaxies_source()
{
int k,j;
double frac, zi;
tomo.shear_Npowerspectra=(int) (tomo.shear_Nbin*(tomo.shear_Nbin+1)/2);
zdistr_histo_1(0.1, NULL);
int zbins =2000;
double da = (redshift.shear_zdistrpar_zmax-redshift.shear_zdistrpar_zmin)/(1.0*zbins);
double *sum;printf("redshift.shear_zdistrpar_zmax,min: %le, %le\n", redshift.shear_zdistrpar_zmax, redshift.shear_zdistrpar_zmin);
sum=create_double_vector(0, zbins);
sum[0] = 0.0;
for (k = 0, zi = redshift.shear_zdistrpar_zmin; k<zbins; k++,zi+=da){
sum[k+1] = sum[k]+zdistr_histo_1(zi, NULL);
}
tomo.shear_zmin[0] = redshift.shear_zdistrpar_zmin;
tomo.shear_zmax[tomo.shear_Nbin-1] = redshift.shear_zdistrpar_zmax;
#ifdef NOMPP
printf("\n");
printf("Source Sample - Tomographic Bin limits:\n");
#endif
for(k=0;k<tomo.shear_Nbin-1;k++){
frac=(k+1.)/(1.*tomo.shear_Nbin)*sum[zbins-1];
j = 0;
while (sum[j]< frac){
j++;
}
tomo.shear_zmax[k] = redshift.shear_zdistrpar_zmin+j*da;
tomo.shear_zmin[k+1] = redshift.shear_zdistrpar_zmin+j*da;
#ifdef NOMPP
printf("min=%le max=%le\n",tomo.shear_zmin[k],tomo.shear_zmax[k]);
#endif
}
#ifdef NOMPP
printf("min=%le max=%le\n",tomo.shear_zmin[tomo.shear_Nbin-1],tomo.shear_zmax[tomo.shear_Nbin-1]);
printf("redshift.shear_zdistrpar_zmin=%le max=%le\n",redshift.shear_zdistrpar_zmin,redshift.shear_zdistrpar_zmax);
#endif
free_double_vector(sum,0,zbins);
}
void set_galaxies_lens_as_source()
{
int i,k,j,n;
double frac, zi;
tomo.clustering_Npowerspectra=tomo.shear_Nbin;
tomo.clustering_Nbin = tomo.shear_Nbin;
redshift.clustering_zdistrpar_zmin = redshift.shear_zdistrpar_zmin;
redshift.clustering_zdistrpar_zmax = redshift.shear_zdistrpar_zmax;
zdistr_histo_1(0.1, NULL);
int zbins =2000;
double da = (redshift.shear_zdistrpar_zmax-redshift.shear_zdistrpar_zmin)/(1.0*zbins);
double *sum;
sum=create_double_vector(0, zbins);
sum[0] = 0.0;
for (k = 0, zi = redshift.shear_zdistrpar_zmin; k<zbins; k++,zi+=da){
sum[k+1] = sum[k]+zdistr_histo_1(zi, NULL);
}
tomo.clustering_zmin[0] = redshift.shear_zdistrpar_zmin;
tomo.clustering_zmax[tomo.clustering_Nbin-1] = redshift.shear_zdistrpar_zmax;
#ifdef NOMPP
printf("\n");
printf("Lens as Source - Tomographic Bin limits:\n");
#endif
for(k=0;k<tomo.clustering_Nbin-1;k++){
frac=(k+1.)/(1.*tomo.clustering_Nbin)*sum[zbins-1];
j = 0;
while (sum[j]< frac){
j++;
}
tomo.clustering_zmax[k] = redshift.shear_zdistrpar_zmin+j*da;
tomo.clustering_zmin[k+1] = redshift.shear_zdistrpar_zmin+j*da;
#ifdef NOMPP
printf("min=%le max=%le\n",tomo.clustering_zmin[k],tomo.clustering_zmax[k]);
#endif
}
#ifdef NOMPP
printf("min=%le max=%le\n",tomo.clustering_zmin[tomo.clustering_Nbin-1],tomo.clustering_zmax[tomo.clustering_Nbin-1]);
printf("redshift.clustering_zdistrpar_zmin=%le max=%le\n",redshift.shear_zdistrpar_zmin,redshift.shear_zdistrpar_zmax);
#endif
free_double_vector(sum,0,zbins);
gbias.b1_function = &b1_per_bin;
for (i =0; i < tomo.clustering_Nbin ; i++){
gbias.b[i] = 0.95/(growfac(1./(1.+(tomo.clustering_zmax[i]+tomo.clustering_zmin[i]/2.)))/growfac(1.));
// gbias.b[i] = 1.3+0.1*i;
printf("Bin %d: galaxy bias=%le\n",i,gbias.b[i]);
}
n=0;
for (i = 0; i < tomo.clustering_Nbin; i++){
for(j = 0; j<tomo.shear_Nbin;j++){
n += test_zoverlap(i,j);
printf("GGL combinations zl=%d zs=%d accept=%d\n",i,j,test_zoverlap(i,j));
}
}
tomo.ggl_Npowerspectra = n;
printf("%d GGL Powerspectra\n",tomo.ggl_Npowerspectra);
}
void set_lens_galaxies_LSSTgoldsample()
{
int i,j,n,k;
double frac, zi;
redshift.clustering_zdistrpar_zmin = 0.01;
redshift.clustering_zdistrpar_zmax = 1.5;
tomo.clustering_Npowerspectra=tomo.clustering_Nbin;
tomo.clustering_zmin[0] = 0.2;
tomo.clustering_zmax[tomo.clustering_Nbin-1] = 1.2;
int zbins =2000;
double da = (tomo.clustering_zmax[tomo.clustering_Nbin-1]-tomo.clustering_zmin[0])/(1.0*zbins);
double *sum;
sum=create_double_vector(0, zbins);
sum[0] = 0.0;
for (k = 0, zi = tomo.clustering_zmin[0]; k<zbins; k++,zi+=da){
sum[k+1] = sum[k]+pf_histo(zi, NULL);
}
printf("\n");
printf("Lens Sample - Tomographic Bin limits:\n");
for(k=0;k<tomo.clustering_Nbin-1;k++){
frac=(k+1.)/(1.*tomo.clustering_Nbin)*sum[zbins-1];
j = 0;
while (sum[j]< frac){
j++;
}
tomo.clustering_zmax[k] = tomo.clustering_zmin[0]+j*da;
tomo.clustering_zmin[k+1] = tomo.clustering_zmin[0]+j*da;
printf("min=%le max=%le\n",tomo.clustering_zmin[k],tomo.clustering_zmax[k]);
}
printf("min=%le max=%le\n",tomo.clustering_zmin[tomo.clustering_Nbin-1],tomo.clustering_zmax[tomo.clustering_Nbin-1]);
printf("redshift.clustering_zdistrpar_zmin=%le max=%le\n",redshift.clustering_zdistrpar_zmin,redshift.clustering_zdistrpar_zmax);
free_double_vector(sum,0,zbins);
gbias.b1_function = &b1_per_bin;
for (i =0; i < tomo.clustering_Nbin ; i++){
gbias.b[i] = 0.95/(growfac(1./(1.+(tomo.clustering_zmax[i]+tomo.clustering_zmin[i]/2.)))/growfac(1.));
//gbias.b[i] = 1.3+0.1*i;
printf("Bin %d: galaxy bias=%le\n",i,gbias.b[i]);
}
n=0;
for (i = 0; i < tomo.clustering_Nbin; i++){
for(j = 0; j<tomo.shear_Nbin;j++){
n += test_zoverlap(i,j);
printf("GGL combinations zl=%d zs=%d accept=%d\n",i,j,test_zoverlap(i,j));
}
}
tomo.ggl_Npowerspectra = n;
printf("%d GGL Powerspectra\n",tomo.ggl_Npowerspectra);
}
void init_IA(char *model,char *lumfct)
{
if(strcmp(lumfct,"GAMA")==0) set_LF_GAMA();
else if(strcmp(lumfct,"DEEP2")==0) set_LF_DEEP2();
else {
printf("init.c:init_IA: %s lumfct not defined\n",lumfct);
printf("USING GAMA LF INSTEAD\n");
set_LF_GAMA();
}
printf("SET LUMINOSITY FUNCTION=%s\n",lumfct);
nuisance.oneplusz0_ia=1.3;
//z0=0.3 is arbitrary pivot redshift J11 p18
nuisance.c1rhocrit_ia=0.0134;
// J11 p.8
if(strcmp(model,"none")==0) like.IA=0;
else if(strcmp(model,"NLA_HF")==0) like.IA=1;
else if(strcmp(model,"lin")==0) like.IA=2;
else{
printf("init.c:init_IA: %s IA model not defined\n",model);
exit(1);
}
printf("SET IA MODEL=%s\n",model);
set_ia_priors();
log_like_f_red();
}
/************ CMB Settings ***********/
void init_cmb(char * cmbName) {
printf("\n");
printf("-----------------------------------\n");
printf("Initializing CMB\n");
printf("-----------------------------------\n");
printf("CMB survey: %s\n", cmbName);
if (strcmp(cmbName, "cmbs4")==0)
set_cmb_cmbs4();
if (strcmp(cmbName, "so_Y1")==0)
set_cmb_so_Y1();
if (strcmp(cmbName, "so_Y5")==0)
set_cmb_so_Y5();
}
void set_cmb_cmbs4() {
sprintf(cmb.name, "cmbs4");
cmb.fwhm = 1. * (constants.pi/180.) / 60.;
cmb.sensitivity = 1.*(constants.pi/180.)/60.;
cmb.pathLensRecNoise = "./cmblensrec/cmbs4/cmb_lmax3000.txt";
like.lmax_kappacmb = 2999.;
printf("path for CMB lens noise: %s\n", cmb.pathLensRecNoise);
}
void set_cmb_so_Y5() {
sprintf(cmb.name, "so_Y5");
// cmb.fwhm = 1.4 * (constants.pi/180.) / 60.;
// cmb.sensitivity = 18.*(constants.pi/180.)/60.;
cmb.pathLensRecNoise = "./cmblensrec/so/YEAR5_2colformat_nlkk_v3_1_0deproj0_SENS1_fsky0p4_it_lT30-3000_lP30-5000.dat";
like.lmax_kappacmb = 2999.;
printf("path for CMB lens noise: %s\n", cmb.pathLensRecNoise);
}
void set_cmb_so_Y1() {
sprintf(cmb.name, "so_Y1");
// cmb.fwhm = 1.4 * (constants.pi/180.) / 60.;
// cmb.sensitivity = 18.*(constants.pi/180.)/60.;
cmb.pathLensRecNoise = "./cmblensrec/so/YEAR1_nlkk_SOlike_y1_tt_SENS1_qe_fsky0p4_lT30-3000.dat";
like.lmax_kappacmb = 2999.;
printf("path for CMB lens noise: %s\n", cmb.pathLensRecNoise);
}
// void set_cmb_so_gold() {
// sprintf(cmb.name, "so_gold");
// // cmb.fwhm = 1.4 * (constants.pi/180.) / 60.;
// // cmb.sensitivity = 18.*(constants.pi/180.)/60.;
// cmb.pathLensRecNoise = "./cmblensrec/so/so_gold_nlkk_lmax3000.txt";
// like.lmax_kappacmb = 2999.;
// printf("path for CMB lens noise: %s\n", cmb.pathLensRecNoise);
// }
////// For WFIRSTxSO forecast
void set_galaxies_WFIRST_SN10()
{
int k,j,n,i;
double frac, zi;
redshift.clustering_zdistrpar_zmin = 0.25;
redshift.clustering_zdistrpar_zmax = 4.0;
tomo.clustering_Npowerspectra=tomo.clustering_Nbin;
tomo.clustering_zmin[0] = redshift.clustering_zdistrpar_zmin;
tomo.clustering_zmax[tomo.clustering_Nbin-1] = redshift.clustering_zdistrpar_zmax;
pf_histo(zi, NULL);
int zbins =2000;
double da = (redshift.clustering_zdistrpar_zmax-redshift.clustering_zdistrpar_zmin)/(1.0*zbins);
double *sum;
sum=create_double_vector(0, zbins);
sum[0] = 0.0;
for (k = 0, zi = redshift.clustering_zdistrpar_zmin; k<zbins; k++,zi+=da){
sum[k+1] = sum[k]+pf_histo(zi, NULL);
}
#ifdef NOMPP
printf("\n");
printf("Lens Sample - Tomographic Bin limits:\n");
#endif
for(k=0;k<tomo.clustering_Nbin-1;k++){
frac=(k+1.)/(1.*tomo.clustering_Nbin)*sum[zbins-1];
j = 0;
while (sum[j]< frac){
j++;
}
tomo.clustering_zmax[k] = redshift.clustering_zdistrpar_zmin+j*da;
tomo.clustering_zmin[k+1] = redshift.clustering_zdistrpar_zmin+j*da;
#ifdef NOMPP
printf("min=%le max=%le\n",tomo.clustering_zmin[k],tomo.clustering_zmax[k]);
#endif
}
#ifdef NOMPP
printf("min=%le max=%le\n",tomo.clustering_zmin[tomo.clustering_Nbin-1],tomo.clustering_zmax[tomo.clustering_Nbin-1]);
printf("redshift.clustering_zdistrpar_zmin=%le max=%le\n",redshift.clustering_zdistrpar_zmin,redshift.clustering_zdistrpar_zmax);
#endif
free_double_vector(sum,0,zbins);
gbias.b1_function = &b1_per_bin;
for (i =0; i < tomo.clustering_Nbin; i++){
gbias.b[i] = 1.3+0.1*i;
#ifdef NOMPP
printf("Bin %d: galaxy bias=%le\n",i,gbias.b[i]);
#endif
}
n=0;
for (i = 0; i < tomo.clustering_Nbin; i++){
for(j = 0; j<tomo.shear_Nbin;j++){
n += test_zoverlap(i,j);
#ifdef NOMPP
printf("GGL combinations zl=%d zs=%d accept=%d\n",i,j,test_zoverlap(i,j));
#endif
}
}
tomo.ggl_Npowerspectra = n;
printf("%d GGL Powerspectra\n",tomo.ggl_Npowerspectra);
}