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