Changeset 3322 in Sophya for trunk/Cosmo


Ignore:
Timestamp:
Sep 5, 2007, 6:16:45 PM (18 years ago)
Author:
cmv
Message:

Intro SchechterMassDist + lecture sur fichier cmv 05/09/2007

Location:
trunk/Cosmo/SimLSS
Files:
2 edited

Legend:

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

    r3316 r3322  
    3434     <<"                  if evol>0 noise evolved with distance (def no)"<<endl
    3535     <<" -2 : compute also 2D spectrum (default: no)"<<endl
     36     <<" -N scalecube,offsetcube: normalize cube before doing final spectrum (default: automatic)"<<endl
    3637     <<" -M schmin,schmax,nsch : min,max mass and nb points for schechter HI"<<endl
     38     <<"                         If nsch<0 alors no,bre de points par decade"<<endl
     39     <<" -Q naleagal : use quick method for turning ngal to mass"<<endl
     40     <<" -R schmassdist.ppf : read mass distribution for trials from file"<<endl
     41     <<"               instead of computing it (ONLY if \"-Q\" option is activated)"<<endl
    3742     <<" -A <log10(S_agn in Jy at 1.4 GHz)>,sigma,powlaw :"<<endl
    3843     <<"    AGN mean and sigma gaussian equiv. distrib. for solid angle of centeral pixel"<<endl
     
    7984 double alpha = -1.37;
    8085
    81  double schmin=1e8, schmax=1e12;
    82  int schnpt = 1000;
     86 double schmin=1e8, schmax=1e13;
     87 int schnpt = -100;
     88 bool use_schmassdist = false;
     89 long naleagal = 100000;
     90 bool recompute_schmassdist = true;
     91 string schmassdistfile = "";
    8392
    8493 // *** Niveau de bruit
     
    103112 bool wslice = false;
    104113 bool compvarreal = false;
     114 double scalecube = -1., offsetcube = 0.;
    105115
    106116 // --- Decodage arguments
    107117 if(narg>0) {
     118   cout<<"\n--- Arguments: "<<endl;
    108119   for(int i=0;i<narg;i++) cout<<arg[i]<<" ";
    109120   cout<<endl;
     
    111122
    112123 char c;
    113  while((c = getopt(narg,arg,"ha0PWSV2GF:x:y:z:s:Z:M:A:T:")) != -1) {
     124 while((c = getopt(narg,arg,"ha0PWSV2GF:x:y:z:s:Z:M:A:T:N:Q:R:")) != -1) {
    114125  int nth = 0;
    115126  switch (c) {
     
    144155    comp2dspec = true;
    145156    break;
     157  case 'N' :
     158    sscanf(optarg,"%lf,%lf",&scalecube,&offsetcube);
     159    break;
    146160  case 'M' :
    147161    sscanf(optarg,"%lf,%lf,%d",&schmin,&schmax,&schnpt);
     162    break;
     163  case 'Q' :
     164    use_schmassdist = true;
     165    sscanf(optarg,"%ld",&naleagal);
     166    break;
     167  case 'R' :
     168    schmassdistfile = optarg;
    148169    break;
    149170  case 'A' :
     
    173194 }
    174195
    175  double lschmin=log10(schmin), lschmax=log10(schmax), dlsch=(lschmax-lschmin)/schnpt;
    176 
    177  string tagobs = "cmvobserv3d.ppf";
    178  POutPersist posobs(tagobs);
     196 double lschmin=log10(schmin), lschmax=log10(schmax);
     197 if(schnpt<=0) {  // alors c'est un nombre de points par decade
     198   schnpt = long( (-schnpt)*(lschmax-lschmin+1.) + 0.5 );
     199   if(schnpt<=2) schnpt = 1000;
     200 }
     201 if(naleagal<=2) naleagal = 100000;
    179202
    180203 cout<<"zref="<<zref<<endl;
     
    189212     <<", schnpt="<<schnpt<<endl;
    190213 cout<<"snoise="<<snoise<<" equivalent Msol, evolution="<<isnoise_evol<<endl;
     214 cout<<"scalecube="<<scalecube<<", offsetcube="<<offsetcube<<endl;
    191215 if(do_agn)
    192216   cout<<"AGN: <log10(Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
    193217       <<" , powlaw="<<powlaw_agn<<endl;
     218
     219 string tagobs = "cmvobserv3d.ppf";
     220 POutPersist posobs(tagobs);
    194221
    195222 //-----------------------------------------------------------------
     
    221248
    222249 PkSpectrumZ pkz(pk0,growth,zref);
    223  
    224  //-----------------------------------------------------------------
    225  cout<<endl<<"\n--- Create mass function"<<endl;
    226 
    227  Schechter sch(nstar,mstar,alpha);
    228  sch.Print();
    229250
    230251 //-----------------------------------------------------------------
     
    274295 double sr2int = varpk_int.Variance(R,k1int,k2int);
    275296 cout<<"varpk_int="<<sr2int<<"  ->  sigma="<<sqrt(sr2int)<<endl;
    276 
    277  //-----------------------------------------------------------------
    278  cout<<endl<<"\n--- Compute galaxy density number"<<endl;
     297 
     298 //-----------------------------------------------------------------
     299 cout<<endl<<"\n--- Create mass function, compute number/mass density, init mass trials"<<endl;
     300
     301 Schechter sch(nstar,mstar,alpha);
     302 sch.Print();
    279303
    280304 sch.SetOutValue(0);
    281305 cout<<"sch(mstar) = "<<sch(mstar)<<" /Mpc^3/Msol"<<endl;
    282  double ngal_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
     306 double ngal_by_mpc3 = sch.Integrate(schmin,schmax,schnpt);
    283307 cout<<"Galaxy density number = "<<ngal_by_mpc3<<" /Mpc^3 between limits"<<endl;
    284308
    285309 sch.SetOutValue(1);
    286310 cout<<"mstar*sch(mstar) = "<<sch(mstar)<<" Msol/Mpc^3/Msol"<<endl;
    287  double mass_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
     311 double mass_by_mpc3 = sch.Integrate(schmin,schmax,schnpt);
    288312 cout<<"Galaxy mass density= "<<mass_by_mpc3<<" Msol/Mpc^3 between limits"<<endl;
    289313 cout<<"Omega_HI at z=0 is "<<mass_by_mpc3/(univ.Rhoc(0.)*GCm3toMsolMpc3_Cst)<<endl
    290314     <<"         at z="<<zref<<" is "<<mass_by_mpc3/(univ.Rhoc(zref)*GCm3toMsolMpc3_Cst)<<endl;
     315
     316 SchechterMassDist schmdist(sch,schmin,schmax,schnpt);
     317 if(use_schmassdist && schmassdistfile.size()>0) {
     318   cout<<"\nWARNING: SchechterMassDist read from "<<schmassdistfile<<endl
     319       <<"      PLEASE CHECK CONSISTENCY WITH REQUESTED PARAMETERS"<<endl;
     320   schmdist.ReadPPF(schmassdistfile);
     321 }
     322 schmdist.Print();
     323 Histo hmdndm = schmdist.GetHmDnDm();
     324 FunRan tirhmdndm = schmdist.GetTmDnDm();
     325 {
     326 tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
     327 Histo hdum1(tirhmdndm);
     328 tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
     329 }
    291330
    292331 PrtTim(">>>> End of definition");
     
    305344 fluct3d.SetGrowthFactor(growth);
    306345 fluct3d.LosComRedshift(0.001,-1);
    307  TArray<r_8>& rgen = fluct3d.GetRealArray();
     346 //TArray<r_8>& rgen = fluct3d.GetRealArray();
    308347 cout<<endl; fluct3d.Print();
     348 cout<<"\nMean number of galaxies per pixel = "<<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
     349 cout<<"Mean mass per pixel = "<<mass_by_mpc3*fluct3d.GetDVol()<<endl;
    309350
    310351 double dkmin = fluct3d.GetKincMin();
    311352 double knyqmax = fluct3d.GetKmax();
    312353 long nherr = long(knyqmax/dkmin+0.5);
    313  cout<<"For HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
     354 cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
    314355
    315356 double dktmin = fluct3d.GetKTincMin();
     
    421462 cout<<"\n--- Computing a realization in real space"<<endl;
    422463 fluct3d.ComputeReal();
    423  double rmin,rmax; rgen.MinMax(rmin,rmax);
     464 double rmin,rmax; fluct3d.MinMax(rmin,rmax);
    424465 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
    425466 PrtTim(">>>> End Computing a realization in real space");
     
    429470   cout<<"...D(z=0)="<<growth(0.)<<"  D(z="<<zref<<")="<<growth(zref)<<endl;
    430471   fluct3d.ApplyGrowthFactor();
    431    rgen.MinMax(rmin,rmax);
     472   fluct3d.MinMax(rmin,rmax);
    432473   cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
    433474   PrtTim(">>>> End Applying growth factor");
    434475 }
    435476
     477 int_8 nm;
     478 double rmref,rs2ref;
     479 cout<<"\n--- Computing reference variance in real space"<<endl;
     480 nm = fluct3d.MeanSigma2(rmref,rs2ref);
     481 cout<<" rs2ref= "<<rs2ref<<" , rmref="<<rmref<<" ("<<nm<<")"<<endl;
     482 PrtTim(">>>> End Computing reference variance in real space");
    436483
    437484 if(wfits) {
     
    448495 }
    449496
    450  int_8 nm;
    451  double rm,rs2;
    452497 cout<<"\n--- Check mean and variance in real space"<<endl;
    453498 fluct3d.NumberOfBad(-1.,1e+200);
     499 double rm,rs2;
    454500 nm = fluct3d.MeanSigma2(rm,rs2);
    455501 PrtTim(">>>> End Check mean and variance in real space");
     
    465511 }
    466512
    467  //return -41; // CMVTEST
     513 //STOP_HERE_FOR QUICK_DEBUG
     514 // return -41;
    468515
    469516 //-----------------------------------------------------------------
     
    473520 PrtTim(">>>> End Converting fluctuations into mass");
    474521
    475  cout<<"\n--- Converting mass into galaxy number"<<endl;
     522 cout<<"\n--- Converting mass into galaxy number: gal per pixel ="
     523     <<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
    476524 rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
    477525   nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
     
    487535   nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
    488536   nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
     537 double xgalmin,xgalmax; fluct3d.MinMax(xgalmin,xgalmax,0.1,1.e50);
    489538 PrtTim(">>>> End Apply poisson on galaxy number");
    490539 if(wslice) {
     
    494543
    495544 cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
    496  long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
    497  Histo hmdndm(lschmin,lschmax,nhmdndm);
    498  sch.SetOutValue(1);
    499  FuncToHisto(sch,hmdndm,true);
    500  FunRan tirhmdndm(hmdndm,true);
    501  {
    502  tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
    503  Histo hdum1(tirhmdndm);
    504  tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
    505  }
    506  double mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
     545 double mhi = 0.;
     546 if(use_schmassdist) {
     547   if(recompute_schmassdist) {
     548     int ngalmax = int(xgalmax+0.5);
     549     schmdist.SetNgalLim(ngalmax,1,naleagal);
     550     PrtTim(">>>> End creating tabulated histograms for trials");
     551   }
     552   mhi = fluct3d.TurnNGal2MassQuick(schmdist);
     553   schmdist.PrintStatus();
     554 } else {
     555   mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
     556 }
    507557 cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
    508558   nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
     
    536586 }
    537587
    538  double scalecube = -1., offsetcube=0.;
    539588 if(snoise>0.) {
    540589   cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl;
    541590   fluct3d.AddNoise2Real(snoise,(isnoise_evol>0? true:false));
    542591     nm = fluct3d.MeanSigma2(rm,rs2);
    543      if(rs2>0. && sr2int>0.) scalecube = sqrt(sr2int)/sqrt(rs2);
    544      offsetcube = -rm;
    545592   PrtTim(">>>> End Add noise");
    546593 }
    547594
    548  if(scalecube>0.) {
    549    cout<<"\n--- Scale and offset scale="<<scalecube
    550        <<" off="<<offsetcube<<endl;
    551    fluct3d.ScaleOffset(scalecube,offsetcube);
     595 if(scalecube!=0.) {  // Si scalecube==0 pas de normalisation
     596   cout<<"\n--- Scale cube rs2ref="<<rs2ref<<endl;
     597   if(scalecube<0. && rs2ref>0.) {  // si negatif on scale automatiquement
     598     nm = fluct3d.MeanSigma2(rm,rs2);
     599     if(rs2>0.) {scalecube=sqrt(rs2ref)/sqrt(rs2); offsetcube=-rm;}
     600   }
     601   cout<<"...scale="<<scalecube<<" offset="<<offsetcube<<endl;
     602   if(scalecube>0.) fluct3d.ScaleOffset(scalecube,offsetcube);
     603   PrtTim(">>>> End Scale cube");
    552604 }
    553605 
  • trunk/Cosmo/SimLSS/cmvschdist.cc

    r3320 r3322  
    99// compare with:
    1010// > cmvschdist -a -v -m 1e+8,1e+13 -n -100 -r 200 -N 100000 -0
    11 // Fabriquer un fichier
     11// Fabriquer un fichier pour la prod
    1212// > cmvschdist -a -m 1e+8,1e+13 -n -100 -r 2000 -N 5000000 -W schdist_2000.ppf
    1313#include <iostream>
     
    245245
    246246# Compare evolution
    247 disp h200               
     247disp h2000               
     248disp h1000 "same red"       
     249disp h500 "same blue"       
     250disp h200 "same green"     
    248251disp h100 "same red"
    249252disp h50 "same blue"
Note: See TracChangeset for help on using the changeset viewer.