source: Sophya/trunk/Cosmo/SimLSS/cmvobserv3d.cc@ 3199

Last change on this file since 3199 was 3199, checked in by cmv, 18 years ago

Intro raffinement dans simul AGN, variation dNu Da Dlum selon Oz cmv 05/04/2007

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