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 | <<" -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 |
|
---|
48 | int 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 | /*
|
---|
346 | // CMVTEST
|
---|
347 | for(int l=0;l<pkgen.SizeX();l++)
|
---|
348 | for(int j=0;j<pkgen.SizeY();j++)
|
---|
349 | for(int i=0;i<pkgen.SizeZ();i++) {
|
---|
350 | double k2 = fluct3d.Kx(i)*fluct3d.Kx(i)
|
---|
351 | +fluct3d.Ky(j)*fluct3d.Ky(j)
|
---|
352 | +fluct3d.Kz(l)*fluct3d.Kz(l);
|
---|
353 | double pk = (k2>0.)? 1./k2: 0.;
|
---|
354 | //pkgen(l,j,i) = ComplexGaussRan(sqrt(pk/2.));
|
---|
355 | //pkgen(l,j,i) = sqrt(pk/2.);
|
---|
356 | pkgen(l,j,i) = 1.;
|
---|
357 | }
|
---|
358 | // CMVTEST
|
---|
359 | */
|
---|
360 |
|
---|
361 | cout<<"\n--- Checking realization spectra"<<endl;
|
---|
362 | HistoErr hpkgen(0.,knyqmax,nherr);
|
---|
363 | hpkgen.ReCenterBin(); hpkgen.Zero();
|
---|
364 | hpkgen.Show();
|
---|
365 | fluct3d.ComputeSpectrum(hpkgen);
|
---|
366 | {
|
---|
367 | tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs);
|
---|
368 | }
|
---|
369 | PrtTim(">>>> End Checking realization spectra");
|
---|
370 |
|
---|
371 | if(comp2dspec) {
|
---|
372 | cout<<"\n--- Checking realization 2D spectra"<<endl;
|
---|
373 | Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
374 | hpkgen2.ReCenterBin(); hpkgen2.Zero();
|
---|
375 | hpkgen2.Show();
|
---|
376 | fluct3d.ComputeSpectrum2D(hpkgen2);
|
---|
377 | {
|
---|
378 | tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs);
|
---|
379 | }
|
---|
380 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
381 | }
|
---|
382 |
|
---|
383 | if(filter_by_pixel!=0) {
|
---|
384 | cout<<"\n--- Computing convolution by pixel shape"<<endl;
|
---|
385 | fluct3d.FilterByPixel();
|
---|
386 | PrtTim(">>>> End Computing convolution by pixel shape");
|
---|
387 |
|
---|
388 | cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
|
---|
389 | HistoErr hpkgenf(0.,knyqmax,nherr);
|
---|
390 | hpkgenf.ReCenterBin(); hpkgenf.Zero();
|
---|
391 | hpkgenf.Show();
|
---|
392 | fluct3d.ComputeSpectrum(hpkgenf);
|
---|
393 | {
|
---|
394 | tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
|
---|
395 | }
|
---|
396 | PrtTim(">>>> End Checking realization spectra");
|
---|
397 |
|
---|
398 | if(comp2dspec) {
|
---|
399 | cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
|
---|
400 | Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
401 | hpkgenf2.ReCenterBin(); hpkgenf2.Zero();
|
---|
402 | hpkgenf2.Show();
|
---|
403 | fluct3d.ComputeSpectrum2D(hpkgenf2);
|
---|
404 | {
|
---|
405 | tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs);
|
---|
406 | }
|
---|
407 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
408 | }
|
---|
409 | }
|
---|
410 |
|
---|
411 | if(wfits) {
|
---|
412 | fluct3d.WriteFits("!cmvobserv3d_k0.fits");
|
---|
413 | PrtTim(">>>> End WriteFits");
|
---|
414 | }
|
---|
415 | if(wppf) {
|
---|
416 | fluct3d.WritePPF("cmvobserv3d_k0.ppf",false);
|
---|
417 | PrtTim(">>>> End WritePPF");
|
---|
418 | }
|
---|
419 |
|
---|
420 | //-----------------------------------------------------------------
|
---|
421 | cout<<"\n--- Computing a realization in real space"<<endl;
|
---|
422 | fluct3d.ComputeReal();
|
---|
423 | double rmin,rmax; rgen.MinMax(rmin,rmax);
|
---|
424 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
425 | PrtTim(">>>> End Computing a realization in real space");
|
---|
426 |
|
---|
427 | if(use_growth_factor) {
|
---|
428 | cout<<"\n--- Apply Growth factor"<<endl;
|
---|
429 | cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
|
---|
430 | fluct3d.ApplyGrowthFactor();
|
---|
431 | rgen.MinMax(rmin,rmax);
|
---|
432 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
433 | PrtTim(">>>> End Applying growth factor");
|
---|
434 | }
|
---|
435 |
|
---|
436 |
|
---|
437 | if(wfits) {
|
---|
438 | fluct3d.WriteFits("!cmvobserv3d_r0.fits");
|
---|
439 | PrtTim(">>>> End WriteFits");
|
---|
440 | }
|
---|
441 | if(wppf) {
|
---|
442 | fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
|
---|
443 | PrtTim(">>>> End WritePPF");
|
---|
444 | }
|
---|
445 | if(wslice) {
|
---|
446 | fluct3d.WriteSlicePPF("cmvobserv3d_s_r0.ppf");
|
---|
447 | PrtTim(">>>> End WriteSlicePPF");
|
---|
448 | }
|
---|
449 |
|
---|
450 | int_8 nm;
|
---|
451 | double rm,rs2;
|
---|
452 | cout<<"\n--- Check mean and variance in real space"<<endl;
|
---|
453 | fluct3d.NumberOfBad(-1.,1e+200);
|
---|
454 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
455 | PrtTim(">>>> End Check mean and variance in real space");
|
---|
456 |
|
---|
457 | if(compvarreal) {
|
---|
458 | cout<<"\n--- Check variance sigmaR in real space"<<endl;
|
---|
459 | double varr;
|
---|
460 | fluct3d.VarianceFrReal(R,varr);
|
---|
461 | cout<<"...Computed variance = "<<varr
|
---|
462 | <<" , Theorical variance at (z=0) = "<<pow(sigmaR,1.)
|
---|
463 | <<" , at (z="<<zref<<") = "<<pow(sigmaR*growth_at_z,1.)<<endl;
|
---|
464 | PrtTim(">>>> End Check variance sigmaR in real space");
|
---|
465 | }
|
---|
466 |
|
---|
467 | //return -41; // CMVTEST
|
---|
468 |
|
---|
469 | //-----------------------------------------------------------------
|
---|
470 | cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
|
---|
471 | fluct3d.TurnFluct2Mass();
|
---|
472 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
473 | PrtTim(">>>> End Converting fluctuations into mass");
|
---|
474 |
|
---|
475 | cout<<"\n--- Converting mass into galaxy number"<<endl;
|
---|
476 | rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
|
---|
477 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
|
---|
478 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
479 | PrtTim(">>>> End Converting mass into galaxy number");
|
---|
480 |
|
---|
481 | cout<<"\n--- Set negative and null pixels to BAD"<<endl;
|
---|
482 | nm = fluct3d.SetToVal(0.,1e+200,-999.);
|
---|
483 | PrtTim(">>>> End Set negative pixels to BAD etc...");
|
---|
484 |
|
---|
485 | cout<<"\n--- Apply poisson on galaxy number"<<endl;
|
---|
486 | fluct3d.ApplyPoisson();
|
---|
487 | nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
|
---|
488 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
489 | PrtTim(">>>> End Apply poisson on galaxy number");
|
---|
490 | if(wslice) {
|
---|
491 | fluct3d.WriteSlicePPF("cmvobserv3d_s_rn.ppf");
|
---|
492 | PrtTim(">>>> End WriteSlicePPF");
|
---|
493 | }
|
---|
494 |
|
---|
495 | cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
|
---|
496 | long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
|
---|
497 | Histo hmdndm(lschmin,lschmax,nhmdndm);
|
---|
498 | sch.SetOutValue(1);
|
---|
499 | FuncToHisto(sch,hmdndm,true);
|
---|
500 | FunRan tirhmdndm(hmdndm,true);
|
---|
501 | {
|
---|
502 | tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
|
---|
503 | Histo hdum1(tirhmdndm);
|
---|
504 | tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
|
---|
505 | }
|
---|
506 | double mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
|
---|
507 | cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
|
---|
508 | nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
|
---|
509 | cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
|
---|
510 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
511 | PrtTim(">>>> End Convert Galaxy number to HI mass");
|
---|
512 |
|
---|
513 | cout<<"\n--- Set BAD pixels to Zero"<<endl;
|
---|
514 | nm = fluct3d.SetToVal(-998.,1e+200,0.);
|
---|
515 | PrtTim(">>>> End Set BAD pixels to Zero etc...");
|
---|
516 |
|
---|
517 | if(wfits) {
|
---|
518 | fluct3d.WriteFits("!cmvobserv3d_r.fits");
|
---|
519 | PrtTim(">>>> End WriteFits");
|
---|
520 | }
|
---|
521 | if(wppf) {
|
---|
522 | fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
|
---|
523 | PrtTim(">>>> End WritePPF");
|
---|
524 | }
|
---|
525 | if(wslice) {
|
---|
526 | fluct3d.WriteSlicePPF("cmvobserv3d_s_r.ppf");
|
---|
527 | PrtTim(">>>> End WriteSlicePPF");
|
---|
528 | }
|
---|
529 |
|
---|
530 | if(do_agn) {
|
---|
531 | cout<<"\n--- Add AGN: <log10(S Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
|
---|
532 | <<" , powlaw="<<powlaw_agn<<endl;
|
---|
533 | fluct3d.AddAGN(lfjy_agn,lsigma_agn,powlaw_agn);
|
---|
534 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
535 | PrtTim(">>>> End Add AGN");
|
---|
536 | }
|
---|
537 |
|
---|
538 | double scalecube = -1., offsetcube=0.;
|
---|
539 | if(snoise>0.) {
|
---|
540 | cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl;
|
---|
541 | fluct3d.AddNoise2Real(snoise,(isnoise_evol>0? true:false));
|
---|
542 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
543 | if(rs2>0. && sr2int>0.) scalecube = sqrt(sr2int)/sqrt(rs2);
|
---|
544 | offsetcube = -rm;
|
---|
545 | PrtTim(">>>> End Add noise");
|
---|
546 | }
|
---|
547 |
|
---|
548 | if(scalecube>0.) {
|
---|
549 | cout<<"\n--- Scale and offset scale="<<scalecube
|
---|
550 | <<" off="<<offsetcube<<endl;
|
---|
551 | fluct3d.ScaleOffset(scalecube,offsetcube);
|
---|
552 | }
|
---|
553 |
|
---|
554 | if(wfits) {
|
---|
555 | fluct3d.WriteFits("!cmvobserv3d_rf.fits");
|
---|
556 | PrtTim(">>>> End WriteFits");
|
---|
557 | }
|
---|
558 | if(wppf) {
|
---|
559 | fluct3d.WritePPF("cmvobserv3d_rf.ppf",true);
|
---|
560 | PrtTim(">>>> End WritePPF");
|
---|
561 | }
|
---|
562 | if(wslice) {
|
---|
563 | fluct3d.WriteSlicePPF("cmvobserv3d_s_rf.ppf");
|
---|
564 | PrtTim(">>>> End WriteSlicePPF");
|
---|
565 | }
|
---|
566 |
|
---|
567 | //-----------------------------------------------------------------
|
---|
568 | // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
|
---|
569 |
|
---|
570 | cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
|
---|
571 | fluct3d.ReComputeFourier();
|
---|
572 | PrtTim(">>>> End ReComputing spectrum");
|
---|
573 |
|
---|
574 | if(wfits) {
|
---|
575 | fluct3d.WriteFits("!cmvobserv3d_k.fits");
|
---|
576 | PrtTim(">>>> End WriteFits");
|
---|
577 | }
|
---|
578 | if(wppf) {
|
---|
579 | fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
|
---|
580 | PrtTim(">>>> End WritePPF");
|
---|
581 | }
|
---|
582 |
|
---|
583 | cout<<endl<<"\n--- Computing final spectrum"<<endl;
|
---|
584 | HistoErr hpkrec(0.,knyqmax,nherr);
|
---|
585 | hpkrec.ReCenterBin();
|
---|
586 | hpkrec.Show();
|
---|
587 | fluct3d.ComputeSpectrum(hpkrec);
|
---|
588 | tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
|
---|
589 | PrtTim(">>>> End Computing final spectrum");
|
---|
590 |
|
---|
591 | if(comp2dspec) {
|
---|
592 | cout<<"\n--- Computing final 2D spectrum"<<endl;
|
---|
593 | Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
594 | hpkrec2.ReCenterBin(); hpkrec2.Zero();
|
---|
595 | hpkrec2.Show();
|
---|
596 | fluct3d.ComputeSpectrum2D(hpkrec2);
|
---|
597 | {
|
---|
598 | tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
|
---|
599 | }
|
---|
600 | PrtTim(">>>> End Computing final 2D spectrum");
|
---|
601 | }
|
---|
602 |
|
---|
603 | PrtTim(">>>> End Of Job");
|
---|
604 | return 0;
|
---|
605 | }
|
---|
606 |
|
---|