Changeset 3781 in Sophya for trunk/Cosmo
- Timestamp:
- May 20, 2010, 11:19:52 AM (15 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvginit3d.cc
r3770 r3781 507 507 PrtTim(">>>> End Reading the Pk(vec(k)) cube"); 508 508 509 if(compdspec&1) { 510 cout<<"\n--- Check realization spectra that has been re-read"<<endl; 511 HistoErr hpkgenf_rr(hpkgen); hpkgenf_rr.Zero(); 512 fluct3d.ComputeSpectrum(hpkgenf_rr); 513 PrtTim(">>>> End Checking re-read realization 1D spectra"); 514 posobs.PutObject(hpkgenf_rr,"hpkgenf_rr"); 515 } 516 509 517 //----------------------------------------------------------------- 510 518 cout<<"\n--- Modifying cube for Transverse velocity"<<endl; -
trunk/Cosmo/SimLSS/cmvrvloscor.cc
r3773 r3781 13 13 #include "histos.h" 14 14 #include "fabtcolread.h" 15 #include "fftwserver.h" 15 16 16 17 #include "constcosmo.h" 17 18 #include "geneutils.h" 18 19 #include "genefluct3d.h" 20 // cmvrvloscorf -n 1,30 -K 75 -S ginit3d_6_0p0_100_r.fits ginit3d_6_0p0_100_rv.fits 19 21 20 22 void usage(void); 21 23 void usage(void) 22 24 { 23 cout<<"cmvrvloscor rho.fits vlos.fits"<<endl; 25 cout 26 <<"cmvrvloscor [options] rho.fits vlos.fits"<<endl 27 <<"-n nplany,nhfill: process one Y plane every \"nplany\" (def:1(all))"<<endl 28 <<" fill histos with \"nhfill\" los (def:25)"<<endl 29 <<"-K npix: compute correlation R*V at +/- npix pixels (def: no)"<<endl 30 <<" (very time comsuming!!!)"<<endl 31 <<"-S: compute cross-power spectrum of V*conj(R) (def: no)"<<endl 32 <<"-N: do not create 3D cube and recompute 1D and 2D spectra (def: no do-it !)"<<endl 33 <<endl; 24 34 } 25 35 26 36 int main(int narg,char *arg[]) 27 37 { 28 int nthread = 1; 29 int_8 nhfill = 100000; 30 31 if(narg<=2) {usage(); return -1;} 38 int nthread = 1, nplany=1, nhfilllos = 25, npixcor = 0; 39 bool docube=true, dopk = false; 40 41 // --- Decodage des arguments 42 char c; 43 while((c = getopt(narg,arg,"hn:K:SN")) != -1) { 44 switch (c) { 45 case 'n' : 46 sscanf(optarg,"%d,%d",&nplany,&nhfilllos); 47 if(nplany<=0) nplany = 1; 48 if(nhfilllos<=0) nhfilllos = 0; 49 break; 50 case 'K' : 51 npixcor = atoi(optarg); 52 break; 53 case 'S' : 54 dopk = true; 55 break; 56 case 'N' : 57 docube = false; 58 break; 59 case 'h' : 60 default : 61 usage(); return -1; 62 } 63 } 64 if(optind>=narg-1) {usage(); return -1;} 32 65 33 66 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH … … 38 71 InitTim(); 39 72 40 cout<<"> read rho: "<<arg[1]<<endl; 41 FitsImg3DRead f3dr(arg[1],0,5); 42 cout<<"> read vlos: "<<arg[2]<<endl; 43 FitsImg3DRead f3dv(arg[2],0,5); 73 // --- open FITS files (dRho/Rho and Vlos) 74 cout<<"> read rho: "<<arg[optind]<<endl; 75 FitsImg3DRead f3dr(arg[optind],0,5); 76 cout<<"> read vlos: "<<arg[optind+1]<<endl; 77 FitsImg3DRead f3dv(arg[optind+1],0,5); 44 78 long Nx = f3dr.ReadKeyL("Nx"); 45 79 long Ny = f3dr.ReadKeyL("Ny");; … … 58 92 cout<<"dmin="<<dmin<<" nmax="<<nmax<<endl; 59 93 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 94 62 95 POutPersist pos("cmvrvloscor.ppf"); 63 64 GeneFluct3D fluct3d(Nx,Ny,Nz,Dx,Dy,Dz,nthread,2); 65 fluct3d.Print(); 66 TArray<GEN3D_TYPE>& rgen = fluct3d.GetRealArray(); 67 rgen = 0.; 68 TVector<GEN3D_TYPE> R(Nz), V(Nz); 96 DVList dvlcor; 97 98 // --- Create a Cube for analysis 99 GeneFluct3D *fluct3d = NULL; 100 TArray<GEN3D_TYPE>* rgen = NULL; 101 if(docube) { 102 cout<<"...Create and fill 3D cube"<<endl; 103 fluct3d = new GeneFluct3D(Nx,Ny,Nz,Dx,Dy,Dz,nthread,2); 104 fluct3d->Print(); 105 rgen = &(fluct3d->GetRealArray()); 106 *rgen = 0.; 107 } 108 109 // --- Vector for real-space correlation computation 110 int imil = Nz-1; 111 dvlcor("imil") = (int_4)imil; 112 TVector<int_4> nKsi; 113 TVector<r_8> Ksirv, Ksirvc, Ksirr, Ksirrc; 114 if(npixcor>0) { 115 Ksirv.ReSize(2*Nz-1); Ksirv = 0.; 116 Ksirvc.ReSize(2*Nz-1); Ksirvc = 0.; 117 Ksirr.ReSize(2*Nz-1); Ksirr = 0.; 118 Ksirrc.ReSize(2*Nz-1); Ksirrc = 0.; 119 nKsi.ReSize(2*Nz-1); nKsi = 0; 120 cout<<"...Compute R*V correlation on +/-"<<npixcor<<" px"<<endl; 121 } 122 123 // --- Vector for PK cross-correlation computation 124 int npk = 0; 125 TVector< complex<r_4> > FR, FV; 126 TVector< complex<r_8> > pkvr, FRdis; 127 TVector<r_8> pkr, pkrc; 128 FFTWServer fftserv; 129 if(dopk) cout<<"...compute V*conj(R) cross-power spectrum"<<endl; 130 131 // --- Read and process data 132 TVector<r_4> R(Nz), V(Nz); 69 133 TVector<r_8> Rdis(Nz); 70 71 cout<<"> filling redshift distorted cube"<<endl; 72 int_8 nread = 0; 134 if(nplany>Ny) nplany = Ny; 135 cout<<"...Will read one Y plane every "<<nplany<<endl; 136 if(nhfilllos) { 137 cout<<"...Fill Mpc displacement histo with "<<nhfilllos<<" los"<<endl; 138 nhfilllos = int((double)Nx*Ny/nplany/nhfilllos + 0.5); 139 if(nhfilllos<=0) nhfilllos = 1; 140 cout<<" -> fill one los every "<<nhfilllos<<endl; 141 } 142 143 cout<<">>> filling redshift distorted cube"<<endl; 144 int nlosread = 0; 73 145 for(int i=0;i<Nx;i++) { 74 if(i%(Nx/10)==0) cout<<"i="<<i<<endl; 75 for(int j=0;j<Ny;j++) { 146 if(i%(Nx/10)==0) cout<<" i="<<i<<endl; 147 for(int j=0;j<Ny;j+=nplany) { 148 bool fhis = false; 149 if(nhfilllos) if(nlosread%nhfilllos==0) fhis = true; 76 150 //for(int l=0;l<Nz;l++) R(l) = f3dr.Read(l,j,i); 77 151 //for(int l=0;l<Nz;l++) V(l) = f3dv.Read(l,j,i); … … 79 153 f3dv.Read(j,i,V); 80 154 Rdis = 0.; 155 // Calcul du champ R redshift distordu 81 156 for(int l=0;l<Nz;l++) { 82 157 double d = (1.+Zref) / Href * V(l); 83 if( nread%nhfill==0) hmpc.Add(d);158 if(fhis) hmpc.Add(d); 84 159 double lpd = (double)l + d/Dz; // valeur du deplacee 85 // on repartit proportion nelement au recouvrement sur 2 pixels86 int l1 = int(lpd); // pixel de droite87 intl2 = l1 + 1; // pixel de gauche160 // on repartit proportionellement au recouvrement sur 2 pixels 161 long l1 = long(lpd); // pixel de droite 162 long l2 = l1 + 1; // pixel de gauche 88 163 lpd -= (double)l1; // recouvrement du pixel du dessus 89 164 if(l1>=0 && l1<Nz) Rdis(l1) += R(l) * (1.-lpd); 90 165 if(l2>=0 && l2<Nz) Rdis(l2) += R(l) * lpd; 91 166 } 92 for(int l=0;l<Nz;l++) rgen(l,j,i) += Rdis(l); 93 } 167 // On remplit le cube avec le champ R redshift distordu 168 if(fluct3d) for(int l=0;l<Nz;l++) (*rgen)(l,j,i) += Rdis(l); 169 // Calcul eventuel de la fonction de correlation R*V 170 if(npixcor>0) { 171 for(long l1=0;l1<Nz;l1++) { 172 for(long l2=max(0L,l1-npixcor);l2<min(Nz,l1+npixcor);l2++) { 173 int lc = imil+(l2-l1); 174 Ksirr(lc) += R(l1)*R(l2); 175 Ksirrc(lc) += Rdis(l1)*R(l2); 176 Ksirv(lc) += R(l1)*V(l2); 177 Ksirvc(lc) += Rdis(l1)*V(l2); 178 nKsi(lc)++; 179 } 180 } 181 } 182 // Cross-power spectrum computation 183 if(dopk) { 184 fftserv.FFTForward(V,FV); 185 int nf = FV.Size(); 186 if(pkvr.Size()<=0) { 187 cout<<"...Create vector for cross-power spectrum computation"<<endl; 188 pkvr.ReSize(nf); pkvr = complex<r_8>(0.); 189 pkr.ReSize(nf); pkr = 0.; 190 pkrc.ReSize(nf); pkrc = 0.; 191 } 192 fftserv.FFTForward(R,FR); 193 for(int l=0;l<nf;l++) { 194 pkvr(l) += FV(l)*conj(FR(l)); 195 pkr(l) += norm(FR(l)); 196 } 197 fftserv.FFTForward(Rdis,FRdis); 198 for(int l=0;l<nf;l++) pkrc(l) += norm(FRdis(l)); 199 npk++; 200 } 201 nlosread++; 202 } 203 } 204 205 cout<<"Number of processed los: "<<nlosread<<" / "<<Nx*Ny<<endl; 206 dvlcor("nlosread") = (int_4)nlosread; 207 if(hmpc.NEntries()>0) { 208 hmpc.Show(); 209 pos.PutObject(hmpc,"hmpc"); 210 } 211 if(Ksirr.Size()>0) { 212 for(int l=0;l<Ksirr.Size();l++) if(nKsi(l)>0) { 213 Ksirr(l) /= nKsi(l); 214 Ksirrc(l) /= nKsi(l); 215 Ksirv(l) /= nKsi(l); 216 Ksirvc(l) /= nKsi(l); 217 } 218 pos.PutObject(Ksirr,"ksirr"); 219 pos.PutObject(Ksirrc,"ksirrc"); 220 pos.PutObject(Ksirv,"ksirv"); 221 pos.PutObject(Ksirvc,"ksirvc"); 222 pos.PutObject(nKsi,"nksi"); 223 } 224 if(npk>0) { 225 pkvr /= (double)npk; 226 pkr /= (double)npk; 227 pkrc /= (double)npk; 228 pos.PutObject(pkvr,"pkvr"); 229 pos.PutObject(pkr,"pkr"); 230 pos.PutObject(pkrc,"pkrc"); 94 231 } 95 232 PrtTim(">>>> End filling redshift distorted cube"); 96 pos.PutObject(hmpc,"hmpc"); 97 98 fluct3d.ReComputeFourier(); 99 PrtTim(">>>> End ReComputing spectrum"); 100 101 cout<<endl<<"\n--- Computing final 1D spectrum"<<endl; 102 double dkmin = fluct3d.GetKincMin(); 103 double knyqmax = fluct3d.GetKmax(); 104 long nherr = long(knyqmax/dkmin+0.5); 105 cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl; 106 HistoErr hpkrec(0.,knyqmax,nherr); hpkrec.Zero(); 107 hpkrec.ReCenterBin(); hpkrec.Show(); 108 fluct3d.ComputeSpectrum(hpkrec); 109 pos.PutObject(hpkrec,"hpkrec"); 110 PrtTim(">>>> End Computing final spectrum"); 111 112 cout<<"\n--- Computing final 2D spectrum"<<endl; 113 double dktmin = fluct3d.GetKTincMin(); 114 double ktnyqmax = fluct3d.GetKTmax(); 115 long nherrt = long(ktnyqmax/dktmin+0.5); 116 double dkzmin = fluct3d.GetKinc()[2]; 117 double kznyqmax = fluct3d.GetKnyq()[2]; 118 long nherrz = long(kznyqmax/dkzmin+0.5); 119 cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin 120 <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl; 121 Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 122 hpkrec2.ReCenterBin(); hpkrec2.Zero(); hpkrec2.Show(); 123 fluct3d.ComputeSpectrum2D(hpkrec2); 124 pos.PutObject(hpkrec2,"hpkrec2"); 125 PrtTim(">>>> End Computing final 2D spectrum"); 233 234 // --- Fourier transform 3D cube and compute 1D and 2D power spectra 235 if(fluct3d) { 236 cout<<">>> Fourier transform 3D cube and compute 1D and 2D power spectra"<<endl; 237 // do the FFT for spectrum analysis 238 fluct3d->ReComputeFourier(); 239 PrtTim(">>>> End ReComputing spectrum"); 240 241 // Compute 1D spectrum 242 cout<<endl<<"\n--- Computing final 1D spectrum"<<endl; 243 double dkmin = fluct3d->GetKincMin(), knyqmax = fluct3d->GetKmax(); 244 long nherr = long(knyqmax/dkmin+0.5); 245 cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl; 246 HistoErr hpkrec(0.,knyqmax,nherr); hpkrec.Zero(); 247 hpkrec.ReCenterBin(); hpkrec.Show(); 248 fluct3d->ComputeSpectrum(hpkrec); 249 pos.PutObject(hpkrec,"hpkrec"); 250 PrtTim(">>>> End Computing final spectrum"); 251 252 // Compute 2D spectrum 253 cout<<"\n--- Computing final 2D spectrum"<<endl; 254 double dktmin = fluct3d->GetKTincMin(), ktnyqmax = fluct3d->GetKTmax(); 255 double dkzmin = fluct3d->GetKinc()[2], kznyqmax = fluct3d->GetKnyq()[2]; 256 long nherrt = long(ktnyqmax/dktmin+0.5), nherrz = long(kznyqmax/dkzmin+0.5); 257 cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin 258 <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl; 259 Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 260 hpkrec2.ReCenterBin(); hpkrec2.Zero(); hpkrec2.Show(); 261 fluct3d->ComputeSpectrum2D(hpkrec2); 262 pos.PutObject(hpkrec2,"hpkrec2"); 263 PrtTim(">>>> End Computing final 2D spectrum"); 264 } 265 266 // --- end of job, write objects in ppf 267 pos.PutObject(dvlcor,"dvlcor"); 268 if(fluct3d) delete fluct3d; 126 269 127 270 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH … … 148 291 disp hmpc 149 292 293 # cross-correlation 294 disp nksi 295 set imil ${dvlcor.imil} 296 n/plot ksirv.val%n-${imil} ! ! "nsta cpts" 297 n/plot ksirvc.val%n-${imil} ! ! "nsta cpts same red" 298 299 n/plot ksirr.val%n-${imil} ! ! "nsta cpts" 300 n/plot ksirrc.val%n-${imil} ! ! "nsta cpts same red" 301 302 # cross-power spectrum 303 n/plot pkr.val%n ! ! "nsta cpts logx" 304 n/plot pkrc.val%n ! ! "nsta cpts logx same red" 305 306 n/plot pkvr.val%n ! ! "nsta cpts logx" 307 308 # reconstructed 1D power spectrum 150 309 n/plot hpkrec.val%x x>0 ! "nsta cpts logx" 151 310 311 # recosntructed 2D power spectrum 152 312 imag hpkrec2 153 313 addoval 0 0 0.05 0.05 "green" false -
trunk/Cosmo/SimLSS/genefluct3d.cc
r3773 r3781 120 120 NRtot_ = (int_8)Nx_*(int_8)Ny_*(int_8)Nz_; // nombre de pixels dans le survey 121 121 NCz_ = Nz_/2 +1; 122 NFcoef_ = (int_8)Nx_*(int_8)Ny_*(int_8)NCz_; // nombre de coeff de Fourier dans le survey 122 123 NTz_ = 2*NCz_; 123 124 … … 659 660 cout<<" Resol: dx="<<Dx_<<" dy="<<Dy_<<" dz="<<Dz_<<" Mpc" 660 661 <<", dVol="<<dVol_<<", Vol="<<Vol_<<" Mpc^3"<<endl; 661 cout<<"Fourier Size : nx="<<Nx_<<" ny="<<Ny_<<" nz="<<NCz_<< endl;662 cout<<"Fourier Size : nx="<<Nx_<<" ny="<<Ny_<<" nz="<<NCz_<<" ncoeff="<<NFcoef_<<endl; 662 663 cout<<" Resol: dkx="<<Dkx_<<" dky="<<Dky_<<" dkz="<<Dkz_<<" Mpc^-1" 663 664 <<", Dk3="<<Dk3_<<" Mpc^-3"<<endl; … … 840 841 if(lp_>1) cout<<"Number of forced conjugate hors cont+nyq ="<<nconj2<<endl; 841 842 842 if(lp_>1) cout<<"Check: ddl= "<<NRtot_<<" =?= "<<2*(N Rtot_-nconj1-nconj2)-nreal<<endl;843 if(lp_>1) cout<<"Check: ddl= "<<NRtot_<<" =?= "<<2*(NFcoef_-nconj1-nconj2)-nreal<<endl; 843 844 844 845 return nreal+nconj1+nconj2; -
trunk/Cosmo/SimLSS/genefluct3d.h
r3770 r3781 77 77 vector<long> GetNpix(void) {return N_;} 78 78 int_8 NPix(void) {return NRtot_;} 79 int_8 NCoeff(void) {return NFcoef_;} 79 80 long Nx(void) {return Nx_;} 80 81 long Ny(void) {return Ny_;} … … 176 177 long Nx_,Ny_,Nz_; vector<long> N_; 177 178 long NCz_,NTz_; 178 int_8 NRtot_ ;179 int_8 NRtot_,NFcoef_; 179 180 180 181 double Dx_,Dy_,Dz_; vector<double> D_;
Note:
See TracChangeset
for help on using the changeset viewer.