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 "histos.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 | int_8 nhfill = 100000;
|
---|
30 |
|
---|
31 | if(narg<=2) {usage(); return -1;}
|
---|
32 |
|
---|
33 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
34 | try {
|
---|
35 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
36 |
|
---|
37 | SophyaInit();
|
---|
38 | InitTim();
|
---|
39 |
|
---|
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);
|
---|
44 | long Nx = f3dr.ReadKeyL("Nx");
|
---|
45 | long Ny = f3dr.ReadKeyL("Ny");;
|
---|
46 | long Nz = f3dr.ReadKeyL("Nz");;
|
---|
47 | cout<<"N: x="<<Nx<<" y="<<Ny<<" z="<<Nz<<endl;
|
---|
48 | double Dx = f3dr.ReadKey("Dx");
|
---|
49 | double Dy = f3dr.ReadKey("Dy");
|
---|
50 | double Dz = f3dr.ReadKey("Dz");
|
---|
51 | cout<<"D: x="<<Dx<<" y="<<Dy<<" z="<<Dz<<endl;
|
---|
52 | double Zref = f3dr.ReadKey("ZREF");
|
---|
53 | double Href = f3dr.ReadKey("HREF");
|
---|
54 | cout<<"Zref="<<Zref<<" Href="<<Href<<endl;
|
---|
55 |
|
---|
56 | double dmin = min(Dx,min(Dy,Dz));
|
---|
57 | double nmax = max(Nx,max(Ny,Nz));
|
---|
58 | cout<<"dmin="<<dmin<<" nmax="<<nmax<<endl;
|
---|
59 | 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 |
|
---|
62 | 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);
|
---|
69 | TVector<r_8> Rdis(Nz);
|
---|
70 |
|
---|
71 | cout<<"> filling redshift distorted cube"<<endl;
|
---|
72 | int_8 nread = 0;
|
---|
73 | 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++) {
|
---|
76 | //for(int l=0;l<Nz;l++) R(l) = f3dr.Read(l,j,i);
|
---|
77 | //for(int l=0;l<Nz;l++) V(l) = f3dv.Read(l,j,i);
|
---|
78 | f3dr.Read(j,i,R);
|
---|
79 | f3dv.Read(j,i,V);
|
---|
80 | Rdis = 0.;
|
---|
81 | for(int l=0;l<Nz;l++) {
|
---|
82 | double d = (1.+Zref) / Href * V(l);
|
---|
83 | if(nread%nhfill==0) hmpc.Add(d);
|
---|
84 | double lpd = (double)l + d/Dz; // valeur du deplacee
|
---|
85 | // on repartit proportionnelement au recouvrement sur 2 pixels
|
---|
86 | int l1 = int(lpd); // pixel de droite
|
---|
87 | int l2 = l1 + 1; // pixel de gauche
|
---|
88 | lpd -= (double)l1; // recouvrement du pixel du dessus
|
---|
89 | if(l1>=0 && l1<Nz) Rdis(l1) += R(l) * (1.-lpd);
|
---|
90 | if(l2>=0 && l2<Nz) Rdis(l2) += R(l) * lpd;
|
---|
91 | }
|
---|
92 | for(int l=0;l<Nz;l++) rgen(l,j,i) += Rdis(l);
|
---|
93 | }
|
---|
94 | }
|
---|
95 | 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");
|
---|
126 |
|
---|
127 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
128 | } catch (PException& exc) {
|
---|
129 | cerr<<"cmvrvloscor.cc catched PException"<<exc.Msg()<<endl;
|
---|
130 | return 77;
|
---|
131 | } catch (std::exception& sex) {
|
---|
132 | cerr << "cmvrvloscor.cc std::exception :"
|
---|
133 | << (string)typeid(sex).name() << "\n msg= "
|
---|
134 | << sex.what() << endl;
|
---|
135 | return 78;
|
---|
136 | } catch (...) {
|
---|
137 | cerr << "cmvrvloscor.cc catched unknown (...) exception " << endl;
|
---|
138 | return 79;
|
---|
139 | }
|
---|
140 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
141 |
|
---|
142 | return 0;
|
---|
143 | }
|
---|
144 |
|
---|
145 | /*
|
---|
146 | openppf cmvrvloscor.ppf
|
---|
147 |
|
---|
148 | disp hmpc
|
---|
149 |
|
---|
150 | n/plot hpkrec.val%x x>0 ! "nsta cpts logx"
|
---|
151 |
|
---|
152 | imag hpkrec2
|
---|
153 | addoval 0 0 0.05 0.05 "green" false
|
---|
154 | addoval 0 0 0.1 0.1 "green" false
|
---|
155 | addoval 0 0 0.25 0.25 "green" false
|
---|
156 | addoval 0 0 0.5 0.5 "green" false
|
---|
157 | x = ${hpkrec2.xmax} / 2.
|
---|
158 | addoval 0 0 $x $x "green" false
|
---|
159 | x = ${hpkrec2.ymax} / 2.
|
---|
160 | addoval 0 0 $x $x "green" false
|
---|
161 |
|
---|
162 | # proj selon kT (black), selon kZ (red)
|
---|
163 | n/plot hpkrec2.val%sqrt(x*x+y*y) ! ! "nsta crossmarker3 logx"
|
---|
164 | */
|
---|