Changeset 3773 in Sophya for trunk/Cosmo


Ignore:
Timestamp:
May 9, 2010, 12:47:58 AM (15 years ago)
Author:
cmv
Message:

speed-up FITS file read, cmv 09/05/2010

Location:
trunk/Cosmo/SimLSS
Files:
2 edited

Legend:

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

    r3771 r3773  
    1111#include "timing.h"
    1212#include "dvlist.h"
    13 #include "ntuple.h"
     13#include "histos.h"
    1414#include "fabtcolread.h"
    1515
     
    2727{
    2828 int nthread = 1;
    29  SophyaInit();
    30  InitTim();
     29 int_8 nhfill = 100000;
    3130
    3231 if(narg<=2) {usage(); return -1;}
     
    3534 try {
    3635 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
     36
     37 SophyaInit();
     38 InitTim();
    3739
    3840 cout<<"> read rho: "<<arg[1]<<endl;
     
    5254 cout<<"Zref="<<Zref<<" Href="<<Href<<endl;
    5355
     56 double dmin = min(Dx,min(Dy,Dz));
     57 double nmax = max(Nx,max(Ny,Nz));
     58 cout<<"dmin="<<dmin<<" nmax="<<nmax<<endl;
     59 Histo hmpc(-dmin*nmax,dmin*nmax,4.*nmax);
     60 nhfill = (int_8)Nx*(int_8)Ny*(int_8)Nz/nhfill; if(nhfill<=0) nhfill = 1;
     61
    5462 POutPersist pos("cmvrvloscor.ppf");
    5563
     
    5866 TArray<GEN3D_TYPE>& rgen = fluct3d.GetRealArray();
    5967 rgen = 0.;
    60  TVector<r_8> R(Nz), Rdis(Nz);
     68 TVector<GEN3D_TYPE> R(Nz), V(Nz);
     69 TVector<r_8> Rdis(Nz);
    6170
    6271 cout<<"> filling redshift distorted cube"<<endl;
     72 int_8 nread = 0;
    6373 for(int i=0;i<Nx;i++) {
    6474   if(i%(Nx/10)==0) cout<<"i="<<i<<endl;
    6575 for(int j=0;j<Ny;j++) {
    66    for(int l=0;l<Nz;l++) R(l) = f3dr.Read(l,j,i);
     76   //for(int l=0;l<Nz;l++) R(l) = f3dr.Read(l,j,i);
     77   //for(int l=0;l<Nz;l++) V(l) = f3dv.Read(l,j,i);
     78   f3dr.Read(j,i,R);
     79   f3dv.Read(j,i,V);
    6780   Rdis = 0.;
    6881   for(int l=0;l<Nz;l++) {
    69      double d = (1.+Zref) / Href * f3dv.Read(l,j,i);
     82     double d = (1.+Zref) / Href * V(l);
     83     if(nread%nhfill==0) hmpc.Add(d);
    7084     double lpd = (double)l + d/Dz; // valeur du deplacee
    7185     // on repartit proportionnelement au recouvrement sur 2 pixels
     
    8094 }
    8195 PrtTim(">>>> End filling redshift distorted cube");
     96 pos.PutObject(hmpc,"hmpc");
    8297
    8398 fluct3d.ReComputeFourier();
     
    131146openppf cmvrvloscor.ppf
    132147
     148disp hmpc
     149
    133150n/plot hpkrec.val%x x>0 ! "nsta cpts logx"
    134151
     
    144161
    145162# proj selon kT (black), selon kZ (red)
    146 n/plot hpkrec2.val%sqrt(x*x+y*y) ! ! "nsta cpts"
     163n/plot hpkrec2.val%sqrt(x*x+y*y) ! ! "nsta crossmarker3 logx"
    147164 */
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3770 r3773  
    118118 Nz_ = nz;  if(Nz_ <= 0) Nz_ = Nx_;
    119119 N_.resize(0); N_.push_back(Nx_); N_.push_back(Ny_); N_.push_back(Nz_);
    120  NRtot_ = Nx_*Ny_*Nz_; // nombre de pixels dans le survey
     120 NRtot_ = (int_8)Nx_*(int_8)Ny_*(int_8)Nz_; // nombre de pixels dans le survey
    121121 NCz_ =  Nz_/2 +1;
    122122 NTz_ = 2*NCz_;
     
    766766// Take into account the real and complexe conjugate coefficients
    767767// because we want a realization of a real data in real space
    768 // On ecrit que: P(k_x,k_y,k_z) = P(-k_x,-k_y,-k_z)
     768// On ecrit que: conj(P(k_x,k_y,k_z)) = P(-k_x,-k_y,-k_z)
    769769//               avec k_x = i, -k_x = N_x - i  etc...
    770770{
     
    773773
    774774 // 1./ Le Continu et Nyquist sont reels
    775  long nreal = 0;
     775 int_8 nreal = 0;
    776776 for(long kk=0;kk<2;kk++) {
    777777   long k=0;  // continu
     
    795795
    796796 // a./ les lignes et colonnes du continu et de nyquist
    797  long nconj1 = 0;
     797 int_8 nconj1 = 0;
    798798 for(long kk=0;kk<2;kk++) {
    799799   long k=0;  // continu
     
    823823
    824824 // b./ les lignes et colonnes hors continu et de nyquist
    825  long nconj2 = 0;
     825 int_8 nconj2 = 0;
    826826 for(long kk=0;kk<2;kk++) {
    827827   long k=0;  // continu
     
    840840 if(lp_>1) cout<<"Number of forced conjugate hors cont+nyq ="<<nconj2<<endl;
    841841
    842  if(lp_>1) cout<<"Check: ddl= "<<NRtot_<<" =?= "<<2*(Nx_*Ny_*NCz_-nconj1-nconj2)-nreal<<endl;
     842 if(lp_>1) cout<<"Check: ddl= "<<NRtot_<<" =?= "<<2*(NRtot_-nconj1-nconj2)-nreal<<endl;
    843843
    844844 return nreal+nconj1+nconj2;
     
    897897//-------------------------------------------------------------------
    898898void GeneFluct3D::ToVelLoS(void)
     899// Le spectre Pk doit etre (dRho/Rho)(k)
    899900{
    900901 double zpk = compute_pk_redsh_ref_;
     
    912913       double kz = Kz(l);
    913914       double k2 = kt2 + kz*kz;
    914        if(k2<=0.) continue;
    915        T_(l,j,i) *= complex<double>(0.,dpsd*kz/k2);
    916      }
    917    }
    918  }
     915       if(l==0) k2 = 0.; else k2 = dpsd*kz/k2;
     916       T_(l,j,i) *= complex<double>(0.,k2);
     917     }
     918   }
     919 }
     920
    919921}
    920922
Note: See TracChangeset for help on using the changeset viewer.