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

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

details cmv 22/05/2007

File size: 20.1 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
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
[3193]34 <<" -M schmin,schmax,nsch : min,max mass and nb points for schechter HI"<<endl
[3200]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
[3154]39 <<" -P : write cube in PPF format"<<endl
[3200]40 <<" -V : compute variance from real space (for check, default: no)"<<endl
41 <<" -K : use power spectrum computation adapted for AGN (bidon!)"<<endl
[3115]42 <<endl;
43}
44
45int main(int narg,char *arg[])
46{
47 InitTim();
48
49 //-----------------------------------------------------------------
50 // *** Survey definition
[3129]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;
[3115]54
55 // *** Cosmography definition (WMAP)
[3157]56 unsigned short flat = 0;
[3115]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;
[3157]60 double perc=0.01,dzinc=-1.,dzmax=5.; unsigned short glorder=4;
[3115]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
[3193]73 double h75 = h100 / 0.75;
74 double nstar = 0.006*pow(h75,3.);
[3115]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
[3196]84 // *** AGN
85 bool do_agn = false;
[3199]86 double lfjy_agn=-99., lsigma_agn=0.; // en Jy
87 double powlaw_agn = 0.;
88 bool killkz = false;
[3196]89
[3115]90 // *** type de generation
91 bool computefourier0=false;
[3157]92 bool use_growth_factor = false;
[3115]93 unsigned short nthread=4;
94
[3154]95 // *** What to do
96 bool comp2dspec = false;
97 bool wfits = false;
98 bool wppf = false;
99 bool compvarreal = false;
100
[3115]101 // --- Decodage arguments
102
103 char c;
[3199]104 while((c = getopt(narg,arg,"ha0PWV2GKx:y:z:s:Z:M:A:")) != -1) {
[3115]105 switch (c) {
106 case 'a' :
107 Auto_Ini_Ranf(5);
108 break;
109 case '0' :
110 computefourier0 = true;
111 break;
[3157]112 case 'G' :
113 use_growth_factor = true;
114 break;
[3115]115 case 'x' :
[3129]116 sscanf(optarg,"%ld,%lf",&nx,&dx);
[3115]117 break;
118 case 'y' :
[3129]119 sscanf(optarg,"%ld,%lf",&ny,&dy);
[3115]120 break;
121 case 'z' :
[3129]122 sscanf(optarg,"%ld,%lf",&nz,&dz);
[3115]123 break;
124 case 's' :
125 sscanf(optarg,"%lf",&snoise);
126 break;
127 case 'Z' :
128 sscanf(optarg,"%lf",&zref);
129 break;
[3154]130 case '2' :
131 comp2dspec = true;
132 break;
[3193]133 case 'M' :
134 sscanf(optarg,"%lf,%lf,%d",&schmin,&schmax,&schnpt);
135 break;
[3196]136 case 'A' :
137 do_agn = true;
[3199]138 sscanf(optarg,"%lf,%lf,%lf",&lfjy_agn,&lsigma_agn,&powlaw_agn);
[3196]139 break;
[3199]140 case 'K' :
141 killkz = true;
142 break;
[3154]143 case 'V' :
144 compvarreal = true;
145 break;
146 case 'W' :
147 wfits = true;
148 break;
149 case 'P' :
150 wppf = true;
151 break;
[3115]152 case 'h' :
153 default :
154 usage(); return -1;
155 }
156 }
157
[3193]158 double lschmin=log10(schmin), lschmax=log10(schmax), dlsch=(lschmax-lschmin)/schnpt;
159
[3115]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;
[3246]168 cout<<"nstar= "<<nstar<<" mstar="<<mstar<<" alpha="<<alpha<<endl;
[3115]169 cout<<"schmin="<<schmin<<" ("<<lschmin
170 <<"), schmax="<<schmax<<" ("<<lschmax<<") Msol"
171 <<", schnpt="<<schnpt<<endl;
172 cout<<"snoise="<<snoise<<" equivalent Msol"<<endl;
[3199]173 if(do_agn)
174 cout<<"AGN: <log10(Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
175 <<" , powlaw="<<powlaw_agn<<endl;
[3115]176
177 //-----------------------------------------------------------------
[3157]178 cout<<endl<<"\n--- Create Cosmology"<<endl;
[3115]179
[3157]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);
[3193]185 cout<<"\nzref = "<<zref<<" -> dloscom = "<<loscomref<<" Mpc"<<endl;
186 univ.Print(zref);
[3157]187
188 //-----------------------------------------------------------------
[3193]189 cout<<endl<<"\n--- Create Spectrum"<<endl;
[3157]190
[3115]191 InitialSpectrum pkini(ns,as);
192
193 TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false);
194 //tf.SetNoOscEnv(2);
195
[3157]196 GrowthFactor growth(om0,ol0);
[3193]197 // GrowthFactor growth(1.,0.); // D(z) = 1/(1+z)
[3115]198
199 PkSpectrum0 pk0(pkini,tf);
200
[3157]201 PkSpectrumZ pkz(pk0,growth,zref);
[3115]202
[3193]203 //-----------------------------------------------------------------
204 cout<<endl<<"\n--- Create mass function"<<endl;
205
[3115]206 Schechter sch(nstar,mstar,alpha);
[3193]207 sch.Print();
[3115]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
[3120]233 Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
[3115]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 //-----------------------------------------------------------------
[3154]257 cout<<endl<<"\n--- Compute galaxy density number"<<endl;
[3115]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;
[3193]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;
[3115]270
[3155]271 PrtTim(">>>> End of definition");
272
[3115]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
[3155]275 cout<<endl<<"\n--- Initialisation de GeneFluct3D"<<endl;
[3115]276
277 TArray< complex<r_8> > pkgen;
[3141]278 GeneFluct3D fluct3d(pkgen);
[3155]279 fluct3d.SetPrtLevel(2);
[3115]280 fluct3d.SetNThread(nthread);
281 fluct3d.SetSize(nx,ny,nz,dx,dy,dz);
[3157]282 fluct3d.SetObservator(zref,nz/2.);
283 fluct3d.SetCosmology(univ);
284 fluct3d.SetGrowthFactor(growth);
[3199]285 fluct3d.LosComRedshift(0.001,-1);
[3141]286 TArray<r_8>& rgen = fluct3d.GetRealArray();
[3157]287 cout<<endl; fluct3d.Print();
[3141]288
289 double dkmin = fluct3d.GetKincMin();
[3115]290 double knyqmax = fluct3d.GetKmax();
[3141]291 long nherr = long(knyqmax/dkmin+0.5);
292 cout<<"For HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
[3115]293
[3141]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
[3157]303 //-----------------------------------------------------------------
[3115]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
[3141]308 double knyqmax_mod = 0.877*knyqmax;
309 ldlkint = (log10(knyqmax_mod)-log10(k1int))/npt;
[3115]310 varpk_int.SetInteg(0.01,ldlkint,-1.,4);
[3141]311 double sr2int_kmax = varpk_int.Variance(R,k1int,knyqmax_mod);
312 cout<<"varpk_int(<"<<knyqmax_mod<<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl;
[3115]313
[3155]314 PrtTim(">>>> End Initialisation de GeneFluct3D");
315
[3157]316 //-----------------------------------------------------------------
[3115]317 cout<<"\n--- Computing a realization in Fourier space"<<endl;
[3157]318 if(use_growth_factor) pkz.SetZ(0.); else pkz.SetZ(zref);
319 cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
[3141]320 if(computefourier0) fluct3d.ComputeFourier0(pkz);
321 else fluct3d.ComputeFourier(pkz);
[3155]322 PrtTim(">>>> End Computing a realization in Fourier space");
[3115]323
[3141]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 }
[3155]333 PrtTim(">>>> End Checking realization spectra");
[3115]334 }
335
[3154]336 if(comp2dspec) {
[3141]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 }
[3155]345 PrtTim(">>>> End Checking realization 2D spectra");
[3141]346 }
347
348 if(1) {
[3115]349 cout<<"\n--- Computing convolution by pixel shape"<<endl;
350 fluct3d.FilterByPixel();
[3155]351 PrtTim(">>>> End Computing convolution by pixel shape");
[3141]352 }
[3115]353
[3155]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 }
[3141]362
363 if(1) {
[3115]364 cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
[3141]365 HistoErr hpkgenf(0.,knyqmax,nherr);
366 hpkgenf.ReCenterBin(); hpkgenf.Zero();
367 hpkgenf.Show();
[3115]368 fluct3d.ComputeSpectrum(hpkgenf);
369 {
370 tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
371 }
[3155]372 PrtTim(">>>> End Checking realization spectra");
[3115]373 }
374
[3154]375 if(comp2dspec) {
[3141]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 }
[3155]384 PrtTim(">>>> End Checking realization 2D spectra");
[3115]385 }
386
[3157]387 //-----------------------------------------------------------------
[3115]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;
[3157]392 PrtTim(">>>> End Computing a realization in real space");
[3115]393
[3157]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;
[3199]397 fluct3d.ApplyGrowthFactor();
[3252]398 rgen.MinMax(rmin,rmax);
[3157]399 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
400 PrtTim(">>>> End Applying growth factor");
401 }
402
[3155]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 }
[3115]411
[3141]412 int_8 nm;
413 double rm,rs2;
[3115]414 if(1) {
[3141]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;
[3155]420 PrtTim(">>>> End Check mean and variance in real space");
[3141]421 }
422
[3154]423 if(compvarreal) {
[3115]424 cout<<"\n--- Check variance sigmaR in real space"<<endl;
425 double varr;
[3134]426 int_8 nvarr = fluct3d.VarianceFrReal(R,varr);
[3115]427 cout<<"R="<<R<<" : sigmaR^2="<<varr<<" -> "<<sqrt(varr)<<", n="<<nvarr<<endl;
[3155]428 PrtTim(">>>> End Check variance sigmaR in real space");
[3115]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;
[3155]437 PrtTim(">>>> End Converting fluctuations into mass");
[3115]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;
[3155]445 PrtTim(">>>> End Converting mass into galaxy number");
[3115]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;
[3155]453 PrtTim(">>>> End Set negative pixels to BAD etc...");
[3115]454
[3154]455 cout<<"\n--- Apply poisson on galaxy number"<<endl;
[3115]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;
[3155]461 PrtTim(">>>> End Apply poisson on galaxy number");
[3115]462
[3154]463 cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
[3129]464 long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
[3115]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;
[3155]480 PrtTim(">>>> End Convert Galaxy number to HI mass");
[3115]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;
[3155]488 PrtTim(">>>> End Set BAD pixels to Zero etc...");
[3115]489
[3155]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 }
[3120]498
[3196]499 if(do_agn) {
[3199]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);
[3196]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
[3193]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 }
[3115]517
[3199]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
[3115]527 //-----------------------------------------------------------------
528 // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
[3141]529
[3115]530 if(1) {
531 cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
532 fluct3d.ReComputeFourier();
[3155]533 PrtTim(">>>> End ReComputing spectrum");
[3141]534 }
535
[3155]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 }
[3154]544
[3141]545 if(1) {
546 cout<<endl<<"\n--- Computing final spectrum"<<endl;
547 HistoErr hpkrec(0.,knyqmax,nherr);
[3115]548 hpkrec.ReCenterBin();
[3141]549 hpkrec.Show();
[3199]550 if(killkz) fluct3d.ComputeSpectrum_bricolo(hpkrec);
551 else fluct3d.ComputeSpectrum(hpkrec);
[3115]552 tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
[3155]553 PrtTim(">>>> End Computing final spectrum");
[3115]554 }
555
[3154]556 if(comp2dspec) {
[3141]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();
[3199]561 if(killkz) fluct3d.ComputeSpectrum2D_bricolo(hpkrec2);
562 else fluct3d.ComputeSpectrum2D(hpkrec2);
[3141]563 {
564 tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
565 }
[3155]566 PrtTim(">>>> End Computing final 2D spectrum");
[3141]567 }
568
[3155]569 PrtTim(">>>> End Of Job");
[3115]570 return 0;
571}
572
573/*
[3141]574######################################################
[3154]575readfits cmvobserv3d_k0.fits
[3141]576readfits cmvobserv3d_k.fits
577readfits cmvobserv3d_r0.fits
578readfits cmvobserv3d_r.fits
[3199]579readfits cmvobserv3d_rf.fits
[3141]580
[3154]581openppf cmvobserv3d_k0.ppf
[3141]582openppf cmvobserv3d_k.ppf
583openppf cmvobserv3d_r0.ppf
584openppf cmvobserv3d_r.ppf
[3199]585openppf cmvobserv3d_rf.ppf
[3141]586
[3199]587# pour le plot 2D d'une slice en Z du 3D: xy2d nom_obj3D num_slice
588defscript xy2d
[3141]589 objaoper $1 sliceyz $2
[3199]590 mv sliceyz_${2} ${1}_Z_$2
591 disp ${1}_Z_$2
592 echo display slice $2 of $1 name is ${1}_Z_$2
593endscript
594
595# pour le plot 2D d'une slice en Y du 3D: xz2d nom_obj3D num_slice
596defscript 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
[3141]601endscript
[3199]602
603# pour le plot 2D d'une slice en X du 3D: yz2d nom_obj3D num_slice
604defscript 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
609endscript
[3141]610
[3199]611xy2d $cobj 0
612xz2d $cobj 0
613yz2d $cobj 0
[3141]614
615######################################################
[3115]616openppf cmvobserv3d.ppf
617
[3141]618zone
[3150]619set k pow(10.,x)
620n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints"
621
[3199]622echo ${hpkgen.sum}
623echo ${hpkgenf.sum}
624echo ${hpkrec.sum}
625
[3150]626zone
[3120]627n/plot hpkz.val%x ! ! "nsta connectpoints"
628n/plot hpkgen.val%log10(x) x>0 ! "nsta same red connectpoints"
629n/plot hpkgenf.val%log10(x) x>0 ! "nsta same orange connectpoints"
630n/plot hpkrec.val%log10(x) x>0 ! "nsta same blue connectpoints"
[3115]631
[3150]632disp hpkgen "hbincont err"
633disp hpkgenf "hbincont err"
634disp hpkrec "hbincont err"
[3115]635
[3141]636zone 2 2
637imag hpkgen2
638imag hpkgenf2
639imag hpkrec2
[3115]640
[3150]641zone 2 1
642disp hmdndm "nsta"
643disp tirhmdndm "nsta"
[3120]644addline 0 1 20 1 "red"
645
[3115]646 */
Note: See TracBrowser for help on using the repository browser.