Changeset 3330 in Sophya for trunk/Cosmo/SimLSS
- Timestamp:
- Oct 1, 2007, 7:10:50 PM (18 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvconcherr.cc
r3289 r3330 32 32 int main(int narg,char *arg[]) 33 33 { 34 // "hpkgen" "hpkgenf" "hpkrec" "hpkgen2" "hpkgenf2" "hpkrec2" 34 // "hpkgen" "hpkgenfb" "hpkgenf" "hpkrecb" "hpkrec" 35 // "hpkgen2" "hpkgenfb2" "hpkgenf2" "hpkrecb2" "hpkrec2" 35 36 string nameh = ""; 36 37 vector<string> ppfname; -
trunk/Cosmo/SimLSS/cmvobserv3d.cc
r3329 r3330 419 419 420 420 cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl; 421 HistoErr hpkgenf(0.,knyqmax,nherr); 422 hpkgenf.ReCenterBin(); hpkgenf.Zero(); 423 hpkgenf.Show(); 424 fluct3d.ComputeSpectrum(hpkgenf); 421 HistoErr hpkgenfb(0.,knyqmax,nherr); 422 hpkgenfb.ReCenterBin(); hpkgenfb.Zero(); 423 hpkgenfb.Show(); 424 fluct3d.ComputeSpectrum(hpkgenfb); 425 { 426 tagobs = "hpkgenfb"; posobs.PutObject(hpkgenfb,tagobs); 427 } 428 PrtTim(">>>> End Checking realization spectra"); 429 430 cout<<"\n--- Checking realization spectra after pixel shape convol. with pixel correc."<<endl; 431 HistoErr hpkgenf(hpkgenfb); hpkgenf.Zero(); 432 fluct3d.ComputeSpectrum(hpkgenf,0.,filter_by_pixel); 425 433 { 426 434 tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs); 427 435 } 428 PrtTim(">>>> End Checking realization spectra ");436 PrtTim(">>>> End Checking realization spectra with pixel correc."); 429 437 430 438 if(comp2dspec) { 431 439 cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl; 432 Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 433 hpkgenf2.ReCenterBin(); hpkgenf2.Zero(); 434 hpkgenf2.Show(); 435 fluct3d.ComputeSpectrum2D(hpkgenf2); 440 Histo2DErr hpkgenfb2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 441 hpkgenfb2.ReCenterBin(); hpkgenfb2.Zero(); 442 hpkgenfb2.Show(); 443 fluct3d.ComputeSpectrum2D(hpkgenfb2); 444 { 445 tagobs = "hpkgenfb2"; posobs.PutObject(hpkgenfb2,tagobs); 446 } 447 PrtTim(">>>> End Checking realization 2D spectra"); 448 449 cout<<"\n--- Checking realization 2D spectra after pixel shape convol. with pixel correc."<<endl; 450 Histo2DErr hpkgenf2(hpkgenfb2); hpkgenf2.Zero(); 451 fluct3d.ComputeSpectrum2D(hpkgenf2,0.,filter_by_pixel); 436 452 { 437 453 tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs); 438 454 } 439 PrtTim(">>>> End Checking realization 2D spectra ");455 PrtTim(">>>> End Checking realization 2D spectra with pixel correc."); 440 456 } 441 457 } … … 589 605 590 606 //----------------------------------------------------------------- 607 double snoisesave = 0.; 591 608 if(snoise>0.) { 592 609 cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl; 593 610 fluct3d.AddNoise2Real(snoise,(isnoise_evol>0? true:false)); 611 snoisesave = snoise; 594 612 nm = fluct3d.MeanSigma2(rm,rs2); 595 613 PrtTim(">>>> End Add noise"); … … 603 621 } 604 622 cout<<"...scale="<<scalecube<<" offset="<<offsetcube<<endl; 605 if(scalecube>0.) fluct3d.ScaleOffset(scalecube,offsetcube); 623 if(scalecube>0.) { 624 fluct3d.ScaleOffset(scalecube,offsetcube); 625 snoisesave *= scalecube; 626 } 606 627 PrtTim(">>>> End Scale cube"); 607 628 } … … 637 658 638 659 cout<<endl<<"\n--- Computing final spectrum"<<endl; 639 HistoErr hpkrec(0.,knyqmax,nherr); 640 hpkrec.ReCenterBin(); 641 hpkrec.Show(); 642 fluct3d.ComputeSpectrum(hpkrec); 660 HistoErr hpkrecb(0.,knyqmax,nherr); hpkrecb.Zero(); 661 hpkrecb.ReCenterBin(); 662 hpkrecb.Show(); 663 fluct3d.ComputeSpectrum(hpkrecb); 664 { 665 tagobs = "hpkrecb"; posobs.PutObject(hpkrecb,tagobs); 666 } 667 PrtTim(">>>> End Computing final spectrum"); 668 669 cout<<endl<<"\n--- Computing final spectrum with pixel deconv."<<endl; 670 HistoErr hpkrec(hpkrecb); hpkrec.Zero(); 671 fluct3d.ComputeSpectrum(hpkrec,snoisesave,filter_by_pixel); 672 { 643 673 tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs); 644 PrtTim(">>>> End Computing final spectrum"); 674 } 675 PrtTim(">>>> End Computing final spectrum with pixel deconv."); 645 676 646 677 if(comp2dspec) { 647 678 cout<<"\n--- Computing final 2D spectrum"<<endl; 648 Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 649 hpkrec2.ReCenterBin(); hpkrec2.Zero(); 650 hpkrec2.Show(); 651 fluct3d.ComputeSpectrum2D(hpkrec2); 679 Histo2DErr hpkrecb2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 680 hpkrecb2.ReCenterBin(); hpkrecb2.Zero(); 681 hpkrecb2.Show(); 682 fluct3d.ComputeSpectrum2D(hpkrecb2); 683 { 684 tagobs = "hpkrecb2"; posobs.PutObject(hpkrecb2,tagobs); 685 } 686 PrtTim(">>>> End Computing final 2D spectrum"); 687 688 cout<<"\n--- Computing final 2D spectrum with pixel deconv."<<endl; 689 Histo2DErr hpkrec2(hpkrecb2); hpkrec2.Zero(); 690 fluct3d.ComputeSpectrum2D(hpkrec2,snoisesave,filter_by_pixel); 652 691 { 653 692 tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs); 654 693 } 655 PrtTim(">>>> End Computing final 2D spectrum"); 694 PrtTim(">>>> End Computing final 2D spectrum with pixel deconv."); 695 656 696 } 657 697 -
trunk/Cosmo/SimLSS/genefluct3d.cc
r3329 r3330 321 321 if(lp_>1 && n>0) 322 322 for(int i=0;i<n;i++) 323 if(i==0 || abs(i-n/2)<2 || i==n-1) 324 cout<<" "<<i<<" "<<loscom2zred_[i]<<endl; 323 if(i<2 || abs(i-n/2)<2 || i>=n-2) 324 cout<<" i="<<i 325 <<" d="<<loscom2zred_min_+i*(loscom2zred_max_-loscom2zred_min_)/(n-1.) 326 <<" Mpc z="<<loscom2zred_[i]<<endl; 325 327 } 326 328 … … 374 376 init_fftw(); 375 377 SetObservator(zref,kzref); 378 array_allocated_ = true; 376 379 } catch (PThrowable & exc) { 377 380 cout<<"Exception : "<<(string)typeid(exc).name() … … 438 441 init_fftw(); 439 442 SetObservator(zref,kzref); 443 array_allocated_ = true; 440 444 } catch (PThrowable & exc) { 441 445 cout<<"Exception : "<<(string)typeid(exc).name() … … 724 728 long ii = (i>Nx_/2) ? Nx_-i : i; 725 729 double kx = ii*Dkx_ *Dx_/2; 726 double pk_x = pixelfilter(kx); 730 double pk_x = pixelfilter(kx); 727 731 for(long j=0;j<Ny_;j++) { 728 732 long jj = (j>Ny_/2) ? Ny_-j : j; 729 733 double ky = jj*Dky_ *Dy_/2; 730 double pk_y = pixelfilter(ky);734 double pk_y = pixelfilter(ky); 731 735 for(long l=0;l<NCz_;l++) { 732 736 double kz = l*Dkz_ *Dz_/2; … … 826 830 double ky = jj*Dky_; ky *= ky; 827 831 for(long l=0;l<NCz_;l++) { 828 double kz = l*Dkz_; kz *= kz;829 double k = sqrt(kx+ky+kz );832 double kz = l*Dkz_; 833 double k = sqrt(kx+ky+kz*kz); 830 834 double pk = MODULE2(T_(l,j,i)); 831 835 herr.Add(k,pk); … … 862 866 double pk = MODULE2(T_(l,j,i)); 863 867 herr.Add(kt,kz,pk); 868 } 869 } 870 } 871 herr.ToVariance(); 872 873 // renormalize to directly compare to original spectrum 874 double norm = Vol_; 875 herr *= norm; 876 877 return 0; 878 } 879 880 //------------------------------------------------------------------- 881 int GeneFluct3D::ComputeSpectrum(HistoErr& herr,double sigma,bool pixcor) 882 // Compute spectrum from "T" and fill HistoErr "herr" 883 // AVEC la soustraction du niveau de bruit et la correction par filterpixel() 884 // Si on ne fait pas ca, alors on obtient un spectre non-isotrope! 885 // 886 // T : dans le format standard de GeneFuct3D: T(nz,ny,nx) 887 // cad T(kz,ky,kx) avec 0<kz<kz_nyq -ky_nyq<ky<ky_nyq -kx_nyq<kx<kx_nyq 888 { 889 if(lp_>0) cout<<"--- ComputeSpectrum: sigma="<<sigma<<endl; 890 check_array_alloc(); 891 892 if(sigma<=0.) sigma = 0.; 893 double sigma2 = sigma*sigma / (double)NRtot_; 894 895 if(herr.NBins()<0) return -1; 896 herr.Zero(); 897 898 TVector<r_8> vfz(NCz_); 899 if(pixcor) // kz = l*Dkz_ 900 for(long l=0;l<NCz_;l++) {vfz(l)=pixelfilter(l*Dkz_ *Dz_/2); vfz(l)*=vfz(l);} 901 902 // Attention a l'ordre 903 for(long i=0;i<Nx_;i++) { 904 long ii = (i>Nx_/2) ? Nx_-i : i; 905 double kx = ii*Dkx_; 906 double fx = (pixcor) ? pixelfilter(kx*Dx_/2): 1.; 907 kx *= kx; fx *= fx; 908 for(long j=0;j<Ny_;j++) { 909 long jj = (j>Ny_/2) ? Ny_-j : j; 910 double ky = jj*Dky_; 911 double fy = (pixcor) ? pixelfilter(ky*Dy_/2): 1.; 912 ky *= ky; fy *= fy; 913 for(long l=0;l<NCz_;l++) { 914 double kz = l*Dkz_; 915 double k = sqrt(kx+ky+kz*kz); 916 double pk = MODULE2(T_(l,j,i)) - sigma2; 917 double fz = (pixcor) ? vfz(l): 1.; 918 double f = fx*fy*fz; 919 if(f>0.) herr.Add(k,pk/f); 920 } 921 } 922 } 923 herr.ToVariance(); 924 925 // renormalize to directly compare to original spectrum 926 double norm = Vol_; 927 herr *= norm; 928 929 return 0; 930 } 931 932 int GeneFluct3D::ComputeSpectrum2D(Histo2DErr& herr,double sigma,bool pixcor) 933 // AVEC la soustraction du niveau de bruit et la correction par filterpixel() 934 { 935 if(lp_>0) cout<<"--- ComputeSpectrum2D: sigma="<<sigma<<endl; 936 check_array_alloc(); 937 938 if(sigma<=0.) sigma = 0.; 939 double sigma2 = sigma*sigma / (double)NRtot_; 940 941 if(herr.NBinX()<0 || herr.NBinY()<0) return -1; 942 herr.Zero(); 943 944 TVector<r_8> vfz(NCz_); 945 if(pixcor) // kz = l*Dkz_ 946 for(long l=0;l<NCz_;l++) {vfz(l)=pixelfilter(l*Dkz_ *Dz_/2); vfz(l)*=vfz(l);} 947 948 // Attention a l'ordre 949 for(long i=0;i<Nx_;i++) { 950 long ii = (i>Nx_/2) ? Nx_-i : i; 951 double kx = ii*Dkx_; 952 double fx = (pixcor) ? pixelfilter(kx*Dx_/2) : 1.; 953 kx *= kx; fx *= fx; 954 for(long j=0;j<Ny_;j++) { 955 long jj = (j>Ny_/2) ? Ny_-j : j; 956 double ky = jj*Dky_; 957 double fy = (pixcor) ? pixelfilter(ky*Dy_/2) : 1.; 958 ky *= ky; fy *= fy; 959 double kt = sqrt(kx+ky); 960 for(long l=0;l<NCz_;l++) { 961 double kz = l*Dkz_; 962 double pk = MODULE2(T_(l,j,i)) - sigma2; 963 double fz = (pixcor) ? vfz(l): 1.; 964 double f = fx*fy*fz; 965 if(f>0.) herr.Add(kt,kz,pk/f); 864 966 } 865 967 } -
trunk/Cosmo/SimLSS/genefluct3d.h
r3329 r3330 51 51 // Pour adressage fdata_[ip][0-1] 52 52 inline int_8 IndexC(long i,long j,long k) {return (int_8)(k+NCz_*(j+Ny_*i));} 53 // - On peut aussi adresser: 54 // TArray< complex<r_8> >& pk = gf3d.GetComplexArray(); pk(i,j,k) = ...; 55 // TArray<r_8>& rgen = gf3d.GetRealArray(); rgen(i,j,k) = ...; 53 // On peut aussi adresser: 54 // TArray< complex<r_8> >& pk = gf3d.GetComplexArray(); 55 // pk(k,j,i) avec k=[0,NCz_[ j=[0,Ny_[ i=[0,Nx_[ 56 // pk[IndexC(i,j,k)] 57 // TArray<r_8>& rgen = gf3d.GetRealArray(); 58 // rgen(k,j,i) avec k=[0,NTz_[ j=[0,Ny_[ i=[0,Nx_[ 59 // mais seul k=[0,Nz_[ est utile 60 // rgen[IndexR(i,j,k)] 61 // ATTENTION: TArray adresse en memoire a l'envers du C ! 62 // Tarray(n1,n2,n3) == Carray[n3][n2][n1] 56 63 57 64 vector<long> GetNpix(void) {return N_;} 58 65 int_8 NPix(void) {return NRtot_;} 66 long GetNx(void) {return Nx_;} 67 long GetNy(void) {return Ny_;} 68 long GetNz(void) {return Nz_;} 59 69 60 70 // Return |K_i| module relative to pixel indices … … 83 93 84 94 void ComputeReal(void); 95 void ApplyGrowthFactor(void); 85 96 86 97 void ReComputeFourier(void); … … 88 99 int ComputeSpectrum(HistoErr& herr); 89 100 int ComputeSpectrum2D(Histo2DErr& herr); 90 void ApplyGrowthFactor(void); 101 int ComputeSpectrum(HistoErr& herr,double sigma,bool pixcor); 102 int ComputeSpectrum2D(Histo2DErr& herr,double sigma,bool pixcor); 91 103 92 104 int_8 VarianceFrReal(double R,double& var); -
trunk/Cosmo/SimLSS/geneutils.cc
r3329 r3330 55 55 //------------------------------------------------------------------- 56 56 // Classe d'inversion d'une fonction STRICTEMENT MONOTONE CROISSANTE 57 // - Le vecteur y a "Nin" elements y_i tels que "y_i = f(x_i)" 58 // - On a x(i) < x(i+1) et y(i) < y(i+1) 59 // - La classe renvoie ymin=y(0) , ymax=y(Nin -1) 60 // et le vecteur x = f^-1(y) de "Nout" elements 61 // Les y_i sont regulierement espaces et ymin et ymax 62 // La re-interpolation inverse est faite par lineaire 57 // 58 // - On part de deux vecteurs x,y de "Nin" elements tels que "y_i = f[x_i]" 59 // ou la fonction "f" est strictement monotone croissante: 60 // x(i) < x(i+1) et y(i) < y(i+1) 61 // - Le but de la classe est de remplir un vecteur X de "Nout" elements 62 // tels que: X_j = f^-1[Y_j] avec j=[0,Nout[ 63 // avec les Y_j regulierement espaces entre ymin=y(0) , ymax=y(Nin -1) 64 // cad: X_j = f^-1[ ymin+j*(ymax-ymin)/(Nout-1) ] 65 // - La construction du vecteur X est realisee 66 // par interpolation lineaire (ComputeLinear) ou parabolique (ComputeParab) 63 67 InverseFunc::InverseFunc(vector<double>& x,vector<double>& y) 64 68 : _ymin(0.) , _ymax(0.) , _x(x) , _y(y) … … 92 96 } 93 97 94 int InverseFunc::ComputeLinear(long n ,vector<double>& xfcty)98 int InverseFunc::ComputeLinear(long nout,vector<double>& xfcty) 95 99 // Compute table "xfcty" by linear interpolation of "x" versus "y" 96 // on "n " points from "ymin" to "ymax":97 // xfcty[i] = interpolation of function "x" for "ymin+i*(ymax-ymin)/(n -1.)"98 { 99 if(n <3) return -1;100 101 xfcty.resize(n );100 // on "nout" points from "ymin" to "ymax": 101 // xfcty[i] = interpolation of function "x" for "ymin+i*(ymax-ymin)/(nout-1)" 102 { 103 if(nout<3) return -1; 104 105 xfcty.resize(nout); 102 106 103 107 long i1,i2; 104 108 double x; 105 for(int_4 i=0;i<n ;i++) {106 double y = _ymin + i*(_ymax-_ymin)/(n -1.);109 for(int_4 i=0;i<nout;i++) { 110 double y = _ymin + i*(_ymax-_ymin)/(nout-1.); 107 111 find_in_y(y,i1,i2); 108 112 double dy = _y[i2]-_y[i1]; … … 118 122 } 119 123 120 int InverseFunc::ComputeParab(long n ,vector<double>& xfcty)121 { 122 if(n <3) return -1;123 124 xfcty.resize(n );124 int InverseFunc::ComputeParab(long nout,vector<double>& xfcty) 125 { 126 if(nout<3) return -1; 127 128 xfcty.resize(nout); 125 129 126 130 long i1,i2,i3; 127 131 double x; 128 for(int_4 i=0;i<n ;i++) {129 double y = _ymin + i*(_ymax-_ymin)/(n -1.);132 for(int_4 i=0;i<nout;i++) { 133 double y = _ymin + i*(_ymax-_ymin)/(nout-1.); 130 134 find_in_y(y,i1,i2); 131 135 // On cherche le 3ieme point selon la position de y / au 2 premiers -
trunk/Cosmo/SimLSS/geneutils.h
r3325 r3330 71 71 } 72 72 73 double _ymin,_ymax; 73 74 vector<double>& _x; 74 75 vector<double>& _y; 75 double _ymin,_ymax,_dy;76 76 }; 77 77
Note:
See TracChangeset
for help on using the changeset viewer.