source: Sophya/trunk/Cosmo/SimLSS/cmvtransf.cc@ 3798

Last change on this file since 3798 was 3572, checked in by cmv, 17 years ago

char* -> const char* pour regler les problemes de deprecated string const... + comparaison unsigned signed + suppression EVOL_PLANCK rz+cmv 07/02/2009

File size: 3.4 KB
RevLine 
[3115]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
15void usage(void);
[3318]16void usage(void) {
17cout
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}
[3115]24
25int 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;
[3318]29 string fcmbfast = "";
[3115]30
[3318]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
[3115]49 if(k1<=0.) {cout<<"k1 must be >0"<<endl; return -1;}
[3318]50 if(npt<=0) npt = 1000;
51 if(k2<=k1) {k1=1.e-4; k2=1.e+2;}
[3115]52 cout<<"k1="<<k1<<" k2="<<k2<<" npt="<<npt<<endl;
53 cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Tcmb="<<tcmb<<endl;
[3318]54 cout<<"fcmbfast="<<fcmbfast<<endl;
[3115]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
[3318]71 TransfertTabulate tfcmbfast(h100,Om0-Ob0,Ob0);
72 bool cmbfastOK = false;
73 if(fcmbfast.size()>0) {
74 cout<<endl<<"TransfertTabulate for CMBfast"<<endl;
75 tfcmbfast.ReadCMBFast(fcmbfast);
76 tfcmbfast.SetInterpTyp(1);
77 if(tfcmbfast.NPoints()>0) cmbfastOK = true;
78 }
79
80 const int n = 6;
[3572]81 const char *vname[n] = {"k","t","tnosc1","tnosc2","tnob","tcmbf"};
[3115]82 NTuple nt(n,vname);
83 double xnt[n];
[3318]84 for(int i=0;i<n;i++) xnt[i]=0.;
[3115]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);
[3318]94 if(cmbfastOK) xnt[5] = tfcmbfast(k);
[3115]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/*
107openppf cmvtransf.ppf
108
109set k k
110set k log10(k)
111
[3318]112# Eisenstein
113n/plot nt.t%$k ! ! "nsta connectpoints"
114n/plot nt.tnob%$k ! ! "nsta red same connectpoints"
115n/plot nt.tnosc2%$k ! ! "nsta blue same connectpoints"
116n/plot nt.tnosc1%$k ! ! "nsta green same connectpoints"
[3115]117
[3318]118n/plot nt.t/tnob%$k tnob>0 ! "nsta red connectpoints"
119n/plot nt.t/tnosc2%$k tnosc2>0 ! "nsta blue same connectpoints"
120n/plot nt.t/tnosc1%$k tnosc1>0 ! "nsta green same connectpoints"
121
122# CMBFast
123n/plot nt.t%$k ! ! "nsta connectpoints"
124n/plot nt.tcmbf%$k ! ! "nsta red same connectpoints"
125
126n/plot nt.(tcmbf-t)%$k tcmbf>0. ! "nsta connectpoints"
127n/plot nt.(tcmbf-t)/tcmbf%$k tcmbf>0. ! "nsta connectpoints"
[3115]128*/
Note: See TracBrowser for help on using the repository browser.