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

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

possibilite de ne pas faire poisson sur Ngal cmv 27/09/2007

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