source: Sophya/trunk/AddOn/TAcq/specmfib.cc@ 3881

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

Ajout classe BRFFTCalculator et programme specmfib.cc, Reza 28/08/2010

File size: 3.3 KB
Line 
1// Utilisation de SOPHYA pour faciliter les tests ...
2#include "sopnamsp.h"
3#include "machdefs.h"
4
5/* ----------------------------------------------------------
6 Programme de lecture multifibres, calcul de spectres
7 BAORadio - LAL/IRFU R. Ansari, C. Magneville
8 Septembre 2010
9 ---------------------------------------------------------- */
10
11// include standard c/c++
12#include <iostream>
13#include <string>
14#include <exception>
15
16// include sophya mesure ressource CPU/memoire ...
17#include "resusage.h"
18#include "ctimer.h"
19#include "timing.h"
20#include "timestamp.h"
21#include "strutilxx.h"
22#include "tarrinit.h"
23#include "histinit.h"
24
25#include "brpaqu.h"
26#include "brfitsrd.h"
27#include "brproc.h"
28#include "brdiskw.h"
29
30#include "branap.h"
31
32
33
34//----------------------------------------------------
35//----------------------------------------------------
36int main(int narg, char* arg[])
37{
38
39 TArrayInitiator _inia;
40
41 int rc = 0;
42 try {
43 // Decodage parametres
44 BRAnaParam par;
45 par.action_="mspec";
46 cout << " ===> specmfib.cc: decoding command line arguments " << endl;
47 rc = par.DecodeArgs(narg, arg);
48 if (rc) return rc;
49 rc = par.PaqSizeFromFits();
50 if (rc) return rc;
51 par.Print(cout);
52 if ((par.action_!="cube3d")&&(par.action_!="mspec")) {
53 cout << " !!! specmfib.cc BAD action = " << par.action_ << " possible values: mspec,cube3d" << endl;
54 return 5;
55 }
56
57 cout << " ---------- specmfib.cc Start - Action= " << par.action_ << " ------------- " << endl;
58 ResourceUsage resu;
59 BRPaquet paq(par.paqsize_);
60 uint_4 procsz=sizeof(float)*(paq.DataSize()+4);
61 if ((par.fgdatafft_)||(par.action_=="cube3d")) procsz = 0;
62 cout << " specmfib: Creating MemZoneMgr/threads - PaqSz= " << par.paqsize_
63 << " ProcPaqSz=" << procsz << endl;
64 RAcqMemZoneMgr mmgr(par.nzones_, par.dirlist_.size(), par.npaqinzone_, par.paqsize_, procsz);
65 if (par.action_ == "cube3d") mmgr.SetFinalizedMask((uint_4)MemZS_Saved);
66 else {
67 if (par.fgdatafft_) mmgr.SetFinalizedMask((uint_4)MemZS_ProcA);
68 else mmgr.SetFinalizedMask((uint_4)MemZS_ProcB);
69 }
70 BRMultiFitsReader reader(mmgr, par.dirlist_, false, par.imin_, par.imax_, par.istep_);
71 reader.SetPrintLevel(par.prtlevel_);
72
73 BRMeanSpecCalculator procms(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
74 BRFFTCalculator procfft(mmgr, par.fgsinglechannel_);
75 if (!par.fgdatafft_) procms.SetMemZAction(MemZA_ProcB);
76
77 FitsCubeWriter wrt(mmgr, par.outpath_, par.nbloc_);
78
79 cout << " specmfib: Starting threads (reader meanSpecCalculator ...) ... " << endl;
80 reader.start();
81 if (par.action_ == "cube3d") wrt.start();
82 else { // Calcul spectre moyenne
83 if (!par.fgdatafft_) procfft.start();
84 procms.start();
85 }
86 usleep(200000);
87 reader.join();
88 if (par.action_ == "cube3d") wrt.join();
89 else {
90 if (!par.fgdatafft_) procfft.join();
91 procms.join();
92 }
93 mmgr.Print(cout);
94 cout << resu ;
95 }
96 catch (std::exception& sex) {
97 cerr << "\n specmfib.cc std::exception :" << (string)typeid(sex).name()
98 << "\n msg= " << sex.what() << endl;
99 rc = 78;
100 }
101 catch (...) {
102 cerr << " specmfib.cc catched unknown (...) exception " << endl;
103 rc = 79;
104 }
105
106 cout << ">>>> specmfib.cc ------- END ----------- RC=" << rc << endl;
107 return rc;
108
109}
110
111
Note: See TracBrowser for help on using the repository browser.