Changeset 3150 in Sophya for trunk/Cosmo/SimLSS/genefluct3d.cc
- Timestamp:
- Jan 18, 2007, 7:23:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/genefluct3d.cc
r3141 r3150 32 32 //------------------------------------------------------- 33 33 GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T) 34 : T_(T) , array_allocated_(false) 34 : T_(T) , array_allocated_(false) , lp_(0) 35 35 { 36 36 SetNThread(); … … 257 257 // (attention on fait une fft pour realiser le spectre) 258 258 { 259 int lp=2;260 261 259 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init) 262 if(lp >1) PrtTim("--- ComputeFourier0: before fftw_plan ---");260 if(lp_>1) PrtTim("--- ComputeFourier0: before fftw_plan ---"); 263 261 #ifdef FFTW_THREAD 264 262 if(nthread_>0) { … … 270 268 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE); 271 269 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE); 272 if(lp >1) PrtTim("--- ComputeFourier0: after fftw_plan ---");270 if(lp_>1) PrtTim("--- ComputeFourier0: after fftw_plan ---"); 273 271 274 272 // --- realisation d'un tableau de tirage gaussiens 275 if(lp >1) PrtTim("--- ComputeFourier0: before gaussian filling ---");273 if(lp_>1) PrtTim("--- ComputeFourier0: before gaussian filling ---"); 276 274 // On tient compte du pb de normalisation de FFTW3 277 275 double sntot = sqrt((double)NRtot_); … … 280 278 data_[ip] = NorRand()/sntot; 281 279 } 282 if(lp >1) PrtTim("--- ComputeFourier0: after gaussian filling ---");280 if(lp_>1) PrtTim("--- ComputeFourier0: after gaussian filling ---"); 283 281 284 282 // --- realisation d'un tableau de tirage gaussiens 285 if(lp >1) PrtTim("--- ComputeFourier0: before fft real ---");283 if(lp_>1) PrtTim("--- ComputeFourier0: before fft real ---"); 286 284 fftw_execute(pf_); 287 if(lp >1) PrtTim("--- ComputeFourier0: after fft real ---");285 if(lp_>1) PrtTim("--- ComputeFourier0: after fft real ---"); 288 286 289 287 // --- On remplit avec une realisation 290 if(lp >1) PrtTim("--- ComputeFourier0: before Fourier realization filling ---");288 if(lp_>1) PrtTim("--- ComputeFourier0: before Fourier realization filling ---"); 291 289 T_(0,0,0) = complex<r_8>(0.); // on coupe le continue et on l'initialise 292 290 long lmod = Nx_/10; if(lmod<1) lmod=1; … … 294 292 long ii = (i>Nx_/2) ? Nx_-i : i; 295 293 double kx = ii*Dkx_; kx *= kx; 296 if(lp >1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl;294 if(lp_>1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl; 297 295 for(long j=0;j<Ny_;j++) { 298 296 long jj = (j>Ny_/2) ? Ny_-j : j; … … 309 307 } 310 308 } 311 if(lp >1) PrtTim("--- ComputeFourier0: after Fourier realization filling ---");309 if(lp_>1) PrtTim("--- ComputeFourier0: after Fourier realization filling ---"); 312 310 313 311 double p = compute_power_carte(); 314 312 cout<<"Puissance dans la realisation: "<<p<<endl; 315 if(lp >1) PrtTim("--- ComputeFourier0: after Computing power ---");313 if(lp_>1) PrtTim("--- ComputeFourier0: after Computing power ---"); 316 314 317 315 } … … 328 326 // sum(fb(x_i)^2) = S*N^2 329 327 { 330 int lp=2;331 332 328 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init) 333 if(lp >1) PrtTim("--- ComputeFourier: before fftw_plan ---");329 if(lp_>1) PrtTim("--- ComputeFourier: before fftw_plan ---"); 334 330 #ifdef FFTW_THREAD 335 331 if(nthread_>0) { … … 342 338 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE); 343 339 //fftw_print_plan(pb_); cout<<endl; 344 if(lp >1) PrtTim("--- ComputeFourier: after fftw_plan ---");340 if(lp_>1) PrtTim("--- ComputeFourier: after fftw_plan ---"); 345 341 346 342 // --- RaZ du tableau … … 348 344 349 345 // --- On remplit avec une realisation 350 if(lp >1) PrtTim("--- ComputeFourier: before Fourier realization filling ---");346 if(lp_>1) PrtTim("--- ComputeFourier: before Fourier realization filling ---"); 351 347 long lmod = Nx_/10; if(lmod<1) lmod=1; 352 348 for(long i=0;i<Nx_;i++) { 353 349 long ii = (i>Nx_/2) ? Nx_-i : i; 354 350 double kx = ii*Dkx_; kx *= kx; 355 if(lp >1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl;351 if(lp_>1 && i%lmod==0) cout<<"i="<<i<<" ii="<<ii<<endl; 356 352 for(long j=0;j<Ny_;j++) { 357 353 long jj = (j>Ny_/2) ? Ny_-j : j; … … 369 365 } 370 366 } 371 if(lp >1) PrtTim("--- ComputeFourier: after Fourier realization filling ---");367 if(lp_>1) PrtTim("--- ComputeFourier: after Fourier realization filling ---"); 372 368 373 369 manage_coefficients(); // gros effet pour les spectres que l'on utilise ! 374 if(lp >1) PrtTim("--- ComputeFourier: after managing coefficients ---");370 if(lp_>1) PrtTim("--- ComputeFourier: after managing coefficients ---"); 375 371 376 372 double p = compute_power_carte(); 377 373 cout<<"Puissance dans la realisation: "<<p<<endl; 378 if(lp >1) PrtTim("--- ComputeFourier: after before Computing power ---");374 if(lp_>1) PrtTim("--- ComputeFourier: after before Computing power ---"); 379 375 380 376 } … … 490 486 // avec y = k_x*dx/2 491 487 { 492 int lp=2; 493 check_array_alloc(); 494 495 if(lp>1) PrtTim("--- FilterByPixel: before ---"); 488 check_array_alloc(); 489 490 if(lp_>1) PrtTim("--- FilterByPixel: before ---"); 496 491 497 492 for(long i=0;i<Nx_;i++) { … … 511 506 } 512 507 513 if(lp >1) PrtTim("--- FilterByPixel: after ---");508 if(lp_>1) PrtTim("--- FilterByPixel: after ---"); 514 509 } 515 510 … … 518 513 // Calcule une realisation dans l'espace reel 519 514 { 520 int lp=2;521 515 check_array_alloc(); 522 516 523 517 // On fait la FFT 524 if(lp >1) PrtTim("--- ComputeReal: before fftw backward ---");518 if(lp_>1) PrtTim("--- ComputeReal: before fftw backward ---"); 525 519 fftw_execute(pb_); 526 if(lp >1) PrtTim("--- ComputeReal: after fftw backward ---");520 if(lp_>1) PrtTim("--- ComputeReal: after fftw backward ---"); 527 521 } 528 522 … … 530 524 void GeneFluct3D::ReComputeFourier(void) 531 525 { 532 int lp=2;533 526 check_array_alloc(); 534 527 535 528 // On fait la FFT 536 if(lp >1) PrtTim("--- ComputeReal: before fftw forward ---");529 if(lp_>1) PrtTim("--- ComputeReal: before fftw forward ---"); 537 530 fftw_execute(pf_); 538 531 // On corrige du pb de la normalisation de FFTW3 … … 542 535 for(long l=0;l<NCz_;l++) T_(l,j,i) /= complex<r_8>(v); 543 536 544 if(lp >1) PrtTim("--- ComputeReal: after fftw forward ---");537 if(lp_>1) PrtTim("--- ComputeReal: after fftw forward ---"); 545 538 } 546 539 … … 552 545 { 553 546 check_array_alloc(); 547 if(lp_>1) PrtTim("--- ComputeSpectrum: before ---"); 554 548 555 549 if(herr.NBins()<0) return -1; … … 571 565 } 572 566 } 573 herr.To Correl();567 herr.ToVariance(); 574 568 575 569 // renormalize to directly compare to original spectrum … … 577 571 herr *= norm; 578 572 573 if(lp_>1) PrtTim("--- ComputeSpectrum: after ---"); 574 579 575 return 0; 580 576 } … … 583 579 { 584 580 check_array_alloc(); 581 if(lp_>1) PrtTim("--- ComputeSpectrum2D: before ---"); 585 582 586 583 if(herr.NBinX()<0 || herr.NBinY()<0) return -1; … … 602 599 } 603 600 } 604 herr.To Correl();601 herr.ToVariance(); 605 602 606 603 // renormalize to directly compare to original spectrum … … 608 605 herr *= norm; 609 606 607 if(lp_>1) PrtTim("--- ComputeSpectrum2D: after ---"); 608 610 609 return 0; 611 610 } … … 615 614 // Recompute MASS variance in spherical top-hat (rayon=R) 616 615 { 617 int lp=2; 618 check_array_alloc(); 619 620 if(lp>1) PrtTim("--- VarianceFrReal: before computation ---"); 616 check_array_alloc(); 617 618 if(lp_>1) PrtTim("--- VarianceFrReal: before computation ---"); 621 619 622 620 long dnx = long(R/Dx_+0.5); if(dnx<=0) dnx = 1; … … 654 652 sum /= nsum; 655 653 sum2 = sum2/nsum - sum*sum; 656 if(lp ) cout<<"VarianceFrReal: nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl;654 if(lp_) cout<<"VarianceFrReal: nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl; 657 655 658 656 var = sum2/(sum*sum); // <dM>^2/<M>^2 659 if(lp ) cout<<"sigmaR^2="<<var<<" -> "<<sqrt(var)<<endl;660 661 if(lp >1) PrtTim("--- VarianceFrReal: after computation ---");657 if(lp_) cout<<"sigmaR^2="<<var<<" -> "<<sqrt(var)<<endl; 658 659 if(lp_>1) PrtTim("--- VarianceFrReal: after computation ---"); 662 660 return nsum; 663 661 } … … 726 724 // d_rho/rho -> Mass (add one!) 727 725 { 728 int lp=2; 729 check_array_alloc(); 730 731 if(lp>1) PrtTim("--- TurnFluct2Mass: before computation ---"); 726 check_array_alloc(); 727 728 if(lp_>1) PrtTim("--- TurnFluct2Mass: before computation ---"); 732 729 733 730 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { … … 736 733 } 737 734 738 if(lp >1) PrtTim("--- TurnFluct2Mass: after computation ---");735 if(lp_>1) PrtTim("--- TurnFluct2Mass: after computation ---"); 739 736 } 740 737 … … 742 739 // do NOT treate negative or nul values 743 740 { 744 int lp=2; 745 if(lp>1) PrtTim("--- TurnMass2MeanNumber: before computation ---"); 741 if(lp_>1) PrtTim("--- TurnMass2MeanNumber: before computation ---"); 746 742 747 743 double m,s2; 748 744 int_8 ngood = MeanSigma2(m,s2,0.,1e+200); 749 if(lp ) cout<<"TurnMass2MeanNumber: ngood="<<ngood745 if(lp_) cout<<"TurnMass2MeanNumber: ngood="<<ngood 750 746 <<" m="<<m<<" s2="<<s2<<" -> "<<sqrt(s2)<<endl; 751 747 … … 758 754 // (rappel sur tout les pixels <1+d_rho/rho>=1) 759 755 double dn = n_by_mpc3*Vol_/m /(double)ngood; // nb de gal a mettre ds 1 px 760 if(lp ) cout<<"galaxy density move from "756 if(lp_) cout<<"galaxy density move from " 761 757 <<n_by_mpc3*Vol_/double(NRtot_)<<" to "<<dn<<" / pixel"<<endl; 762 758 double sum = 0.; … … 766 762 if(data_[ip]>0.) sum += data_[ip]; // mais on ne les compte pas 767 763 } 768 if(lp ) cout<<sum<<" galaxies put into survey / "<<n_by_mpc3*Vol_<<endl;769 770 if(lp >1) PrtTim("--- TurnMass2MeanNumber: after computation ---");764 if(lp_) cout<<sum<<" galaxies put into survey / "<<n_by_mpc3*Vol_<<endl; 765 766 if(lp_>1) PrtTim("--- TurnMass2MeanNumber: after computation ---"); 771 767 return sum; 772 768 } … … 775 771 // do NOT treate negative or nul mass -> let it as it is 776 772 { 777 int lp=2; 778 check_array_alloc(); 779 780 if(lp>1) PrtTim("--- ApplyPoisson: before computation ---"); 773 check_array_alloc(); 774 775 if(lp_>1) PrtTim("--- ApplyPoisson: before computation ---"); 781 776 782 777 double sum = 0.; … … 790 785 } 791 786 } 792 if(lp ) cout<<sum<<" galaxies put into survey"<<endl;793 794 if(lp >1) PrtTim("--- ApplyPoisson: before computation ---");787 if(lp_) cout<<sum<<" galaxies put into survey"<<endl; 788 789 if(lp_>1) PrtTim("--- ApplyPoisson: before computation ---"); 795 790 return sum; 796 791 } … … 804 799 // RETURN la masse totale 805 800 { 806 int lp=2; 807 check_array_alloc(); 808 809 if(lp>1) PrtTim("--- TurnNGal2Mass: before computation ---"); 801 check_array_alloc(); 802 803 if(lp_>1) PrtTim("--- TurnNGal2Mass: before computation ---"); 810 804 811 805 double sum = 0.; … … 824 818 } 825 819 } 826 if(lp ) cout<<sum<<" MSol HI mass put into survey"<<endl;827 828 if(lp >1) PrtTim("--- TurnNGal2Mass: after computation ---");820 if(lp_) cout<<sum<<" MSol HI mass put into survey"<<endl; 821 822 if(lp_>1) PrtTim("--- TurnNGal2Mass: after computation ---"); 829 823 return sum; 830 824 } … … 833 827 // add noise to every pixels (meme les <=0 !) 834 828 { 835 int lp=2; 836 check_array_alloc(); 837 838 if(lp>1) PrtTim("--- AddNoise2Real: before computation ---"); 829 check_array_alloc(); 830 831 if(lp_>1) PrtTim("--- AddNoise2Real: before computation ---"); 839 832 840 833 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { … … 843 836 } 844 837 845 if(lp >1) PrtTim("--- AddNoise2Real: after computation ---");846 } 838 if(lp_>1) PrtTim("--- AddNoise2Real: after computation ---"); 839 }
Note:
See TracChangeset
for help on using the changeset viewer.