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 | #include "timing.h"
|
---|
10 | #include "ntuple.h"
|
---|
11 | #include "matharr.h"
|
---|
12 |
|
---|
13 | #include "constcosmo.h"
|
---|
14 | #include "cosmocalc.h"
|
---|
15 | #include "schechter.h"
|
---|
16 | #include "geneutils.h"
|
---|
17 | #include "integfunc.h"
|
---|
18 | #include "genefluct3d.h"
|
---|
19 |
|
---|
20 | void usage(void);
|
---|
21 | void usage(void)
|
---|
22 | {
|
---|
23 | cout<<"cmvobserv3d [-a] [-0]"<<endl
|
---|
24 | <<" -a : init auto de l aleatoire"<<endl
|
---|
25 | <<" -0 : use methode ComputeFourier0"<<endl
|
---|
26 | <<" -G : compute Pk(z=0) and apply growth factor in real space"<<endl
|
---|
27 | <<" -x nx,dx : taille en x (npix,Mpc)"<<endl
|
---|
28 | <<" -y ny,dy : taille en y (npix,Mpc)"<<endl
|
---|
29 | <<" -z nz,dz : taille en z (npix,Mpc)"<<endl
|
---|
30 | <<" -Z zref : redshift median"<<endl
|
---|
31 | <<" -s snoise : sigma du bruit en Msol"<<endl
|
---|
32 | <<" -2 : compute 2D spectrum"<<endl
|
---|
33 | <<" -F : write cube in FITS format"<<endl
|
---|
34 | <<" -P : write cube in PPF format"<<endl
|
---|
35 | <<" -V : compute variance from real space"<<endl
|
---|
36 | <<endl;
|
---|
37 | }
|
---|
38 |
|
---|
39 | int main(int narg,char *arg[])
|
---|
40 | {
|
---|
41 | InitTim();
|
---|
42 |
|
---|
43 | //-----------------------------------------------------------------
|
---|
44 | // *** Survey definition
|
---|
45 | long nx=360, ny=-1, nz=64; double dx=1., dy=-1., dz=-1.;
|
---|
46 | //long nx=1000, ny=-1, nz=128; double dx=3., dy=-1., dz=6.;
|
---|
47 | //long nx=1200, ny=-1, nz=128; double dx=1., dy=-1., dz=3;
|
---|
48 |
|
---|
49 | // *** Cosmography definition (WMAP)
|
---|
50 | unsigned short flat = 0;
|
---|
51 | double ob0 = 0.0444356;
|
---|
52 | double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
|
---|
53 | double zref = 0.5;
|
---|
54 | double perc=0.01,dzinc=-1.,dzmax=5.; unsigned short glorder=4;
|
---|
55 |
|
---|
56 | // *** Spectrum and variance definition
|
---|
57 | double ns = 1., as = 1.;
|
---|
58 | double R=8./h100, Rg=R/sqrt(5.);
|
---|
59 | double sigmaR = 1.;
|
---|
60 |
|
---|
61 | double kmin=1e-5,kmax=1000.;
|
---|
62 | int npt = 10000;
|
---|
63 | double lkmin=log10(kmin), lkmax=log10(kmax);
|
---|
64 | double eps=1.e-3;
|
---|
65 |
|
---|
66 | // *** Schechter mass function definition
|
---|
67 | double h75 = 0.71 / 0.75;
|
---|
68 | double nstar = 0.006*pow(h75,3.);
|
---|
69 | double mstar = pow(10.,9.8/(h75*h75)); // MSol
|
---|
70 | double alpha = -1.37;
|
---|
71 |
|
---|
72 | double schmin=1e8, schmax=1e12;
|
---|
73 | int schnpt = 1000;
|
---|
74 | double lschmin=log10(schmin), lschmax=log10(schmax), dlsch=(lschmax-lschmin)/schnpt;
|
---|
75 |
|
---|
76 | // *** Niveau de bruit
|
---|
77 | double snoise= 0.; // en equivalent MSol
|
---|
78 |
|
---|
79 | // *** type de generation
|
---|
80 | bool computefourier0=false;
|
---|
81 | bool use_growth_factor = false;
|
---|
82 | unsigned short nthread=4;
|
---|
83 |
|
---|
84 | // *** What to do
|
---|
85 | bool comp2dspec = false;
|
---|
86 | bool wfits = false;
|
---|
87 | bool wppf = false;
|
---|
88 | bool compvarreal = false;
|
---|
89 |
|
---|
90 | // --- Decodage arguments
|
---|
91 |
|
---|
92 | char c;
|
---|
93 | while((c = getopt(narg,arg,"ha0PWV2Gx:y:z:s:Z:")) != -1) {
|
---|
94 | switch (c) {
|
---|
95 | case 'a' :
|
---|
96 | Auto_Ini_Ranf(5);
|
---|
97 | break;
|
---|
98 | case '0' :
|
---|
99 | computefourier0 = true;
|
---|
100 | break;
|
---|
101 | case 'G' :
|
---|
102 | use_growth_factor = true;
|
---|
103 | break;
|
---|
104 | case 'x' :
|
---|
105 | sscanf(optarg,"%ld,%lf",&nx,&dx);
|
---|
106 | break;
|
---|
107 | case 'y' :
|
---|
108 | sscanf(optarg,"%ld,%lf",&ny,&dy);
|
---|
109 | break;
|
---|
110 | case 'z' :
|
---|
111 | sscanf(optarg,"%ld,%lf",&nz,&dz);
|
---|
112 | break;
|
---|
113 | case 's' :
|
---|
114 | sscanf(optarg,"%lf",&snoise);
|
---|
115 | break;
|
---|
116 | case 'Z' :
|
---|
117 | sscanf(optarg,"%lf",&zref);
|
---|
118 | break;
|
---|
119 | case '2' :
|
---|
120 | comp2dspec = true;
|
---|
121 | break;
|
---|
122 | case 'V' :
|
---|
123 | compvarreal = true;
|
---|
124 | break;
|
---|
125 | case 'W' :
|
---|
126 | wfits = true;
|
---|
127 | break;
|
---|
128 | case 'P' :
|
---|
129 | wppf = true;
|
---|
130 | break;
|
---|
131 | case 'h' :
|
---|
132 | default :
|
---|
133 | usage(); return -1;
|
---|
134 | }
|
---|
135 | }
|
---|
136 |
|
---|
137 | string tagobs = "cmvobserv3d.ppf";
|
---|
138 | POutPersist posobs(tagobs);
|
---|
139 |
|
---|
140 | cout<<"zref="<<zref<<endl;
|
---|
141 | cout<<"nx="<<nx<<" dx="<<dx<<" ny="<<ny<<" dy="<<dy<<" nz="<<nz<<" dz="<<dz<<endl;
|
---|
142 | cout<<"kmin="<<kmin<<" ("<<lkmin<<"), kmax="<<kmax<<" ("<<lkmax<<") Mpc^-1"
|
---|
143 | <<", npt="<<npt<<endl;
|
---|
144 | cout<<"R="<<R<<" Rg="<<Rg<<" Mpc, sigmaR="<<sigmaR<<endl;
|
---|
145 | cout<<"nstar= "<<nstar<<" mstar="<<mstar<<" alpa="<<alpha<<endl;
|
---|
146 | cout<<"schmin="<<schmin<<" ("<<lschmin
|
---|
147 | <<"), schmax="<<schmax<<" ("<<lschmax<<") Msol"
|
---|
148 | <<", schnpt="<<schnpt<<endl;
|
---|
149 | cout<<"snoise="<<snoise<<" equivalent Msol"<<endl;
|
---|
150 |
|
---|
151 | //-----------------------------------------------------------------
|
---|
152 | cout<<endl<<"\n--- Create Cosmology"<<endl;
|
---|
153 |
|
---|
154 | CosmoCalc univ(flat,true,zref+1.);
|
---|
155 | univ.SetInteg(perc,dzinc,dzmax,glorder);
|
---|
156 | univ.SetDynParam(h100,om0,or0,ol0,w0);
|
---|
157 | univ.Print();
|
---|
158 | double loscomref = univ.Dloscom(zref);
|
---|
159 | cout<<"zref = "<<zref<<" -> dloscom = "<<loscomref<<" Mpc"<<endl;
|
---|
160 |
|
---|
161 | //-----------------------------------------------------------------
|
---|
162 | cout<<endl<<"\n--- Create Spectrum and mass function"<<endl;
|
---|
163 |
|
---|
164 | InitialSpectrum pkini(ns,as);
|
---|
165 |
|
---|
166 | TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false);
|
---|
167 | //tf.SetNoOscEnv(2);
|
---|
168 |
|
---|
169 | GrowthFactor growth(om0,ol0);
|
---|
170 |
|
---|
171 | PkSpectrum0 pk0(pkini,tf);
|
---|
172 |
|
---|
173 | PkSpectrumZ pkz(pk0,growth,zref);
|
---|
174 |
|
---|
175 | Schechter sch(nstar,mstar,alpha);
|
---|
176 |
|
---|
177 | //-----------------------------------------------------------------
|
---|
178 | pkz.SetZ(0.);
|
---|
179 | cout<<endl<<"\n--- Compute variance for top-hat R="<<R
|
---|
180 | <<" at z="<<pkz.GetZ()<<endl;
|
---|
181 | VarianceSpectrum varpk_th(pkz,0);
|
---|
182 | double kfind_th = varpk_th.FindMaximum(R,kmin,kmax,eps);
|
---|
183 | double pkmax_th = varpk_th(kfind_th);
|
---|
184 | cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
|
---|
185 | double k1=kmin, k2=kmax;
|
---|
186 | int rc = varpk_th.FindLimits(R,pkmax_th/1.e4,k1,k2,eps);
|
---|
187 | cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "
|
---|
188 | <<k2<<" ("<<log10(k2)<<")"<<endl;
|
---|
189 |
|
---|
190 | double ldlk = (log10(k2)-log10(k1))/npt;
|
---|
191 | varpk_th.SetInteg(0.01,ldlk,-1.,4);
|
---|
192 | double sr2 = varpk_th.Variance(R,k1,k2);
|
---|
193 | cout<<"varpk_th="<<sr2<<" -> sigma="<<sqrt(sr2)<<endl;
|
---|
194 |
|
---|
195 | double normpkz = sigmaR*sigmaR/sr2;
|
---|
196 | pkz.SetScale(normpkz);
|
---|
197 | cout<<"Spectrum normalisation = "<<pkz.GetScale()<<endl;
|
---|
198 |
|
---|
199 | pkz.SetZ(zref);
|
---|
200 |
|
---|
201 | Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
|
---|
202 | FuncToHisto(pkz,hpkz,true);
|
---|
203 | {
|
---|
204 | tagobs = "hpkz"; posobs.PutObject(hpkz,tagobs);
|
---|
205 | }
|
---|
206 |
|
---|
207 | //-----------------------------------------------------------------
|
---|
208 | cout<<endl<<"\n--- Compute variance for Pk at z="<<pkz.GetZ()<<endl;
|
---|
209 | VarianceSpectrum varpk_int(pkz,2);
|
---|
210 |
|
---|
211 | double kfind_int = varpk_int.FindMaximum(R,kmin,kmax,eps);
|
---|
212 | double pkmax_int = varpk_int(kfind_int);
|
---|
213 | cout<<"kfind_int = "<<kfind_int<<" ("<<log10(kfind_int)<<"), integrand="<<pkmax_int<<endl;
|
---|
214 | double k1int=kmin, k2int=kmax;
|
---|
215 | int rcint = varpk_int.FindLimits(R,pkmax_int/1.e4,k1int,k2int,eps);
|
---|
216 | cout<<"limit_int: rc="<<rcint<<" : "<<k1int<<" ("<<log10(k1int)<<") , "
|
---|
217 | <<k2int<<" ("<<log10(k2int)<<")"<<endl;
|
---|
218 |
|
---|
219 | double ldlkint = (log10(k2int)-log10(k1int))/npt;
|
---|
220 | varpk_int.SetInteg(0.01,ldlkint,-1.,4);
|
---|
221 | double sr2int = varpk_int.Variance(R,k1int,k2int);
|
---|
222 | cout<<"varpk_int="<<sr2int<<" -> sigma="<<sqrt(sr2int)<<endl;
|
---|
223 |
|
---|
224 | //-----------------------------------------------------------------
|
---|
225 | cout<<endl<<"\n--- Compute galaxy density number"<<endl;
|
---|
226 |
|
---|
227 | sch.SetOutValue(0);
|
---|
228 | cout<<"sch(mstar) = "<<sch(mstar)<<" /Mpc^3/Msol"<<endl;
|
---|
229 | double ngal_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
|
---|
230 | cout<<"Galaxy density number = "<<ngal_by_mpc3<<" /Mpc^3 between limits"<<endl;
|
---|
231 |
|
---|
232 | sch.SetOutValue(1);
|
---|
233 | cout<<"mstar*sch(mstar) = "<<sch(mstar)<<" Msol/Mpc^3/Msol"<<endl;
|
---|
234 | double mass_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
|
---|
235 | cout<<"Galaxy mass density= "<<mass_by_mpc3<<" Msol/Mpc^3 between limits"<<endl;
|
---|
236 |
|
---|
237 | PrtTim(">>>> End of definition");
|
---|
238 |
|
---|
239 | //-----------------------------------------------------------------
|
---|
240 | // FFTW3 (p26): faster if sizes 2^a 3^b 5^c 7^d 11^e 13^f with e+f=0 ou 1
|
---|
241 | cout<<endl<<"\n--- Initialisation de GeneFluct3D"<<endl;
|
---|
242 |
|
---|
243 | TArray< complex<r_8> > pkgen;
|
---|
244 | GeneFluct3D fluct3d(pkgen);
|
---|
245 | fluct3d.SetPrtLevel(2);
|
---|
246 | fluct3d.SetNThread(nthread);
|
---|
247 | fluct3d.SetSize(nx,ny,nz,dx,dy,dz);
|
---|
248 | fluct3d.SetObservator(zref,nz/2.);
|
---|
249 | fluct3d.SetCosmology(univ);
|
---|
250 | fluct3d.SetGrowthFactor(growth);
|
---|
251 | fluct3d.LosComRedshift(0.001);
|
---|
252 | TArray<r_8>& rgen = fluct3d.GetRealArray();
|
---|
253 | cout<<endl; fluct3d.Print();
|
---|
254 |
|
---|
255 | double dkmin = fluct3d.GetKincMin();
|
---|
256 | double knyqmax = fluct3d.GetKmax();
|
---|
257 | long nherr = long(knyqmax/dkmin+0.5);
|
---|
258 | cout<<"For HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
|
---|
259 |
|
---|
260 | double dktmin = fluct3d.GetKTincMin();
|
---|
261 | double ktnyqmax = fluct3d.GetKTmax();
|
---|
262 | long nherrt = long(ktnyqmax/dktmin+0.5);
|
---|
263 | double dkzmin = fluct3d.GetKinc()[2];
|
---|
264 | double kznyqmax = fluct3d.GetKnyq()[2];
|
---|
265 | long nherrz = long(kznyqmax/dkzmin+0.5);
|
---|
266 | cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin
|
---|
267 | <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
|
---|
268 |
|
---|
269 | //-----------------------------------------------------------------
|
---|
270 | cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl;
|
---|
271 | // En fait on travaille sur un cube inscrit dans la sphere de rayon kmax:
|
---|
272 | // sphere: Vs = 4Pi/3 k^3 , cube inscrit (cote k*sqrt(2)): Vc = (k*sqrt(2))^3
|
---|
273 | // Vc/Vs = 0.675 -> keff = kmax * (0.675)^(1/3) = kmax * 0.877
|
---|
274 | double knyqmax_mod = 0.877*knyqmax;
|
---|
275 | ldlkint = (log10(knyqmax_mod)-log10(k1int))/npt;
|
---|
276 | varpk_int.SetInteg(0.01,ldlkint,-1.,4);
|
---|
277 | double sr2int_kmax = varpk_int.Variance(R,k1int,knyqmax_mod);
|
---|
278 | cout<<"varpk_int(<"<<knyqmax_mod<<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl;
|
---|
279 |
|
---|
280 | PrtTim(">>>> End Initialisation de GeneFluct3D");
|
---|
281 |
|
---|
282 | //-----------------------------------------------------------------
|
---|
283 | cout<<"\n--- Computing a realization in Fourier space"<<endl;
|
---|
284 | if(use_growth_factor) pkz.SetZ(0.); else pkz.SetZ(zref);
|
---|
285 | cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
|
---|
286 | if(computefourier0) fluct3d.ComputeFourier0(pkz);
|
---|
287 | else fluct3d.ComputeFourier(pkz);
|
---|
288 | PrtTim(">>>> End Computing a realization in Fourier space");
|
---|
289 |
|
---|
290 | if(1) {
|
---|
291 | cout<<"\n--- Checking realization spectra"<<endl;
|
---|
292 | HistoErr hpkgen(0.,knyqmax,nherr);
|
---|
293 | hpkgen.ReCenterBin(); hpkgen.Zero();
|
---|
294 | hpkgen.Show();
|
---|
295 | fluct3d.ComputeSpectrum(hpkgen);
|
---|
296 | {
|
---|
297 | tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs);
|
---|
298 | }
|
---|
299 | PrtTim(">>>> End Checking realization spectra");
|
---|
300 | }
|
---|
301 |
|
---|
302 | if(comp2dspec) {
|
---|
303 | cout<<"\n--- Checking realization 2D spectra"<<endl;
|
---|
304 | Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
305 | hpkgen2.ReCenterBin(); hpkgen2.Zero();
|
---|
306 | hpkgen2.Show();
|
---|
307 | fluct3d.ComputeSpectrum2D(hpkgen2);
|
---|
308 | {
|
---|
309 | tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs);
|
---|
310 | }
|
---|
311 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
312 | }
|
---|
313 |
|
---|
314 | if(1) {
|
---|
315 | cout<<"\n--- Computing convolution by pixel shape"<<endl;
|
---|
316 | fluct3d.FilterByPixel();
|
---|
317 | PrtTim(">>>> End Computing convolution by pixel shape");
|
---|
318 | }
|
---|
319 |
|
---|
320 | if(wfits) {
|
---|
321 | fluct3d.WriteFits("!cmvobserv3d_k0.fits");
|
---|
322 | PrtTim(">>>> End WriteFits");
|
---|
323 | }
|
---|
324 | if(wppf) {
|
---|
325 | fluct3d.WritePPF("cmvobserv3d_k0.ppf",false);
|
---|
326 | PrtTim(">>>> End WritePPF");
|
---|
327 | }
|
---|
328 |
|
---|
329 | if(1) {
|
---|
330 | cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
|
---|
331 | HistoErr hpkgenf(0.,knyqmax,nherr);
|
---|
332 | hpkgenf.ReCenterBin(); hpkgenf.Zero();
|
---|
333 | hpkgenf.Show();
|
---|
334 | fluct3d.ComputeSpectrum(hpkgenf);
|
---|
335 | {
|
---|
336 | tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
|
---|
337 | }
|
---|
338 | PrtTim(">>>> End Checking realization spectra");
|
---|
339 | }
|
---|
340 |
|
---|
341 | if(comp2dspec) {
|
---|
342 | cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
|
---|
343 | Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
344 | hpkgenf2.ReCenterBin(); hpkgenf2.Zero();
|
---|
345 | hpkgenf2.Show();
|
---|
346 | fluct3d.ComputeSpectrum2D(hpkgenf2);
|
---|
347 | {
|
---|
348 | tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs);
|
---|
349 | }
|
---|
350 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
351 | }
|
---|
352 |
|
---|
353 | //-----------------------------------------------------------------
|
---|
354 | cout<<"\n--- Computing a realization in real space"<<endl;
|
---|
355 | fluct3d.ComputeReal();
|
---|
356 | double rmin,rmax; rgen.MinMax(rmin,rmax);
|
---|
357 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
358 | PrtTim(">>>> End Computing a realization in real space");
|
---|
359 |
|
---|
360 | if(use_growth_factor) {
|
---|
361 | cout<<"\n--- Apply Growth factor"<<endl;
|
---|
362 | cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
|
---|
363 | fluct3d.ApplyGrowthFactor(-1);
|
---|
364 | rmin,rmax; rgen.MinMax(rmin,rmax);
|
---|
365 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
366 | PrtTim(">>>> End Applying growth factor");
|
---|
367 | }
|
---|
368 |
|
---|
369 | if(wfits) {
|
---|
370 | fluct3d.WriteFits("!cmvobserv3d_r0.fits");
|
---|
371 | PrtTim(">>>> End WriteFits");
|
---|
372 | }
|
---|
373 | if(wppf) {
|
---|
374 | fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
|
---|
375 | PrtTim(">>>> End WritePPF");
|
---|
376 | }
|
---|
377 |
|
---|
378 | int_8 nm;
|
---|
379 | double rm,rs2;
|
---|
380 | if(1) {
|
---|
381 | cout<<"\n--- Check mean and variance in real space"<<endl;
|
---|
382 | int_8 nlowone = fluct3d.NumberOfBad(-1.,1e+200);
|
---|
383 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
384 | cout<<"rgen:("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
385 | <<rs2<<" -> "<<sqrt(rs2)<<", n(<-1)="<<nlowone<<endl;
|
---|
386 | PrtTim(">>>> End Check mean and variance in real space");
|
---|
387 | }
|
---|
388 |
|
---|
389 | if(compvarreal) {
|
---|
390 | cout<<"\n--- Check variance sigmaR in real space"<<endl;
|
---|
391 | double varr;
|
---|
392 | int_8 nvarr = fluct3d.VarianceFrReal(R,varr);
|
---|
393 | cout<<"R="<<R<<" : sigmaR^2="<<varr<<" -> "<<sqrt(varr)<<", n="<<nvarr<<endl;
|
---|
394 | PrtTim(">>>> End Check variance sigmaR in real space");
|
---|
395 | }
|
---|
396 |
|
---|
397 | //-----------------------------------------------------------------
|
---|
398 | cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
|
---|
399 | fluct3d.TurnFluct2Mass();
|
---|
400 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
401 | cout<<"1+rgen: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
402 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
403 | PrtTim(">>>> End Converting fluctuations into mass");
|
---|
404 |
|
---|
405 | cout<<"\n--- Converting mass into galaxy number"<<endl;
|
---|
406 | rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
|
---|
407 | cout<<rm<<" galaxies put into survey"<<endl;
|
---|
408 | nm = fluct3d.MeanSigma2(rm,rs2,0.);
|
---|
409 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
410 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
411 | PrtTim(">>>> End Converting mass into galaxy number");
|
---|
412 |
|
---|
413 | cout<<"\n--- Set negative pixels to BAD"<<endl;
|
---|
414 | nm = fluct3d.SetToVal(0.,1e+200,-999.);
|
---|
415 | cout<<nm<<" negative in survey set to BAD"<<endl;
|
---|
416 | nm = fluct3d.MeanSigma2(rm,rs2,-998.);
|
---|
417 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
418 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
419 | PrtTim(">>>> End Set negative pixels to BAD etc...");
|
---|
420 |
|
---|
421 | cout<<"\n--- Apply poisson on galaxy number"<<endl;
|
---|
422 | nm = fluct3d.ApplyPoisson();
|
---|
423 | cout<<nm<<" galaxies into survey after poisson"<<endl;
|
---|
424 | nm = fluct3d.MeanSigma2(rm,rs2,-998.);
|
---|
425 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
426 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
427 | PrtTim(">>>> End Apply poisson on galaxy number");
|
---|
428 |
|
---|
429 | cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
|
---|
430 | long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
|
---|
431 | Histo hmdndm(lschmin,lschmax,nhmdndm);
|
---|
432 | sch.SetOutValue(1);
|
---|
433 | FuncToHisto(sch,hmdndm,true);
|
---|
434 | FunRan tirhmdndm(hmdndm,true);
|
---|
435 | {
|
---|
436 | tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
|
---|
437 | Histo hdum1(tirhmdndm);
|
---|
438 | tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
|
---|
439 | }
|
---|
440 | double mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
|
---|
441 | cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
|
---|
442 | nm = fluct3d.MeanSigma2(rm,rs2,0.);
|
---|
443 | cout<<"HI mass: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
444 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
445 | cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
|
---|
446 | PrtTim(">>>> End Convert Galaxy number to HI mass");
|
---|
447 |
|
---|
448 | cout<<"\n--- Set BAD pixels to Zero"<<endl;
|
---|
449 | nm = fluct3d.SetToVal(-998.,1e+200,0.);
|
---|
450 | cout<<nm<<" BAD in survey set to zero"<<endl;
|
---|
451 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
452 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
453 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
454 | PrtTim(">>>> End Set BAD pixels to Zero etc...");
|
---|
455 |
|
---|
456 | if(wfits) {
|
---|
457 | fluct3d.WriteFits("!cmvobserv3d_r.fits");
|
---|
458 | PrtTim(">>>> End WriteFits");
|
---|
459 | }
|
---|
460 | if(wppf) {
|
---|
461 | fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
|
---|
462 | PrtTim(">>>> End WritePPF");
|
---|
463 | }
|
---|
464 |
|
---|
465 | cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<endl;
|
---|
466 | fluct3d.AddNoise2Real(snoise);
|
---|
467 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
468 | cout<<"HI mass with noise: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
469 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
470 | PrtTim(">>>> End Add noise");
|
---|
471 |
|
---|
472 | //-----------------------------------------------------------------
|
---|
473 | // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
|
---|
474 |
|
---|
475 | if(1) {
|
---|
476 | cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
|
---|
477 | fluct3d.ReComputeFourier();
|
---|
478 | PrtTim(">>>> End ReComputing spectrum");
|
---|
479 | }
|
---|
480 |
|
---|
481 | if(wfits) {
|
---|
482 | fluct3d.WriteFits("!cmvobserv3d_k.fits");
|
---|
483 | PrtTim(">>>> End WriteFits");
|
---|
484 | }
|
---|
485 | if(wppf) {
|
---|
486 | fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
|
---|
487 | PrtTim(">>>> End WritePPF");
|
---|
488 | }
|
---|
489 |
|
---|
490 | if(1) {
|
---|
491 | cout<<endl<<"\n--- Computing final spectrum"<<endl;
|
---|
492 | HistoErr hpkrec(0.,knyqmax,nherr);
|
---|
493 | hpkrec.ReCenterBin();
|
---|
494 | hpkrec.Show();
|
---|
495 | fluct3d.ComputeSpectrum(hpkrec);
|
---|
496 | tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
|
---|
497 | PrtTim(">>>> End Computing final spectrum");
|
---|
498 | }
|
---|
499 |
|
---|
500 | if(comp2dspec) {
|
---|
501 | cout<<"\n--- Computing final 2D spectrum"<<endl;
|
---|
502 | Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
503 | hpkrec2.ReCenterBin(); hpkrec2.Zero();
|
---|
504 | hpkrec2.Show();
|
---|
505 | fluct3d.ComputeSpectrum2D(hpkrec2);
|
---|
506 | {
|
---|
507 | tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
|
---|
508 | }
|
---|
509 | PrtTim(">>>> End Computing final 2D spectrum");
|
---|
510 | }
|
---|
511 |
|
---|
512 | PrtTim(">>>> End Of Job");
|
---|
513 | return 0;
|
---|
514 | }
|
---|
515 |
|
---|
516 | /*
|
---|
517 | ######################################################
|
---|
518 | readfits cmvobserv3d_k0.fits
|
---|
519 | readfits cmvobserv3d_k.fits
|
---|
520 | readfits cmvobserv3d_r0.fits
|
---|
521 | readfits cmvobserv3d_r.fits
|
---|
522 |
|
---|
523 | openppf cmvobserv3d_k0.ppf
|
---|
524 | openppf cmvobserv3d_k.ppf
|
---|
525 | openppf cmvobserv3d_r0.ppf
|
---|
526 | openppf cmvobserv3d_r.ppf
|
---|
527 |
|
---|
528 | # pour le plot 2D d'une slice en Z du 3D: to2d nom_obj3D num_slice
|
---|
529 | defscript to2d
|
---|
530 | objaoper $1 sliceyz $2
|
---|
531 | mv sliceyz_${2} ${1}_$2
|
---|
532 | disp ${1}_$2
|
---|
533 | echo display slice $2 of $1
|
---|
534 | endscript
|
---|
535 |
|
---|
536 | to2d $cobj 0
|
---|
537 |
|
---|
538 | ######################################################
|
---|
539 | openppf cmvobserv3d.ppf
|
---|
540 |
|
---|
541 | zone
|
---|
542 | set k pow(10.,x)
|
---|
543 | n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints"
|
---|
544 |
|
---|
545 | zone
|
---|
546 | n/plot hpkz.val%x ! ! "nsta connectpoints"
|
---|
547 | n/plot hpkgen.val%log10(x) x>0 ! "nsta same red connectpoints"
|
---|
548 | n/plot hpkgenf.val%log10(x) x>0 ! "nsta same orange connectpoints"
|
---|
549 | n/plot hpkrec.val%log10(x) x>0 ! "nsta same blue connectpoints"
|
---|
550 |
|
---|
551 | disp hpkgen "hbincont err"
|
---|
552 | disp hpkgenf "hbincont err"
|
---|
553 | disp hpkrec "hbincont err"
|
---|
554 |
|
---|
555 | zone 2 2
|
---|
556 | imag hpkgen2
|
---|
557 | imag hpkgenf2
|
---|
558 | imag hpkrec2
|
---|
559 |
|
---|
560 | zone 2 1
|
---|
561 | disp hmdndm "nsta"
|
---|
562 | disp tirhmdndm "nsta"
|
---|
563 | addline 0 1 20 1 "red"
|
---|
564 |
|
---|
565 | */
|
---|