Changeset 3322 in Sophya for trunk/Cosmo/SimLSS/cmvobserv3d.cc
- Timestamp:
- Sep 5, 2007, 6:16:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvobserv3d.cc
r3316 r3322 34 34 <<" if evol>0 noise evolved with distance (def no)"<<endl 35 35 <<" -2 : compute also 2D spectrum (default: no)"<<endl 36 <<" -N scalecube,offsetcube: normalize cube before doing final spectrum (default: automatic)"<<endl 36 37 <<" -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 37 42 <<" -A <log10(S_agn in Jy at 1.4 GHz)>,sigma,powlaw :"<<endl 38 43 <<" AGN mean and sigma gaussian equiv. distrib. for solid angle of centeral pixel"<<endl … … 79 84 double alpha = -1.37; 80 85 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 = ""; 83 92 84 93 // *** Niveau de bruit … … 103 112 bool wslice = false; 104 113 bool compvarreal = false; 114 double scalecube = -1., offsetcube = 0.; 105 115 106 116 // --- Decodage arguments 107 117 if(narg>0) { 118 cout<<"\n--- Arguments: "<<endl; 108 119 for(int i=0;i<narg;i++) cout<<arg[i]<<" "; 109 120 cout<<endl; … … 111 122 112 123 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) { 114 125 int nth = 0; 115 126 switch (c) { … … 144 155 comp2dspec = true; 145 156 break; 157 case 'N' : 158 sscanf(optarg,"%lf,%lf",&scalecube,&offsetcube); 159 break; 146 160 case 'M' : 147 161 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; 148 169 break; 149 170 case 'A' : … … 173 194 } 174 195 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; 179 202 180 203 cout<<"zref="<<zref<<endl; … … 189 212 <<", schnpt="<<schnpt<<endl; 190 213 cout<<"snoise="<<snoise<<" equivalent Msol, evolution="<<isnoise_evol<<endl; 214 cout<<"scalecube="<<scalecube<<", offsetcube="<<offsetcube<<endl; 191 215 if(do_agn) 192 216 cout<<"AGN: <log10(Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn 193 217 <<" , powlaw="<<powlaw_agn<<endl; 218 219 string tagobs = "cmvobserv3d.ppf"; 220 POutPersist posobs(tagobs); 194 221 195 222 //----------------------------------------------------------------- … … 221 248 222 249 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();229 250 230 251 //----------------------------------------------------------------- … … 274 295 double sr2int = varpk_int.Variance(R,k1int,k2int); 275 296 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(); 279 303 280 304 sch.SetOutValue(0); 281 305 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); 283 307 cout<<"Galaxy density number = "<<ngal_by_mpc3<<" /Mpc^3 between limits"<<endl; 284 308 285 309 sch.SetOutValue(1); 286 310 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); 288 312 cout<<"Galaxy mass density= "<<mass_by_mpc3<<" Msol/Mpc^3 between limits"<<endl; 289 313 cout<<"Omega_HI at z=0 is "<<mass_by_mpc3/(univ.Rhoc(0.)*GCm3toMsolMpc3_Cst)<<endl 290 314 <<" 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 } 291 330 292 331 PrtTim(">>>> End of definition"); … … 305 344 fluct3d.SetGrowthFactor(growth); 306 345 fluct3d.LosComRedshift(0.001,-1); 307 TArray<r_8>& rgen = fluct3d.GetRealArray();346 //TArray<r_8>& rgen = fluct3d.GetRealArray(); 308 347 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; 309 350 310 351 double dkmin = fluct3d.GetKincMin(); 311 352 double knyqmax = fluct3d.GetKmax(); 312 353 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; 314 355 315 356 double dktmin = fluct3d.GetKTincMin(); … … 421 462 cout<<"\n--- Computing a realization in real space"<<endl; 422 463 fluct3d.ComputeReal(); 423 double rmin,rmax; rgen.MinMax(rmin,rmax);464 double rmin,rmax; fluct3d.MinMax(rmin,rmax); 424 465 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl; 425 466 PrtTim(">>>> End Computing a realization in real space"); … … 429 470 cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl; 430 471 fluct3d.ApplyGrowthFactor(); 431 rgen.MinMax(rmin,rmax);472 fluct3d.MinMax(rmin,rmax); 432 473 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl; 433 474 PrtTim(">>>> End Applying growth factor"); 434 475 } 435 476 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"); 436 483 437 484 if(wfits) { … … 448 495 } 449 496 450 int_8 nm;451 double rm,rs2;452 497 cout<<"\n--- Check mean and variance in real space"<<endl; 453 498 fluct3d.NumberOfBad(-1.,1e+200); 499 double rm,rs2; 454 500 nm = fluct3d.MeanSigma2(rm,rs2); 455 501 PrtTim(">>>> End Check mean and variance in real space"); … … 465 511 } 466 512 467 //return -41; // CMVTEST 513 //STOP_HERE_FOR QUICK_DEBUG 514 // return -41; 468 515 469 516 //----------------------------------------------------------------- … … 473 520 PrtTim(">>>> End Converting fluctuations into mass"); 474 521 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; 476 524 rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3); 477 525 nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200); … … 487 535 nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200); 488 536 nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.); 537 double xgalmin,xgalmax; fluct3d.MinMax(xgalmin,xgalmax,0.1,1.e50); 489 538 PrtTim(">>>> End Apply poisson on galaxy number"); 490 539 if(wslice) { … … 494 543 495 544 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 } 507 557 cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl; 508 558 nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200); … … 536 586 } 537 587 538 double scalecube = -1., offsetcube=0.;539 588 if(snoise>0.) { 540 589 cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl; 541 590 fluct3d.AddNoise2Real(snoise,(isnoise_evol>0? true:false)); 542 591 nm = fluct3d.MeanSigma2(rm,rs2); 543 if(rs2>0. && sr2int>0.) scalecube = sqrt(sr2int)/sqrt(rs2);544 offsetcube = -rm;545 592 PrtTim(">>>> End Add noise"); 546 593 } 547 594 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"); 552 604 } 553 605
Note:
See TracChangeset
for help on using the changeset viewer.