Changeset 3947 in Sophya for trunk/Cosmo/RadioBeam/specpk.cc


Ignore:
Timestamp:
Feb 14, 2011, 12:58:29 AM (15 years ago)
Author:
ansari
Message:

Amelioration et modifs diverses lors de la redaction du papier, Reza 13/02/2011

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/RadioBeam/specpk.cc

    r3931 r3947  
    266266}
    267267
     268// Compute noise power spectrum as a function of wave number k
     269// No random generation, computes profile of noise sigma^2
     270// cells with amp^2=re^2+im^2>s2cut are ignored
     271// Output : noise power spectrum (profile histogram)
     272HProf Four3DPk::ComputeNoisePk(Four2DResponse& resp, Histo& fracmodok, DataTable& dt,
     273                               double s2cut, int nbin, double kmin, double kmax)
     274{
     275  // The second half of the array along Y (matrix rows) contain
     276  // negative frequencies
     277  //  int nbh = sqrt(fourAmp.SizeX()*fourAmp.SizeX()+fourAmp.SizeY()*fourAmp.SizeY()/4.+fourAmp.SizeZ()*fourAmp.SizeY()/4.);
     278  // The profile histogram will contain the mean value of noise sigma^2
     279  // as a function of wave-number k = sqrt((double)(kx*kx+ky*ky))
     280  //  if (nbin < 1) nbin = nbh/2;
     281  if ((kmax<0.)||(kmax<kmin)) {
     282    kmin=0.;
     283    double maxx=fourAmp.SizeX()*dkx_;
     284    double maxy=fourAmp.SizeY()*dky_/2;
     285    double maxz=fourAmp.SizeZ()*dkz_/2;
     286    kmax=sqrt(maxx*maxx+maxy*maxy+maxz*maxz);
     287  }
     288  if (nbin<2) nbin=128;
     289  HProf hp(kmin, kmax, nbin);
     290  hp.SetErrOpt(false);
     291  Histo hmcnt(kmin, kmax, nbin);
     292  Histo hmcntok(kmin, kmax, nbin);
     293
     294  uint_8 nmodeok=0;
     295  // fourAmp represent 3-D fourier transform of a real input array.
     296  // The second half of the array along Y and Z contain negative frequencies
     297  double kxx, kyy, kzz;
     298  // sa_size_t is large integer type 
     299  // We ignore 0th term in all frequency directions ...
     300  for(sa_size_t kz=1; kz<fourAmp.SizeZ(); kz++) {
     301    kzz =  (kz > fourAmp.SizeZ()/2) ? (double)(fourAmp.SizeZ()-kz)*dkz_ : (double)kz*dkz_;
     302    for(sa_size_t ky=1; ky<fourAmp.SizeY(); ky++) {
     303      kyy =  (ky > fourAmp.SizeY()/2) ? (double)(fourAmp.SizeY()-ky)*dky_ : (double)ky*dky_;
     304      for(sa_size_t kx=1; kx<fourAmp.SizeX(); kx++) {  // ignore the 0th coefficient (constant term)
     305        double kxx=(double)kx*dkx_;
     306        double wk = sqrt(kxx*kxx+kyy*kyy+kzz*kzz);
     307        double amp2 = 1./resp(kxx, kyy);
     308        hmcnt.Add(wk);
     309        if ((s2cut>1.e-9)&&(amp2>s2cut))  continue;
     310        hmcntok.Add(wk);
     311        hp.Add(wk, amp2);
     312        nmodeok++;
     313      }
     314    }
     315  }
     316  if ((prtlev_>1)||((prtlev_>0)&&(s2cut>1.e-9))) {
     317    cout << " Four3DPk::ComputeNoisePk/Info : NModeOK=" << nmodeok << " / NMode=" << fourAmp.Size()
     318         << " -> " << 100.*(double)nmodeok/(double)fourAmp.Size() << "%" << endl;
     319  }
     320
     321  fracmodok=hmcntok/hmcnt;
     322
     323  char* nomcol[5] = {"k","pnoise","nmode","nmodok","fracmodok"};
     324  dt.Clear();
     325  dt.AddDoubleColumn(nomcol[0]);   
     326  dt.AddDoubleColumn(nomcol[1]);   
     327  dt.AddIntegerColumn(nomcol[2]);   
     328  dt.AddIntegerColumn(nomcol[3]);   
     329  dt.AddFloatColumn(nomcol[4]);   
     330  DataTableRow  dtr = dt.EmptyRow();
     331  for(int_4 ib=0; ib<hp.NBins(); ib++) {
     332    dtr[0]=hp.BinCenter(ib);
     333    dtr[1]=hp(ib);
     334    dtr[2]=hmcnt(ib);
     335    dtr[3]=hmcntok(ib);
     336    dtr[4]=fracmodok(ib);
     337    dt.AddRow(dtr);
     338  }
     339  return hp;
     340}
     341
    268342//-----------------------------------------------------
    269343// -- MassDist2D class :  2D mass distribution
Note: See TracChangeset for help on using the changeset viewer.