Changeset 3154 in Sophya for trunk/Cosmo/SimLSS
- Timestamp:
- Jan 19, 2007, 5:19:49 PM (19 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvconcherr.cc
r3150 r3154 119 119 nread++; 120 120 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++; 122 122 } 123 123 herrconc->ToVariance(); … … 182 182 nread++; 183 183 for(int i=0;i<nherrx;i++) 184 for(int j=0;j<nherr x;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++; 186 186 } 187 187 herrconc->ToVariance(); 188 if(nsum>0) {sum/=nsum; sum2/=nsum; sum2-=sum*sum;} 188 189 cout<<"Test bin "<<itestx<<","<<itesty 189 190 <<" mean="<<sum<<" sigma^2="<<sum2<<" nsum="<<nsum<<endl; … … 214 215 openppf cmvconcherr.ppf 215 216 217 zone 2 2 216 218 disp herrconc "hbincont err" 217 219 disp herrconc "hbinerr" 218 220 disp herrconc "hbinent" 219 221 222 zone 220 223 n/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"224 n/plot herrconc.sqrt(err2)%log10(x) x>0&&err2>0 ! "connectpoints same red" 225 226 n/plot herrconc.sqrt(err2)/val%log10(x) x>0&&err2>0&&val>0 ! "connectpoints" 224 227 225 228 #### Histo2DErr 2D 226 229 openppf cmvconcherr2.ppf 227 230 228 disp herrconc2 "hbincont" 229 disp herrconc2 "hbinerr" 230 disp herrconc2 "hbinent" 231 zone 2 2 232 imag herrconc2 "hbincont" 233 imag herrconc2 "hbinerr" 234 imag herrconc2 "hbinent" 231 235 */ -
trunk/Cosmo/SimLSS/cmvobserv3d.cc
r3150 r3154 28 28 <<" -Z zref : redshift median"<<endl 29 29 <<" -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 30 34 <<endl; 31 35 } … … 73 77 unsigned short nthread=4; 74 78 79 // *** What to do 80 bool comp2dspec = false; 81 bool wfits = false; 82 bool wppf = false; 83 bool compvarreal = false; 84 75 85 // --- Decodage arguments 76 86 77 87 char c; 78 while((c = getopt(narg,arg,"ha0 x:y:z:s:Z:")) != -1) {88 while((c = getopt(narg,arg,"ha0PWV2x:y:z:s:Z:")) != -1) { 79 89 switch (c) { 80 90 case 'a' : … … 98 108 case 'Z' : 99 109 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; 100 122 break; 101 123 case 'h' : … … 185 207 186 208 //----------------------------------------------------------------- 187 cout<<endl<<"\n--- Compute galax iesdensity number"<<endl;209 cout<<endl<<"\n--- Compute galaxy density number"<<endl; 188 210 189 211 sch.SetOutValue(0); … … 249 271 } 250 272 251 if( 1) {273 if(comp2dspec) { 252 274 cout<<"\n--- Checking realization 2D spectra"<<endl; 253 275 Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); … … 265 287 } 266 288 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); 269 291 270 292 if(1) { … … 279 301 } 280 302 281 if( 1) {303 if(comp2dspec) { 282 304 cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl; 283 305 Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); … … 295 317 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl; 296 318 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); 299 321 300 322 int_8 nm; … … 308 330 } 309 331 310 if( 1) {332 if(compvarreal) { 311 333 cout<<"\n--- Check variance sigmaR in real space"<<endl; 312 334 double varr; … … 336 358 <<rs2<<" -> "<<sqrt(rs2)<<endl; 337 359 338 cout<<"\n--- Apply poisson on galax ienumber"<<endl;360 cout<<"\n--- Apply poisson on galaxy number"<<endl; 339 361 nm = fluct3d.ApplyPoisson(); 340 362 cout<<nm<<" galaxies into survey after poisson"<<endl; … … 343 365 <<rs2<<" -> "<<sqrt(rs2)<<endl; 344 366 345 cout<<"\n--- Convert Galax iesnumber to HI mass"<<endl;367 cout<<"\n--- Convert Galaxy number to HI mass"<<endl; 346 368 long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5); 347 369 Histo hmdndm(lschmin,lschmax,nhmdndm); … … 368 390 <<rs2<<" -> "<<sqrt(rs2)<<endl; 369 391 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); 372 394 373 395 cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<endl; … … 384 406 fluct3d.ReComputeFourier(); 385 407 } 408 409 if(wfits) fluct3d.WriteFits("!cmvobserv3d_k.fits"); 410 if(wppf) fluct3d.WritePPF("cmvobserv3d_k.ppf",false); 386 411 387 412 if(1) { … … 394 419 } 395 420 396 if( 1) {421 if(comp2dspec) { 397 422 cout<<"\n--- Computing final 2D spectrum"<<endl; 398 423 Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); … … 410 435 /* 411 436 ###################################################### 437 readfits cmvobserv3d_k0.fits 412 438 readfits cmvobserv3d_k.fits 413 439 readfits cmvobserv3d_r0.fits 414 440 readfits cmvobserv3d_r.fits 415 441 442 openppf cmvobserv3d_k0.ppf 416 443 openppf cmvobserv3d_k.ppf 417 444 openppf cmvobserv3d_r0.ppf -
trunk/Cosmo/SimLSS/genefluct3d.cc
r3150 r3154 32 32 //------------------------------------------------------- 33 33 GeneFluct3D::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.) 35 36 { 36 37 SetNThread(); … … 52 53 setalloc(); 53 54 setpointers(false); 55 init_fftw(); 56 } 57 58 void 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; 54 72 } 55 73 … … 126 144 } 127 145 146 void 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 128 162 129 163 //------------------------------------------------------- … … 142 176 fwrt.WriteKey("DKY",Dky_," Mpc^-1"); 143 177 fwrt.WriteKey("DKZ",Dkz_," Mpc^-1"); 178 fwrt.WriteKey("ZREF",redshref_," reference redshift"); 179 fwrt.WriteKey("KZREF",kredshref_," reference redshift on z axe"); 144 180 fwrt.Write(R_); 145 181 } catch (PThrowable & exc) { … … 165 201 double dy = fimg.ReadKey("DY"); 166 202 double dz = fimg.ReadKey("DZ"); 203 double zref = fimg.ReadKey("ZREF"); 204 double kzref = fimg.ReadKey("KZREF"); 167 205 setsize(nx,ny,nz,dx,dy,dz); 168 206 setpointers(true); 207 init_fftw(); 208 SetObservator(zref,kzref); 169 209 } catch (PThrowable & exc) { 170 210 cout<<"Exception : "<<(string)typeid(exc).name() … … 188 228 R_.Info()["DY"] = (r_8)Dy_; 189 229 R_.Info()["DZ"] = (r_8)Dz_; 230 R_.Info()["ZREF"] = (r_8)redshref_; 231 R_.Info()["KZREF"] = (r_8)kredshref_; 190 232 POutPersist pos(cfname.c_str()); 191 233 if(write_real) pos << PPFNameTag("rgen") << R_; … … 217 259 pis >> PPFNameTag("rgen") >> R_; 218 260 } 261 setpointers(from_real); // a mettre ici pour relire les DVInfo 219 262 int_8 nx = R_.Info()["NX"]; 220 263 int_8 ny = R_.Info()["NY"]; … … 223 266 r_8 dy = R_.Info()["DY"]; 224 267 r_8 dz = R_.Info()["DZ"]; 268 r_8 zref = R_.Info()["ZREF"]; 269 r_8 kzref = R_.Info()["KZREF"]; 225 270 setsize(nx,ny,nz,dx,dy,dz); 226 setpointers(from_real); 271 init_fftw(); 272 SetObservator(zref,kzref); 227 273 } catch (PThrowable & exc) { 228 274 cout<<"Exception : "<<(string)typeid(exc).name() … … 250 296 <<", Kmax="<<GetKmax()<<" Mpc^-1"<<endl; 251 297 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; 252 299 } 253 300 … … 257 304 // (attention on fait une fft pour realiser le spectre) 258 305 { 259 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)260 if(lp_>1) PrtTim("--- ComputeFourier0: before fftw_plan ---");261 #ifdef FFTW_THREAD262 if(nthread_>0) {263 cout<<"Computing with "<<nthread_<<" threads"<<endl;264 fftw_init_threads();265 fftw_plan_with_nthreads(nthread_);266 }267 #endif268 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 ---");271 306 272 307 // --- realisation d'un tableau de tirage gaussiens … … 326 361 // sum(fb(x_i)^2) = S*N^2 327 362 { 328 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)329 if(lp_>1) PrtTim("--- ComputeFourier: before fftw_plan ---");330 #ifdef FFTW_THREAD331 if(nthread_>0) {332 cout<<"Computing with "<<nthread_<<" threads"<<endl;333 fftw_init_threads();334 fftw_plan_with_nthreads(nthread_);335 }336 #endif337 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 342 363 // --- RaZ du tableau 343 364 T_ = complex<r_8>(0.); -
trunk/Cosmo/SimLSS/genefluct3d.h
r3150 r3154 27 27 void SetNThread(unsigned short nthread=0) {nthread_ = nthread;} 28 28 void SetSize(long nx,long ny,long nz,double dx,double dy,double dz); // Mpc 29 void SetObservator(double redshref=0.,double kredshref=-1.); 29 30 30 31 TArray< complex<r_8> >& GetComplexArray(void) {return T_;} … … 92 93 void setalloc(void); 93 94 void setpointers(bool from_real); 95 void init_fftw(void); 94 96 long manage_coefficients(void); 95 97 double compute_power_carte(void); … … 98 100 {return (x<0.025) ? 1.-x*x/6.*(1.-x*x/20.): sin(x)/x;} 99 101 102 // valeurs dans l'espace reel 100 103 long Nx_,Ny_,Nz_; vector<long> N_; 101 104 long NCz_,NTz_; … … 104 107 double Dx_,Dy_,Dz_; vector<double> D_; 105 108 109 // valeurs dans l'espace des K 106 110 double Dkx_,Dky_,Dkz_; vector<double> Dk_; 107 111 double Knyqx_,Knyqy_,Knyqz_; vector<double> Knyq_; … … 109 113 double dVol_, Vol_; 110 114 115 // la gestion de la FFT 111 116 fftw_plan pf_,pb_; 112 117 unsigned short nthread_; 113 118 int lp_; 114 119 120 // le stockage du Cube de donnees et les pointeurs 115 121 bool array_allocated_; // true if array has been allocated 116 117 122 TArray< complex<r_8> >& T_; 118 123 fftw_complex *fdata_; 119 124 TArray<r_8> R_; 120 125 double *data_; 126 127 // l'observateur 128 double redshref_,kredshref_; 121 129 }; 122 130
Note:
See TracChangeset
for help on using the changeset viewer.