Changeset 3806 in Sophya


Ignore:
Timestamp:
Jul 24, 2010, 6:15:07 PM (15 years ago)
Author:
cmv
Message:

suite de la mise au point pour lecture fichiers CAMB, cmv 24/07/2010

Location:
trunk/Cosmo/SimLSS
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/SimLSS/cmvginit3d.cc

    r3805 r3806  
    2020#include "geneutils.h"
    2121#include "genefluct3d.h"
     22
     23string decodecambarg(string arg,double& h, double& z);
    2224
    2325void usage(void);
     
    3638     <<" -z nz,dz : size along z axis (redshift axis, npix,Mpc)"<<endl
    3739     <<" -Z zref : redshift for the center of the simulation cube"<<endl
     40     <<" -f cambspec.dat,h100tab,ztab : use CAMB file (def: Eisenstein spectrum)"<<endl
    3841     <<" -1 : compute 1D spectrum (default: no)"<<endl
    3942     <<" -2 : compute 2D spectrum (default: no)"<<endl
     
    6972 unsigned short flat = 0;
    7073 double ob0 = 0.0444356;
    71  double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
     74 double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73, w0=-1.;
    7275 double zref = 0.5;
    7376 double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
     
    7881 double sigmaR = 1.;
    7982
    80  double kmin=1e-5,kmax=1000.;
    81  int npt = 10000;
    82  double lkmin=log10(kmin), lkmax=log10(kmax);
     83 double kmin=1e-4,kmax=100.;
     84 int npt = 1000;
    8385 double eps=1.e-3;
     86
     87 // *** Spectrum read from CAMB file
     88 string cambfread = "";
    8489
    8590 // *** type de generation
     
    115120 // --- Decodage des arguments
    116121 char c;
    117  while((c = getopt(narg,arg,"haG:F:x:y:z:Z:128:v:n:CO:So:VT:")) != -1) {
     122 while((c = getopt(narg,arg,"haG:F:x:y:z:Z:128:v:n:CO:So:VT:f:")) != -1) {
    118123  int nth = 0;
    119124  switch (c) {
     
    175180    nthread = (nth<1)? 0: nth;
    176181    break;
     182  case 'f' :
     183    cambfread = optarg;
     184    break;
    177185  case 'h' :
    178186  default :
     
    189197 cout<<"zref="<<zref<<endl;
    190198 cout<<"nx="<<nx<<" dx="<<dx<<" ny="<<ny<<" dy="<<dy<<" nz="<<nz<<" dz="<<dz<<endl;
    191  cout<<"kmin="<<kmin<<" ("<<lkmin<<"), kmax="<<kmax<<" ("<<lkmax<<") Mpc^-1"<<", npt="<<npt<<endl;
     199 cout<<"kmin="<<kmin<<" ("<<log10(kmin)<<"), kmax="<<kmax<<" ("<<log10(kmax)<<") Mpc^-1"<<", npt="<<npt<<endl;
    192200 cout<<"Filter by pixel = "<<filter_by_pixel<<endl;
    193201 if(comptransveloc) cout<<"Tansverse velocity generation requested"<<endl;
     202 if(cambfread.size()>0) cout<<"use CAMB file: cambfread="<<cambfread<<endl;
    194203 cout<<"R="<<R<<" Rg="<<Rg<<" Mpc, sigmaR="<<sigmaR<<endl;
    195204 cout<<"Use_growth_factor = "<<use_growth_factor<<endl;
     
    216225
    217226 //-----------------------------------------------------------------
    218  cout<<endl<<"\n--- Create Spectrum"<<endl;
    219 
    220  InitialPowerLaw pkini(ns,as);
    221 
    222  TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false);
    223  TransfertEisenstein tfnos(h100,om0-ob0,ob0,T_CMB_Par,false);
    224    tfnos.SetNoOscEnv(2);
     227 cout<<endl<<"\n--- Create GrowthFactor"<<endl;
    225228
    226229 GrowthEisenstein growth(om0,ol0);
     
    229232 cout<<"...Growth factor at z="<<zref<<" = "<<growth_at_z<<endl;
    230233
    231  PkSpecCalc pkz(pkini,tf,growth,zref);
     234 //-----------------------------------------------------------------
     235 cout<<endl<<"\n--- Create Spectrum"<<endl;
     236
     237 InitialPowerLaw pkini(ns,as);
     238
     239 TransfertEisenstein tfnos(h100,om0-ob0,ob0,T_CMB_Par,false);
     240   tfnos.SetNoOscEnv(2);
     241 TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false);
     242
    232243 PkSpecCalc pkznos(pkini,tfnos,growth,zref);
    233 
    234  //-----------------------------------------------------------------
    235  pkz.SetZ(0.);
     244 PkSpectrum* pkz = NULL;
     245 if(cambfread.size()>0) {  // read pk in CAMB file
     246   double h100tab, ztab;
     247   string fn = decodecambarg(cambfread,h100tab,ztab);
     248   if(h100tab<=0.) h100tab = h100;
     249   PkTabulate* pkzt = new PkTabulate;
     250   pkzt->ReadCAMB(fn,h100tab,ztab);
     251   pkzt->SetGrowthFactor(&growth);
     252   pkzt->SetZ(zref);
     253   pkz = pkzt;
     254   // change k limits
     255   kmin = pkzt->KMin();
     256   kmax = pkzt->KMax();
     257   cout<<"Change k limits to kmin="<<kmin<<" kmax="<<kmax<<endl;
     258 } else {   // use Eisenstein pk
     259   PkSpecCalc* pkze = new PkSpecCalc(pkini,tf,growth,zref);
     260   pkz = pkze;
     261 }
     262
     263 //-----------------------------------------------------------------
     264 cout<<endl<<"\n--- Normalize Spectrum"<<endl;
     265
     266 pkz->SetZ(0.);
    236267 pkznos.SetZ(0.);
    237  cout<<endl<<"\n--- Compute variance for top-hat R="<<R<<" at z="<<pkz.GetZ()<<endl;
    238  VarianceSpectrum varpk_th(pkz,R,VarianceSpectrum::TOPHAT);
    239  double kfind_th = varpk_th.FindMaximum(kmin,kmax,eps);
    240  double pkmax_th = varpk_th(kfind_th);
    241  cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
    242  double k1=kmin, k2=kmax;
    243  int rc = varpk_th.FindLimits(pkmax_th/1.e4,k1,k2,eps);
    244  cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "
    245      <<k2<<" ("<<log10(k2)<<")"<<endl;
    246 
    247  double ldlk = (log10(k2)-log10(k1))/npt;
    248  varpk_th.SetInteg(0.01,ldlk,-1.,4);
    249  double sr2 = varpk_th.Variance(k1,k2);
    250  cout<<"varpk_th="<<sr2<<"  ->  sigma="<<sqrt(sr2)<<endl;
    251 
    252  double normpkz = sigmaR*sigmaR/sr2;
    253  pkz.SetScale(normpkz);
    254  pkznos.SetScale(normpkz);
    255  cout<<"Spectrum normalisation = "<<pkz.GetScale()<<endl;
     268
     269 double normpkz[2] = {0.,0.};
     270 for(int i=0;i<2;i++) {
     271   PkSpectrum* pkvar = NULL; string nam = "";
     272   if(i==0) pkvar = pkz; else {pkvar = &pkznos; nam = "NoOsc";}
     273   cout<<endl<<"\n--- Compute variance for Pk "<<nam<<" with top-hat R="<<R<<" at z="<<pkvar->GetZ()<<endl;
     274   VarianceSpectrum varpk_th(*pkvar,R,VarianceSpectrum::TOPHAT);
     275   double kfind_th = varpk_th.FindMaximum(kmin,kmax,eps);
     276   double pkmax_th = varpk_th(kfind_th);
     277   cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
     278   double k1=kmin, k2=kmax;
     279   int rc = varpk_th.FindLimits(pkmax_th/1.e4,k1,k2,eps);
     280   cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "
     281       <<k2<<" ("<<log10(k2)<<")"<<endl;
     282   double ldlk = (log10(k2)-log10(k1))/npt;
     283   varpk_th.SetInteg(0.01,ldlk,-1.,4);
     284   double sr2 = varpk_th.Variance(k1,k2);
     285   normpkz[i] = sigmaR*sigmaR/sr2;
     286   cout<<"varpk_th="<<sr2<<"  ->  sigma="<<sqrt(sr2)<<" normpkz="<<normpkz[i]<<endl;
     287 }
     288 cout<<endl;
     289
     290 if(cambfread.size()>0) {
     291   pkz->SetScale(1.);
     292   pkznos.SetScale(normpkz[1]);
     293   cout<<"Warning: CAMB spectrum, no normalisation applied, scale="<<pkz->GetScale()<<endl;
     294 } else {
     295   pkz->SetScale(normpkz[0]);
     296   pkznos.SetScale(normpkz[0]);
     297   cout<<"Spectrum normalisation (osc+noosc), scale = "<<pkz->GetScale()<<endl;
     298 }
     299
    256300 {
    257  Histo hpkz0(lkmin,lkmax,npt); hpkz0.ReCenterBin();
    258  FuncToHisto(pkz,hpkz0,true);
     301 Histo hpkz0(log10(kmin),log10(kmax),npt); hpkz0.ReCenterBin();
     302 FuncToHisto(*pkz,hpkz0,true);
    259303 posobs.PutObject(hpkz0,"hpkz0");
    260304 Histo hpkz0nos(hpkz0);
     
    263307 }
    264308
    265  pkz.SetZ(zref);
     309 pkz->SetZ(zref);
    266310 pkznos.SetZ(zref);
     311
    267312 {
    268  Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
    269  FuncToHisto(pkz,hpkz,true);
     313 Histo hpkz(log10(kmin),log10(kmax),npt); hpkz.ReCenterBin();
     314 FuncToHisto(*pkz,hpkz,true);
    270315 posobs.PutObject(hpkz,"hpkz");
    271316 Histo hpkznos(hpkz);
     
    275320
    276321 //-----------------------------------------------------------------
    277  cout<<endl<<"\n--- Compute variance for Pk at z="<<pkz.GetZ()<<endl;
    278  VarianceSpectrum varpk_int(pkz,R,VarianceSpectrum::NOFILTER);
     322 cout<<endl<<"\n--- Compute variance for Pk at z="<<pkz->GetZ()<<endl;
     323 VarianceSpectrum varpk_int(*pkz,R,VarianceSpectrum::NOFILTER);
    279324 double kfind_int = varpk_int.FindMaximum(kmin,kmax,eps);
    280325 double pkmax_int = varpk_int(kfind_int);
     
    325370
    326371 //-----------------------------------------------------------------
    327  cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl;
     372 cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz->GetZ()<<endl;
    328373 // En fait on travaille sur un cube inscrit dans la sphere de rayon kmax:
    329374 // sphere: Vs = 4Pi/3 k^3 , cube inscrit (cote k*sqrt(2)): Vc = (k*sqrt(2))^3
     
    339384 //-----------------------------------------------------------------
    340385 cout<<"\n--- Computing a realization in Fourier space"<<endl;
    341  if(use_growth_factor>0) pkz.SetZ(0.); else pkz.SetZ(zref);
    342  cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
    343  fluct3d.ComputeFourier(pkz);
     386 if(use_growth_factor>0) pkz->SetZ(0.); else pkz->SetZ(zref);
     387 cout<<"Power spectrum set at redshift: "<<pkz->GetZ()<<endl;
     388 fluct3d.ComputeFourier(*pkz);
    344389 fluct3d.NTupleCheck(posobs,string("ntpkgen"),ntnent);
    345390 PrtTim(">>>> End Computing a realization in Fourier space");
     
    411456 //-----------------------------------------------------------------
    412457 cout<<"\n--- Computing a realization in real space"<<endl;
     458 double vdum1,vdum2;
    413459 fluct3d.ComputeReal();
    414  double rmin,rmax; fluct3d.MinMax(rmin,rmax);
    415  cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
     460 fluct3d.MinMax(vdum1,vdum2);
     461 fluct3d.MeanSigma2(vdum1,vdum2);
    416462 fluct3d.NTupleCheck(posobs,string("ntreal"),ntnent);
    417463 PrtTim(">>>> End Computing a realization in real space");
     
    421467   cout<<"...D(z=0)="<<growth(0.)<<"  D(z="<<zref<<")="<<growth(zref)<<endl;
    422468   fluct3d.ApplyGrowthFactor(use_growth_factor);
    423    fluct3d.MinMax(rmin,rmax);
    424    cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
     469   fluct3d.MinMax(vdum1,vdum2);
     470   fluct3d.MeanSigma2(vdum1,vdum2);
    425471   fluct3d.NTupleCheck(posobs,string("ntgrow"),ntnent);
    426472   PrtTim(">>>> End Applying growth factor");
    427473 }
    428 
    429  int_8 nm;
    430  double rmref,rs2ref;
    431  cout<<"\n--- Computing reference variance in real space"<<endl;
    432  nm = fluct3d.MeanSigma2(rmref,rs2ref);
    433  cout<<" rs2ref= "<<rs2ref<<" , rmref="<<rmref<<" ("<<nm<<")"<<endl;
    434  PrtTim(">>>> End Computing reference variance in real space");
    435474
    436475 if(whattowrt[1]&1) {
     
    561600   cout<<"\n--- Computing a realization in real space for Transverse velocity"<<endl;
    562601   fluct3d.ComputeReal();
    563    double rmin,rmax; fluct3d.MinMax(rmin,rmax);
    564    cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
     602   fluct3d.MinMax(vdum1,vdum2);
     603   fluct3d.MeanSigma2(vdum1,vdum2);
    565604   fluct3d.NTupleCheck(posobs,string("nvreal"),ntnent);
    566605   PrtTim(">>>> End Computing a realization in real space");
    567606
    568607    if(use_growth_factor>0) {
    569       cout<<"\n--- Apply Growth factor"<<endl;
     608      cout<<"\n--- Apply Growth factor for transverse velocity"<<endl;
    570609      cout<<"...D(z=0)="<<growth(0.)<<"  D(z="<<zref<<")="<<growth(zref)<<endl;
    571610      fluct3d.ApplyVelLosGrowthFactor(use_growth_factor);
    572       fluct3d.MinMax(rmin,rmax);
    573       cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
     611      fluct3d.MinMax(vdum1,vdum2);
     612      fluct3d.MeanSigma2(vdum1,vdum2);
    574613      fluct3d.NTupleCheck(posobs,string("nvgrow"),ntnent);
    575614      PrtTim(">>>> End Applying growth factor");
    576615    }
    577 
    578     int_8 nmv;
    579     double vmref,vs2ref;
    580     cout<<"\n--- Computing reference variance in real space"<<endl;
    581     nmv = fluct3d.MeanSigma2(vmref,vs2ref);
    582     cout<<" vs2ref= "<<vs2ref<<" , vmref="<<vmref<<" ("<<nmv<<")"<<endl;
    583     PrtTim(">>>> End Computing reference variance in real space");
    584616
    585617    if(whattowrt[1]&1) {
     
    610642 dvl("s8") = sigmaR;
    611643 dvl("Dtype") = (int_4)use_growth_factor; dvl("Pxfilt") = (int_4)filter_by_pixel;
     644 if(cambfread.size()>0) dvl("fCAMB") = cambfread;
    612645 posobs.PutObject(dvl,"siminfo");
    613646 }
    614647
    615648 delete RandGen;
     649 if(pkz != NULL) delete pkz;
    616650 PrtTim(">>>> End Of Job");
    617651
     
    634668}
    635669
     670#include "strutilxx.h"
     671string decodecambarg(string arg,double& h, double& z)
     672// - decode argument for CAMB generation:
     673// input: arg = "cambfilename,h100tab,ztab"
     674// output: h = h100 use to generate CAMB file
     675//         z = redshift use to generate CAMB file
     676// return: CAMB file name
     677{
     678  h = -1.;
     679  z = 0.;
     680  vector<string> vs;
     681  FillVStringFrString(arg,vs,',');
     682  if(vs.size()>1) h = atof(vs[1].c_str());
     683  if(vs.size()>2) z = atof(vs[2].c_str());
     684  cout<<"decodecambarg: "<<arg<<" fn=\""<<vs[0]<<"\" h="<<h<<" z="<<z<<endl;
     685  return vs[0];
     686}
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3805 r3806  
    978978//             (tous les pixels d'un plan Z sont mis au meme redshift z que celui du milieu)
    979979{
    980  if(lp_>0) cout<<"--- ApplyGrowthFactor: evol="<<type_evol<<endl;
     980  if(lp_>0) cout<<"--- ApplyGrowthFactor: evol="<<type_evol<<" (zpk="<<compute_pk_redsh_ref_<<")"<<endl;
    981981 check_array_alloc();
    982982
     
    10351035
    10361036 double zpk = compute_pk_redsh_ref_;
    1037  double dpsd_orig = - cosmo_->H(zpk) * (1.+zpk) * growth_->DsDz(zpk,good_dzinc_) / (*growth_)(zpk);
     1037 double grw_orig = (*growth_)(zpk);
     1038 double dpsd_orig = - cosmo_->H(zpk) * (1.+zpk) * growth_->DsDz(zpk,good_dzinc_) / grw_orig;
     1039 if(lp_>0) cout<<"    original growth="<<grw_orig<<" dpsd="<<dpsd_orig<<" computed at z="<<zpk<<endl;
    10381040
    10391041 InterpFunc interpinv(loscom2zred_min_,loscom2zred_max_,loscom2zred_);
     
    10491051         else dz = fabs(dz); // tous les plans Z au meme redshift
    10501052       double z = interpinv(dz);   // interpolation par morceau
     1053       double grw = (*growth_)(z);
    10511054       double dpsd = interdpd(z);
    10521055       int_8 ip = IndexR(i,j,l);
    1053        data_[ip] *= dpsd / dpsd_orig;
     1056       // on remet le beta au bon z
     1057       // on corrige du growth factor car data_ a ete calcule avec pk(zpk)
     1058       data_[ip] *= (dpsd / dpsd_orig) * (grw / grw_orig);
    10541059     }
    10551060   }
     
    10621067// Calcule une realisation dans l'espace reel
    10631068{
    1064  if(lp_>0) cout<<"--- ComputeReal ---"<<endl;
    1065  check_array_alloc();
    1066 
    1067  // On fait la FFT
    1068  GEN3D_FFTW_EXECUTE(pb_);
    1069  array_type = 1;
     1069  if(lp_>0) cout<<"--- ComputeReal --- from spectrum at z="<<compute_pk_redsh_ref_<<endl;
     1070  check_array_alloc();
     1071
     1072  // On fait la FFT
     1073  GEN3D_FFTW_EXECUTE(pb_);
     1074  array_type = 1;
    10701075}
    10711076
  • trunk/Cosmo/SimLSS/pkspectrum.cc

    r3805 r3806  
    390390double GrowthFactor::DsDz(double z, double)
    391391{
    392   cout<<"Error: GrowthFactor::DsDz not implemented"<<endl;
    393   throw AllocationError("Error: GrowthFactor::DsDz not implemented");
     392  cout<<"GrowthFactor::DsDz_Error not implemented"<<endl;
     393  throw AllocationError(" GrowthFactor::DsDz_Error not implemented");
    394394}
    395395
     
    404404{
    405405  if(OmegaMatter0==0.) {
    406     cout<<"GrowthEisenstein::GrowthEisenstein: Error bad OmegaMatter0  value : "<<OmegaMatter0<<endl;
    407     throw ParmError("GrowthEisenstein::GrowthEisenstein: Error badOmegaMatter0  value");
     406    cout<<"GrowthEisenstein::GrowthEisenstein_Error: bad OmegaMatter0  value : "<<OmegaMatter0<<endl;
     407    throw ParmError("GrowthEisenstein::GrowthEisenstein_Error:  bad OmegaMatter0  value");
    408408  }
    409409}
     
    446446{
    447447 if(z<0. || dzinc<=0.) {
    448    cout<<"GrowthEisenstein::DsDz: z<0 or dzinc<=0. !"<<endl;
    449    throw ParmError("GrowthEisenstein::DsDz: z<0 or dzinc<=0. !");
     448   cout<<"GrowthEisenstein::DsDz_Error: z<0 or dzinc<=0. !"<<endl;
     449   throw ParmError("GrowthEisenstein::DsDz_Error: z<0 or dzinc<=0. !");
    450450 }
    451451
     
    543543
    544544PkTabulate::PkTabulate(void)
    545 : kmin_(1.) , kmax_(-1.) , interptyp_(0)
     545  : kmin_(1.) , kmax_(-1.) , interptyp_(0), d1_(NULL)
    546546{
    547547  k_.resize(0);
     
    550550
    551551PkTabulate::PkTabulate(PkTabulate& pkz)
    552  : kmin_(pkz.kmin_) , kmax_(pkz.kmax_) , interptyp_(pkz.interptyp_) , k_(pkz.k_) , pk_(pkz.pk_)
    553 {
    554 }
    555 
     552 : kmin_(pkz.kmin_) , kmax_(pkz.kmax_) , interptyp_(pkz.interptyp_)
     553 , k_(pkz.k_) , pk_(pkz.pk_)
     554 , d1_(pkz.d1_)
     555{
     556}
    556557
    557558PkTabulate::~PkTabulate(void)
     
    575576double PkTabulate::operator() (double k,double z)
    576577{
    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)
     578  cout<<"PkTabulate::operator(double k,double z)_Error: not implemented"<<endl;
     579  throw AllocationError("PkTabulate::operator(double k,double z)_Error: not implemented");
     580}
     581
     582void PkTabulate::SetZ(double z)
     583{
     584  if(d1_ == NULL) {
     585    cout<<"PkTabulate::SetZ_Error: d1==NULL, no possible redshift change for tabulated Pk"<<endl;
     586    throw ParmError("PkTabulate::SetZ_Error: d1==NULL, no possible redshift change for tabulated Pk");
     587  }
     588  if(pk_.size() == 0) {
     589    cout<<"PkTabulate::SetZ_Error: pk_.size()==0, no possible redshift change for tabulated Pk"<<endl;
     590    throw ParmError("PkTabulate::SetZ_Error: pk_.size()==0, no possible redshift change for tabulated Pk");
     591  }
     592
     593  double zold = zref_;
     594  if(fabs(z-zold)<1.e-4) return;
     595
     596  zref_ = z;
     597  double d0 = (*d1_)(zold);
     598  double d1 = (*d1_)(zref_);
     599  double conv = d1*d1 / (d0*d0);
     600  cout<<"PkTabulate::SetZ: change redshift from "<<zold<<" (d="<<d0
     601      <<") to "<<zref_<<" (d="<<d1<<") conv="<<conv<<endl;
     602  for(unsigned int i=0;i<pk_.size();i++) pk_[i] *= conv;
     603}
     604
     605int PkTabulate::ReadCAMB(string filename, double h100tab, double zreftab)
    582606{
    583607 FILE *file = fopen(filename.c_str(),"r");
    584608 if(file==NULL) return -1;
    585  cout<<"PkTabulate::ReadCAMB: fn="<<filename<<" h100="<<h100<<" zreftab = "<<zreftab<<endl;
     609 cout<<"PkTabulate::ReadCAMB: fn="<<filename<<" h100="<<h100tab<<" zreftab = "<<zreftab<<endl;
    586610
    587611 const int lenline = 512;
    588612 char *line = new char[lenline];
     613 double h = h100tab, h3 = pow(h100tab,3.);
    589614
    590615 k_.resize(0); pk_.resize(0);
     616 double kmax = 0., pkmax = 0.;
    591617 while ( fgets(line,lenline,file) != NULL ) {
    592618   double k, pk;
    593619   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
     620   k *= h;      // convert h    Mpc^-1  ->  Mpc^-1
     621   pk /= h3;    // convert h^-3 Mpc^3   ->  Mpc^3
     622   if(pk>pkmax) {pkmax = pk; kmax = k;}
    596623   k_.push_back(k);
    597624   pk_.push_back(pk);
    598625 }
    599626
    600  SetZ(zreftab);
    601  cout<<"PkTabulate::ReadCAMB nread="<<pk_.size()<<"zref="<<GetZ()<<endl;
     627 zref_ = zreftab;
     628 cout<<"  nread="<<pk_.size()<<" zref="<<GetZ()<<" , k,pk: max="<<kmax<<","<<pkmax;
     629 if(pk_.size()>0) cout<<" [0]="<<k_[0]<<","<<pk_[0]
     630                      <<" [n]="<<k_[pk_.size()-1]<<","<<pk_[pk_.size()-1];
     631 cout<<endl;
     632
    602633 delete [] line;
    603634
     
    667698{
    668699 if(R<=0.) {
    669     cout<<"VarianceSpectrum::SetRadius: Error R<=0"<<endl;
    670     throw ParmError("VarianceSpectrum::SetRadius: Error R<=0");
     700    cout<<"VarianceSpectrum::SetRadius_Error: R<=0"<<endl;
     701    throw ParmError("VarianceSpectrum::SetRadius_Error: R<=0");
    671702  }
    672703  R_ = R;
     
    737768{
    738769  if(kmin<=0 || kmax<=0. || kmin>=kmax) {
    739     cout<<"VarianceSpectrum::Variance: Error kmin<=0 or kmax<=0 or kmin>=kmax"<<endl;
    740     throw ParmError("VarianceSpectrum::Variance: Error kmin<=0 or kmax<=0 or kmin>=kmax");
     770    cout<<"VarianceSpectrum::Variance_Error: kmin<=0 or kmax<=0 or kmin>=kmax"<<endl;
     771    throw ParmError("VarianceSpectrum::Variance_Error: kmin<=0 or kmax<=0 or kmin>=kmax");
    741772  }
    742773
     
    759790{
    760791  if(kmin<=0 || kmax<=0. || kmin>=kmax) {
    761     cout<<"VarianceSpectrum::FindMaximum: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"<<endl;
    762     throw ParmError("VarianceSpectrum::FindMaximum: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
     792    cout<<"VarianceSpectrum::FindMaximum_Error: kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"<<endl;
     793    throw ParmError("VarianceSpectrum::FindMaximum_Error: kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
    763794  }
    764795
     
    802833{
    803834  if(kmin<=0 || kmax<=0. || kmin>=kmax  || eps<=0.) {
    804     cout<<"VarianceSpectrum::FindLimits: Error kmin<=0 or kmax<=0 or kmin>=kmax or eps<=0"<<endl;
    805     throw ParmError("VarianceSpectrum::FindLimits: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
     835    cout<<"VarianceSpectrum::FindLimits_Error: kmin<=0 or kmax<=0 or kmin>=kmax or eps<=0"<<endl;
     836    throw ParmError("VarianceSpectrum::FindLimits_Error: kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
    806837  }
    807838
  • trunk/Cosmo/SimLSS/pkspectrum.h

    r3805 r3806  
    154154  virtual double operator() (double k);
    155155  virtual double operator() (double k,double z);
     156  virtual void SetZ(double z);
    156157  int NPoints(void) {return k_.size();}
    157158  void SetInterpTyp(int typ=0);
    158   int ReadCAMB(string filename, double h100=0.71, double zreftab = 0.);
     159  int ReadCAMB(string filename, double h100tab=0.71, double zreftab=0.);
     160  void SetGrowthFactor(GrowthFactor* d1) {d1_ = d1;}
     161  GrowthFactor* GetGrowthFactor(void) {return d1_;}
     162  double KMin(void) {if(k_.size()!=0) return k_[0]; else return 0.;}
     163  double KMax(void) {if(k_.size()!=0) return k_[k_.size()-1]; else return 0.;}
    159164protected:
    160165  double kmin_,kmax_;
    161166  int interptyp_;
    162167  vector<double> k_, pk_;
     168  GrowthFactor* d1_;
    163169};
    164170
Note: See TracChangeset for help on using the changeset viewer.