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

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

Ajout classes / programmes de calcul d'effet de lobe sur les radio-sources, Reza 25/06/2010

File size: 3.1 KB
RevLine 
[3783]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"
[3787]21#include "lobe.h"
22
[3783]23#include "histinit.h"
24#include "fftwserver.h"
25#include "randr48.h"
26
27#include "ctimer.h"
28
29typedef ThSDR48RandGen RandomGenerator ;
30
31//-------------------------------------------------------------------------
32// ------------------ MAIN PROGRAM ------------------------------
33//-------------------------------------------------------------------------
34int main(int narg, const char* arg[])
35{
36 if (narg<3) {
[3787]37 cout << " Usage: calcpk In3DMap OutPk [InRenormFactor] [PixNoiseLevel] " << endl;
[3783]38 return 1;
39 }
40 Timer tm("calcpk");
41 int rc = 0;
42 try {
43 string inppfname = arg[1];
44 string outname = arg[2];
[3787]45 double renfact=1.;
[3783]46 bool fgrenfact=false;
47 if (narg>3) {
48 renfact=atof(arg[3]);
49 fgrenfact=true;
50 }
[3787]51 double pixsignoise = 0.;
52 bool fgaddnoise=false;
53 if (narg>4) {
54 pixsignoise=atof(arg[3]);
55 fgaddnoise=true;
56 }
57
[3783]58 cout << "calcpk[1] : reading 3D map from file " << inppfname << endl;
59 TArray<r_4> inmap;
60 {
61 PInPersist pin(inppfname);
62 pin >> inmap;
63 }
[3787]64 if (fgrenfact) {
65 cout << " Applying RenormFactor inmap = inmap*rfact, rfact=" << renfact << endl;
66 inmap *= renfact;
67 }
[3783]68 double mean, sigma;
69 MeanSigma(inmap, mean, sigma);
70 cout << " InMap sizes " << inmap.InfoString() << endl;
71 inmap.Show();
72 cout << " Mean=" << mean << " Sigma=" << sigma << endl;
[3787]73 if (fgaddnoise) {
74 BeamEffect::AddNoise(inmap, pixsignoise);
75 }
76
[3783]77 tm.Split(" After read ");
78
79 cout << "calcpk[2] : computing 3D Fourier coefficients ... " << endl;
80 FFTWServer ffts;
81 TArray< complex<r_4> > four3d;
82 ffts.FFTForward(inmap, four3d);
83 tm.Split(" After FFTForward ");
84
85 cout << "calcpk[3] : computing power spectrum ... " << endl;
86 RandomGenerator rg;
87 Four3DPk pkc(four3d, rg);
88
89 HProf hp = pkc.ComputePk(0.,256);
90 {
91 cout << "calcpk[4] : writing profile P(k) to PPF file " << outname << endl;
92 POutPersist po(outname);
93 po << hp;
94 }
95 tm.Split(" Done CalcP(k) ");
96 } // End of try bloc
97 catch (PThrowable & exc) { // catching SOPHYA exceptions
98 cerr << " calcpk.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
99 << "\n...exc.Msg= " << exc.Msg() << endl;
100 rc = 99;
101 }
102 catch (std::exception & e) { // catching standard C++ exceptions
103 cerr << " calcpk.cc: Catched std::exception " << " - what()= " << e.what() << endl;
104 rc = 98;
105 }
106 catch (...) { // catching other exceptions
107 cerr << " calcpk.cc: some other exception (...) was caught ! " << endl;
108 rc = 97;
109 }
110 cout << " ==== End of calcpk.cc program Rc= " << rc << endl;
111 return rc;
112}
Note: See TracBrowser for help on using the repository browser.