Changeset 3262 in Sophya for trunk/Cosmo/SimLSS


Ignore:
Timestamp:
Jun 5, 2007, 7:52:59 PM (18 years ago)
Author:
cmv
Message:

affinage du calcul des meansigma cmv 5/6/2007

Location:
trunk/Cosmo/SimLSS
Files:
2 edited

Legend:

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

    r3261 r3262  
    100100
    101101 // --- Decodage arguments
     102 if(narg>0) {
     103   for(int i=0;i<narg;i++) cout<<arg[i]<<" ";
     104   cout<<endl;
     105 }
    102106
    103107 char c;
     
    414418 if(1) {
    415419   cout<<"\n--- Check mean and variance in real space"<<endl;
    416    int_8 nlowone = fluct3d.NumberOfBad(-1.,1e+200);
     420   fluct3d.NumberOfBad(-1.,1e+200);
    417421   nm = fluct3d.MeanSigma2(rm,rs2);
    418    cout<<"rgen:("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    419        <<rs2<<" -> "<<sqrt(rs2)<<",  n(<-1)="<<nlowone<<endl;
    420422   PrtTim(">>>> End Check mean and variance in real space");
    421423 }
     
    424426   cout<<"\n--- Check variance sigmaR in real space"<<endl;
    425427   double varr;
    426    int_8 nvarr = fluct3d.VarianceFrReal(R,varr);
    427    cout<<"R="<<R<<" : sigmaR^2="<<varr<<" -> "<<sqrt(varr)<<",   n="<<nvarr<<endl;
     428   fluct3d.VarianceFrReal(R,varr);
    428429   PrtTim(">>>> End Check variance sigmaR in real space");
    429430 }
     
    432433 cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
    433434 fluct3d.TurnFluct2Mass();
    434  nm = fluct3d.MeanSigma2(rm,rs2);
    435  cout<<"1+rgen: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    436      <<rs2<<" -> "<<sqrt(rs2)<<endl;
    437  nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    438  cout<<"1+rgen with_neg_a_zero: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    439      <<rs2<<" -> "<<sqrt(rs2)<<endl;
     435   nm = fluct3d.MeanSigma2(rm,rs2);
    440436 PrtTim(">>>> End Converting fluctuations into mass");
    441437
    442438 cout<<"\n--- Converting mass into galaxy number"<<endl;
    443439 rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
    444  cout<<rm<<" galaxies put into survey"<<endl;
    445  nm = fluct3d.MeanSigma2(rm,rs2,0.);
    446  cout<<"galaxy mass: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    447      <<rs2<<" -> "<<sqrt(rs2)<<endl;
    448  nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    449  cout<<"galaxy mass with_neg_a_zero: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    450      <<rs2<<" -> "<<sqrt(rs2)<<endl;
    451  PrtTim(">>>> End Converting mass into galaxy number");
     440   nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
     441   nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
     442  PrtTim(">>>> End Converting mass into galaxy number");
    452443
    453444 cout<<"\n--- Set negative and null pixels to BAD"<<endl;
    454445 nm = fluct3d.SetToVal(0.,1e+200,-999.);
    455  cout<<nm<<" negative in survey set to BAD"<<endl;
    456  nm = fluct3d.MeanSigma2(rm,rs2,-998.);
    457  cout<<"galaxy mass: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    458      <<rs2<<" -> "<<sqrt(rs2)<<endl;
    459446 PrtTim(">>>> End Set negative pixels to BAD etc...");
    460447
    461448 cout<<"\n--- Apply poisson on galaxy number"<<endl;
    462  nm = fluct3d.ApplyPoisson();
    463  cout<<nm<<" galaxies into survey after poisson"<<endl;
    464  nm = fluct3d.MeanSigma2(rm,rs2,-998.);
    465  cout<<"galaxy number: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    466      <<rs2<<" -> "<<sqrt(rs2)<<endl;
    467  nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    468  cout<<"galaxy number with_neg_a_zero: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    469      <<rs2<<" -> "<<sqrt(rs2)<<endl;
     449 fluct3d.ApplyPoisson();
     450   nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
     451   nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    470452 PrtTim(">>>> End Apply poisson on galaxy number");
    471453
     
    483465 double mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
    484466 cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
    485  nm = fluct3d.MeanSigma2(rm,rs2,-998.);
    486  cout<<"HI mass: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    487      <<rs2<<" -> "<<sqrt(rs2)<<endl;
    488  cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
    489  nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    490  cout<<"HI mass with_neg_a_zero: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    491      <<rs2<<" -> "<<sqrt(rs2)<<endl;
     467   nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
     468   cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
     469   nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    492470 PrtTim(">>>> End Convert Galaxy number to HI mass");
    493471
    494472 cout<<"\n--- Set BAD pixels to Zero"<<endl;
    495473 nm = fluct3d.SetToVal(-998.,1e+200,0.);
    496  cout<<nm<<" BAD in survey set to zero"<<endl;
    497  nm = fluct3d.MeanSigma2(rm,rs2);
    498  cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    499      <<rs2<<" -> "<<sqrt(rs2)<<endl;
    500474 PrtTim(">>>> End Set BAD pixels to Zero etc...");
    501475
     
    513487       <<" , powlaw="<<powlaw_agn<<endl;
    514488   fluct3d.AddAGN(lfjy_agn,lsigma_agn,powlaw_agn);
    515    nm = fluct3d.MeanSigma2(rm,rs2);
    516    cout<<"HI mass with AGN: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    517        <<rs2<<" -> "<<sqrt(rs2)<<endl;
     489     nm = fluct3d.MeanSigma2(rm,rs2);
    518490   PrtTim(">>>> End Add AGN");
    519491 }
     
    522494   cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<endl;
    523495   fluct3d.AddNoise2Real(snoise);
    524    nm = fluct3d.MeanSigma2(rm,rs2);
    525    cout<<"HI mass with noise: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
    526        <<rs2<<" -> "<<sqrt(rs2)<<endl;
     496     nm = fluct3d.MeanSigma2(rm,rs2);
    527497   PrtTim(">>>> End Add noise");
    528498 }
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3261 r3262  
    381381   bool found_tag_k = pis.GotoNameTag("pkgen");
    382382   if(found_tag_k) {
    383      cout<<"           ...reading spectrun into TArray<complex <r_8> >"<<endl;
     383     cout<<"           ...reading spectrum into TArray<complex <r_8> >"<<endl;
    384384     pis >> PPFNameTag("pkgen")  >> T_;
    385385     from_real = false;
     
    792792// Recompute MASS variance in spherical top-hat (rayon=R)
    793793{
    794  if(lp_>0) cout<<"--- VarianceFrReal ---"<<endl;
     794  if(lp_>0) cout<<"--- VarianceFrReal R="<<R<<endl;
    795795 check_array_alloc();
    796796
     
    829829 sum /= nsum;
    830830 sum2 = sum2/nsum - sum*sum;
    831  if(lp_>0) cout<<"VarianceFrReal: nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl;
     831 if(lp_>0) cout<<"...nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl;
    832832
    833833 var = sum2/(sum*sum);  // <dM>^2/<M>^2
    834  if(lp_>0) cout<<"sigmaR^2="<<var<<" -> "<<sqrt(var)<<endl;
     834 if(lp_>0) cout<<"...sigmaR^2="<<var<<" -> "<<sqrt(var)<<endl;
    835835
    836836 return nsum;
     
    851851 }
    852852
     853 if(lp_>0) cout<<"--- NumberOfBad "<<nbad<<" px out of ]"<<vmin<<","<<vmax<<"["<<endl;
    853854 return nbad;
    854855}
     
    863864 bool tstval = (vmax>vmin)? true: false;
    864865 if(lp_>0) {
    865    cout<<"--- MeanSigma2: ";
    866    if(tstval) cout<<"range=]"<<vmin<<","<<vmax<<"[";
     866   cout<<"--- MeanSigma2";
     867   if(tstval) cout<<"  range=]"<<vmin<<","<<vmax<<"[";
    867868   if(useout) cout<<", useout="<<useout<<" vout="<<vout;
    868869   cout<<endl;
     
    898899// cad set to "val0" if in [vmin,vmax] -> vmin and vmax are set to val0
    899900{
    900  if(lp_>0) cout<<"--- SetToVal set to="<<val0
    901                <<" when in range=["<<vmin<<","<<vmax<<"]"<<endl;
    902901 check_array_alloc();
    903902
     
    909908 }
    910909
     910 if(lp_>0) cout<<"--- SetToVal "<<nbad<<" px set to="<<val0
     911               <<" because out of range=]"<<vmin<<","<<vmax<<"["<<endl;
    911912 return nbad;
    912913}
     
    931932 if(lp_>0) cout<<"--- TurnMass2MeanNumber ---"<<endl;
    932933
    933  double m,s2;
    934  int_8 ngood = MeanSigma2(m,s2,0.,1e+200);
    935  if(lp_>0) cout<<"...ngood="<<ngood
    936                <<" m="<<m<<" s2="<<s2<<" -> "<<sqrt(s2)<<endl;
     934 double mall=0., mgood=0.;
     935 int_8  nall=0,  ngood=0;
     936 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) {
     937   int_8 ip = IndexR(i,j,l);
     938   mall += data_[ip]; nall++;
     939   if(data_[ip]>0.) {mgood += data_[ip]; ngood++;}
     940 }
     941 if(ngood>0) mgood /= (double)ngood;
     942 if(nall>0)  mall  /= (double)nall;
     943 if(lp_>0) cout<<"...ngood="<<ngood<<" mgood="<<mgood
     944               <<",  nall="<<nall<<" mall="<<mall<<endl;
     945 if(ngood<=0 || mall<=0.) {
     946   cout<<"TurnMass2MeanNumber_Error: ngood="<<ngood<<" <=0 || mall="<<mall<<" <=0"<<endl;
     947   throw RangeCheckError("TurnMass2MeanNumber_Error: ngood<=0 || mall<=0");
     948 }
    937949
    938950 // On doit mettre n*Vol galaxies dans notre survey
     
    943955 //   a la moyenne de <1+d_rho/rho> sur ces pixels
    944956 //   (rappel sur tout les pixels <1+d_rho/rho>=1)
    945  double dn = n_by_mpc3*Vol_/m /(double)ngood;  // nb de gal a mettre ds 1 px
     957 // nb de gal a mettre ds 1 px:
     958 double dn = n_by_mpc3*Vol_/ (mgood/mall) /(double)ngood;
    946959 if(lp_>0) cout<<"...galaxy density move from "
    947960               <<n_by_mpc3*Vol_/double(NRtot_)<<" to "<<dn<<" / pixel"<<endl;
     961
    948962 double sum = 0.;
    949963 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) {
     
    952966   if(data_[ip]>0.) sum += data_[ip];  // mais on ne les compte pas
    953967 }
     968
    954969 if(lp_>0) cout<<sum<<"...galaxies put into survey / "<<n_by_mpc3*Vol_<<endl;
    955970
Note: See TracChangeset for help on using the changeset viewer.