source: Sophya/trunk/Cosmo/SimLSS/cmvrvloscor.cc@ 3770

Last change on this file since 3770 was 3770, checked in by cmv, 15 years ago

relecture des redshift-distorsion + calcul des spectres, cmv 07/05/2010

File size: 4.2 KB
RevLine 
[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
20void usage(void);
21void usage(void)
22{
23 cout<<"cmvrvloscor rho.fits vlos.fits"<<endl;
24}
25
26int main(int narg,char *arg[])
27{
28 int nthread = 1;
29 int_8 ntfill = 100000;
30 SophyaInit();
31 InitTim();
32
33 if(narg<=2) {usage(); return -1;}
34
35 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
36 try {
37 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
38
39 cout<<"> read rho: "<<arg[1]<<endl;
40 FitsImg3DRead f3dr(arg[1],0,5);
41 cout<<"> read vlos: "<<arg[2]<<endl;
42 FitsImg3DRead f3dv(arg[2],0,5);
43 long naxis1 = f3dr.ReadKeyL("NAXIS1");
44 long naxis2 = f3dr.ReadKeyL("NAXIS2");
45 long naxis3 = f3dr.ReadKeyL("NAXIS3");
46 cout<<"Naxis: 1="<<naxis1<<" 2="<<naxis2<<" 3="<<naxis3<<endl;
47 long nx = f3dr.ReadKeyL("Nx");
48 long ny = f3dr.ReadKeyL("Ny");;
49 long nz = f3dr.ReadKeyL("Nz");;
50 cout<<"N: x="<<nx<<" y="<<ny<<" z="<<nz<<endl;
51 double dx = f3dr.ReadKey("Dx");
52 double dy = f3dr.ReadKey("Dy");
53 double dz = f3dr.ReadKey("Dz");
54 cout<<"D: x="<<dx<<" y="<<dy<<" z="<<dz<<endl;
55 double zref = f3dr.ReadKey("ZREF");
56 double href = f3dr.ReadKey("HREF");
57 cout<<"Zref="<<zref<<" Href="<<href<<endl;
58
59 POutPersist pos("cmvrvloscor.ppf");
60
61 GeneFluct3D fluct3d(nx,ny,nz,dx,dy,dz,nthread,2);
62 fluct3d.Print();
63 TArray<GEN3D_TYPE>& rgen = fluct3d.GetRealArray();
64 rgen = 0.;
65 TVector<r_8> R(nz), Rdis(nz);
66
67 const int nvar = 3;
68 const char *vname[nvar] = {"l","ll","d"};
69 NTuple nt(nvar,vname);
70 r_4 xnt[nvar];
71 int_8 ntmod = fluct3d.NPix()/ntfill; if(ntmod==0) ntmod = 1;
72
73 cout<<"> filling redshift distorted cube"<<endl;
74 int_8 nf = 0;
75 for(int i=0;i<nx;i++) {
76 if(i%(nx/10)==0) cout<<"i="<<i<<endl;
77 for(int j=0;j<ny;j++) {
78 for(int l=0;l<nz;l++) R(l) = f3dr.Read(l,j,i);
79 Rdis = 0.;
80 for(int l=0;l<nz;l++) {
81 double d = (1.+zref) / href * f3dv.Read(l,j,i);
82 int ll = int((double)l + d/dz + 0.5);
83 if(ll<0 || ll>=nz) continue;
84 Rdis(ll) += R(l);
85 if(ntfill>0 && nf%ntmod==0)
86 {xnt[0]=l; xnt[1]=ll; xnt[2]=d; nt.Fill(xnt);}
87 nf++;
88 }
89 for(int l=0;l<nz;l++) rgen(l,j,i) += Rdis(l);
90 }
91 }
92 PrtTim(">>>> End filling redshift distorted cube");
93 pos.PutObject(nt,"nt");
94
95 fluct3d.ReComputeFourier();
96 PrtTim(">>>> End ReComputing spectrum");
97
98 cout<<endl<<"\n--- Computing final 1D spectrum"<<endl;
99 double dkmin = fluct3d.GetKincMin();
100 double knyqmax = fluct3d.GetKmax();
101 long nherr = long(knyqmax/dkmin+0.5);
102 cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
103 HistoErr hpkrec(0.,knyqmax,nherr); hpkrec.Zero();
104 hpkrec.ReCenterBin(); hpkrec.Show();
105 fluct3d.ComputeSpectrum(hpkrec);
106 pos.PutObject(hpkrec,"hpkrec");
107 PrtTim(">>>> End Computing final spectrum");
108
109 cout<<"\n--- Computing final 2D spectrum"<<endl;
110 double dktmin = fluct3d.GetKTincMin();
111 double ktnyqmax = fluct3d.GetKTmax();
112 long nherrt = long(ktnyqmax/dktmin+0.5);
113 double dkzmin = fluct3d.GetKinc()[2];
114 double kznyqmax = fluct3d.GetKnyq()[2];
115 long nherrz = long(kznyqmax/dkzmin+0.5);
116 cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin
117 <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
118 Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
119 hpkrec2.ReCenterBin(); hpkrec2.Zero(); hpkrec2.Show();
120 fluct3d.ComputeSpectrum2D(hpkrec2);
121 pos.PutObject(hpkrec2,"hpkrec2");
122 PrtTim(">>>> End Computing final 2D spectrum");
123
124 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
125 } catch (PException& exc) {
126 cerr<<"cmvrvloscor.cc catched PException"<<exc.Msg()<<endl;
127 return 77;
128 } catch (std::exception& sex) {
129 cerr << "cmvrvloscor.cc std::exception :"
130 << (string)typeid(sex).name() << "\n msg= "
131 << sex.what() << endl;
132 return 78;
133 } catch (...) {
134 cerr << "cmvrvloscor.cc catched unknown (...) exception " << endl;
135 return 79;
136 }
137 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
138
139 return 0;
140}
141
142/*
143openppf cmvrvloscor.ppf
144
145n/plot hpkrec.val%x x>0 ! "nsta cpts logx"
146
147imag hpkrec2
148
149# proj selon kT (black), selon kZ (red)
150n/plot hpkrec2.val%sqrt(x*x+y*y) ! ! "nsta cpts"
151
152 */
Note: See TracBrowser for help on using the repository browser.