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

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

update logique Init_Spline de CosmoCalc cmv 29/07/07

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