1 | #include "sopnamsp.h"
|
---|
2 | #include "machdefs.h"
|
---|
3 | #include <iostream>
|
---|
4 | #include <stdlib.h>
|
---|
5 | #include <stdio.h>
|
---|
6 | #include <string.h>
|
---|
7 | #include <math.h>
|
---|
8 | #include <unistd.h>
|
---|
9 | #include "timing.h"
|
---|
10 | #include "ntuple.h"
|
---|
11 |
|
---|
12 | #include "constcosmo.h"
|
---|
13 | #include "pkspectrum.h"
|
---|
14 |
|
---|
15 | void usage(void);
|
---|
16 | void usage(void) {
|
---|
17 | cout
|
---|
18 | <<"cmvtransf [options]"<<endl
|
---|
19 | <<" -k k1,k2,npt : k range in Mpc^-1"<<endl
|
---|
20 | <<" -U h100,Om0,Ob0,tcmb : cosmology"<<endl
|
---|
21 | <<" -F filename : read also CMBFast file"<<endl
|
---|
22 | <<endl;
|
---|
23 | }
|
---|
24 |
|
---|
25 | int main(int narg,char *arg[])
|
---|
26 | {
|
---|
27 | double k1 = 1e-6, k2 = 10.; int_4 npt = 100;
|
---|
28 | double h100 = 0.71, Om0 = 0.267804, Ob0 = 0.0444356, tcmb = T_CMB_Par;
|
---|
29 | string fcmbfast = "";
|
---|
30 |
|
---|
31 | char c;
|
---|
32 | while((c = getopt(narg,arg,"hk:U:F:")) != -1) {
|
---|
33 | switch (c) {
|
---|
34 | case 'k' :
|
---|
35 | sscanf(optarg,"%d,%lf,%lf",&npt,&k1,&k2);
|
---|
36 | break;
|
---|
37 | case 'U' :
|
---|
38 | sscanf(optarg,"%lf,%lf,%lf,%lf",&h100,&Om0,&Ob0,&tcmb);
|
---|
39 | break;
|
---|
40 | case 'F' :
|
---|
41 | fcmbfast = optarg;
|
---|
42 | break;
|
---|
43 | case 'h' :
|
---|
44 | default :
|
---|
45 | usage(); return -1;
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | if(k1<=0.) {cout<<"k1 must be >0"<<endl; return -1;}
|
---|
50 | if(npt<=0) npt = 1000;
|
---|
51 | if(k2<=k1) {k1=1.e-4; k2=1.e+2;}
|
---|
52 | cout<<"k1="<<k1<<" k2="<<k2<<" npt="<<npt<<endl;
|
---|
53 | cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Tcmb="<<tcmb<<endl;
|
---|
54 | cout<<"fcmbfast="<<fcmbfast<<endl;
|
---|
55 |
|
---|
56 | cout<<"TransfertEisenstein with baryon"<<endl;
|
---|
57 | TransfertEisenstein tf(h100,Om0-Ob0,Ob0,tcmb);
|
---|
58 | cout<<"KPeak = "<<tf.KPeak()<<" 1/Mpc"<<endl;
|
---|
59 |
|
---|
60 | cout<<endl<<"TransfertEisenstein with baryon without oscillation approx.1"<<endl;
|
---|
61 | TransfertEisenstein tfnosc1(h100,Om0-Ob0,Ob0,tcmb); // No oscillation approx.1
|
---|
62 | tfnosc1.SetNoOscEnv(1);
|
---|
63 |
|
---|
64 | cout<<endl<<"TransfertEisenstein with baryon without oscillation approx.2"<<endl;
|
---|
65 | TransfertEisenstein tfnosc2(h100,Om0-Ob0,Ob0,tcmb); // No oscillation approx.2
|
---|
66 | tfnosc2.SetNoOscEnv(2);
|
---|
67 |
|
---|
68 | cout<<endl<<"TransfertEisenstein without baryon"<<endl;
|
---|
69 | TransfertEisenstein tfnob(h100,Om0-Ob0,Ob0,tcmb,true); // No baryons
|
---|
70 |
|
---|
71 | TransfertTabulate tfcmbfast;
|
---|
72 | bool cmbfastOK = false;
|
---|
73 | if(fcmbfast.size()>0) {
|
---|
74 | cout<<endl<<"TransfertTabulate for CMBfast"<<endl;
|
---|
75 | tfcmbfast.ReadCMBFast(fcmbfast,h100,Om0-Ob0,Ob0);
|
---|
76 | tfcmbfast.SetInterpTyp(1);
|
---|
77 | if(tfcmbfast.NPoints()>0) cmbfastOK = true;
|
---|
78 | }
|
---|
79 |
|
---|
80 | const int n = 6;
|
---|
81 | const char *vname[n] = {"k","t","tnosc1","tnosc2","tnob","tcmbf"};
|
---|
82 | NTuple nt(n,vname);
|
---|
83 | double xnt[n];
|
---|
84 | for(int i=0;i<n;i++) xnt[i]=0.;
|
---|
85 |
|
---|
86 | double lnk1 = log10(k1), lnk2=log10(k2), dlnk=(lnk2-lnk1)/npt;
|
---|
87 | for(double lnk=lnk1;lnk<lnk2+dlnk/2.;lnk+=dlnk) {
|
---|
88 | double k = pow(10.,lnk);
|
---|
89 | xnt[0] = k;
|
---|
90 | xnt[1] = tf(k);
|
---|
91 | xnt[2] = tfnosc1(k);
|
---|
92 | xnt[3] = tfnosc2(k);
|
---|
93 | xnt[4] = tfnob(k);
|
---|
94 | if(cmbfastOK) xnt[5] = tfcmbfast(k);
|
---|
95 | nt.Fill(xnt);
|
---|
96 | }
|
---|
97 |
|
---|
98 | cout<<">>>> Ecriture"<<endl;
|
---|
99 | string tag = "cmvtransf.ppf";
|
---|
100 | POutPersist pos(tag);
|
---|
101 | tag = "nt"; pos.PutObject(nt,tag);
|
---|
102 |
|
---|
103 | return 0;
|
---|
104 | }
|
---|
105 |
|
---|
106 | /*
|
---|
107 | openppf cmvtransf.ppf
|
---|
108 |
|
---|
109 | set k k
|
---|
110 | set k log10(k)
|
---|
111 |
|
---|
112 | # Eisenstein
|
---|
113 | n/plot nt.t%$k ! ! "nsta connectpoints"
|
---|
114 | n/plot nt.tnob%$k ! ! "nsta red same connectpoints"
|
---|
115 | n/plot nt.tnosc2%$k ! ! "nsta blue same connectpoints"
|
---|
116 | n/plot nt.tnosc1%$k ! ! "nsta green same connectpoints"
|
---|
117 |
|
---|
118 | n/plot nt.t/tnob%$k tnob>0 ! "nsta red connectpoints"
|
---|
119 | n/plot nt.t/tnosc2%$k tnosc2>0 ! "nsta blue same connectpoints"
|
---|
120 | n/plot nt.t/tnosc1%$k tnosc1>0 ! "nsta green same connectpoints"
|
---|
121 |
|
---|
122 | # CMBFast
|
---|
123 | n/plot nt.t%$k ! ! "nsta connectpoints"
|
---|
124 | n/plot nt.tcmbf%$k ! ! "nsta red same connectpoints"
|
---|
125 |
|
---|
126 | n/plot nt.(tcmbf-t)%$k tcmbf>0. ! "nsta connectpoints"
|
---|
127 | n/plot nt.(tcmbf-t)/tcmbf%$k tcmbf>0. ! "nsta connectpoints"
|
---|
128 | */
|
---|