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

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

scale du spectre final cmv 24/07/2007

File size: 20.5 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 double growth_at_z = growth(zref);
211 cout<<"...Growth factor at z="<<zref<<" = "<<growth_at_z<<endl;
212
213 PkSpectrum0 pk0(pkini,tf);
214
215 PkSpectrumZ pkz(pk0,growth,zref);
216
217 //-----------------------------------------------------------------
218 cout<<endl<<"\n--- Create mass function"<<endl;
219
220 Schechter sch(nstar,mstar,alpha);
221 sch.Print();
222
223 //-----------------------------------------------------------------
224 pkz.SetZ(0.);
225 cout<<endl<<"\n--- Compute variance for top-hat R="<<R
226 <<" at z="<<pkz.GetZ()<<endl;
227 VarianceSpectrum varpk_th(pkz,0);
228 double kfind_th = varpk_th.FindMaximum(R,kmin,kmax,eps);
229 double pkmax_th = varpk_th(kfind_th);
230 cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
231 double k1=kmin, k2=kmax;
232 int rc = varpk_th.FindLimits(R,pkmax_th/1.e4,k1,k2,eps);
233 cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "
234 <<k2<<" ("<<log10(k2)<<")"<<endl;
235
236 double ldlk = (log10(k2)-log10(k1))/npt;
237 varpk_th.SetInteg(0.01,ldlk,-1.,4);
238 double sr2 = varpk_th.Variance(R,k1,k2);
239 cout<<"varpk_th="<<sr2<<" -> sigma="<<sqrt(sr2)<<endl;
240
241 double normpkz = sigmaR*sigmaR/sr2;
242 pkz.SetScale(normpkz);
243 cout<<"Spectrum normalisation = "<<pkz.GetScale()<<endl;
244
245 pkz.SetZ(zref);
246
247 Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
248 FuncToHisto(pkz,hpkz,true);
249 {
250 tagobs = "hpkz"; posobs.PutObject(hpkz,tagobs);
251 }
252
253 //-----------------------------------------------------------------
254 cout<<endl<<"\n--- Compute variance for Pk at z="<<pkz.GetZ()<<endl;
255 VarianceSpectrum varpk_int(pkz,2);
256
257 double kfind_int = varpk_int.FindMaximum(R,kmin,kmax,eps);
258 double pkmax_int = varpk_int(kfind_int);
259 cout<<"kfind_int = "<<kfind_int<<" ("<<log10(kfind_int)<<"), integrand="<<pkmax_int<<endl;
260 double k1int=kmin, k2int=kmax;
261 int rcint = varpk_int.FindLimits(R,pkmax_int/1.e4,k1int,k2int,eps);
262 cout<<"limit_int: rc="<<rcint<<" : "<<k1int<<" ("<<log10(k1int)<<") , "
263 <<k2int<<" ("<<log10(k2int)<<")"<<endl;
264
265 double ldlkint = (log10(k2int)-log10(k1int))/npt;
266 varpk_int.SetInteg(0.01,ldlkint,-1.,4);
267 double sr2int = varpk_int.Variance(R,k1int,k2int);
268 cout<<"varpk_int="<<sr2int<<" -> sigma="<<sqrt(sr2int)<<endl;
269
270 //-----------------------------------------------------------------
271 cout<<endl<<"\n--- Compute galaxy density number"<<endl;
272
273 sch.SetOutValue(0);
274 cout<<"sch(mstar) = "<<sch(mstar)<<" /Mpc^3/Msol"<<endl;
275 double ngal_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
276 cout<<"Galaxy density number = "<<ngal_by_mpc3<<" /Mpc^3 between limits"<<endl;
277
278 sch.SetOutValue(1);
279 cout<<"mstar*sch(mstar) = "<<sch(mstar)<<" Msol/Mpc^3/Msol"<<endl;
280 double mass_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
281 cout<<"Galaxy mass density= "<<mass_by_mpc3<<" Msol/Mpc^3 between limits"<<endl;
282 cout<<"Omega_HI at z=0 is "<<mass_by_mpc3/(univ.Rhoc(0.)*GCm3toMsolMpc3_Cst)<<endl
283 <<" at z="<<zref<<" is "<<mass_by_mpc3/(univ.Rhoc(zref)*GCm3toMsolMpc3_Cst)<<endl;
284
285 PrtTim(">>>> End of definition");
286
287 //-----------------------------------------------------------------
288 // FFTW3 (p26): faster if sizes 2^a 3^b 5^c 7^d 11^e 13^f with e+f=0 ou 1
289 cout<<endl<<"\n--- Initialisation de GeneFluct3D"<<endl;
290
291 TArray< complex<r_8> > pkgen;
292 GeneFluct3D fluct3d(pkgen);
293 fluct3d.SetPrtLevel(2);
294 fluct3d.SetNThread(nthread);
295 fluct3d.SetSize(nx,ny,nz,dx,dy,dz);
296 fluct3d.SetObservator(zref,-nz/2.);
297 fluct3d.SetCosmology(univ);
298 fluct3d.SetGrowthFactor(growth);
299 fluct3d.LosComRedshift(0.001,-1);
300 TArray<r_8>& rgen = fluct3d.GetRealArray();
301 cout<<endl; fluct3d.Print();
302
303 double dkmin = fluct3d.GetKincMin();
304 double knyqmax = fluct3d.GetKmax();
305 long nherr = long(knyqmax/dkmin+0.5);
306 cout<<"For HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
307
308 double dktmin = fluct3d.GetKTincMin();
309 double ktnyqmax = fluct3d.GetKTmax();
310 long nherrt = long(ktnyqmax/dktmin+0.5);
311 double dkzmin = fluct3d.GetKinc()[2];
312 double kznyqmax = fluct3d.GetKnyq()[2];
313 long nherrz = long(kznyqmax/dkzmin+0.5);
314 cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin
315 <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
316
317 //-----------------------------------------------------------------
318 cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl;
319 // En fait on travaille sur un cube inscrit dans la sphere de rayon kmax:
320 // sphere: Vs = 4Pi/3 k^3 , cube inscrit (cote k*sqrt(2)): Vc = (k*sqrt(2))^3
321 // Vc/Vs = 0.675 -> keff = kmax * (0.675)^(1/3) = kmax * 0.877
322 double knyqmax_mod = 0.877*knyqmax;
323 ldlkint = (log10(knyqmax_mod)-log10(k1int))/npt;
324 varpk_int.SetInteg(0.01,ldlkint,-1.,4);
325 double sr2int_kmax = varpk_int.Variance(R,k1int,knyqmax_mod);
326 cout<<"varpk_int(<"<<knyqmax_mod<<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl;
327
328 PrtTim(">>>> End Initialisation de GeneFluct3D");
329
330 //-----------------------------------------------------------------
331 cout<<"\n--- Computing a realization in Fourier space"<<endl;
332 if(use_growth_factor) pkz.SetZ(0.); else pkz.SetZ(zref);
333 cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
334 if(computefourier0) fluct3d.ComputeFourier0(pkz);
335 else fluct3d.ComputeFourier(pkz);
336 PrtTim(">>>> End Computing a realization in Fourier space");
337
338 if(1) {
339 cout<<"\n--- Checking realization spectra"<<endl;
340 HistoErr hpkgen(0.,knyqmax,nherr);
341 hpkgen.ReCenterBin(); hpkgen.Zero();
342 hpkgen.Show();
343 fluct3d.ComputeSpectrum(hpkgen);
344 {
345 tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs);
346 }
347 PrtTim(">>>> End Checking realization spectra");
348 }
349
350 if(comp2dspec) {
351 cout<<"\n--- Checking realization 2D spectra"<<endl;
352 Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
353 hpkgen2.ReCenterBin(); hpkgen2.Zero();
354 hpkgen2.Show();
355 fluct3d.ComputeSpectrum2D(hpkgen2);
356 {
357 tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs);
358 }
359 PrtTim(">>>> End Checking realization 2D spectra");
360 }
361
362 if(1) {
363 cout<<"\n--- Computing convolution by pixel shape"<<endl;
364 fluct3d.FilterByPixel();
365 PrtTim(">>>> End Computing convolution by pixel shape");
366 }
367
368 if(wfits) {
369 fluct3d.WriteFits("!cmvobserv3d_k0.fits");
370 PrtTim(">>>> End WriteFits");
371 }
372 if(wppf) {
373 fluct3d.WritePPF("cmvobserv3d_k0.ppf",false);
374 PrtTim(">>>> End WritePPF");
375 }
376
377 if(1) {
378 cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
379 HistoErr hpkgenf(0.,knyqmax,nherr);
380 hpkgenf.ReCenterBin(); hpkgenf.Zero();
381 hpkgenf.Show();
382 fluct3d.ComputeSpectrum(hpkgenf);
383 {
384 tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
385 }
386 PrtTim(">>>> End Checking realization spectra");
387 }
388
389 if(comp2dspec) {
390 cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
391 Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
392 hpkgenf2.ReCenterBin(); hpkgenf2.Zero();
393 hpkgenf2.Show();
394 fluct3d.ComputeSpectrum2D(hpkgenf2);
395 {
396 tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs);
397 }
398 PrtTim(">>>> End Checking realization 2D spectra");
399 }
400
401 //-----------------------------------------------------------------
402 cout<<"\n--- Computing a realization in real space"<<endl;
403 fluct3d.ComputeReal();
404 double rmin,rmax; rgen.MinMax(rmin,rmax);
405 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
406 PrtTim(">>>> End Computing a realization in real space");
407
408 if(use_growth_factor) {
409 cout<<"\n--- Apply Growth factor"<<endl;
410 cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
411 fluct3d.ApplyGrowthFactor();
412 rgen.MinMax(rmin,rmax);
413 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
414 PrtTim(">>>> End Applying growth factor");
415 }
416
417 if(wfits) {
418 fluct3d.WriteFits("!cmvobserv3d_r0.fits");
419 PrtTim(">>>> End WriteFits");
420 }
421 if(wppf) {
422 fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
423 PrtTim(">>>> End WritePPF");
424 }
425 if(wslice) {
426 fluct3d.WriteSlicePPF("cmvobserv3d_s_r0.ppf");
427 PrtTim(">>>> End WriteSlicePPF");
428 }
429
430 int_8 nm;
431 double rm,rs2;
432 if(1) {
433 cout<<"\n--- Check mean and variance in real space"<<endl;
434 fluct3d.NumberOfBad(-1.,1e+200);
435 nm = fluct3d.MeanSigma2(rm,rs2);
436 PrtTim(">>>> End Check mean and variance in real space");
437 }
438
439 if(compvarreal) {
440 cout<<"\n--- Check variance sigmaR in real space"<<endl;
441 double varr;
442 fluct3d.VarianceFrReal(R,varr);
443 cout<<"...Computed variance = "<<varr
444 <<" , Theorical variance at (z=0) = "<<pow(sigmaR,1.)
445 <<" , at (z="<<zref<<") = "<<pow(sigmaR*growth_at_z,1.)<<endl;
446 PrtTim(">>>> End Check variance sigmaR in real space");
447 }
448
449 //-----------------------------------------------------------------
450 cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
451 fluct3d.TurnFluct2Mass();
452 nm = fluct3d.MeanSigma2(rm,rs2);
453 PrtTim(">>>> End Converting fluctuations into mass");
454
455 cout<<"\n--- Converting mass into galaxy number"<<endl;
456 rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
457 nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
458 nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
459 PrtTim(">>>> End Converting mass into galaxy number");
460
461 cout<<"\n--- Set negative and null pixels to BAD"<<endl;
462 nm = fluct3d.SetToVal(0.,1e+200,-999.);
463 PrtTim(">>>> End Set negative pixels to BAD etc...");
464
465 cout<<"\n--- Apply poisson on galaxy number"<<endl;
466 fluct3d.ApplyPoisson();
467 nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
468 nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
469 PrtTim(">>>> End Apply poisson on galaxy number");
470 if(wslice) {
471 fluct3d.WriteSlicePPF("cmvobserv3d_s_rn.ppf");
472 PrtTim(">>>> End WriteSlicePPF");
473 }
474
475 cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
476 long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
477 Histo hmdndm(lschmin,lschmax,nhmdndm);
478 sch.SetOutValue(1);
479 FuncToHisto(sch,hmdndm,true);
480 FunRan tirhmdndm(hmdndm,true);
481 {
482 tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
483 Histo hdum1(tirhmdndm);
484 tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
485 }
486 double mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
487 cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
488 nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
489 cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
490 nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
491 PrtTim(">>>> End Convert Galaxy number to HI mass");
492
493 cout<<"\n--- Set BAD pixels to Zero"<<endl;
494 nm = fluct3d.SetToVal(-998.,1e+200,0.);
495 PrtTim(">>>> End Set BAD pixels to Zero etc...");
496
497 if(wfits) {
498 fluct3d.WriteFits("!cmvobserv3d_r.fits");
499 PrtTim(">>>> End WriteFits");
500 }
501 if(wppf) {
502 fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
503 PrtTim(">>>> End WritePPF");
504 }
505 if(wslice) {
506 fluct3d.WriteSlicePPF("cmvobserv3d_s_r.ppf");
507 PrtTim(">>>> End WriteSlicePPF");
508 }
509
510 if(do_agn) {
511 cout<<"\n--- Add AGN: <log10(S Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
512 <<" , powlaw="<<powlaw_agn<<endl;
513 fluct3d.AddAGN(lfjy_agn,lsigma_agn,powlaw_agn);
514 nm = fluct3d.MeanSigma2(rm,rs2);
515 PrtTim(">>>> End Add AGN");
516 }
517
518 double scalecube = -1., offsetcube=0.;
519 if(snoise>0.) {
520 cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl;
521 fluct3d.AddNoise2Real(snoise,(isnoise_evol>0? true:false));
522 nm = fluct3d.MeanSigma2(rm,rs2);
523 if(rs2>0. && sr2int>0.) scalecube = sqrt(sr2int)/sqrt(rs2);
524 offsetcube = -rm;
525 PrtTim(">>>> End Add noise");
526 }
527
528 if(scalecube>0.) {
529 cout<<"\n--- Scale and offset scale="<<scalecube
530 <<" off="<<offsetcube<<endl;
531 fluct3d.ScaleOffset(scalecube,offsetcube);
532 }
533
534 if(wfits) {
535 fluct3d.WriteFits("!cmvobserv3d_rf.fits");
536 PrtTim(">>>> End WriteFits");
537 }
538 if(wppf) {
539 fluct3d.WritePPF("cmvobserv3d_rf.ppf",true);
540 PrtTim(">>>> End WritePPF");
541 }
542 if(wslice) {
543 fluct3d.WriteSlicePPF("cmvobserv3d_s_rf.ppf");
544 PrtTim(">>>> End WriteSlicePPF");
545 }
546
547 //-----------------------------------------------------------------
548 // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
549
550 if(1) {
551 cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
552 fluct3d.ReComputeFourier();
553 PrtTim(">>>> End ReComputing spectrum");
554 }
555
556 if(wfits) {
557 fluct3d.WriteFits("!cmvobserv3d_k.fits");
558 PrtTim(">>>> End WriteFits");
559 }
560 if(wppf) {
561 fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
562 PrtTim(">>>> End WritePPF");
563 }
564
565 if(1) {
566 cout<<endl<<"\n--- Computing final spectrum"<<endl;
567 HistoErr hpkrec(0.,knyqmax,nherr);
568 hpkrec.ReCenterBin();
569 hpkrec.Show();
570 fluct3d.ComputeSpectrum(hpkrec);
571 tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
572 PrtTim(">>>> End Computing final spectrum");
573 }
574
575 if(comp2dspec) {
576 cout<<"\n--- Computing final 2D spectrum"<<endl;
577 Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
578 hpkrec2.ReCenterBin(); hpkrec2.Zero();
579 hpkrec2.Show();
580 fluct3d.ComputeSpectrum2D(hpkrec2);
581 {
582 tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
583 }
584 PrtTim(">>>> End Computing final 2D spectrum");
585 }
586
587 PrtTim(">>>> End Of Job");
588 return 0;
589}
590
591/*
592######################################################
593readfits cmvobserv3d_k0.fits
594readfits cmvobserv3d_k.fits
595readfits cmvobserv3d_r0.fits
596readfits cmvobserv3d_r.fits
597readfits cmvobserv3d_rf.fits
598
599openppf cmvobserv3d_k0.ppf
600openppf cmvobserv3d_k.ppf
601openppf cmvobserv3d_r0.ppf
602openppf cmvobserv3d_r.ppf
603openppf cmvobserv3d_rf.ppf
604
605# pour le plot 2D d'une slice en Z du 3D: xy2d nom_obj3D num_slice
606defscript xy2d
607 objaoper $1 sliceyz $2
608 mv sliceyz_${2} ${1}_Z_$2
609 disp ${1}_Z_$2
610 echo display slice $2 of $1 name is ${1}_Z_$2
611endscript
612
613# pour le plot 2D d'une slice en Y du 3D: xz2d nom_obj3D num_slice
614defscript xz2d
615 objaoper $1 slicexy $2
616 mv slicexy_${2} ${1}_Y_$2
617 disp ${1}_Y_$2
618 echo display slice $2 of $1 name is ${1}_Y_$2
619endscript
620
621# pour le plot 2D d'une slice en X du 3D: yz2d nom_obj3D num_slice
622defscript yz2d
623 objaoper $1 slicexz $2
624 mv slicexz_${2} ${1}_X_$2
625 disp ${1}_X_$2
626 echo display slice $2 of $1 name is ${1}_X_$2
627endscript
628
629xy2d $cobj 0
630xz2d $cobj 0
631yz2d $cobj 0
632
633######################################################
634openppf cmvobserv3d_s_r0.ppf
635openppf cmvobserv3d_s_rn.ppf
636openppf cmvobserv3d_s_r.ppf
637openppf cmvobserv3d_s_rf.ppf
638
639######################################################
640openppf cmvobserv3d.ppf
641
642zone
643set k pow(10.,x)
644n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints"
645
646echo ${hpkgen.sum}
647echo ${hpkgenf.sum}
648echo ${hpkrec.sum}
649
650zone
651n/plot hpkz.val%x ! ! "nsta connectpoints"
652n/plot hpkgen.val%log10(x) x>0 ! "nsta same red connectpoints"
653n/plot hpkgenf.val%log10(x) x>0 ! "nsta same orange connectpoints"
654n/plot hpkrec.val%log10(x) x>0 ! "nsta same blue connectpoints"
655
656disp hpkgen "hbincont err"
657disp hpkgenf "hbincont err"
658disp hpkrec "hbincont err"
659
660zone 2 2
661imag hpkgen2
662imag hpkgenf2
663imag hpkrec2
664
665zone 2 1
666disp hmdndm "nsta"
667disp tirhmdndm "nsta"
668addline 0 1 20 1 "red"
669
670 */
Note: See TracBrowser for help on using the repository browser.