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

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

ecriture fichiers de tranches du cube cmv 10/07/2007

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