source: Sophya/trunk/Cosmo/SimLSS/cmvginit3d.cc@ 3782

Last change on this file since 3782 was 3782, checked in by cmv, 15 years ago

ajout des spectre NoOsc dans cmvginit3d, cmv 7/6/2010

File size: 22.1 KB
Line 
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
10#include "sophyainit.h"
11#include "timing.h"
12#include "dvlist.h"
13#include "ntuple.h"
14#include "matharr.h"
15#include "randfmt.h"
16//#include "randr48.h"
17#include "srandgen.h"
18
19#include "constcosmo.h"
20#include "geneutils.h"
21#include "genefluct3d.h"
22
23void usage(void);
24void usage(void)
25{
26 cout<<"cmvginit3d [...options...]"<<endl
27 <<" -a : auto init random seed (needed for multiple simul)"<<endl
28 <<" -G typevol: compute Pk(z=0) and apply growth factor in real space"<<endl
29 <<" typevol=1 evolved with distance / observateur (def)"<<endl
30 <<" typevol=2 evolved with distance to middle of Z planes"<<endl
31 <<" else : no evol, spectrum Pk(z=z_median) for all cube (def)"<<endl
32 <<" -F : filter spectrum by pixel shape (0=no 1=yes(default)"<<endl
33 <<" -x nx,dx : size along x axis (npix,Mpc)"<<endl
34 <<" -y ny,dy : size along y axis (npix,Mpc)"<<endl
35 <<" if ny or dy <=0 take same value as for x"<<endl
36 <<" -z nz,dz : size along z axis (redshift axis, npix,Mpc)"<<endl
37 <<" -Z zref : redshift for the center of the simulation cube"<<endl
38 <<" -1 : compute 1D spectrum (default: no)"<<endl
39 <<" -2 : compute 2D spectrum (default: no)"<<endl
40 <<" -C : go back to cube in FT space and compute P(k) for check (def: do nothing)"<<endl
41 <<" -8 sigmaR,R : normalisation du spectre de puissance, R en Mpc"<<endl
42 <<" (default sigmaR=1, R=8/h100 Mpc)"<<endl
43 <<" -v temp_file.ppf: generate los velocity cube"<<endl
44 <<" temporary save cube in temp_file.ppf"<<endl
45 <<" -n nent : fill control ntuple with nent entries (def: do not fill)"<<endl
46 <<" -O a,b : tell what you want to write"<<endl
47 <<" a : write generated fourier cube (_k0)"<<endl
48 <<" b : write real space cube dRho/Rho at z (_r0)"<<endl
49 <<" a,b= 0 no write, 1 ppf write, 2 fits write, 3 ppf+fits write"<<endl
50 <<" -S : write cube slices in PPF format"<<endl
51 <<" -o out_base_name : base string for output file name (def: cmvginit3d)"<<endl
52 <<" -V : compute variance from real space (for check, default: no)"<<endl
53 <<" -T nth : nombre de threads (si compil multi-thread, default: 0)"<<endl
54 <<endl;
55}
56
57int main(int narg,char *arg[])
58{
59 SophyaInit();
60 InitTim();
61
62 //-----------------------------------------------------------------
63 // *** Survey definition
64 long nx=360, ny=-1, nz=64; double dx=1., dy=-1., dz=-1.;
65 //long nx=1000, ny=-1, nz=128; double dx=3., dy=-1., dz=6.;
66 //long nx=1200, ny=-1, nz=128; double dx=1., dy=-1., dz=3;
67
68 // *** Cosmography definition (WMAP)
69 unsigned short flat = 0;
70 double ob0 = 0.0444356;
71 double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
72 double zref = 0.5;
73 double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
74
75 // *** Spectrum and variance definition
76 double ns = 1., as = 1.;
77 double R=8./h100, Rg=R/sqrt(5.);
78 double sigmaR = 1.;
79
80 double kmin=1e-5,kmax=1000.;
81 int npt = 10000;
82 double lkmin=log10(kmin), lkmax=log10(kmax);
83 double eps=1.e-3;
84
85 // *** type de generation
86 int use_growth_factor = 0;
87 unsigned short nthread=0;
88 int filter_by_pixel = 1;
89
90 // *** What to do
91 bool comptransveloc = false;
92 string temporay_file = "cmvginit3d_tmp.ppf";
93 // compute: 1=1D spectra, 2=2D spectra,
94 // 4=recompute spectra after real space generation
95 unsigned short compdspec = 0;
96 long ntnent = 0; // fill control NTuple
97 bool wslice = false;
98 bool compvarreal = false;
99 unsigned short whattowrt[2] = {1,1};
100 string rootnameout = "cmvobserv3d";
101
102 // --- Decodage arguments
103 if(narg>0) {
104 cout<<"\n--- Arguments: "<<endl;
105 for(int i=0;i<narg;i++) cout<<arg[i]<<" ";
106 cout<<endl;
107 }
108 system("date -u");
109
110 // --- Choix du generateur aleatoire (a faire ICI imperativement avant AutoInitRand)
111 FMTRandGen *RandGen = new FMTRandGen;
112 RandGen->SelectGaussianAlgo(C_Gaussian_RandLibSNorm);
113 RandomGeneratorInterface::SetGlobalRandGenP(RandGen);
114
115 // --- Decodage des arguments
116 char c;
117 while((c = getopt(narg,arg,"haG:F:x:y:z:Z:128:v:n:CO:So:VT:")) != -1) {
118 int nth = 0;
119 switch (c) {
120 case 'a' :
121 AutoInitRand(5);
122 break;
123 case 'G' :
124 use_growth_factor = atoi(optarg);
125 break;
126 case 'F' :
127 filter_by_pixel = atoi(optarg);
128 break;
129 case 'x' :
130 sscanf(optarg,"%ld,%lf",&nx,&dx);
131 break;
132 case 'y' :
133 sscanf(optarg,"%ld,%lf",&ny,&dy);
134 break;
135 case 'z' :
136 sscanf(optarg,"%ld,%lf",&nz,&dz);
137 break;
138 case 'Z' :
139 zref = atof(optarg);
140 break;
141 case 'v' :
142 comptransveloc = true;
143 temporay_file = optarg;
144 break;
145 case '1' :
146 compdspec |= 1;
147 break;
148 case '2' :
149 compdspec |= 2;
150 break;
151 case 'C' :
152 compdspec |= 4;
153 break;
154 case '8' :
155 sscanf(optarg,"%lf,%lf",&sigmaR,&R);
156 break;
157 case 'V' :
158 compvarreal = true;
159 break;
160 case 'n':
161 ntnent = atol(optarg);
162 if(ntnent<0) ntnent = 0;
163 break;
164 case 'O' :
165 sscanf(optarg,"%hu,%hu",&whattowrt[0],&whattowrt[1]);
166 break;
167 case 'S' :
168 wslice = true;
169 break;
170 case 'o' :
171 rootnameout = optarg;
172 break;
173 case 'T' :
174 nth = atoi(optarg);
175 nthread = (nth<1)? 0: nth;
176 break;
177 case 'h' :
178 default :
179 usage(); return -1;
180 }
181 }
182
183 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
184 try {
185 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
186
187 //-----------------------------------------------------------------
188 cout<<endl<<"\n--- Initialisation and parameters"<<endl;
189 cout<<"zref="<<zref<<endl;
190 cout<<"nx="<<nx<<" dx="<<dx<<" ny="<<ny<<" dy="<<dy<<" nz="<<nz<<" dz="<<dz<<endl;
191 cout<<"kmin="<<kmin<<" ("<<lkmin<<"), kmax="<<kmax<<" ("<<lkmax<<") Mpc^-1"<<", npt="<<npt<<endl;
192 cout<<"Filter by pixel = "<<filter_by_pixel<<endl;
193 if(comptransveloc) cout<<"Tansverse velocity generation requested"<<endl;
194 cout<<"R="<<R<<" Rg="<<Rg<<" Mpc, sigmaR="<<sigmaR<<endl;
195 cout<<"Use_growth_factor = "<<use_growth_factor<<endl;
196 cout<<"wslice="<<wslice<<" what?="<<whattowrt[0]<<","<<whattowrt[1]<<endl;
197 cout<<"rootnameout="<<rootnameout<<endl;
198 ShowRandom();
199 cout<<" First random is: "<<drand01()<<endl;
200
201 string tagobs = rootnameout + ".ppf";
202 cout<<"Writing result in "<<tagobs<<endl;
203 POutPersist posobs(tagobs);
204
205 //-----------------------------------------------------------------
206 cout<<endl<<"\n--- Create Cosmology"<<endl;
207
208 CosmoCalc univ(flat,true,zref+1.);
209 univ.SetInteg(perc,dzinc,dzmax,glorder);
210 univ.SetDynParam(h100,om0,or0,ol0,w0);
211 univ.PrtInteg();
212 univ.Print();
213 double loscomref = univ.Dloscom(zref);
214 cout<<"\nzref = "<<zref<<" -> dloscom = "<<loscomref<<" Mpc"<<endl;
215 univ.Print(zref);
216
217 //-----------------------------------------------------------------
218 cout<<endl<<"\n--- Create Spectrum"<<endl;
219
220 InitialSpectrum pkini(ns,as);
221
222 TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false);
223 TransfertEisenstein tfnos(h100,om0-ob0,ob0,T_CMB_Par,false);
224 tfnos.SetNoOscEnv(2);
225
226 GrowthFactor growth(om0,ol0);
227 // GrowthFactor growth(1.,0.); // D(z) = 1/(1+z)
228 double growth_at_z = growth(zref);
229 cout<<"...Growth factor at z="<<zref<<" = "<<growth_at_z<<endl;
230
231 PkSpectrum0 pk0(pkini,tf);
232 PkSpectrum0 pk0nos(pkini,tfnos);
233
234 PkSpectrumZ pkz(pk0,growth,zref);
235 PkSpectrumZ pkznos(pk0nos,growth,zref);
236
237 //-----------------------------------------------------------------
238 pkz.SetZ(0.);
239 pkznos.SetZ(0.);
240 cout<<endl<<"\n--- Compute variance for top-hat R="<<R<<" at z="<<pkz.GetZ()<<endl;
241 VarianceSpectrum varpk_th(pkz,R,VarianceSpectrum::TOPHAT);
242 double kfind_th = varpk_th.FindMaximum(kmin,kmax,eps);
243 double pkmax_th = varpk_th(kfind_th);
244 cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
245 double k1=kmin, k2=kmax;
246 int rc = varpk_th.FindLimits(pkmax_th/1.e4,k1,k2,eps);
247 cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "
248 <<k2<<" ("<<log10(k2)<<")"<<endl;
249
250 double ldlk = (log10(k2)-log10(k1))/npt;
251 varpk_th.SetInteg(0.01,ldlk,-1.,4);
252 double sr2 = varpk_th.Variance(k1,k2);
253 cout<<"varpk_th="<<sr2<<" -> sigma="<<sqrt(sr2)<<endl;
254
255 double normpkz = sigmaR*sigmaR/sr2;
256 pkz.SetScale(normpkz);
257 pkznos.SetScale(normpkz);
258 cout<<"Spectrum normalisation = "<<pkz.GetScale()<<endl;
259 {
260 Histo hpkz0(lkmin,lkmax,npt); hpkz0.ReCenterBin();
261 FuncToHisto(pkz,hpkz0,true);
262 posobs.PutObject(hpkz0,"hpkz0");
263 Histo hpkz0nos(hpkz0);
264 FuncToHisto(pkznos,hpkz0nos,true);
265 posobs.PutObject(hpkz0nos,"hpkz0nos");
266 }
267
268 pkz.SetZ(zref);
269 pkznos.SetZ(zref);
270 {
271 Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
272 FuncToHisto(pkz,hpkz,true);
273 posobs.PutObject(hpkz,"hpkz");
274 Histo hpkznos(hpkz);
275 FuncToHisto(pkznos,hpkznos,true);
276 posobs.PutObject(hpkznos,"hpkznos");
277 }
278
279 //-----------------------------------------------------------------
280 cout<<endl<<"\n--- Compute variance for Pk at z="<<pkz.GetZ()<<endl;
281 VarianceSpectrum varpk_int(pkz,R,VarianceSpectrum::NOFILTER);
282 double kfind_int = varpk_int.FindMaximum(kmin,kmax,eps);
283 double pkmax_int = varpk_int(kfind_int);
284 cout<<"kfind_int = "<<kfind_int<<" ("<<log10(kfind_int)<<"), integrand="<<pkmax_int<<endl;
285 double k1int=kmin, k2int=kmax;
286 int rcint = varpk_int.FindLimits(pkmax_int/1.e4,k1int,k2int,eps);
287 cout<<"limit_int: rc="<<rcint<<" : "<<k1int<<" ("<<log10(k1int)<<") , "
288 <<k2int<<" ("<<log10(k2int)<<")"<<endl;
289
290 double ldlkint = (log10(k2int)-log10(k1int))/npt;
291 varpk_int.SetInteg(0.01,ldlkint,-1.,4);
292 double sr2int = varpk_int.Variance(k1int,k2int);
293 cout<<"varpk_int="<<sr2int<<" -> sigma="<<sqrt(sr2int)<<endl;
294
295 //-----------------------------------------------------------------
296
297 PrtTim(">>>> End of definition");
298
299 //-----------------------------------------------------------------
300 // Le cube et sa cosmlogie
301 // FFTW3 (p26): faster if sizes 2^a 3^b 5^c 7^d 11^e 13^f with e+f=0 ou 1
302 cout<<endl<<"\n--- Initialisation de GeneFluct3D"<<endl;
303
304 GeneFluct3D fluct3d(nx,ny,nz,dx,dy,dz,nthread,2);
305 fluct3d.SetCosmology(univ);
306 fluct3d.SetGrowthFactor(growth);
307 fluct3d.SetObservator(zref,-nz/2.);
308 fluct3d.LosComRedshift(0.001,-1);
309 //TArray< complex<GEN3D_TYPE> >& pkgen = fluct3d.GetComplexArray();
310 //TArray<GEN3D_TYPE>& rgen = fluct3d.GetRealArray();
311 cout<<endl; fluct3d.Print();
312
313 //-----------------------------------------------------------------
314 // Les bins et ranges en k pour les histos 1D et 2D
315 double dkmin = fluct3d.GetKincMin();
316 double knyqmax = fluct3d.GetKmax();
317 long nherr = long(knyqmax/dkmin+0.5);
318 cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
319
320 double dktmin = fluct3d.GetKTincMin();
321 double ktnyqmax = fluct3d.GetKTmax();
322 long nherrt = long(ktnyqmax/dktmin+0.5);
323 double dkzmin = fluct3d.GetKinc()[2];
324 double kznyqmax = fluct3d.GetKnyq()[2];
325 long nherrz = long(kznyqmax/dkzmin+0.5);
326 cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin
327 <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
328
329 //-----------------------------------------------------------------
330 cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl;
331 // En fait on travaille sur un cube inscrit dans la sphere de rayon kmax:
332 // sphere: Vs = 4Pi/3 k^3 , cube inscrit (cote k*sqrt(2)): Vc = (k*sqrt(2))^3
333 // Vc/Vs = 0.675 -> keff = kmax * (0.675)^(1/3) = kmax * 0.877
334 double knyqmax_mod = 0.877*knyqmax;
335 ldlkint = (log10(knyqmax_mod)-log10(k1int))/npt;
336 varpk_int.SetInteg(0.01,ldlkint,-1.,4);
337 double sr2int_kmax = varpk_int.Variance(k1int,knyqmax_mod);
338 cout<<"varpk_int(<"<<knyqmax_mod<<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl;
339
340 PrtTim(">>>> End Initialisation of GeneFluct3D");
341
342 //-----------------------------------------------------------------
343 cout<<"\n--- Computing a realization in Fourier space"<<endl;
344 if(use_growth_factor>0) pkz.SetZ(0.); else pkz.SetZ(zref);
345 cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
346 fluct3d.ComputeFourier(pkz);
347 fluct3d.NTupleCheck(posobs,string("ntpkgen"),ntnent);
348 PrtTim(">>>> End Computing a realization in Fourier space");
349
350 HistoErr hpkgen(0.,knyqmax,nherr);
351 if(compdspec&1) {
352 cout<<"\n--- Checking realization spectra"<<endl;
353 hpkgen.ReCenterBin(); hpkgen.Zero(); hpkgen.Show();
354 fluct3d.ComputeSpectrum(hpkgen);
355 posobs.PutObject(hpkgen,"hpkgen");
356 PrtTim(">>>> End Checking realization 1D spectra");
357 }
358 Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
359 if(compdspec&2) {
360 cout<<"\n--- Checking realization 2D spectra"<<endl;
361 hpkgen2.ReCenterBin(); hpkgen2.Zero(); hpkgen2.Show();
362 fluct3d.ComputeSpectrum2D(hpkgen2);
363 posobs.PutObject(hpkgen2,"hpkgen2");
364 PrtTim(">>>> End Checking realization 2D spectra");
365 }
366
367 //-----------------------------------------------------------------
368 if(filter_by_pixel!=0) {
369 cout<<"\n--- Computing convolution by pixel shape"<<endl;
370 fluct3d.FilterByPixel();
371 fluct3d.NTupleCheck(posobs,string("ntpkgenf"),ntnent);
372 PrtTim(">>>> End Computing convolution by pixel shape");
373 }
374
375 if(compdspec&1) {
376 HistoErr hpkgenf(hpkgen);
377 if(filter_by_pixel!=0) {
378 cout<<"\n--- Checking realization spectra"<<endl;
379 hpkgenf.Zero(); hpkgenf.Show();
380 fluct3d.ComputeSpectrum(hpkgenf);
381 PrtTim(">>>> End Checking realization 1D spectra");
382 }
383 posobs.PutObject(hpkgenf,"hpkgenf");
384 }
385 if(compdspec&2) {
386 Histo2DErr hpkgenf2(hpkgen2);
387 if(filter_by_pixel!=0) {
388 cout<<"\n--- Checking realization 2D spectra"<<endl;
389 hpkgenf2.Zero(); hpkgenf2.Show();
390 fluct3d.ComputeSpectrum2D(hpkgenf2);
391 PrtTim(">>>> End Checking realization 2D spectra");
392 }
393 posobs.PutObject(hpkgenf2,"hpkgenf2");
394 }
395
396 //-----------------------------------------------------------------
397 if(whattowrt[0]&1) {
398 tagobs = rootnameout + "_k.ppf";
399 fluct3d.WritePPF(tagobs,false);
400 PrtTim(">>>> End WritePPF");
401 temporay_file = tagobs;
402 }
403 if(whattowrt[0]&2) {
404 tagobs = "!" + rootnameout + "_k.fits";
405 fluct3d.WriteFits(tagobs);
406 PrtTim(">>>> End WriteFits");
407 }
408 if(comptransveloc && !(whattowrt[0]&1)) {
409 cout<<">>> Writing FT cube (for transv veloc.) in "<<temporay_file<<endl;
410 fluct3d.WritePPF(temporay_file,false);
411 PrtTim(">>>> End Writing FT cube");
412 }
413
414 //-----------------------------------------------------------------
415 cout<<"\n--- Computing a realization in real space"<<endl;
416 fluct3d.ComputeReal();
417 double rmin,rmax; fluct3d.MinMax(rmin,rmax);
418 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
419 fluct3d.NTupleCheck(posobs,string("ntreal"),ntnent);
420 PrtTim(">>>> End Computing a realization in real space");
421
422 if(use_growth_factor>0) {
423 cout<<"\n--- Apply Growth factor"<<endl;
424 cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
425 fluct3d.ApplyGrowthFactor(use_growth_factor);
426 fluct3d.MinMax(rmin,rmax);
427 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
428 fluct3d.NTupleCheck(posobs,string("ntgrow"),ntnent);
429 PrtTim(">>>> End Applying growth factor");
430 }
431
432 int_8 nm;
433 double rmref,rs2ref;
434 cout<<"\n--- Computing reference variance in real space"<<endl;
435 nm = fluct3d.MeanSigma2(rmref,rs2ref);
436 cout<<" rs2ref= "<<rs2ref<<" , rmref="<<rmref<<" ("<<nm<<")"<<endl;
437 PrtTim(">>>> End Computing reference variance in real space");
438
439 if(whattowrt[1]&1) {
440 tagobs = rootnameout + "_r.ppf";
441 fluct3d.WritePPF(tagobs,true);
442 PrtTim(">>>> End WritePPF");
443 }
444 if(whattowrt[1]&2) {
445 tagobs = "!" + rootnameout + "_r.fits";
446 fluct3d.WriteFits(tagobs);
447 PrtTim(">>>> End WriteFits");
448 }
449 if(wslice) {
450 tagobs = rootnameout + "_s_r.ppf";
451 fluct3d.WriteSlicePPF(tagobs);
452 PrtTim(">>>> End WriteSlicePPF");
453 }
454
455 //-----------------------------------------------------------------
456 if(compvarreal) {
457 cout<<"\n--- Check variance sigmaR in real space"<<endl;
458 double varr;
459 fluct3d.VarianceFrReal(R,varr);
460 cout<<"...Computed variance = "<<varr
461 <<" , Theorical variance at (z=0) = "<<pow(sigmaR,2.)
462 <<" , at (z="<<zref<<") = "<<pow(sigmaR*growth_at_z,2.)<<endl;
463 PrtTim(">>>> End Check variance sigmaR in real space");
464 }
465
466 //-----------------------------------------------------------------
467 if(compdspec&4) { // ATTENTION: d_rho/rho ecrase
468 cout<<endl<<"\n--- ReComputing spectrum from real space"
469 <<"\n Warning: REAL SPACE CUBE OVERWRITTEN"<<endl;
470 fluct3d.ReComputeFourier();
471 fluct3d.NTupleCheck(posobs,string("ntpkrec"),ntnent);
472 PrtTim(">>>> End ReComputing spectrum");
473
474 cout<<endl<<"\n--- Computing final spectrum"<<endl;
475 HistoErr hpkrecb(0.,knyqmax,nherr); hpkrecb.Zero();
476 hpkrecb.ReCenterBin(); hpkrecb.Show();
477 fluct3d.ComputeSpectrum(hpkrecb);
478 posobs.PutObject(hpkrecb,"hpkrecb");
479 PrtTim(">>>> End Computing final spectrum");
480
481 HistoErr hpkrec(hpkrecb);
482 if(filter_by_pixel!=0) {
483 cout<<endl<<"\n--- Computing final spectrum with pixel deconv."<<endl;
484 hpkrec.Zero();
485 fluct3d.ComputeSpectrum(hpkrec,0.,filter_by_pixel);
486 PrtTim(">>>> End Computing final spectrum with pixel deconv.");
487 }
488 posobs.PutObject(hpkrec,"hpkrec");
489
490 cout<<"\n--- Computing final 2D spectrum"<<endl;
491 Histo2DErr hpkrecb2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
492 hpkrecb2.ReCenterBin(); hpkrecb2.Zero(); hpkrecb2.Show();
493 fluct3d.ComputeSpectrum2D(hpkrecb2);
494 posobs.PutObject(hpkrecb2,"hpkrecb2");
495 PrtTim(">>>> End Computing final 2D spectrum");
496
497 Histo2DErr hpkrec2(hpkrecb2);
498 if(filter_by_pixel!=0) {
499 cout<<"\n--- Computing final 2D spectrum with pixel deconv."<<endl;
500 hpkrec2.Zero();
501 fluct3d.ComputeSpectrum2D(hpkrec2,0.,filter_by_pixel);
502 PrtTim(">>>> End Computing final 2D spectrum with pixel deconv.");
503 }
504 posobs.PutObject(hpkrec2,"hpkrec2");
505 }
506
507 //-----------------------------------------------------------------
508 //-----------------------------------------------------------------
509 //-----------------------------------------------------------------
510
511 if(comptransveloc) {
512 cout<<"\n\n\n"<<"---------------------------------------------\n"
513 <<"--- Transverse velocity space computation ---\n"
514 <<"---------------------------------------------\n"<<endl;
515
516 //-----------------------------------------------------------------
517 cout<<"\n--- Reading back the Pk(vec(k)) cube from "<<temporay_file<<endl;
518 fluct3d.ReadPPF(temporay_file);
519 PrtTim(">>>> End Reading the Pk(vec(k)) cube");
520
521 if(compdspec&1) {
522 cout<<"\n--- Check realization spectra that has been re-read"<<endl;
523 HistoErr hpkgenf_rr(hpkgen); hpkgenf_rr.Zero();
524 fluct3d.ComputeSpectrum(hpkgenf_rr);
525 PrtTim(">>>> End Checking re-read realization 1D spectra");
526 posobs.PutObject(hpkgenf_rr,"hpkgenf_rr");
527 }
528
529 //-----------------------------------------------------------------
530 cout<<"\n--- Modifying cube for Transverse velocity"<<endl;
531 fluct3d.ToVelLoS();
532 fluct3d.NTupleCheck(posobs,string("ntpvgenf"),ntnent);
533 PrtTim(">>>> End Modifying cube for Transverse velocity");
534
535 if(compdspec&1) {
536 cout<<"\n--- Checking realization spectra"<<endl;
537 HistoErr hpvgen(0.,knyqmax,nherr);
538 hpvgen.ReCenterBin(); hpvgen.Zero(); hpvgen.Show();
539 fluct3d.ComputeSpectrum(hpvgen);
540 posobs.PutObject(hpvgen,"hpvgen");
541 PrtTim(">>>> End Checking realization 1D spectra");
542 }
543 if(compdspec&2) {
544 cout<<"\n--- Checking realization 2D spectra"<<endl;
545 Histo2DErr hpvgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
546 hpvgen2.ReCenterBin(); hpvgen2.Zero(); hpvgen2.Show();
547 fluct3d.ComputeSpectrum2D(hpvgen2);
548 posobs.PutObject(hpvgen2,"hpvgen2");
549 PrtTim(">>>> End Checking realization 2D spectra");
550 }
551
552 if(whattowrt[0]&1) {
553 tagobs = rootnameout + "_kv.ppf";
554 fluct3d.WritePPF(tagobs,false);
555 PrtTim(">>>> End WritePPF");
556 }
557 if(whattowrt[0]&2) {
558 tagobs = "!" + rootnameout + "_kv.fits";
559 fluct3d.WriteFits(tagobs);
560 PrtTim(">>>> End WriteFits");
561 }
562
563 //-----------------------------------------------------------------
564 cout<<"\n--- Computing a realization in real space for Transverse velocity"<<endl;
565 fluct3d.ComputeReal();
566 double rmin,rmax; fluct3d.MinMax(rmin,rmax);
567 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
568 fluct3d.NTupleCheck(posobs,string("nvreal"),ntnent);
569 PrtTim(">>>> End Computing a realization in real space");
570
571 if(use_growth_factor>0) {
572 cout<<"\n--- Apply Growth factor"<<endl;
573 cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
574 fluct3d.ApplyDerGrowthFactor(use_growth_factor);
575 fluct3d.MinMax(rmin,rmax);
576 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
577 fluct3d.NTupleCheck(posobs,string("nvgrow"),ntnent);
578 PrtTim(">>>> End Applying growth factor");
579 }
580
581 int_8 nmv;
582 double vmref,vs2ref;
583 cout<<"\n--- Computing reference variance in real space"<<endl;
584 nmv = fluct3d.MeanSigma2(vmref,vs2ref);
585 cout<<" vs2ref= "<<vs2ref<<" , vmref="<<vmref<<" ("<<nmv<<")"<<endl;
586 PrtTim(">>>> End Computing reference variance in real space");
587
588 if(whattowrt[1]&1) {
589 tagobs = rootnameout + "_rv.ppf";
590 fluct3d.WritePPF(tagobs,true);
591 PrtTim(">>>> End WritePPF");
592 }
593 if(whattowrt[1]&2) {
594 tagobs = "!" + rootnameout + "_rv.fits";
595 fluct3d.WriteFits(tagobs);
596 PrtTim(">>>> End WriteFits");
597 }
598 if(wslice) {
599 tagobs = rootnameout + "_s_rv.ppf";
600 fluct3d.WriteSlicePPF(tagobs);
601 PrtTim(">>>> End WriteSlicePPF");
602 }
603
604 }
605
606 //-----------------------------------------------------------------
607 {
608 DVList dvl;
609 dvl("Nx") = (int_4)fluct3d.Nx(); dvl("Ny") = (int_4)fluct3d.Ny(); dvl("Nz") = (int_4)fluct3d.Nz();
610 dvl("Dx") = fluct3d.Dx(); dvl("Dy") = fluct3d.Dy(); dvl("Dz") = fluct3d.Dz();
611 dvl("Z") = fluct3d.Zref(); dvl("Zpk") = fluct3d.ZrefPk();
612 dvl("D") = fluct3d.Dref(); dvl("Dpk") = fluct3d.DrefPk();
613 dvl("s8") = sigmaR;
614 dvl("Dtype") = (int_4)use_growth_factor; dvl("Pxfilt") = (int_4)filter_by_pixel;
615 posobs.PutObject(dvl,"siminfo");
616 }
617
618 delete RandGen;
619 PrtTim(">>>> End Of Job");
620
621 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
622 } catch (PException& exc) {
623 cerr<<"cmvginit3d.cc catched PException"<<exc.Msg()<<endl;
624 return 77;
625 } catch (std::exception& sex) {
626 cerr << "cmvginit3d.cc std::exception :"
627 << (string)typeid(sex).name() << "\n msg= "
628 << sex.what() << endl;
629 return 78;
630 } catch (...) {
631 cerr << "cmvginit3d.cc catched unknown (...) exception " << endl;
632 return 79;
633 }
634 //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
635
636 return 0;
637}
638
Note: See TracBrowser for help on using the repository browser.