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

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

petites mises en formes cmv 06/08/2007

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