Changeset 3805 in Sophya
- Timestamp:
- Jul 24, 2010, 12:01:34 AM (15 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvdefsurv.cc
r3749 r3805 183 183 univ.SetDynParam(h100,om0,or0,ol0,w0); 184 184 185 Growth Factorgrowth(om0,ol0);185 GrowthEisenstein growth(om0,ol0); 186 186 187 187 // --- -
trunk/Cosmo/SimLSS/cmvfitpk.cc
r3572 r3805 26 26 class MyFCN : public FCNBase { 27 27 public: 28 MyFCN(HistoErr& herr,Pk SpectrumZ& pk);28 MyFCN(HistoErr& herr,PkEisenstein& pk); 29 29 void Init(const vector<double>& par) const; 30 30 double Func(double x,const vector<double>& par) const; … … 33 33 private: 34 34 HistoErr& herr_; 35 Pk SpectrumZ& pk_;35 PkEisenstein& pk_; 36 36 }; 37 37 } } // namespace ROOT + Minuit2 … … 84 84 // --- Create spectrum 85 85 cout<<endl<<"\n--- Create Spectrum"<<endl; 86 Initial Spectrumpkini(ns,as);86 InitialPowerLaw pkini(ns,as); 87 87 bool nobaryon = false; 88 88 double ocdm0 = om0-ob0; 89 89 TransfertEisenstein tf(h100,ocdm0,ob0,T_CMB_Par,nobaryon); 90 GrowthFactor growth(om0,ol0); cout<<"...Growth="<<growth(zref)<<endl; 91 PkSpectrum0 pk0(pkini,tf); 92 PkSpectrumZ pkz(pk0,growth,zref); 90 GrowthEisenstein growth(om0,ol0); cout<<"...Growth="<<growth(zref)<<endl; 91 PkEisenstein pkz(pkini,tf,growth,zref); 93 92 94 93 // --- Compute variance and normalize spectrum … … 256 255 257 256 //-------------------------------------------------- 258 MyFCN::MyFCN(HistoErr& herr,Pk SpectrumZ& pk)257 MyFCN::MyFCN(HistoErr& herr,PkEisenstein& pk) 259 258 : herr_(herr) , pk_(pk) 260 259 { … … 264 263 { 265 264 double A=par[1], Ocdm0=par[2], Ob0=par[3], Ol0=par[4], h100=par[5], ns=par[6]; 266 pk_.GetPk 0().GetPkIni().SetSlope(ns);267 pk_.GetPk 0().GetPkIni().SetNorm(A);268 pk_.Get Pk0().GetTransfert().SetParTo(h100,Ocdm0,Ob0);265 pk_.GetPkIni().SetSlope(ns); 266 pk_.GetPkIni().SetNorm(A); 267 pk_.GetTransfert().SetParTo(h100,Ocdm0,Ob0); 269 268 pk_.GetGrowthFactor().SetParTo(Ocdm0+Ob0,Ol0); 270 269 } -
trunk/Cosmo/SimLSS/cmvginit3d.cc
r3800 r3805 218 218 cout<<endl<<"\n--- Create Spectrum"<<endl; 219 219 220 Initial Spectrumpkini(ns,as);220 InitialPowerLaw pkini(ns,as); 221 221 222 222 TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false); … … 224 224 tfnos.SetNoOscEnv(2); 225 225 226 Growth Factorgrowth(om0,ol0);227 // Growth Factorgrowth(1.,0.); // D(z) = 1/(1+z)226 GrowthEisenstein growth(om0,ol0); 227 // GrowthEisenstein growth(1.,0.); // D(z) = 1/(1+z) 228 228 double growth_at_z = growth(zref); 229 229 cout<<"...Growth factor at z="<<zref<<" = "<<growth_at_z<<endl; 230 230 231 PkSpectrum0 pk0(pkini,tf); 232 PkSpectrum0 pk0nos(pkini,tfnos); 233 234 PkSpectrumZ pkz(pk0,growth,zref); 235 PkSpectrumZ pkznos(pk0nos,growth,zref); 231 PkSpecCalc pkz(pkini,tf,growth,zref); 232 PkSpecCalc pkznos(pkini,tfnos,growth,zref); 236 233 237 234 //----------------------------------------------------------------- -
trunk/Cosmo/SimLSS/cmvobserv3d.cc
r3768 r3805 299 299 cout<<endl<<"\n--- Create Spectrum"<<endl; 300 300 301 Initial Spectrumpkini(ns,as);301 InitialPowerLaw pkini(ns,as); 302 302 303 303 TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false); 304 304 //tf.SetNoOscEnv(2); 305 305 306 Growth Factorgrowth(om0,ol0);307 // Growth Factorgrowth(1.,0.); // D(z) = 1/(1+z)306 GrowthEisenstein growth(om0,ol0); 307 // GrowthEisenstein growth(1.,0.); // D(z) = 1/(1+z) 308 308 double growth_at_z = growth(zref); 309 309 cout<<"...Growth factor at z="<<zref<<" = "<<growth_at_z<<endl; 310 310 311 PkSpectrum0 pk0(pkini,tf); 312 313 PkSpectrumZ pkz(pk0,growth,zref); 311 PkSpecCalc pkz(pkini,tf,growth,zref); 314 312 315 313 //----------------------------------------------------------------- -
trunk/Cosmo/SimLSS/cmvtgrowth.cc
r3768 r3805 30 30 cout<<"Om0="<<om0<<" Ol0="<<ol0<<endl; 31 31 32 Growth Factorgrowth(om0,ol0);32 GrowthEisenstein growth(om0,ol0); 33 33 cout<<"D1(z=0) = "<<growth(0.)<<endl; 34 34 -
trunk/Cosmo/SimLSS/cmvtintfun.cc
r3196 r3805 44 44 unsigned short glorder=4; 45 45 46 if(narg>1) sscanf(arg[1],"%lf",&n);47 if(narg>2) sscanf(arg[2],"%lf,%lf,%d",&xmin,&xmax,&npt);48 46 cout<<"n="<<n<<" xmin="<<xmin<<" xmax="<<xmax<<" npt="<<npt<<endl; 49 47 -
trunk/Cosmo/SimLSS/cmvtransf.cc
r3802 r3805 17 17 cout 18 18 <<"cmvtransf [options]"<<endl 19 <<" -k k1,k2,npt: k range in Mpc^-1"<<endl19 <<" -k npt,k1,k2 : k range in Mpc^-1"<<endl 20 20 <<" -U h100,Om0,Ob0,tcmb : cosmology"<<endl 21 <<" -F filename : read also C MBFastfile"<<endl21 <<" -F filename : read also CAMB file"<<endl 22 22 <<endl; 23 23 } … … 27 27 double k1 = 1e-6, k2 = 10.; int_4 npt = 100; 28 28 double h100 = 0.71, Om0 = 0.267804, Ob0 = 0.0444356, tcmb = T_CMB_Par; 29 string fcmbf ast= "";29 string fcmbfile = ""; 30 30 31 31 char c; … … 39 39 break; 40 40 case 'F' : 41 fcmbf ast= optarg;41 fcmbfile = optarg; 42 42 break; 43 43 case 'h' : … … 52 52 cout<<"k1="<<k1<<" k2="<<k2<<" npt="<<npt<<endl; 53 53 cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Tcmb="<<tcmb<<endl; 54 cout<<"fcmbf ast="<<fcmbfast<<endl;54 cout<<"fcmbfile="<<fcmbfile<<endl; 55 55 56 56 cout<<"TransfertEisenstein with baryon"<<endl; … … 69 69 TransfertEisenstein tfnob(h100,Om0-Ob0,Ob0,tcmb,true); // No baryons 70 70 71 TransfertTabulate tf cmbfast;72 bool cmbf astOK = false;73 if(fcmbf ast.size()>0) {74 cout<<endl<<"TransfertTabulate for C MBfast"<<endl;75 tf cmbfast.ReadCMBFast(fcmbfast,h100,Om0-Ob0,Ob0);76 tf cmbfast.SetInterpTyp(1);77 if(tf cmbfast.NPoints()>0) cmbfastOK = true;71 TransfertTabulate tf_cmbfile; 72 bool cmbfileOK = false; 73 if(fcmbfile.size()>0) { 74 cout<<endl<<"TransfertTabulate for CAMB"<<endl; 75 tf_cmbfile.ReadCAMB(fcmbfile,h100); 76 tf_cmbfile.SetInterpTyp(1); 77 if(tf_cmbfile.NPoints()>0) cmbfileOK = true; 78 78 } 79 79 … … 92 92 xnt[3] = tfnosc2(k); 93 93 xnt[4] = tfnob(k); 94 if(cmbf astOK) xnt[5] = tfcmbfast(k);94 if(cmbfileOK) xnt[5] = tf_cmbfile(k); 95 95 nt.Fill(xnt); 96 96 } … … 107 107 openppf cmvtransf.ppf 108 108 109 set k k 110 set k log10(k) 109 # Eisenstein 110 n/plot nt.t%k t>0&&k>0 ! "nsta connectpoints logx logy" 111 n/plot nt.tnob%k tnob>0&&k>0 ! "nsta red same connectpoints logx logy" 112 n/plot nt.tnosc2%k tnosc2>0&&k>0 ! "nsta blue same connectpoints logx logy" 113 n/plot nt.tnosc1%k tnosc1>0&&k>0 ! "nsta green same connectpoints logx logy" 111 114 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" 115 n/plot nt.t/tnob%k tnob>0 ! "nsta red connectpoints" 116 n/plot nt.t/tnosc2%k tnosc2>0 ! "nsta blue same connectpoints" 117 n/plot nt.t/tnosc1%k tnosc1>0 ! "nsta green same connectpoints" 117 118 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"119 # CAMB 120 n/plot nt.t%k t>0&&k>0 ! "nsta connectpoints logx logy" 121 n/plot nt.tcmbf%k tcmbf>0&&k>0 ! "nsta red same connectpoints logx logy" 121 122 122 # CMBFast 123 n/plot nt.t%$k ! ! "nsta connectpoints" 124 n/plot nt.tcmbf%$k ! ! "nsta red same connectpoints" 123 n/plot nt.(tcmbf-t)%k tcmbf>0. ! "nsta connectpoints" 124 n/plot nt.(tcmbf-t)/tcmbf%k tcmbf>0. ! "nsta connectpoints" 125 125 126 n/plot nt. (tcmbf-t)%$k tcmbf>0. ! "nsta connectpoints"127 n/plot nt. (tcmbf-t)/tcmbf%$k tcmbf>0. ! "nsta connectpoints"126 n/plot nt.t/tnosc2%k tnosc2>0&&t>0&&k>0 ! "nsta connectpoints logx logy" 127 n/plot nt.tcmbf/tnosc2%k tnosc2>0&&tcmbf>0&&k>0 ! "nsta connectpoints same red logx logy" 128 128 */ -
trunk/Cosmo/SimLSS/cmvtstpk.cc
r3679 r3805 19 19 void usage(void); 20 20 void usage(void) { 21 cout<<"cmvtstpk [options] z_redshift"<<endl 22 <<" -H h100 -B Ob0 -M Om0 -L Ol0,w0"<<endl 23 <<" -k npt,lkmin,lkmax : les valeurs sont en log10"<<endl 24 <<" -s scale : on normalise le spectre avec scale"<<endl 25 <<" -w : write spectra on ASCII file"<<endl; 21 cout 22 <<"cmvtstpk [options] z_redshift"<<endl 23 <<" -H h100 -B Ob0 -M Om0 -L Ol0,w0"<<endl 24 <<" -k npt,lkmin,lkmax : les valeurs sont en log10"<<endl 25 <<" -s scale : on normalise le spectre avec scale"<<endl 26 <<" -w : write spectra on ASCII file"<<endl 27 <<" -F filename : read also CAMB file"<<endl; 26 28 } 27 29 … … 36 38 double scale = 2.54499e+07; // normalisation du spectre a z=0 selon SDSS 37 39 bool wrascii = false; 40 string fcmbfile = ""; 38 41 39 42 char c; 40 while((c = getopt(narg,arg,"hwk:s:H:M:B:L: ")) != -1) {43 while((c = getopt(narg,arg,"hwk:s:H:M:B:L:F:")) != -1) { 41 44 switch (c) { 42 45 case 'H' : … … 63 66 wrascii = true; 64 67 break; 68 case 'F' : 69 fcmbfile = optarg; 70 break; 65 71 case 'h' : 66 72 default : … … 78 84 cout<<"scale="<<scale<<endl; 79 85 cout<<"zval="<<zval<<endl; 80 81 //-------------------------- 82 InitialSpectrum pkini(ns,as); 86 cout<<"fcmbfile="<<fcmbfile<<endl; 87 88 //-------------------------- 89 InitialPowerLaw pkini(ns,as); 83 90 pkini.SetNorm(scale); 84 91 … … 89 96 TransfertEisenstein tfnob(h100,Om0,0.,T_CMB_Par,true); 90 97 91 Growth Factord1(Om0,Ol0);98 GrowthEisenstein d1(Om0,Ol0); 92 99 cout<<"GrowthFactor: "<<d1(zval)<<endl; 93 100 94 PkSpectrum0 pk0(pkini,tf); 95 PkSpectrum0 pk0nosc2(pkini,tfnosc2); 96 PkSpectrum0 pk0nosc1(pkini,tfnosc1); 97 PkSpectrum0 pk0nob(pkini,tfnob); 98 99 PkSpectrumZ pkz(pk0,d1,zval); 100 PkSpectrumZ pkznosc2(pk0nosc2,d1,zval); 101 PkSpectrumZ pkznosc1(pk0nosc1,d1,zval); 102 PkSpectrumZ pkznob(pk0nob,d1,zval); 101 PkSpecCalc pk0(pkini,tf,d1,0.); 102 PkSpecCalc pk0nosc2(pkini,tfnosc2,d1,0.); 103 PkSpecCalc pk0nosc1(pkini,tfnosc1,d1,0.); 104 PkSpecCalc pk0nob(pkini,tfnob,d1,0.); 105 106 PkSpecCalc pkz(pkini,tf,d1,zval); 107 PkSpecCalc pkznosc2(pkini,tfnosc2,d1,zval); 108 PkSpecCalc pkznosc1(pkini,tfnosc1,d1,zval); 109 PkSpecCalc pkznob(pkini,tfnob,d1,zval); 110 111 PkTabulate* pkcamb = NULL; 112 if(fcmbfile.size()>0) { 113 cout<<endl<<"PkTabulate for CAMB"<<endl; 114 pkcamb = new PkTabulate; 115 pkcamb->ReadCAMB(fcmbfile,h100,0.); 116 pkcamb->SetInterpTyp(1); 117 if(pkcamb->NPoints()==0) {delete pkcamb; pkcamb = NULL;} 118 } 103 119 104 120 //-------------------------- … … 118 134 119 135 //-------------------------- 120 const int n = 1 4;136 const int n = 15; 121 137 const char *vname[n] = { 122 138 "k","pkini", … … 124 140 "tfnosc2","pk0nosc2","pknosc2", 125 141 "tfnosc1","pk0nosc1","pknosc1", 126 "tfnob","pk0nob","pknob" 142 "tfnob","pk0nob","pknob","pktab" 127 143 }; 128 144 NTuple nt(n,vname); … … 145 161 xnt[12] = pk0nob(k); 146 162 xnt[13] = pkznob(k,zval); 163 if(pkcamb != NULL) xnt[14] = (*pkcamb)(k); else xnt[14] = 0; 147 164 nt.Fill(xnt); 148 165 } 166 167 if(pkcamb != NULL) {delete pkcamb; pkcamb = NULL;} 149 168 150 169 //-------------------------- … … 190 209 n/plot nt.log10(pkini)%log10(k) pkini>0.&&k>0. ! "nsta connectpoints" 191 210 192 #### Gestion des abscisses193 set xk log10(k)194 set xk k195 196 211 #### fct de transfert 197 212 zone 198 n/plot nt.tf% $xk ! ! "nsta connectpoints"199 n/plot nt.tfnosc2% $xk ! ! "nsta connectpoints same red"200 n/plot nt.tfnosc1% $xk ! ! "nsta connectpoints same blue"201 n/plot nt.tfnob% $xk ! ! "nsta connectpoints same green"202 203 n/plot nt.tf/tfnosc2% $xk ! ! "nsta connectpoints red"204 n/plot nt.tf/tfnosc1% $xk ! ! "nsta connectpoints same blue"205 n/plot nt.tf/tfnob% $xk ! ! "nsta connectpoints same green"213 n/plot nt.tf%k k>0&&tf>0 ! "nsta connectpoints logx logy" 214 n/plot nt.tfnosc2%k k>0&&tfnosc2>0 ! "nsta connectpoints same red logx logy" 215 n/plot nt.tfnosc1%k k>0&&tfnosc1>0 ! "nsta connectpoints same blue logx logy" 216 n/plot nt.tfnob%k k>0&&tfnob>0 ! "nsta connectpoints same green logx logy" 217 218 n/plot nt.tf/tfnosc2%k k>0&&tfnosc2>0 ! "nsta connectpoints red logx" 219 n/plot nt.tf/tfnosc1%k k>0&&tfnosc1>0 ! "nsta connectpoints same blue logx" 220 n/plot nt.tf/tfnob%k k>0&&tfnob>0 ! "nsta connectpoints same green logx" 206 221 addline -10 1 10 1 207 222 208 223 #### Spectre a z=0 209 224 zone 210 n/plot nt.pk0% $xk ! ! "nsta connectpoints"211 n/plot nt.pk0nosc2% $xk ! ! "nsta connectpoints same red"212 n/plot nt.pk0nosc1% $xk ! ! "nsta connectpoints same blue"213 n/plot nt.pk0nob% $xk ! ! "nsta connectpoints same green"225 n/plot nt.pk0%k k>0&&pk0>0 ! "nsta connectpoints logx logy" 226 n/plot nt.pk0nosc2%k k>0&&pk0nosc2>0 ! "nsta connectpoints same red logx logy" 227 n/plot nt.pk0nosc1%k k>0&&pk0nosc1>0 ! "nsta connectpoints same blue logx logy" 228 n/plot nt.pk0nob%k k>0&&pk0nob>0 ! "nsta connectpoints same green logx logy" 214 229 215 230 # Check 216 231 zone 2 2 217 n/plot nt.pk0/pkini-tf*tf% $xk pkini>0 ! "nsta crossmarker3"218 n/plot nt.pk0nosc2/pkini-tfnosc2*tfnosc2% $xk pkini>0 ! "nsta crossmarker3"219 n/plot nt.pk0nosc1/pkini-tfnosc1*tfnosc1% $xk pkini>0 ! "nsta crossmarker3"220 n/plot nt.pk0nob/pkini-tfnob*tfnob% $xk pkini>0 ! "nsta crossmarker3"232 n/plot nt.pk0/pkini-tf*tf%k k>0&&pkini>0 ! "nsta crossmarker3 logx" 233 n/plot nt.pk0nosc2/pkini-tfnosc2*tfnosc2%k k>0&&pkini>0 ! "nsta crossmarker3 logx" 234 n/plot nt.pk0nosc1/pkini-tfnosc1*tfnosc1%k k>0&&pkini>0 ! "nsta crossmarker3 logx" 235 n/plot nt.pk0nob/pkini-tfnob*tfnob%k k>0&&pkini>0 ! "nsta crossmarker3 logx" 221 236 222 237 #### Spectre a z 223 238 zone 224 n/plot nt.pk% $xk ! ! "nsta connectpoints"225 n/plot nt.pknosc2% $xk ! ! "nsta connectpoints same red"226 n/plot nt.pknosc1% $xk ! ! "nsta connectpoints same blue"227 n/plot nt.pknob% $xk ! ! "nsta connectpoints same green"228 229 n/plot nt.pk/pknosc2% $xk ! ! "nsta connectpoints red"230 n/plot nt.pk/pknosc1% $xk ! ! "nsta connectpoints same blue"231 n/plot nt.pk/pknob% $xk ! ! "nsta connectpoints same green"239 n/plot nt.pk%k k>0&&pk>0 ! "nsta connectpoints logx logy" 240 n/plot nt.pknosc2%k k>0&&pknosc2>0 ! "nsta connectpoints same red logx logy" 241 n/plot nt.pknosc1%k k>0&&pknosc1>0 ! "nsta connectpoints same blue logx logy" 242 n/plot nt.pknob%k k>0&&pknob>0 ! "nsta connectpoints same green logx logy" 243 244 n/plot nt.pk/pknosc2%k k>0&&pknosc2>0 ! "nsta connectpoints red logx" 245 n/plot nt.pk/pknosc1%k k>0&&pknosc1>0 ! "nsta connectpoints same blue logx" 246 n/plot nt.pk/pknob%k k>0&&pknob>0 ! "nsta connectpoints same green logx" 232 247 addline -10 1 10 1 233 248 234 249 #### Le spectre version Delta^2 235 250 set D2 k*k*k*pk/(2*M_PI*M_PI) 236 n/plot nt.$D2% $xk ! ! "nsta crossmarker3 connectpoints"251 n/plot nt.$D2%k k>0 ! "nsta crossmarker3 connectpoints logx" 237 252 238 253 #### Test des transferts dans Histo et TVector … … 248 263 disp halea "same red" 249 264 265 #### Le spectre tabule 266 n/plot nt.pk%k pk>0&&k>0 ! "nsta connectpoints logx logy" 267 n/plot nt.pktab%k pktab>0&&k>0 ! "nsta connectpoints same red logx logy" 268 269 n/plot nt.(pktab-pk)%k k>0&&pk>0 ! "nsta connectpoints" 270 n/plot nt.(pktab-pk)/pk%k k>0&&pk>0 ! "nsta connectpoints" 271 272 n/plot nt.pk/pknosc2%k k>0&&pknosc2>0 ! "nsta connectpoints logx" 273 n/plot nt.pktab/pknosc2%k k>0&&pknosc2>0 ! "nsta connectpoints same red logx" 274 250 275 */ -
trunk/Cosmo/SimLSS/cmvtvarspec.cc
r3572 r3805 75 75 76 76 //----------------------------------------------------------------- 77 Initial Spectrumpkini(ns,as);77 InitialPowerLaw pkini(ns,as); 78 78 79 79 TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false); 80 80 //tf.SetNoOscEnv(2); 81 81 82 Growth Factord1(om0,ol0);82 GrowthEisenstein d1(om0,ol0); 83 83 84 PkSpectrum0 pk0(pkini,tf); 85 86 PkSpectrumZ pkz(pk0,d1,zref); 84 PkSpecCalc pkz(pkini,tf,d1,zref); 87 85 88 86 //----------------------------------------------------------------- -
trunk/Cosmo/SimLSS/genefluct3d.cc
r3800 r3805 678 678 679 679 //------------------------------------------------------- 680 void GeneFluct3D::ComputeFourier0(PkSpectrum Z& pk_at_z)680 void GeneFluct3D::ComputeFourier0(PkSpectrum& pk_at_z) 681 681 // cf ComputeFourier() mais avec autre methode de realisation du spectre 682 682 // (attention on fait une fft pour realiser le spectre) … … 727 727 728 728 //------------------------------------------------------- 729 void GeneFluct3D::ComputeFourier(PkSpectrum Z& pk_at_z)729 void GeneFluct3D::ComputeFourier(PkSpectrum& pk_at_z) 730 730 // Calcule une realisation du spectre "pk_at_z" 731 731 // Attention: dans TArray le premier indice varie le + vite -
trunk/Cosmo/SimLSS/genefluct3d.h
r3800 r3805 115 115 double Href(void) {return h_ref_;} 116 116 117 void ComputeFourier0(PkSpectrum Z& pk_at_z);118 void ComputeFourier(PkSpectrum Z& pk_at_z);117 void ComputeFourier0(PkSpectrum& pk_at_z); 118 void ComputeFourier(PkSpectrum& pk_at_z); 119 119 void FilterByPixel(void); 120 120 void ToRedshiftSpace(void); -
trunk/Cosmo/SimLSS/pkspectrum.cc
r3802 r3805 16 16 17 17 /////////////////////////////////////////////////////////// 18 //******************** Initial Spectrum******************//19 /////////////////////////////////////////////////////////// 20 21 Initial Spectrum::InitialSpectrum(double n,double a)18 //******************** InitialPowerLaw ******************// 19 /////////////////////////////////////////////////////////// 20 21 InitialPowerLaw::InitialPowerLaw(double n,double a) 22 22 : n_(n), A_(a) 23 23 { 24 24 } 25 25 26 Initial Spectrum::InitialSpectrum(InitialSpectrum& pkinf)26 InitialPowerLaw::InitialPowerLaw(InitialPowerLaw& pkinf) 27 27 : n_(pkinf.n_), A_(pkinf.A_) 28 28 { 29 29 } 30 30 31 Initial Spectrum::~InitialSpectrum(void)31 InitialPowerLaw::~InitialPowerLaw(void) 32 32 { 33 33 } … … 298 298 : kmin_(1.) , kmax_(-1.) , interptyp_(0) 299 299 { 300 k_.resize(0); 301 tf_.resize(0); 300 302 } 301 303 … … 331 333 char *line = new char[lenline]; 332 334 333 int nread = 0;335 k_.resize(0); tf_.resize(0); 334 336 double tmax = -1.; 335 337 while ( fgets(line,lenline,file) != NULL ) { … … 341 343 k_.push_back(k); 342 344 tf_.push_back(tf); 343 nread++;344 345 } 345 346 346 cout<<"TransfertTabulate::ReadCMBFast: nread="<< nread<<" tf_max="<<tmax<<endl;347 cout<<"TransfertTabulate::ReadCMBFast: nread="<<tf_.size()<<" tf_max="<<tmax<<endl; 347 348 delete [] line; 348 if( nread==0) return nread;349 if(tf_.size()==0) return (int)tf_.size(); 349 350 350 351 for(unsigned int i=0;i<tf_.size();i++) tf_[i] /= tmax; 351 352 352 return nread; 353 } 353 return (int)tf_.size(); 354 } 355 356 int TransfertTabulate::ReadCAMB(string filename, double h100) 357 { 358 FILE *file = fopen(filename.c_str(),"r"); 359 if(file==NULL) return -1; 360 cout<<"TransfertTabulate::ReadCAMB: fn="<<filename<<" h100="<<h100<<endl; 361 362 const int lenline = 512; 363 char *line = new char[lenline]; 364 365 k_.resize(0); tf_.resize(0); 366 double tmax = -1.; 367 while ( fgets(line,lenline,file) != NULL ) { 368 double k,tcdm,tbar,tph,trel,tnu,ttot, tf; 369 sscanf(line,"%lf %lf %lf %lf %lf %lf %lf",&k,&tcdm,&tbar,&tph,&trel,&tnu,&ttot); 370 k *= h100; // convert h Mpc^-1 -> Mpc^-1 371 tf = ttot; 372 if(tf>tmax) tmax = tf; 373 k_.push_back(k); 374 tf_.push_back(tf); 375 } 376 377 cout<<"TransfertTabulate::ReadCAMB nread="<<tf_.size()<<" tf_max="<<tmax<<endl; 378 delete [] line; 379 if(tf_.size()==0) return (int)tf_.size(); 380 381 for(unsigned int i=0;i<tf_.size();i++) tf_[i] /= tmax; 382 383 return (int)tf_.size(); 384 } 385 354 386 355 387 /////////////////////////////////////////////////////////// 356 388 //********************* GrowthFactor ********************// 389 /////////////////////////////////////////////////////////// 390 double GrowthFactor::DsDz(double z, double) 391 { 392 cout<<"Error: GrowthFactor::DsDz not implemented"<<endl; 393 throw AllocationError("Error: GrowthFactor::DsDz not implemented"); 394 } 395 396 /////////////////////////////////////////////////////////// 397 //********************* GrowthEisenstein ********************// 357 398 /////////////////////////////////////////////////////////// 358 399 359 400 // From Eisenstein & Hu ApJ 496:605-614 1998 April 1 360 401 // Pour avoir D(z) = 1/(1+z) faire: OmegaMatter0=1 OmegaLambda0=0 361 Growth Factor::GrowthFactor(double OmegaMatter0,double OmegaLambda0)402 GrowthEisenstein::GrowthEisenstein(double OmegaMatter0,double OmegaLambda0) 362 403 : O0_(OmegaMatter0) , Ol_(OmegaLambda0) 363 404 { 364 405 if(OmegaMatter0==0.) { 365 cout<<"Growth Factor::GrowthFactor: Error bad OmegaMatter0 value : "<<OmegaMatter0<<endl;366 throw ParmError("Growth Factor::GrowthFactor: Error badOmegaMatter0 value");367 } 368 } 369 370 Growth Factor::GrowthFactor(GrowthFactor& d1)406 cout<<"GrowthEisenstein::GrowthEisenstein: Error bad OmegaMatter0 value : "<<OmegaMatter0<<endl; 407 throw ParmError("GrowthEisenstein::GrowthEisenstein: Error badOmegaMatter0 value"); 408 } 409 } 410 411 GrowthEisenstein::GrowthEisenstein(GrowthEisenstein& d1) 371 412 : O0_(d1.O0_) , Ol_(d1.Ol_) 372 413 { 373 414 } 374 415 375 Growth Factor::~GrowthFactor(void)376 { 377 } 378 379 double Growth Factor::operator() (double z)416 GrowthEisenstein::~GrowthEisenstein(void) 417 { 418 } 419 420 double GrowthEisenstein::operator() (double z) 380 421 // see Formulae A4 + A5 + A6 page 614 381 422 { … … 399 440 } 400 441 401 double Growth Factor::DsDz(double z,double dzinc)442 double GrowthEisenstein::DsDz(double z,double dzinc) 402 443 // y-y0 = a*(x-x0)^2 + b*(x-x0) 403 444 // dy = a*dx^2 + b*dx avec dx = x-x0 … … 405 446 { 406 447 if(z<0. || dzinc<=0.) { 407 cout<<"Growth Factor::DsDz: z<0 or dzinc<=0. !"<<endl;408 throw ParmError("Growth Factor::DsDz: z<0 or dzinc<=0. !");448 cout<<"GrowthEisenstein::DsDz: z<0 or dzinc<=0. !"<<endl; 449 throw ParmError("GrowthEisenstein::DsDz: z<0 or dzinc<=0. !"); 409 450 } 410 451 … … 431 472 } 432 473 433 void Growth Factor::SetParTo(double OmegaMatter0,double OmegaLambda0)474 void GrowthEisenstein::SetParTo(double OmegaMatter0,double OmegaLambda0) 434 475 { 435 476 if(OmegaMatter0>0.) O0_ = OmegaMatter0; … … 437 478 } 438 479 439 bool Growth Factor::SetParTo(double OmegaMatter0)480 bool GrowthEisenstein::SetParTo(double OmegaMatter0) 440 481 // idem precedent sans changer OmegaLambda0 441 482 { … … 447 488 448 489 /////////////////////////////////////////////////////////// 449 //************** PkSpectrum0 et PkSpectrumZ *************// 450 /////////////////////////////////////////////////////////// 451 452 PkSpectrum0::PkSpectrum0(InitialSpectrum& pkinf,TransfertEisenstein& tf) 453 : pkinf_(pkinf) , tf_(tf) 454 { 455 } 456 457 PkSpectrum0::PkSpectrum0(PkSpectrum0& pk0) 458 : pkinf_(pk0.pkinf_) , tf_(pk0.tf_) 459 { 460 } 461 462 PkSpectrum0::~PkSpectrum0(void) 463 { 464 } 465 466 double PkSpectrum0::operator() (double k) 490 //********************** PkSpectrum *********************// 491 /////////////////////////////////////////////////////////// 492 493 PkSpectrum::PkSpectrum(void) 494 : zref_(0.) , scale_(1.) , typspec_(PK) 495 { 496 } 497 498 PkSpectrum::PkSpectrum(PkSpectrum& pk) 499 : zref_(pk.zref_) , scale_(pk.scale_) , typspec_(pk.typspec_) 500 { 501 } 502 503 504 /////////////////////////////////////////////////////////// 505 //********************** PkSpecCalc *********************// 506 /////////////////////////////////////////////////////////// 507 508 PkSpecCalc::PkSpecCalc(InitialSpectrum& pkinf,TransfertFunction& tf,GrowthFactor& d1,double zref) 509 : pkinf_(pkinf) , tf_(tf) , d1_(d1) 510 { 511 zref_ = zref; 512 } 513 514 PkSpecCalc::PkSpecCalc(PkSpecCalc& pkz) 515 : pkinf_(pkz.pkinf_) , tf_(pkz.tf_) , d1_(pkz.d1_) 516 { 517 } 518 519 PkSpecCalc::~PkSpecCalc(void) 520 { 521 } 522 523 double PkSpecCalc::operator() (double k) 524 { 525 return (*this)(k,zref_); 526 } 527 528 double PkSpecCalc::operator() (double k,double z) 467 529 { 468 530 double tf = tf_(k); 469 531 double pkinf = pkinf_(k); 470 return pkinf *tf*tf; 471 } 472 473 //------------------------------------ 474 PkSpectrumZ::PkSpectrumZ(PkSpectrum0& pk0,GrowthFactor& d1,double zref) 475 : pk0_(pk0) , d1_(d1) , zref_(zref) , scale_(1.) , typspec_(PK) 476 { 477 } 478 479 PkSpectrumZ::PkSpectrumZ(PkSpectrumZ& pkz) 480 : pk0_(pkz.pk0_) , d1_(pkz.d1_) , zref_(pkz.zref_) , scale_(pkz.scale_) , typspec_(PK) 481 { 482 } 483 484 PkSpectrumZ::~PkSpectrumZ(void) 485 { 486 } 487 488 void PkSpectrumZ::SetTypSpec(ReturnSpectrum typspec) 489 // typsec = PK : compute Pk(k) 490 // = DELTA : compute Delta^2(k) = k^3*Pk(k)/2Pi^2 491 { 492 typspec_ = typspec; 493 } 494 495 double PkSpectrumZ::operator() (double k) 532 double d1 = d1_(z); 533 534 double v = pkinf * (tf*tf) * (d1*d1); 535 if(typspec_ == DELTA) v *= k*k*k/(2.*M_PI*M_PI); 536 537 return scale_ * v; 538 } 539 540 /////////////////////////////////////////////////////////// 541 //********************** PkTabulate *********************// 542 /////////////////////////////////////////////////////////// 543 544 PkTabulate::PkTabulate(void) 545 : kmin_(1.) , kmax_(-1.) , interptyp_(0) 546 { 547 k_.resize(0); 548 pk_.resize(0); 549 } 550 551 PkTabulate::PkTabulate(PkTabulate& pkz) 552 : kmin_(pkz.kmin_) , kmax_(pkz.kmax_) , interptyp_(pkz.interptyp_) , k_(pkz.k_) , pk_(pkz.pk_) 553 { 554 } 555 556 557 PkTabulate::~PkTabulate(void) 558 { 559 } 560 561 void PkTabulate ::SetInterpTyp(int typ) 562 // see comment in InterpTab 563 { 564 if(typ<0) typ=0; else if(typ>2) typ=2; 565 interptyp_ = typ; 566 } 567 568 double PkTabulate::operator() (double k) 569 { 570 double v = InterpTab(k,k_,pk_,interptyp_); 571 if(typspec_ == DELTA) v *= k*k*k/(2.*M_PI*M_PI); 572 return scale_ * v; 573 } 574 575 double PkTabulate::operator() (double k,double z) 576 { 577 cout<<"Error: PkTabulate::operator(double k,double z) not implemented"<<endl; 578 throw AllocationError("Error: PkTabulate::operator(double k,double z) not implemented"); 579 } 580 581 int PkTabulate::ReadCAMB(string filename, double h100, double zreftab) 582 { 583 FILE *file = fopen(filename.c_str(),"r"); 584 if(file==NULL) return -1; 585 cout<<"PkTabulate::ReadCAMB: fn="<<filename<<" h100="<<h100<<" zreftab = "<<zreftab<<endl; 586 587 const int lenline = 512; 588 char *line = new char[lenline]; 589 590 k_.resize(0); pk_.resize(0); 591 while ( fgets(line,lenline,file) != NULL ) { 592 double k, pk; 593 sscanf(line,"%lf %lf",&k,&pk); 594 k *= h100; // convert h Mpc^-1 -> Mpc^-1 595 pk /= h100*h100*h100; // convert h^-3 Mpc^3 -> Mpc^3 596 k_.push_back(k); 597 pk_.push_back(pk); 598 } 599 600 SetZ(zreftab); 601 cout<<"PkTabulate::ReadCAMB nread="<<pk_.size()<<"zref="<<GetZ()<<endl; 602 delete [] line; 603 604 return (int)pk_.size(); 605 } 606 607 /////////////////////////////////////////////////////////// 608 //********************* PkEisenstein ********************// 609 /////////////////////////////////////////////////////////// 610 611 PkEisenstein::PkEisenstein(InitialPowerLaw& pkinf,TransfertEisenstein& tf,GrowthEisenstein& d1,double zref) 612 : pkinf_(pkinf) , tf_(tf) , d1_(d1) 613 { 614 zref_ = zref; 615 } 616 617 PkEisenstein::PkEisenstein(PkEisenstein& pkz) 618 : pkinf_(pkz.pkinf_) , tf_(pkz.tf_) , d1_(pkz.d1_) 619 { 620 } 621 622 PkEisenstein::~PkEisenstein(void) 623 { 624 } 625 626 double PkEisenstein::operator() (double k) 496 627 { 497 628 return (*this)(k,zref_); 498 629 } 499 630 500 double PkSpectrumZ::operator() (double k,double z) 501 { 631 double PkEisenstein::operator() (double k,double z) 632 { 633 double tf = tf_(k); 634 double pkinf = pkinf_(k); 502 635 double d1 = d1_(z); 503 636 504 double v = pk 0_(k) * d1*d1;505 if(typspec_ ==DELTA) v *= k*k*k/(2.*M_PI*M_PI);637 double v = pkinf * (tf*tf) * (d1*d1); 638 if(typspec_ == DELTA) v *= k*k*k/(2.*M_PI*M_PI); 506 639 507 640 return scale_ * v; 508 641 } 509 510 642 511 643 -
trunk/Cosmo/SimLSS/pkspectrum.h
r3802 r3805 10 10 class InitialSpectrum : public GenericFunc { 11 11 public: 12 InitialSpectrum(double n,double a=1.); 13 InitialSpectrum(InitialSpectrum& pkinf); 14 virtual ~InitialSpectrum(void); 12 InitialSpectrum(void) {}; 13 InitialSpectrum(InitialSpectrum& pkinf) {}; 14 virtual ~InitialSpectrum(void) {}; 15 }; 16 17 //----------------------------------------------------------------------------------- 18 class InitialPowerLaw : public InitialSpectrum { 19 public: 20 InitialPowerLaw(double n,double a=1.); 21 InitialPowerLaw(InitialPowerLaw& pkinf); 22 virtual ~InitialPowerLaw(void); 15 23 virtual double operator() (double k) {return A_ * pow(k,n_);} 16 24 void SetNorm(double a) {A_ = a;} … … 21 29 22 30 //----------------------------------------------------------------------------------- 23 class TransfertEisenstein : public GenericFunc { 31 class TransfertFunction : public GenericFunc { 32 public: 33 TransfertFunction(void) {}; 34 virtual ~TransfertFunction(void) {}; 35 }; 36 37 //----------------------------------------------------------------------------------- 38 class TransfertEisenstein : public TransfertFunction { 24 39 public: 25 40 … … 53 68 54 69 //----------------------------------------------------------------------------------- 55 class TransfertTabulate : public GenericFunc{70 class TransfertTabulate : public TransfertFunction { 56 71 public: 57 72 TransfertTabulate(void); … … 62 77 void SetInterpTyp(int typ=0); 63 78 int ReadCMBFast(string filename,double h100,double OmegaCDM0,double OmegaBaryon0); 79 int ReadCAMB(string filename, double h100=0.71); 64 80 protected: 65 81 double kmin_,kmax_; … … 72 88 class GrowthFactor : public GenericFunc { 73 89 public: 74 GrowthFactor(double OmegaMatter0,double OmegaLambda0); 75 GrowthFactor(GrowthFactor& d1); 76 virtual ~GrowthFactor(void); 90 GrowthFactor(void) {}; 91 virtual ~GrowthFactor(void) {}; 92 virtual double DsDz(double z, double); 93 }; 94 95 //----------------------------------------------------------------------------------- 96 class GrowthEisenstein : public GrowthFactor { 97 public: 98 GrowthEisenstein(double OmegaMatter0,double OmegaLambda0); 99 GrowthEisenstein(GrowthEisenstein& d1); 100 virtual ~GrowthEisenstein(void); 77 101 virtual double operator() (double z); 78 102 virtual double DsDz(double z,double dzinc=0.01); … … 85 109 86 110 //----------------------------------------------------------------------------------- 87 class PkSpectrum0 : public GenericFunc { 88 public: 89 PkSpectrum0(InitialSpectrum& pkinf,TransfertEisenstein& tf); 90 PkSpectrum0(PkSpectrum0& pk0); 91 virtual ~PkSpectrum0(void); 92 virtual double operator() (double z); 93 InitialSpectrum& GetPkIni(void) {return pkinf_;} 94 TransfertEisenstein& GetTransfert(void) {return tf_;} 95 protected: 96 InitialSpectrum& pkinf_; 97 TransfertEisenstein& tf_; 98 }; 99 100 //----------------------------------------------------------------------------------- 101 class PkSpectrumZ : public GenericFunc { 102 public: 111 class PkSpectrum : public GenericFunc { 112 public: 113 // typsec = PK : compute Pk(k) 114 // = DELTA : compute Delta^2(k) = k^3*Pk(k)/2Pi^2 103 115 typedef enum {PK=0, DELTA=1} ReturnSpectrum; 104 PkSpectrumZ(PkSpectrum0& pk0,GrowthFactor& d1,double zref=0.); 105 PkSpectrumZ(PkSpectrumZ& pkz); 106 virtual ~PkSpectrumZ(void); 107 virtual double operator() (double k); 108 virtual double operator() (double k,double z); 109 void SetZ(double z) {zref_ = z;} 110 double GetZ(void) {return zref_;} 111 void SetTypSpec(ReturnSpectrum typspec=PK); 112 void SetScale(double scale=1.) {scale_=scale;} 113 double GetScale(void) {return scale_;} 114 PkSpectrum0& GetPk0(void) {return pk0_;} 115 GrowthFactor& GetGrowthFactor(void) {return d1_;} 116 protected: 117 PkSpectrum0& pk0_; 118 GrowthFactor& d1_; 116 117 PkSpectrum(void); 118 PkSpectrum(PkSpectrum& pk); 119 virtual ~PkSpectrum(void) {}; 120 virtual void SetZ(double z) {zref_ = z;} 121 virtual double GetZ(void) {return zref_;} 122 virtual void SetScale(double scale=1.) {scale_ = scale;} 123 virtual double GetScale(void) {return scale_;} 124 virtual void SetTypSpec(ReturnSpectrum typspec=PK) {typspec_ = typspec;} 125 virtual ReturnSpectrum GetTypSpec(void) {return typspec_ ;} 126 protected: 119 127 double zref_, scale_; 120 128 ReturnSpectrum typspec_; … … 122 130 123 131 //----------------------------------------------------------------------------------- 132 class PkSpecCalc : public PkSpectrum { 133 public: 134 PkSpecCalc(InitialSpectrum& pkinf,TransfertFunction& tf,GrowthFactor& d1,double zref=0.); 135 PkSpecCalc(PkSpecCalc& pkz); 136 virtual ~PkSpecCalc(void); 137 virtual double operator() (double k); 138 virtual double operator() (double k,double z); 139 InitialSpectrum& GetPkIni(void) {return pkinf_;} 140 TransfertFunction& GetTransfert(void) {return tf_;} 141 GrowthFactor& GetGrowthFactor(void) {return d1_;} 142 protected: 143 InitialSpectrum& pkinf_; 144 TransfertFunction& tf_; 145 GrowthFactor& d1_; 146 }; 147 148 //----------------------------------------------------------------------------------- 149 class PkTabulate : public PkSpectrum { 150 public: 151 PkTabulate(void); 152 PkTabulate(PkTabulate& pkz); 153 virtual ~PkTabulate(void); 154 virtual double operator() (double k); 155 virtual double operator() (double k,double z); 156 int NPoints(void) {return k_.size();} 157 void SetInterpTyp(int typ=0); 158 int ReadCAMB(string filename, double h100=0.71, double zreftab = 0.); 159 protected: 160 double kmin_,kmax_; 161 int interptyp_; 162 vector<double> k_, pk_; 163 }; 164 165 //----------------------------------------------------------------------------------- 166 class PkEisenstein : public PkSpectrum { 167 public: 168 PkEisenstein(InitialPowerLaw& pkinf,TransfertEisenstein& tf,GrowthEisenstein& d1,double zref=0.); 169 PkEisenstein(PkEisenstein& pkz); 170 virtual ~PkEisenstein(void); 171 virtual double operator() (double k); 172 virtual double operator() (double k,double z); 173 InitialPowerLaw& GetPkIni(void) {return pkinf_;} 174 TransfertEisenstein& GetTransfert(void) {return tf_;} 175 GrowthEisenstein& GetGrowthFactor(void) {return d1_;} 176 protected: 177 InitialPowerLaw& pkinf_; 178 TransfertEisenstein& tf_; 179 GrowthEisenstein& d1_; 180 }; 181 182 //----------------------------------------------------------------------------------- 124 183 class VarianceSpectrum : public GenericFunc { 125 184 public: … … 128 187 129 188 VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter); 130 VarianceSpectrum(VarianceSpectrum& pkinf);189 VarianceSpectrum(VarianceSpectrum& vpk); 131 190 virtual ~VarianceSpectrum(void); 132 191
Note:
See TracChangeset
for help on using the changeset viewer.