Changeset 3150 in Sophya


Ignore:
Timestamp:
Jan 18, 2007, 7:23:56 PM (19 years ago)
Author:
cmv
Message:

suite modifs structure code + bug HistoErr/2D dans ComputeSpectrum cmv 18/01/2007

Location:
trunk/Cosmo/SimLSS
Files:
4 edited

Legend:

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

    r3141 r3150  
    99#include "timing.h"
    1010#include "histerr.h"
    11 
     11#include "hist2err.h"
     12#include "fitshisterr.h"
     13
     14int ObjectType(string nameh,string nameppf);
     15int ConcatHistoErr(string nameh,vector<string> ppfname,int wrtyp);
     16int ConcatHisto2DErr(string nameh,vector<string> ppfname,int wrtyp);
    1217void usage(void);
    1318void usage(void)
    1419{
    15  cout<<"cmvconchprof -n name_histoerr file1.ppf file2.ppf ..."<<endl;
    16 }
    17 
     20cout
     21<<"cmvconcherr -w wtyp -n name_histoerr file1.ppf file2.ppf ..."<<endl
     22<<"  name_histoerr: object name"<<endl
     23<<"  wtyp: bit0 write ASCII, bit1 write PPF, bit2 write FITS (all=7)"<<endl;
     24}
     25
     26
     27//---------------------------------------------------------------
    1828int main(int narg,char *arg[])
    1929{
    20  string nameh = ""; // "hpkgen" "hpkgenf" "hpkrec"
     30 // "hpkgen" "hpkgenf" "hpkrec" "hpkgen2" "hpkgenf2" "hpkrec2"
     31 string nameh = "";
    2132 vector<string> ppfname;
     33 int Write_Type = 3;
    2234
    2335 // --- Decodage arguments
    2436 char c;
    25  while((c = getopt(narg,arg,"hn:")) != -1) {
     37 while((c = getopt(narg,arg,"hn:w:")) != -1) {
    2638  switch (c) {
    2739  case 'n' :
    2840    nameh = optarg;
     41    break;
     42  case 'w' :
     43    sscanf(optarg,"%d",&Write_Type);
    2944    break;
    3045  case 'h' :
     
    3550 if(nameh.size()<=0 || optind>=narg) {usage(); return -1;}
    3651 for (int i=optind;i<narg;i++) ppfname.push_back(arg[i]);
    37  cout<<"nameh = "<<nameh<<" , number of file to be read = "<<ppfname.size()<<endl;
    38 
    39  // --- lecture et moyenne des HistoErr
     52 cout<<"nameh = "<<nameh
     53     <<" , number of file to be read = "<<ppfname.size()
     54     <<" , write_type="<<Write_Type<<endl;
     55
     56 // --- Quel type d'objet ?
     57 int obtyp = ObjectType(nameh,ppfname[0]);
     58
     59 // --- lecture et moyenne des HistoErr ou Histo2DErr
     60 int nread=0;
     61 if(obtyp==1) nread = ConcatHistoErr(nameh,ppfname,Write_Type);
     62 else if(obtyp==2) nread = ConcatHisto2DErr(nameh,ppfname,Write_Type);
     63 else {
     64   cout<<"Type of object "<<nameh<<" not decoded"<<endl;
     65   return -1;
     66 }
     67 cout<<"Number of file read: "<<nread<<endl;
     68 return 0;
     69}
     70
     71//---------------------------------------------------------------
     72int ObjectType(string nameh,string nameppf)
     73// retourne: 1 si HistoErr
     74//           2 si Histo2DErr,
     75//           0 si autre objet
     76//          -1 si il n'y a pas d'objet de nom "nameh"
     77{
     78 PInPersist pis(nameppf.c_str());
     79
     80 bool found_tag = pis.GotoNameTag(nameh.c_str());
     81 if(!found_tag) return -1;
     82
     83 PPersist *pps = pis.ReadObject();
     84 AnyDataObj *obj = pps->DataObj();
     85 cout<<"Object type read from input PPF file : "<<typeid(*obj).name()<< endl;
     86
     87 HistoErr *herr = dynamic_cast<HistoErr *>(obj);
     88 if(herr) return 1;
     89
     90 Histo2DErr *herr2 = dynamic_cast<Histo2DErr *>(obj);
     91 if(herr2) return 2;
     92
     93 return 0;
     94}
     95
     96//---------------------------------------------------------------
     97int ConcatHistoErr(string nameh,vector<string> ppfname,int wrtyp)
     98{
     99 if(ppfname.size()<=0) return 0;
     100
    40101 HistoErr *herrconc = NULL;
    41  int nherr = 0;
    42  int itest = 0;
     102 int nherr=0, nread=0, itest=0;
    43103 double sum=0., sum2=0., nsum=0;
    44104 for (int ifile=0;ifile<ppfname.size();ifile++) {
     
    46106   HistoErr herr;
    47107   pis.GetObject(herr,nameh);
    48    int n = herr.NBins();
    49    cout<<ifile<<" : "<<ppfname[ifile]<<"  nbin="<<n<<endl;
     108   cout<<ifile<<" : "<<ppfname[ifile]<<"  nbin="<<herr.NBins()<<endl;
    50109   if(ifile==0) {
    51110     herrconc = new HistoErr(herr.XMin(),herr.XMax(),herr.NBins());
    52      nherr = n;
     111     nherr = herr.NBins();
    53112     itest = int(herrconc->NBins()/5.+0.5);
     113   } else if(nherr!=herr.NBins()) {
     114     cout<<"BAD NUMBER OF BINS"<<endl;
     115     continue;
    54116   }
    55    if(n!=nherr) {cout<<"BAD NUMBER OF BINS"<<endl; continue;}
     117   if(herr.NMean()!=1) cout<<"ATTENTION: file="<<ppfname[ifile]
     118                             <<" nmean="<<herr.NMean()<<endl;
     119   nread++;
    56120   for(int i=0;i<nherr;i++) herrconc->AddBin(i,herr(i));
    57121   sum+=herr(itest); sum2+=herr(itest)*herr(itest), nsum++;
    58122 }
    59  herrconc->ToCorrel();
     123 herrconc->ToVariance();
    60124 if(nsum>0) {sum/=nsum; sum2/=nsum; sum2-=sum*sum;}
    61125 cout<<"Test bin "<<itest<<" mean="<<sum<<" sigma^2="<<sum2<<"  nsum="<<nsum<<endl;
    62  cout<<"         "<<" mean="<<(*herrconc)(itest)<<" sigma^2="<<herrconc->Error2(itest)<<endl;
    63 
    64  // --- ecriture ascii
    65  if(1) {
    66    FILE * fdata = fopen("cmvconchprof.data","w");
    67    fprintf(fdata,"# k(Mpc^-1) <pkz_reconstruit> variance_pkz\n");
     126 cout<<"         "<<" mean="<<(*herrconc)(itest)
     127                  <<" sigma^2="<<herrconc->Error2(itest)<<endl;
     128
     129 // --- ecriture
     130 if(wrtyp&1) {   // ecriture ASCII
     131   FILE * fdata = fopen("cmvconcherr.data","w");
     132   fprintf(fdata,"# x <mean> variance\n");
     133   fprintf(fdata,"%.17e %.17e %d %d\n",herrconc->XMin(),herrconc->XMax()
     134          ,herrconc->NBins(),herrconc->NMean());
    68135   for(int i=0;i<herrconc->NBins();i++) {
    69      double k = herrconc->BinCenter(i);
    70      fprintf(fdata,"%e %e %e\n",k,(*herrconc)(i),herrconc->Error2(i));
     136     double x = herrconc->BinCenter(i);
     137     fprintf(fdata,"%e %e %e\n",x,(*herrconc)(i),herrconc->Error2(i));
    71138   }
    72139   fclose(fdata);
    73140 }
    74 
    75  // --- ecriture ppf
    76  string tagobs = "cmvconchprof.ppf";
    77  POutPersist posobs(tagobs);
    78  tagobs = "herrconc"; posobs.PutObject(*herrconc,tagobs);
     141 if(wrtyp&2) {   // ecriture PPF
     142   string tagobs = "cmvconcherr.ppf";
     143   POutPersist posobs(tagobs);
     144   tagobs = "herrconc"; posobs.PutObject(*herrconc,tagobs);
     145 }
     146 if(wrtyp&4) {   // ecriture FITS
     147   FitsInOutFile fio("!cmvconcherr.fits",FitsInOutFile::Fits_Create);
     148   fio << *herrconc;
     149 }
    79150
    80151 delete herrconc;
    81152
    82  return 0;
     153 return nread;
     154}
     155
     156//---------------------------------------------------------------
     157int ConcatHisto2DErr(string nameh,vector<string> ppfname,int wrtyp)
     158{
     159 if(ppfname.size()<=0) return 0;
     160
     161 Histo2DErr *herrconc = NULL;
     162 int nherrx=0, nherry=0, nread=0, itestx=0, itesty=0;
     163 double sum=0., sum2=0., nsum=0;
     164 for (int ifile=0;ifile<ppfname.size();ifile++) {
     165   PInPersist pis(ppfname[ifile].c_str());
     166   Histo2DErr herr;
     167   pis.GetObject(herr,nameh);
     168   cout<<ifile<<" : "<<ppfname[ifile]<<"  nbin="
     169       <<herr.NBinX()<<","<<herr.NBinY()<<endl;
     170   if(ifile==0) {
     171     herrconc = new Histo2DErr(herr.XMin(),herr.XMax(),herr.NBinX()
     172                              ,herr.YMin(),herr.YMax(),herr.NBinY());
     173     nherrx = herr.NBinX(); nherry = herr.NBinY();
     174     itestx = int(herrconc->NBinX()/5.+0.5);
     175     itesty = int(herrconc->NBinY()/5.+0.5);
     176   } else if(nherrx!=herr.NBinX() || nherry!=herr.NBinY()) {
     177     cout<<"BAD NUMBER OF BINS"<<endl;
     178     continue;
     179   }
     180   if(herr.NMean()!=1) cout<<"ATTENTION: file="<<ppfname[ifile]
     181                             <<" nmean="<<herr.NMean()<<endl;
     182   nread++;
     183   for(int i=0;i<nherrx;i++)
     184     for(int j=0;j<nherrx;j++) herrconc->AddBin(i,j,herr(i,j));
     185   sum+=herr(itestx,itesty); sum2+=herr(itestx,itesty)*herr(itestx,itesty), nsum++;
     186 }
     187 herrconc->ToVariance();
     188 cout<<"Test bin "<<itestx<<","<<itesty
     189     <<" mean="<<sum<<" sigma^2="<<sum2<<"  nsum="<<nsum<<endl;
     190 cout<<"         "<<" mean="<<(*herrconc)(itestx,itesty)
     191                  <<" sigma^2="<<herrconc->Error2(itestx,itesty)<<endl;
     192
     193 // --- ecriture
     194 if(wrtyp&1) {   // ecriture ASCII
     195   cout<<"ERROR: No ASCII writing implemented"<<endl;
     196 }
     197 if(wrtyp&2) {   // ecriture PPF
     198   string tagobs = "cmvconcherr2.ppf";
     199   POutPersist posobs(tagobs);
     200   tagobs = "herrconc2"; posobs.PutObject(*herrconc,tagobs);
     201 }
     202 if(wrtyp&4) {   // ecriture FITS
     203   FitsInOutFile fio("!cmvconcherr2.fits",FitsInOutFile::Fits_Create);
     204   fio << *herrconc;
     205 }
     206
     207 delete herrconc;
     208
     209 return nread;
    83210}
    84211
    85212/*
    86 openppf cmvconchprof.ppf
    87 
    88 disp herrconc
     213#### HistoErr 1D
     214openppf cmvconcherr.ppf
     215
     216disp herrconc "hbincont err"
     217disp herrconc "hbinerr"
     218disp herrconc "hbinent"
    89219
    90220n/plot herrconc.val%log10(x) x>0 ! "connectpoints"
    91 n/plot herrconc.err%log10(x) x>0 ! "connectpoints same red"
    92 
    93 n/plot herrconc.err/val%log10(x) x>0&&val>0 ! "connectpoints"
     221n/plot herrconc.sqrt(err2)%log10(x) x>0&&err2>0. ! "connectpoints same red"
     222
     223n/plot herrconc.sqrt(err2)/val%log10(x) x>0&&err2>0.&&val>0 ! "connectpoints"
     224
     225#### Histo2DErr 2D
     226openppf cmvconcherr2.ppf
     227
     228disp herrconc2 "hbincont"
     229disp herrconc2 "hbinerr"
     230disp herrconc2 "hbinent"
    94231*/
  • trunk/Cosmo/SimLSS/cmvobserv3d.cc

    r3141 r3150  
    204204 TArray< complex<r_8> > pkgen;
    205205 GeneFluct3D fluct3d(pkgen);
     206 fluct3d.SetPrtLevel(3);
    206207 fluct3d.SetNThread(nthread);
    207208 fluct3d.SetSize(nx,ny,nz,dx,dy,dz);
     
    431432
    432433zone
     434set k pow(10.,x)
     435n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints"
     436
     437zone
    433438n/plot hpkz.val%x ! ! "nsta connectpoints"
    434439n/plot hpkgen.val%log10(x) x>0 ! "nsta same red connectpoints"
     
    436441n/plot hpkrec.val%log10(x) x>0 ! "nsta same blue connectpoints"
    437442
    438 set k pow(10.,x)
    439 n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints"
     443disp hpkgen "hbincont err"
     444disp hpkgenf "hbincont err"
     445disp hpkrec "hbincont err"
    440446
    441447zone 2 2
     
    444450imag hpkrec2
    445451
    446 zone
    447 disp hmdndm
    448 disp tirhmdndm
     452zone 2 1
     453disp hmdndm "nsta"
     454disp tirhmdndm "nsta"
    449455addline 0 1 20 1 "red"
    450456
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3141 r3150  
    3232//-------------------------------------------------------
    3333GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T)
    34   : T_(T) , array_allocated_(false)
     34  : T_(T) , array_allocated_(false) , lp_(0)
    3535{
    3636 SetNThread();
     
    257257//    (attention on fait une fft pour realiser le spectre)
    258258{
    259  int lp=2;
    260 
    261259 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
    262  if(lp>1) PrtTim("--- ComputeFourier0: before fftw_plan ---");
     260 if(lp_>1) PrtTim("--- ComputeFourier0: before fftw_plan ---");
    263261#ifdef FFTW_THREAD
    264262 if(nthread_>0) {
     
    270268 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);
    271269 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
    272  if(lp>1) PrtTim("--- ComputeFourier0: after fftw_plan ---");
     270 if(lp_>1) PrtTim("--- ComputeFourier0: after fftw_plan ---");
    273271
    274272 // --- realisation d'un tableau de tirage gaussiens
    275  if(lp>1) PrtTim("--- ComputeFourier0: before gaussian filling ---");
     273 if(lp_>1) PrtTim("--- ComputeFourier0: before gaussian filling ---");
    276274 // On tient compte du pb de normalisation de FFTW3
    277275 double sntot = sqrt((double)NRtot_);
     
    280278   data_[ip] = NorRand()/sntot;
    281279 }
    282  if(lp>1) PrtTim("--- ComputeFourier0: after gaussian filling ---");
     280 if(lp_>1) PrtTim("--- ComputeFourier0: after gaussian filling ---");
    283281
    284282 // --- realisation d'un tableau de tirage gaussiens
    285  if(lp>1) PrtTim("--- ComputeFourier0: before fft real ---");
     283 if(lp_>1) PrtTim("--- ComputeFourier0: before fft real ---");
    286284 fftw_execute(pf_);
    287  if(lp>1) PrtTim("--- ComputeFourier0: after fft real ---");
     285 if(lp_>1) PrtTim("--- ComputeFourier0: after fft real ---");
    288286
    289287 // --- On remplit avec une realisation
    290  if(lp>1) PrtTim("--- ComputeFourier0: before Fourier realization filling ---");
     288 if(lp_>1) PrtTim("--- ComputeFourier0: before Fourier realization filling ---");
    291289 T_(0,0,0) = complex<r_8>(0.);  // on coupe le continue et on l'initialise
    292290 long lmod = Nx_/10; if(lmod<1) lmod=1;
     
    294292   long ii = (i>Nx_/2) ? Nx_-i : i;
    295293   double kx = ii*Dkx_;  kx *= kx;
    296    if(lp>1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl;
     294   if(lp_>1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl;
    297295   for(long j=0;j<Ny_;j++) {
    298296     long jj = (j>Ny_/2) ? Ny_-j : j;
     
    309307   }
    310308 }
    311  if(lp>1) PrtTim("--- ComputeFourier0: after Fourier realization filling ---");
     309 if(lp_>1) PrtTim("--- ComputeFourier0: after Fourier realization filling ---");
    312310
    313311 double p = compute_power_carte();
    314312 cout<<"Puissance dans la realisation: "<<p<<endl;
    315  if(lp>1) PrtTim("--- ComputeFourier0: after Computing power ---");
     313 if(lp_>1) PrtTim("--- ComputeFourier0: after Computing power ---");
    316314
    317315}
     
    328326//                                          sum(fb(x_i)^2) = S*N^2
    329327{
    330  int lp=2;
    331 
    332328 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
    333  if(lp>1) PrtTim("--- ComputeFourier: before fftw_plan ---");
     329 if(lp_>1) PrtTim("--- ComputeFourier: before fftw_plan ---");
    334330#ifdef FFTW_THREAD
    335331 if(nthread_>0) {
     
    342338 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
    343339 //fftw_print_plan(pb_); cout<<endl;
    344  if(lp>1) PrtTim("--- ComputeFourier: after fftw_plan ---");
     340 if(lp_>1) PrtTim("--- ComputeFourier: after fftw_plan ---");
    345341
    346342 // --- RaZ du tableau
     
    348344
    349345 // --- On remplit avec une realisation
    350  if(lp>1) PrtTim("--- ComputeFourier: before Fourier realization filling ---");
     346 if(lp_>1) PrtTim("--- ComputeFourier: before Fourier realization filling ---");
    351347 long lmod = Nx_/10; if(lmod<1) lmod=1;
    352348 for(long i=0;i<Nx_;i++) {
    353349   long ii = (i>Nx_/2) ? Nx_-i : i;
    354350   double kx = ii*Dkx_;  kx *= kx;
    355    if(lp>1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl;
     351   if(lp_>1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl;
    356352   for(long j=0;j<Ny_;j++) {
    357353     long jj = (j>Ny_/2) ? Ny_-j : j;
     
    369365   }
    370366 }
    371  if(lp>1) PrtTim("--- ComputeFourier: after Fourier realization filling ---");
     367 if(lp_>1) PrtTim("--- ComputeFourier: after Fourier realization filling ---");
    372368
    373369 manage_coefficients();   // gros effet pour les spectres que l'on utilise !
    374  if(lp>1) PrtTim("--- ComputeFourier: after managing coefficients ---");
     370 if(lp_>1) PrtTim("--- ComputeFourier: after managing coefficients ---");
    375371
    376372 double p = compute_power_carte();
    377373 cout<<"Puissance dans la realisation: "<<p<<endl;
    378  if(lp>1) PrtTim("--- ComputeFourier: after before Computing power ---");
     374 if(lp_>1) PrtTim("--- ComputeFourier: after before Computing power ---");
    379375
    380376}
     
    490486//                          avec y = k_x*dx/2
    491487{
    492  int lp=2;
    493  check_array_alloc();
    494 
    495  if(lp>1) PrtTim("--- FilterByPixel: before ---");
     488 check_array_alloc();
     489
     490 if(lp_>1) PrtTim("--- FilterByPixel: before ---");
    496491
    497492 for(long i=0;i<Nx_;i++) {
     
    511506 }
    512507
    513  if(lp>1) PrtTim("--- FilterByPixel: after ---");
     508 if(lp_>1) PrtTim("--- FilterByPixel: after ---");
    514509}
    515510
     
    518513// Calcule une realisation dans l'espace reel
    519514{
    520  int lp=2;
    521515 check_array_alloc();
    522516
    523517 // On fait la FFT
    524  if(lp>1) PrtTim("--- ComputeReal: before fftw backward ---");
     518 if(lp_>1) PrtTim("--- ComputeReal: before fftw backward ---");
    525519 fftw_execute(pb_);
    526  if(lp>1) PrtTim("--- ComputeReal: after fftw backward ---");
     520 if(lp_>1) PrtTim("--- ComputeReal: after fftw backward ---");
    527521}
    528522
     
    530524void GeneFluct3D::ReComputeFourier(void)
    531525{
    532  int lp=2;
    533526 check_array_alloc();
    534527
    535528 // On fait la FFT
    536  if(lp>1) PrtTim("--- ComputeReal: before fftw forward ---");
     529 if(lp_>1) PrtTim("--- ComputeReal: before fftw forward ---");
    537530 fftw_execute(pf_);
    538531 // On corrige du pb de la normalisation de FFTW3
     
    542535     for(long l=0;l<NCz_;l++) T_(l,j,i) /= complex<r_8>(v);
    543536
    544  if(lp>1) PrtTim("--- ComputeReal: after fftw forward ---");
     537 if(lp_>1) PrtTim("--- ComputeReal: after fftw forward ---");
    545538}
    546539
     
    552545{
    553546 check_array_alloc();
     547 if(lp_>1) PrtTim("--- ComputeSpectrum: before ---");
    554548
    555549 if(herr.NBins()<0) return -1;
     
    571565   }
    572566 }
    573  herr.ToCorrel();
     567 herr.ToVariance();
    574568
    575569 // renormalize to directly compare to original spectrum
     
    577571 herr *= norm;
    578572
     573 if(lp_>1) PrtTim("--- ComputeSpectrum: after ---");
     574
    579575 return 0;
    580576}
     
    583579{
    584580 check_array_alloc();
     581 if(lp_>1) PrtTim("--- ComputeSpectrum2D: before ---");
    585582
    586583 if(herr.NBinX()<0 || herr.NBinY()<0) return -1;
     
    602599   }
    603600 }
    604  herr.ToCorrel();
     601 herr.ToVariance();
    605602
    606603 // renormalize to directly compare to original spectrum
     
    608605 herr *= norm;
    609606
     607 if(lp_>1) PrtTim("--- ComputeSpectrum2D: after ---");
     608
    610609 return 0;
    611610}
     
    615614// Recompute MASS variance in spherical top-hat (rayon=R)
    616615{
    617  int lp=2;
    618  check_array_alloc();
    619 
    620  if(lp>1) PrtTim("--- VarianceFrReal: before computation ---");
     616 check_array_alloc();
     617
     618 if(lp_>1) PrtTim("--- VarianceFrReal: before computation ---");
    621619
    622620 long dnx = long(R/Dx_+0.5); if(dnx<=0) dnx = 1;
     
    654652 sum /= nsum;
    655653 sum2 = sum2/nsum - sum*sum;
    656  if(lp) cout<<"VarianceFrReal: nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl;
     654 if(lp_) cout<<"VarianceFrReal: nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl;
    657655
    658656 var = sum2/(sum*sum);  // <dM>^2/<M>^2
    659  if(lp) cout<<"sigmaR^2="<<var<<" -> "<<sqrt(var)<<endl;
    660 
    661  if(lp>1) PrtTim("--- VarianceFrReal: after computation ---");
     657 if(lp_) cout<<"sigmaR^2="<<var<<" -> "<<sqrt(var)<<endl;
     658
     659 if(lp_>1) PrtTim("--- VarianceFrReal: after computation ---");
    662660 return nsum;
    663661}
     
    726724// d_rho/rho -> Mass  (add one!)
    727725{
    728  int lp=2;
    729  check_array_alloc();
    730 
    731  if(lp>1) PrtTim("--- TurnFluct2Mass: before computation ---");
     726 check_array_alloc();
     727
     728 if(lp_>1) PrtTim("--- TurnFluct2Mass: before computation ---");
    732729
    733730 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) {
     
    736733 }
    737734
    738  if(lp>1) PrtTim("--- TurnFluct2Mass: after computation ---");
     735 if(lp_>1) PrtTim("--- TurnFluct2Mass: after computation ---");
    739736}
    740737
     
    742739// do NOT treate negative or nul values
    743740{
    744  int lp=2;
    745  if(lp>1) PrtTim("--- TurnMass2MeanNumber: before computation ---");
     741 if(lp_>1) PrtTim("--- TurnMass2MeanNumber: before computation ---");
    746742
    747743 double m,s2;
    748744 int_8 ngood = MeanSigma2(m,s2,0.,1e+200);
    749  if(lp) cout<<"TurnMass2MeanNumber: ngood="<<ngood
     745 if(lp_) cout<<"TurnMass2MeanNumber: ngood="<<ngood
    750746            <<" m="<<m<<" s2="<<s2<<" -> "<<sqrt(s2)<<endl;
    751747
     
    758754 //   (rappel sur tout les pixels <1+d_rho/rho>=1)
    759755 double dn = n_by_mpc3*Vol_/m /(double)ngood;  // nb de gal a mettre ds 1 px
    760  if(lp) cout<<"galaxy density move from "
     756 if(lp_) cout<<"galaxy density move from "
    761757            <<n_by_mpc3*Vol_/double(NRtot_)<<" to "<<dn<<" / pixel"<<endl;
    762758 double sum = 0.;
     
    766762   if(data_[ip]>0.) sum += data_[ip];  // mais on ne les compte pas
    767763 }
    768  if(lp) cout<<sum<<" galaxies put into survey / "<<n_by_mpc3*Vol_<<endl;
    769 
    770  if(lp>1) PrtTim("--- TurnMass2MeanNumber: after computation ---");
     764 if(lp_) cout<<sum<<" galaxies put into survey / "<<n_by_mpc3*Vol_<<endl;
     765
     766 if(lp_>1) PrtTim("--- TurnMass2MeanNumber: after computation ---");
    771767 return sum;
    772768}
     
    775771// do NOT treate negative or nul mass  -> let it as it is
    776772{
    777  int lp=2;
    778  check_array_alloc();
    779 
    780  if(lp>1) PrtTim("--- ApplyPoisson: before computation ---");
     773 check_array_alloc();
     774
     775 if(lp_>1) PrtTim("--- ApplyPoisson: before computation ---");
    781776
    782777 double sum = 0.;
     
    790785   }
    791786 }
    792  if(lp) cout<<sum<<" galaxies put into survey"<<endl;
    793 
    794  if(lp>1) PrtTim("--- ApplyPoisson: before computation ---");
     787 if(lp_) cout<<sum<<" galaxies put into survey"<<endl;
     788
     789 if(lp_>1) PrtTim("--- ApplyPoisson: before computation ---");
    795790 return sum;
    796791}
     
    804799// RETURN la masse totale
    805800{
    806  int lp=2;
    807  check_array_alloc();
    808 
    809  if(lp>1) PrtTim("--- TurnNGal2Mass: before computation ---");
     801 check_array_alloc();
     802
     803 if(lp_>1) PrtTim("--- TurnNGal2Mass: before computation ---");
    810804
    811805 double sum = 0.;
     
    824818   }
    825819 }
    826  if(lp) cout<<sum<<" MSol HI mass put into survey"<<endl;
    827 
    828  if(lp>1) PrtTim("--- TurnNGal2Mass: after computation ---");
     820 if(lp_) cout<<sum<<" MSol HI mass put into survey"<<endl;
     821
     822 if(lp_>1) PrtTim("--- TurnNGal2Mass: after computation ---");
    829823 return sum;
    830824}
     
    833827// add noise to every pixels (meme les <=0 !)
    834828{
    835  int lp=2;
    836  check_array_alloc();
    837 
    838  if(lp>1) PrtTim("--- AddNoise2Real: before computation ---");
     829 check_array_alloc();
     830
     831 if(lp_>1) PrtTim("--- AddNoise2Real: before computation ---");
    839832
    840833 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) {
     
    843836 }
    844837
    845  if(lp>1) PrtTim("--- AddNoise2Real: after computation ---");
    846 }
     838 if(lp_>1) PrtTim("--- AddNoise2Real: after computation ---");
     839}
  • trunk/Cosmo/SimLSS/genefluct3d.h

    r3141 r3150  
    8585  void ReadPPF(string cfname);
    8686
     87  void SetPrtLevel(int lp=0) {lp_ = lp;}
    8788  void Print(void);
    8889
     
    9697  inline double pixelfilter(double x)
    9798    {return (x<0.025) ? 1.-x*x/6.*(1.-x*x/20.): sin(x)/x;}
    98 
    9999
    100100  long Nx_,Ny_,Nz_;  vector<long> N_;
     
    111111  fftw_plan pf_,pb_;
    112112  unsigned short nthread_;
     113  int lp_;
    113114
    114115  bool array_allocated_;  // true if array has been allocated
Note: See TracChangeset for help on using the changeset viewer.