Changeset 3262 in Sophya for trunk/Cosmo/SimLSS/genefluct3d.cc


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

affinage du calcul des meansigma cmv 5/6/2007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.