Changeset 3329 in Sophya


Ignore:
Timestamp:
Sep 27, 2007, 6:21:55 PM (18 years ago)
Author:
cmv
Message:

possibilite de ne pas faire poisson sur Ngal cmv 27/09/2007

Location:
trunk/Cosmo/SimLSS
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/SimLSS/Makefile

    r3317 r3329  
    1414MYLIB = $(SOPHYAEXTSLBLIST) -L$(LIB) -lcmvsimbao -lfftw3_threads -lfftw3 -lm
    1515
    16 #---- Les programmes utilitaires de calcul de cartes
    1716PROGS = \
    1817       $(EXE)cmvtuniv $(EXE)cmvtransf $(EXE)cmvtgrowth $(EXE)cmvtstpk \
  • trunk/Cosmo/SimLSS/cmvobserv3d.cc

    r3323 r3329  
    2626     <<"      (default: no, spectrum Pk(z=z_median) for all cube)"<<endl
    2727     <<" -F : filter spectrum by pixel shape (0=no 1=yes(default)"<<endl
     28     <<" -U : do not poisson fluctuate with Ngal, convert directly to HI mass"<<endl
    2829     <<" -x nx,dx : size along x axis (npix,Mpc)"<<endl
    2930     <<" -y ny,dy : size along y axis (npix,Mpc)"<<endl
     
    9091 bool recompute_schmassdist = true;
    9192 string schmassdistfile = "";
     93 bool no_poisson = false;
    9294
    9395 // *** Niveau de bruit
     
    122124
    123125 char c;
    124  while((c = getopt(narg,arg,"ha0PWSV2GF:x:y:z:s:Z:M:A:T:N:Q:R:")) != -1) {
     126 while((c = getopt(narg,arg,"ha0PWSV2GUF:x:y:z:s:Z:M:A:T:N:Q:R:")) != -1) {
    125127  int nth = 0;
    126128  switch (c) {
     
    133135  case 'G' :
    134136    use_growth_factor = true;
     137    break;
     138  case 'U' :
     139    no_poisson = true;
    135140    break;
    136141  case 'F' :
     
    211216     <<"), schmax="<<schmax<<" ("<<lschmax<<") Msol"
    212217     <<", schnpt="<<schnpt<<endl;
     218 if(no_poisson) cout<<"No poisson fluctuation, direct conversion to HI mass"<<endl;
    213219 cout<<"snoise="<<snoise<<" equivalent Msol, evolution="<<isnoise_evol<<endl;
    214220 cout<<"scalecube="<<scalecube<<", offsetcube="<<offsetcube<<endl;
     
    385391 PrtTim(">>>> End Computing a realization in Fourier space");
    386392
    387  /*
    388  // CMVTEST
    389  for(int l=0;l<pkgen.SizeX();l++)
    390  for(int j=0;j<pkgen.SizeY();j++)
    391    for(int i=0;i<pkgen.SizeZ();i++) {
    392      double k2 = fluct3d.Kx(i)*fluct3d.Kx(i)
    393                 +fluct3d.Ky(j)*fluct3d.Ky(j)
    394                 +fluct3d.Kz(l)*fluct3d.Kz(l);
    395      double pk = (k2>0.)? 1./k2: 0.;
    396      //pkgen(l,j,i) = ComplexGaussRan(sqrt(pk/2.));
    397      //pkgen(l,j,i) = sqrt(pk/2.);
    398      pkgen(l,j,i) = 1.;
    399    }
    400    // CMVTEST
    401    */
    402 
    403393 cout<<"\n--- Checking realization spectra"<<endl;
    404394 HistoErr hpkgen(0.,knyqmax,nherr);
     
    512502 }
    513503
    514  //STOP_HERE_FOR QUICK_DEBUG
    515  // return -41;
    516 
    517504 //-----------------------------------------------------------------
    518505 cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
     
    521508 PrtTim(">>>> End Converting fluctuations into mass");
    522509
    523  cout<<"\n--- Converting mass into galaxy number: gal per pixel ="
    524      <<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
    525  rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
    526    nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
    527    nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    528   PrtTim(">>>> End Converting mass into galaxy number");
    529 
    530  cout<<"\n--- Set negative and null pixels to BAD"<<endl;
    531  nm = fluct3d.SetToVal(0.,1e+200,-999.);
    532  PrtTim(">>>> End Set negative pixels to BAD etc...");
    533 
    534  cout<<"\n--- Apply poisson on galaxy number"<<endl;
    535  fluct3d.ApplyPoisson();
    536    nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
    537    nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    538  double xgalmin,xgalmax; fluct3d.MinMax(xgalmin,xgalmax,0.1,1.e50);
    539  PrtTim(">>>> End Apply poisson on galaxy number");
    540  if(wslice) {
    541    fluct3d.WriteSlicePPF("cmvobserv3d_s_rn.ppf");
    542    PrtTim(">>>> End WriteSlicePPF");
    543  }
    544 
    545  cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
    546  double mhi = 0.;
    547  if(use_schmassdist) {
    548    if(recompute_schmassdist) {
    549      int ngalmax = int(xgalmax+0.5);
    550      schmdist.SetNgalLim(ngalmax,1,naleagal);
    551      PrtTim(">>>> End creating tabulated histograms for trials");
     510 if(no_poisson) {
     511
     512   cout<<"\n--- Converting !!!DIRECTLY!!! mass into HI mass: mass per pixel ="
     513       <<mass_by_mpc3*fluct3d.GetDVol()<<endl;
     514   rm = fluct3d.TurnMass2HIMass(mass_by_mpc3);
     515     nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
     516     nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
     517   PrtTim(">>>> End Converting !!!DIRECTLY!!! mass into HI mass");
     518
     519 } else {
     520
     521   cout<<"\n--- Converting mass into galaxy number: gal per pixel ="
     522       <<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
     523   rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
     524     nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
     525     nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
     526   PrtTim(">>>> End Converting mass into galaxy number");
     527
     528   cout<<"\n--- Set negative and null pixels to BAD"<<endl;
     529   nm = fluct3d.SetToVal(0.,1e+200,-999.);
     530   PrtTim(">>>> End Set negative pixels to BAD etc...");
     531
     532   cout<<"\n--- Apply poisson on galaxy number"<<endl;
     533   fluct3d.ApplyPoisson();
     534     nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
     535     nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
     536   double xgalmin,xgalmax; fluct3d.MinMax(xgalmin,xgalmax,0.1,1.e50);
     537   PrtTim(">>>> End Apply poisson on galaxy number");
     538   if(wslice) {
     539     fluct3d.WriteSlicePPF("cmvobserv3d_s_rn.ppf");
     540     PrtTim(">>>> End WriteSlicePPF");
    552541   }
    553    mhi = fluct3d.TurnNGal2MassQuick(schmdist);
    554    schmdist.PrintStatus();
    555  } else {
    556    mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
    557  }
    558  cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
    559    nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
    560    cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
    561    nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
    562  PrtTim(">>>> End Convert Galaxy number to HI mass");
    563 
    564  cout<<"\n--- Set BAD pixels to Zero"<<endl;
    565  nm = fluct3d.SetToVal(-998.,1e+200,0.);
    566  PrtTim(">>>> End Set BAD pixels to Zero etc...");
     542
     543   cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
     544   double mhi = 0.;
     545   if(use_schmassdist) {
     546     if(recompute_schmassdist) {
     547       int ngalmax = int(xgalmax+0.5);
     548       schmdist.SetNgalLim(ngalmax,1,naleagal);
     549       PrtTim(">>>> End creating tabulated histograms for trials");
     550     }
     551     mhi = fluct3d.TurnNGal2MassQuick(schmdist);
     552     schmdist.PrintStatus();
     553   } else {
     554     mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
     555   }
     556   cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
     557     nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
     558     cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
     559     nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
     560   PrtTim(">>>> End Convert Galaxy number to HI mass");
     561
     562   cout<<"\n--- Set BAD pixels to Zero"<<endl;
     563   nm = fluct3d.SetToVal(-998.,1e+200,0.);
     564   PrtTim(">>>> End Set BAD pixels to Zero etc...");
     565
     566 }
    567567
    568568 if(wfits) {
     
    579579 }
    580580
     581 //-----------------------------------------------------------------
    581582 if(do_agn) {
    582583   cout<<"\n--- Add AGN: <log10(S Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
     
    587588 }
    588589
     590 //-----------------------------------------------------------------
    589591 if(snoise>0.) {
    590592   cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl;
  • trunk/Cosmo/SimLSS/cmvtvarspec.cc

    r3246 r3329  
    2424 double ob0 = 0.0444356;
    2525 // -- WMAP
    26  double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
     26 double h100=0.71, om0=0.267804, ol0=0.73;
    2727 // -- ouvert matter only
    28  //double h100=0.71, om0=0.3, or0=0., ol0=0.,w0=-1.;
     28 //double h100=0.71, om0=0.3, ol0=0.;
    2929 // -- plat matter only
    30  //double h100=0.71, om0=1., or0=0., ol0=0.,w0=-1.;
     30 //double h100=0.71, om0=1., ol0=0.;
    3131
    3232 double ns = 1., as = 1.;
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3325 r3329  
    10541054}
    10551055
     1056double  GeneFluct3D::TurnMass2HIMass(double m_by_mpc3)
     1057{
     1058 if(lp_>0) cout<<"--- TurnMass2HIMass : "<<m_by_mpc3<<" Msol/Mpc^3"<<endl;
     1059
     1060 double mall=0., mgood=0.;
     1061 int_8  nall=0,  ngood=0;
     1062 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) {
     1063   int_8 ip = IndexR(i,j,l);
     1064   mall += data_[ip]; nall++;
     1065   if(data_[ip]>0.) {mgood += data_[ip]; ngood++;}
     1066 }
     1067 if(ngood>0) mgood /= (double)ngood;
     1068 if(nall>0)  mall  /= (double)nall;
     1069 if(lp_>0) cout<<"...ngood="<<ngood<<" mgood="<<mgood
     1070               <<",  nall="<<nall<<" mall="<<mall<<endl;
     1071 if(ngood<=0 || mall<=0.) {
     1072   cout<<"TurnMass2HIMass_Error: ngood="<<ngood<<" <=0 || mall="<<mall<<" <=0"<<endl;
     1073   throw RangeCheckError("TurnMass2HIMass_Error: ngood<=0 || mall<=0");
     1074 }
     1075
     1076 // On doit mettre m*Vol masse de HI dans notre survey
     1077 // On en met uniquement dans les pixels de masse >0.
     1078 // On MET a zero les pixels <0
     1079 // On renormalise sur les pixels>0 pour qu'on ait m*Vol masse de HI
     1080 //   comme on ne prend que les pixels >0, on doit normaliser
     1081 //   a la moyenne de <1+d_rho/rho> sur ces pixels
     1082 //   (rappel sur tout les pixels <1+d_rho/rho>=1)
     1083 // masse de HI a mettre ds 1 px:
     1084 double dm = m_by_mpc3*Vol_/ (mgood/mall) /(double)ngood;
     1085 if(lp_>0) cout<<"...HI mass density move from "
     1086               <<m_by_mpc3*Vol_/double(NRtot_)<<" to "<<dm<<" / pixel"<<endl;
     1087
     1088 double sum = 0.;
     1089 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) {
     1090   int_8 ip = IndexR(i,j,l);
     1091   if(data_[ip]<=0.) data_[ip] = 0.;
     1092   else {
     1093     data_[ip] *= dm; // par coherence on multiplie aussi les <=0
     1094     sum += data_[ip];  // mais on ne les compte pas
     1095   }
     1096 }
     1097
     1098 if(lp_>0) cout<<sum<<"...mass HI put into survey / "<<m_by_mpc3*Vol_<<endl;
     1099
     1100 return sum;
     1101}
     1102
    10561103double GeneFluct3D::TurnMass2MeanNumber(double n_by_mpc3)
    10571104// do NOT treate negative or nul values
    10581105{
    1059  if(lp_>0) cout<<"--- TurnMass2MeanNumber ---"<<endl;
     1106 if(lp_>0) cout<<"--- TurnMass2MeanNumber : "<<n_by_mpc3<<" gal/Mpc^3"<<endl;
    10601107
    10611108 double mall=0., mgood=0.;
  • trunk/Cosmo/SimLSS/genefluct3d.h

    r3325 r3329  
    9999
    100100  void TurnFluct2Mass(void);
     101  double TurnMass2HIMass(double m_by_mpc3);
    101102  double TurnMass2MeanNumber(double n_by_mpc3);
    102103  double ApplyPoisson(void);
  • trunk/Cosmo/SimLSS/geneutils.cc

    r3325 r3329  
    6464  : _ymin(0.) , _ymax(0.) , _x(x) , _y(y)
    6565{
    66   int_4 ns = _x.size();
     66  uint_4 ns = _x.size();
    6767  if(ns<3 || _y.size()<=0 || ns!=_y.size())
    6868    throw ParmError("InverseFunc::InverseFunc_Error: bad array size");
    6969
    7070  // Check "x" strictement monotone croissant
    71   for(int_4 i=0;i<ns-1;i++)
     71  for(uint_4 i=0;i<ns-1;i++)
    7272    if(_x[i+1]<=_x[i]) {
    7373      cout<<"InverseFunc::InverseFunc_Error: _x array not stricly growing"<<endl;
     
    7676
    7777  // Check "y" monotone croissant
    78   for(int_4 i=0;i<ns-1;i++)
     78  for(uint_4 i=0;i<ns-1;i++)
    7979    if(_y[i+1]<_y[i]) {
    8080      cout<<"InverseFunc::InverseFunc_Error: _y array not growing"<<endl;
     
    134134    // Protection
    135135    if(i1<0) {i1++; i2++; i3++;}
    136     if(i3==_y.size()) {i1--; i2--; i3--;}
     136    if(i3==(long)_y.size()) {i1--; i2--; i3--;}
    137137    // Interpolation parabolique
    138138    double dy = _y[i3]-_y[i1];
     
    163163{
    164164 long n = X.size();
    165  if(Y.size()<n || n<2)
     165 if(n>(long)Y.size() || n<2)
    166166   throw ParmError("InterpTab_Error :  incompatible size between X and Y tables!");
    167167
  • trunk/Cosmo/SimLSS/pkspectrum.cc

    r3325 r3329  
    7878  O0_ = Oc_ + Ob_;
    7979  if(nobaryon_) {O0_ = Oc_; Ob_ = 0.;}
    80   if(lp_) cout<<"h100="<<h_<<" Omatter="<<O0_<<" Ocdm="<<Oc_<<" Ob="<<Ob_<<endl;
    81 
    8280  double H0 = 100. * h_, h2 = h_*h_;
     81  if(lp_) cout<<"h100="<<h_<<" H0="<<H0<<") Omatter="<<O0_<<" Ocdm="<<Oc_<<" Ob="<<Ob_<<endl;
     82
    8383
    8484  if(tcmb_<0.) tcmb_ = T_CMB_Par;
Note: See TracChangeset for help on using the changeset viewer.