Changeset 3154 in Sophya for trunk/Cosmo


Ignore:
Timestamp:
Jan 19, 2007, 5:19:49 PM (19 years ago)
Author:
cmv
Message:

modifs d'options de cmvobserv3d.cc
creation de init_fftw() et deplacement a l'initialisation
creation de SetObservator pour positionner l'observateur + ecriture FITS et PPF

(mais le codage des distance/redshift reste a coder)

cmv 19/01/2007

Location:
trunk/Cosmo/SimLSS
Files:
4 edited

Legend:

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

    r3150 r3154  
    119119   nread++;
    120120   for(int i=0;i<nherr;i++) herrconc->AddBin(i,herr(i));
    121    sum+=herr(itest); sum2+=herr(itest)*herr(itest), nsum++;
     121   sum+=herr(itest); sum2+=herr(itest)*herr(itest); nsum++;
    122122 }
    123123 herrconc->ToVariance();
     
    182182   nread++;
    183183   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++;
     184     for(int j=0;j<nherry;j++) herrconc->AddBin(i,j,herr(i,j));
     185   sum+=herr(itestx,itesty); sum2+=herr(itestx,itesty)*herr(itestx,itesty); nsum++;
    186186 }
    187187 herrconc->ToVariance();
     188 if(nsum>0) {sum/=nsum; sum2/=nsum; sum2-=sum*sum;}
    188189 cout<<"Test bin "<<itestx<<","<<itesty
    189190     <<" mean="<<sum<<" sigma^2="<<sum2<<"  nsum="<<nsum<<endl;
     
    214215openppf cmvconcherr.ppf
    215216
     217zone 2 2
    216218disp herrconc "hbincont err"
    217219disp herrconc "hbinerr"
    218220disp herrconc "hbinent"
    219221
     222zone
    220223n/plot herrconc.val%log10(x) x>0 ! "connectpoints"
    221 n/plot herrconc.sqrt(err2)%log10(x) x>0&&err2>0. ! "connectpoints same red"
    222 
    223 n/plot herrconc.sqrt(err2)/val%log10(x) x>0&&err2>0.&&val>0 ! "connectpoints"
     224n/plot herrconc.sqrt(err2)%log10(x) x>0&&err2>0 ! "connectpoints same red"
     225
     226n/plot herrconc.sqrt(err2)/val%log10(x) x>0&&err2>0&&val>0 ! "connectpoints"
    224227
    225228#### Histo2DErr 2D
    226229openppf cmvconcherr2.ppf
    227230
    228 disp herrconc2 "hbincont"
    229 disp herrconc2 "hbinerr"
    230 disp herrconc2 "hbinent"
     231zone 2 2
     232imag herrconc2 "hbincont"
     233imag herrconc2 "hbinerr"
     234imag herrconc2 "hbinent"
    231235*/
  • trunk/Cosmo/SimLSS/cmvobserv3d.cc

    r3150 r3154  
    2828     <<" -Z zref : redshift median"<<endl
    2929     <<" -s snoise : sigma du bruit en Msol"<<endl
     30     <<" -2 : compute 2D spectrum"<<endl
     31     <<" -F : write cube in FITS format"<<endl
     32     <<" -P : write cube in PPF format"<<endl
     33     <<" -V : compute variance from real space"<<endl
    3034     <<endl;
    3135}
     
    7377 unsigned short nthread=4;
    7478
     79 // *** What to do
     80 bool comp2dspec = false;
     81 bool wfits = false;
     82 bool wppf = false;
     83 bool compvarreal = false;
     84
    7585 // --- Decodage arguments
    7686
    7787 char c;
    78  while((c = getopt(narg,arg,"ha0x:y:z:s:Z:")) != -1) {
     88 while((c = getopt(narg,arg,"ha0PWV2x:y:z:s:Z:")) != -1) {
    7989  switch (c) {
    8090  case 'a' :
     
    98108  case 'Z' :
    99109    sscanf(optarg,"%lf",&zref);
     110    break;
     111  case '2' :
     112    comp2dspec = true;
     113    break;
     114  case 'V' :
     115    compvarreal = true;
     116    break;
     117  case 'W' :
     118    wfits = true;
     119    break;
     120  case 'P' :
     121    wppf = true;
    100122    break;
    101123  case 'h' :
     
    185207
    186208 //-----------------------------------------------------------------
    187  cout<<endl<<"\n--- Compute galaxies density number"<<endl;
     209 cout<<endl<<"\n--- Compute galaxy density number"<<endl;
    188210
    189211 sch.SetOutValue(0);
     
    249271 }
    250272
    251  if(1) {
     273 if(comp2dspec) {
    252274   cout<<"\n--- Checking realization 2D spectra"<<endl;
    253275   Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
     
    265287 }
    266288
    267  if(1) fluct3d.WriteFits("!cmvobserv3d_k.fits");
    268  if(1) fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
     289 if(wfits) fluct3d.WriteFits("!cmvobserv3d_k0.fits");
     290 if(wppf) fluct3d.WritePPF("cmvobserv3d_k0.ppf",false);
    269291
    270292 if(1) {
     
    279301 }
    280302
    281  if(1) {
     303 if(comp2dspec) {
    282304   cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
    283305   Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
     
    295317 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
    296318
    297  if(1) fluct3d.WriteFits("!cmvobserv3d_r0.fits");
    298  if(1) fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
     319 if(wfits) fluct3d.WriteFits("!cmvobserv3d_r0.fits");
     320 if(wppf) fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
    299321
    300322 int_8 nm;
     
    308330 }
    309331
    310  if(1) {
     332 if(compvarreal) {
    311333   cout<<"\n--- Check variance sigmaR in real space"<<endl;
    312334   double varr;
     
    336358     <<rs2<<" -> "<<sqrt(rs2)<<endl;
    337359
    338  cout<<"\n--- Apply poisson on galaxie number"<<endl;
     360 cout<<"\n--- Apply poisson on galaxy number"<<endl;
    339361 nm = fluct3d.ApplyPoisson();
    340362 cout<<nm<<" galaxies into survey after poisson"<<endl;
     
    343365     <<rs2<<" -> "<<sqrt(rs2)<<endl;
    344366
    345  cout<<"\n--- Convert Galaxies number to HI mass"<<endl;
     367 cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
    346368 long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
    347369 Histo hmdndm(lschmin,lschmax,nhmdndm);
     
    368390     <<rs2<<" -> "<<sqrt(rs2)<<endl;
    369391
    370  if(1) fluct3d.WriteFits("!cmvobserv3d_r.fits");
    371  if(1) fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
     392 if(wfits) fluct3d.WriteFits("!cmvobserv3d_r.fits");
     393 if(wppf) fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
    372394
    373395 cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<endl;
     
    384406   fluct3d.ReComputeFourier();
    385407 }
     408
     409 if(wfits) fluct3d.WriteFits("!cmvobserv3d_k.fits");
     410 if(wppf) fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
    386411
    387412 if(1) {
     
    394419 }
    395420
    396  if(1) {
     421 if(comp2dspec) {
    397422   cout<<"\n--- Computing final 2D spectrum"<<endl;
    398423   Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
     
    410435/*
    411436######################################################
     437readfits cmvobserv3d_k0.fits
    412438readfits cmvobserv3d_k.fits
    413439readfits cmvobserv3d_r0.fits
    414440readfits cmvobserv3d_r.fits
    415441
     442openppf cmvobserv3d_k0.ppf
    416443openppf cmvobserv3d_k.ppf
    417444openppf cmvobserv3d_r0.ppf
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3150 r3154  
    3232//-------------------------------------------------------
    3333GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T)
    34   : T_(T) , array_allocated_(false) , lp_(0)
     34  : T_(T) , Nx_(0) , Ny_(0) , Nz_(0) , array_allocated_(false) , lp_(0)
     35  , redshref_(-999.) , kredshref_(-999.)
    3536{
    3637 SetNThread();
     
    5253  setalloc();
    5354  setpointers(false);
     55  init_fftw();
     56}
     57
     58void GeneFluct3D::SetObservator(double redshref,double kredshref)
     59// L'observateur est au redshift z=0
     60//               est situe sur la "perpendiculaire" a la face x,y
     61//                         issue du centre de cette face
     62// Il faut positionner le cube sur l'axe des z cad des redshifts:
     63//     redshref  = redshift de reference
     64//                 Si redshref<0 alors redshref=0
     65//     kredshref = indice (en double) correspondant a ce redshift
     66//                 Si kredshref<0 alors kredshref=0
     67{
     68 if(redshref<0.) redshref = 0.;
     69 if(kredshref<0.) kredshref = 0.;
     70 redshref_ = redshref;
     71 kredshref_ = kredshref;
    5472}
    5573
     
    126144}
    127145
     146void GeneFluct3D::init_fftw(void)
     147{
     148 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
     149 if(lp_>1) PrtTim("--- GeneFluct3D::init_fftw: before fftw_plan ---");
     150#ifdef FFTW_THREAD
     151 if(nthread_>0) {
     152   cout<<"Computing with "<<nthread_<<" threads"<<endl;
     153   fftw_init_threads();
     154   fftw_plan_with_nthreads(nthread_);
     155 }
     156#endif
     157 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);
     158 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
     159 if(lp_>1) PrtTim("--- GeneFluct3D::init_fftw: after fftw_plan ---");
     160}
     161
    128162
    129163//-------------------------------------------------------
     
    142176   fwrt.WriteKey("DKY",Dky_," Mpc^-1");
    143177   fwrt.WriteKey("DKZ",Dkz_," Mpc^-1");
     178   fwrt.WriteKey("ZREF",redshref_," reference redshift");
     179   fwrt.WriteKey("KZREF",kredshref_," reference redshift on z axe");
    144180   fwrt.Write(R_);
    145181 } catch (PThrowable & exc) {
     
    165201   double dy = fimg.ReadKey("DY");
    166202   double dz = fimg.ReadKey("DZ");
     203   double zref = fimg.ReadKey("ZREF");
     204   double kzref = fimg.ReadKey("KZREF");
    167205   setsize(nx,ny,nz,dx,dy,dz);
    168206   setpointers(true);
     207   init_fftw();
     208   SetObservator(zref,kzref);
    169209 } catch (PThrowable & exc) {
    170210   cout<<"Exception : "<<(string)typeid(exc).name()
     
    188228   R_.Info()["DY"] = (r_8)Dy_;
    189229   R_.Info()["DZ"] = (r_8)Dz_;
     230   R_.Info()["ZREF"] = (r_8)redshref_;
     231   R_.Info()["KZREF"] = (r_8)kredshref_;
    190232   POutPersist pos(cfname.c_str());
    191233   if(write_real) pos << PPFNameTag("rgen")  << R_;
     
    217259     pis >> PPFNameTag("rgen")  >> R_;
    218260   }
     261   setpointers(from_real);  // a mettre ici pour relire les DVInfo
    219262   int_8 nx = R_.Info()["NX"];
    220263   int_8 ny = R_.Info()["NY"];
     
    223266   r_8 dy = R_.Info()["DY"];
    224267   r_8 dz = R_.Info()["DZ"];
     268   r_8 zref = R_.Info()["ZREF"];
     269   r_8 kzref = R_.Info()["KZREF"];
    225270   setsize(nx,ny,nz,dx,dy,dz);
    226    setpointers(from_real);
     271   init_fftw();
     272   SetObservator(zref,kzref);
    227273 } catch (PThrowable & exc) {
    228274   cout<<"Exception : "<<(string)typeid(exc).name()
     
    250296     <<", Kmax="<<GetKmax()<<" Mpc^-1"<<endl;
    251297 cout<<"          (2Pi/k: "<<2.*M_PI/Knyqx_<<" "<<2.*M_PI/Knyqy_<<" "<<2.*M_PI/Knyqz_<<" Mpc)"<<endl;
     298 cout<<"Redshift "<<redshref_<<" for z axe at k="<<kredshref_<<endl;
    252299}
    253300
     
    257304//    (attention on fait une fft pour realiser le spectre)
    258305{
    259  // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
    260  if(lp_>1) PrtTim("--- ComputeFourier0: before fftw_plan ---");
    261 #ifdef FFTW_THREAD
    262  if(nthread_>0) {
    263    cout<<"Computing with "<<nthread_<<" threads"<<endl;
    264    fftw_init_threads();
    265    fftw_plan_with_nthreads(nthread_);
    266  }
    267 #endif
    268  pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);
    269  pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
    270  if(lp_>1) PrtTim("--- ComputeFourier0: after fftw_plan ---");
    271306
    272307 // --- realisation d'un tableau de tirage gaussiens
     
    326361//                                          sum(fb(x_i)^2) = S*N^2
    327362{
    328  // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
    329  if(lp_>1) PrtTim("--- ComputeFourier: before fftw_plan ---");
    330 #ifdef FFTW_THREAD
    331  if(nthread_>0) {
    332    cout<<"Computing with "<<nthread_<<" threads"<<endl;
    333    fftw_init_threads();
    334    fftw_plan_with_nthreads(nthread_);
    335  }
    336 #endif
    337  pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);
    338  pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
    339  //fftw_print_plan(pb_); cout<<endl;
    340  if(lp_>1) PrtTim("--- ComputeFourier: after fftw_plan ---");
    341 
    342363 // --- RaZ du tableau
    343364 T_ = complex<r_8>(0.);
  • trunk/Cosmo/SimLSS/genefluct3d.h

    r3150 r3154  
    2727  void SetNThread(unsigned short nthread=0) {nthread_ = nthread;}
    2828  void SetSize(long nx,long ny,long nz,double dx,double dy,double dz);  // Mpc
     29  void SetObservator(double redshref=0.,double kredshref=-1.);
    2930
    3031  TArray< complex<r_8> >& GetComplexArray(void) {return T_;}
     
    9293  void setalloc(void);
    9394  void setpointers(bool from_real);
     95  void init_fftw(void);
    9496  long manage_coefficients(void);
    9597  double compute_power_carte(void);
     
    98100    {return (x<0.025) ? 1.-x*x/6.*(1.-x*x/20.): sin(x)/x;}
    99101
     102  // valeurs dans l'espace reel
    100103  long Nx_,Ny_,Nz_;  vector<long> N_;
    101104  long NCz_,NTz_;
     
    104107  double Dx_,Dy_,Dz_;  vector<double> D_;
    105108
     109  // valeurs dans l'espace des K
    106110  double Dkx_,Dky_,Dkz_;  vector<double> Dk_;
    107111  double Knyqx_,Knyqy_,Knyqz_;  vector<double> Knyq_;
     
    109113  double dVol_, Vol_;
    110114
     115  // la gestion de la FFT
    111116  fftw_plan pf_,pb_;
    112117  unsigned short nthread_;
    113118  int lp_;
    114119
     120  // le stockage du Cube de donnees et les pointeurs
    115121  bool array_allocated_;  // true if array has been allocated
    116 
    117122  TArray< complex<r_8> >& T_;
    118123  fftw_complex *fdata_;
    119124  TArray<r_8> R_;
    120125  double *data_;
     126
     127  // l'observateur
     128  double redshref_,kredshref_;
    121129};
    122130
Note: See TracChangeset for help on using the changeset viewer.