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

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

affinage du calcul des meansigma cmv 5/6/2007

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