source: Sophya/trunk/Cosmo/RadioBeam/calcpk.cc@ 3785

Last change on this file since 3785 was 3783, checked in by ansari, 15 years ago

Ajout des programmes calcpk.cc calcpk2.cc syncube.cc tjyk.cc (voir fichier README) Reza 15/06/2010

File size: 2.8 KB
Line 
1/* ------------------------ Projet BAORadio --------------------
2 Programme de calcul du spectre de puissance (3D) a partir d'un
3 cube de donnees (delta rho/rho ou delta T/T)
4 R. Ansari , C. Magneville - Juin 2010
5
6 Usage: calcpk In3DMap OutPk [InRenormFactor]
7--------------------------------------------------------------- */
8
9#include "machdefs.h"
10#include "sopnamsp.h"
11#include <iostream>
12#include <string>
13#include <math.h>
14
15#include <typeinfo>
16
17#include "specpk.h"
18#include "histats.h"
19
20#include "qhist.h"
21#include "histinit.h"
22#include "fftwserver.h"
23#include "randr48.h"
24
25#include "ctimer.h"
26
27typedef ThSDR48RandGen RandomGenerator ;
28
29//-------------------------------------------------------------------------
30// ------------------ MAIN PROGRAM ------------------------------
31//-------------------------------------------------------------------------
32int main(int narg, const char* arg[])
33{
34 if (narg<3) {
35 cout << " Usage: calcpk In3DMap OutPk [InRenormFactor] " << endl;
36 return 1;
37 }
38 Timer tm("calcpk");
39 int rc = 0;
40 try {
41 string inppfname = arg[1];
42 string outname = arg[2];
43 r_4 renfact=1.;
44 bool fgrenfact=false;
45 if (narg>3) {
46 renfact=atof(arg[3]);
47 fgrenfact=true;
48 }
49 cout << "calcpk[1] : reading 3D map from file " << inppfname << endl;
50 TArray<r_4> inmap;
51 {
52 PInPersist pin(inppfname);
53 pin >> inmap;
54 }
55 if (fgrenfact) inmap *= renfact;
56 double mean, sigma;
57 MeanSigma(inmap, mean, sigma);
58 cout << " InMap sizes " << inmap.InfoString() << endl;
59 inmap.Show();
60 cout << " Mean=" << mean << " Sigma=" << sigma << endl;
61 tm.Split(" After read ");
62
63 cout << "calcpk[2] : computing 3D Fourier coefficients ... " << endl;
64 FFTWServer ffts;
65 TArray< complex<r_4> > four3d;
66 ffts.FFTForward(inmap, four3d);
67 tm.Split(" After FFTForward ");
68
69 cout << "calcpk[3] : computing power spectrum ... " << endl;
70 RandomGenerator rg;
71 Four3DPk pkc(four3d, rg);
72
73 HProf hp = pkc.ComputePk(0.,256);
74 {
75 cout << "calcpk[4] : writing profile P(k) to PPF file " << outname << endl;
76 POutPersist po(outname);
77 po << hp;
78 }
79 tm.Split(" Done CalcP(k) ");
80 } // End of try bloc
81 catch (PThrowable & exc) { // catching SOPHYA exceptions
82 cerr << " calcpk.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
83 << "\n...exc.Msg= " << exc.Msg() << endl;
84 rc = 99;
85 }
86 catch (std::exception & e) { // catching standard C++ exceptions
87 cerr << " calcpk.cc: Catched std::exception " << " - what()= " << e.what() << endl;
88 rc = 98;
89 }
90 catch (...) { // catching other exceptions
91 cerr << " calcpk.cc: some other exception (...) was caught ! " << endl;
92 rc = 97;
93 }
94 cout << " ==== End of calcpk.cc program Rc= " << rc << endl;
95 return rc;
96}
Note: See TracBrowser for help on using the repository browser.