[3770] | 1 | #include "sopnamsp.h"
|
---|
| 2 | #include "machdefs.h"
|
---|
| 3 | #include <iostream>
|
---|
| 4 | #include <stdlib.h>
|
---|
| 5 | #include <stdio.h>
|
---|
| 6 | #include <string.h>
|
---|
| 7 | #include <math.h>
|
---|
| 8 | #include <unistd.h>
|
---|
| 9 |
|
---|
| 10 | #include "sophyainit.h"
|
---|
| 11 | #include "timing.h"
|
---|
| 12 | #include "dvlist.h"
|
---|
| 13 | #include "ntuple.h"
|
---|
| 14 | #include "fabtcolread.h"
|
---|
| 15 |
|
---|
| 16 | #include "constcosmo.h"
|
---|
| 17 | #include "geneutils.h"
|
---|
| 18 | #include "genefluct3d.h"
|
---|
| 19 |
|
---|
| 20 | void usage(void);
|
---|
| 21 | void usage(void)
|
---|
| 22 | {
|
---|
| 23 | cout<<"cmvrvloscor rho.fits vlos.fits"<<endl;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | int main(int narg,char *arg[])
|
---|
| 27 | {
|
---|
| 28 | int nthread = 1;
|
---|
| 29 | SophyaInit();
|
---|
| 30 | InitTim();
|
---|
| 31 |
|
---|
| 32 | if(narg<=2) {usage(); return -1;}
|
---|
| 33 |
|
---|
| 34 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 35 | try {
|
---|
| 36 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 37 |
|
---|
| 38 | cout<<"> read rho: "<<arg[1]<<endl;
|
---|
| 39 | FitsImg3DRead f3dr(arg[1],0,5);
|
---|
| 40 | cout<<"> read vlos: "<<arg[2]<<endl;
|
---|
| 41 | FitsImg3DRead f3dv(arg[2],0,5);
|
---|
[3771] | 42 | long Nx = f3dr.ReadKeyL("Nx");
|
---|
| 43 | long Ny = f3dr.ReadKeyL("Ny");;
|
---|
| 44 | long Nz = f3dr.ReadKeyL("Nz");;
|
---|
| 45 | cout<<"N: x="<<Nx<<" y="<<Ny<<" z="<<Nz<<endl;
|
---|
| 46 | double Dx = f3dr.ReadKey("Dx");
|
---|
| 47 | double Dy = f3dr.ReadKey("Dy");
|
---|
| 48 | double Dz = f3dr.ReadKey("Dz");
|
---|
| 49 | cout<<"D: x="<<Dx<<" y="<<Dy<<" z="<<Dz<<endl;
|
---|
| 50 | double Zref = f3dr.ReadKey("ZREF");
|
---|
| 51 | double Href = f3dr.ReadKey("HREF");
|
---|
| 52 | cout<<"Zref="<<Zref<<" Href="<<Href<<endl;
|
---|
[3770] | 53 |
|
---|
| 54 | POutPersist pos("cmvrvloscor.ppf");
|
---|
| 55 |
|
---|
[3771] | 56 | GeneFluct3D fluct3d(Nx,Ny,Nz,Dx,Dy,Dz,nthread,2);
|
---|
[3770] | 57 | fluct3d.Print();
|
---|
| 58 | TArray<GEN3D_TYPE>& rgen = fluct3d.GetRealArray();
|
---|
| 59 | rgen = 0.;
|
---|
[3771] | 60 | TVector<r_8> R(Nz), Rdis(Nz);
|
---|
[3770] | 61 |
|
---|
| 62 | cout<<"> filling redshift distorted cube"<<endl;
|
---|
[3771] | 63 | for(int i=0;i<Nx;i++) {
|
---|
| 64 | if(i%(Nx/10)==0) cout<<"i="<<i<<endl;
|
---|
| 65 | for(int j=0;j<Ny;j++) {
|
---|
| 66 | for(int l=0;l<Nz;l++) R(l) = f3dr.Read(l,j,i);
|
---|
[3770] | 67 | Rdis = 0.;
|
---|
[3771] | 68 | for(int l=0;l<Nz;l++) {
|
---|
| 69 | double d = (1.+Zref) / Href * f3dv.Read(l,j,i);
|
---|
| 70 | double lpd = (double)l + d/Dz; // valeur du deplacee
|
---|
| 71 | // on repartit proportionnelement au recouvrement sur 2 pixels
|
---|
| 72 | int l1 = int(lpd); // pixel de droite
|
---|
| 73 | int l2 = l1 + 1; // pixel de gauche
|
---|
| 74 | lpd -= (double)l1; // recouvrement du pixel du dessus
|
---|
| 75 | if(l1>=0 && l1<Nz) Rdis(l1) += R(l) * (1.-lpd);
|
---|
| 76 | if(l2>=0 && l2<Nz) Rdis(l2) += R(l) * lpd;
|
---|
[3770] | 77 | }
|
---|
[3771] | 78 | for(int l=0;l<Nz;l++) rgen(l,j,i) += Rdis(l);
|
---|
[3770] | 79 | }
|
---|
| 80 | }
|
---|
| 81 | PrtTim(">>>> End filling redshift distorted cube");
|
---|
| 82 |
|
---|
| 83 | fluct3d.ReComputeFourier();
|
---|
| 84 | PrtTim(">>>> End ReComputing spectrum");
|
---|
| 85 |
|
---|
| 86 | cout<<endl<<"\n--- Computing final 1D spectrum"<<endl;
|
---|
| 87 | double dkmin = fluct3d.GetKincMin();
|
---|
| 88 | double knyqmax = fluct3d.GetKmax();
|
---|
| 89 | long nherr = long(knyqmax/dkmin+0.5);
|
---|
| 90 | cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
|
---|
| 91 | HistoErr hpkrec(0.,knyqmax,nherr); hpkrec.Zero();
|
---|
| 92 | hpkrec.ReCenterBin(); hpkrec.Show();
|
---|
| 93 | fluct3d.ComputeSpectrum(hpkrec);
|
---|
| 94 | pos.PutObject(hpkrec,"hpkrec");
|
---|
| 95 | PrtTim(">>>> End Computing final spectrum");
|
---|
| 96 |
|
---|
| 97 | cout<<"\n--- Computing final 2D spectrum"<<endl;
|
---|
| 98 | double dktmin = fluct3d.GetKTincMin();
|
---|
| 99 | double ktnyqmax = fluct3d.GetKTmax();
|
---|
| 100 | long nherrt = long(ktnyqmax/dktmin+0.5);
|
---|
| 101 | double dkzmin = fluct3d.GetKinc()[2];
|
---|
| 102 | double kznyqmax = fluct3d.GetKnyq()[2];
|
---|
| 103 | long nherrz = long(kznyqmax/dkzmin+0.5);
|
---|
| 104 | cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin
|
---|
| 105 | <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
|
---|
| 106 | Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 107 | hpkrec2.ReCenterBin(); hpkrec2.Zero(); hpkrec2.Show();
|
---|
| 108 | fluct3d.ComputeSpectrum2D(hpkrec2);
|
---|
| 109 | pos.PutObject(hpkrec2,"hpkrec2");
|
---|
| 110 | PrtTim(">>>> End Computing final 2D spectrum");
|
---|
| 111 |
|
---|
| 112 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 113 | } catch (PException& exc) {
|
---|
| 114 | cerr<<"cmvrvloscor.cc catched PException"<<exc.Msg()<<endl;
|
---|
| 115 | return 77;
|
---|
| 116 | } catch (std::exception& sex) {
|
---|
| 117 | cerr << "cmvrvloscor.cc std::exception :"
|
---|
| 118 | << (string)typeid(sex).name() << "\n msg= "
|
---|
| 119 | << sex.what() << endl;
|
---|
| 120 | return 78;
|
---|
| 121 | } catch (...) {
|
---|
| 122 | cerr << "cmvrvloscor.cc catched unknown (...) exception " << endl;
|
---|
| 123 | return 79;
|
---|
| 124 | }
|
---|
| 125 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 126 |
|
---|
| 127 | return 0;
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | /*
|
---|
| 131 | openppf cmvrvloscor.ppf
|
---|
| 132 |
|
---|
| 133 | n/plot hpkrec.val%x x>0 ! "nsta cpts logx"
|
---|
| 134 |
|
---|
| 135 | imag hpkrec2
|
---|
[3771] | 136 | addoval 0 0 0.05 0.05 "green" false
|
---|
| 137 | addoval 0 0 0.1 0.1 "green" false
|
---|
| 138 | addoval 0 0 0.25 0.25 "green" false
|
---|
| 139 | addoval 0 0 0.5 0.5 "green" false
|
---|
| 140 | x = ${hpkrec2.xmax} / 2.
|
---|
| 141 | addoval 0 0 $x $x "green" false
|
---|
| 142 | x = ${hpkrec2.ymax} / 2.
|
---|
| 143 | addoval 0 0 $x $x "green" false
|
---|
[3770] | 144 |
|
---|
| 145 | # proj selon kT (black), selon kZ (red)
|
---|
| 146 | n/plot hpkrec2.val%sqrt(x*x+y*y) ! ! "nsta cpts"
|
---|
| 147 | */
|
---|