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

Last change on this file since 3193 was 3193, checked in by cmv, 19 years ago

petis changements cmv 21/03/2007

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