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

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

Codage remplissage n_tuple avec les variances, Reza 23/09/2010

File size: 3.4 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_, par.rdsamefc_, par.imin_, par.imax_, par.istep_);
71 reader.SetPrintLevel(par.prtlevel_,par.prtmodulo_);
72
73 BRMeanSpecCalculator procms(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
74 procms.SetVarianceLimits(par.vmin_, par.vmax_);
75 BRFFTCalculator procfft(mmgr, par.fgsinglechannel_);
76 if (!par.fgdatafft_) procms.SetMemZAction(MemZA_ProcB);
77
78 FitsCubeWriter wrt(mmgr, par.outpath_, par.nbloc_);
79
80 cout << " specmfib: Starting threads (reader meanSpecCalculator ...) ... " << endl;
81 reader.start();
82 if (par.action_ == "cube3d") wrt.start();
83 else { // Calcul spectre moyenne
84 if (!par.fgdatafft_) procfft.start();
85 procms.start();
86 }
87 usleep(200000);
88 reader.join();
89 if (par.action_ == "cube3d") wrt.join();
90 else {
91 if (!par.fgdatafft_) procfft.join();
92 procms.join();
93 }
94 mmgr.Print(cout);
95 cout << resu ;
96 }
97 catch (std::exception& sex) {
98 cerr << "\n specmfib.cc std::exception :" << (string)typeid(sex).name()
99 << "\n msg= " << sex.what() << endl;
100 rc = 78;
101 }
102 catch (...) {
103 cerr << " specmfib.cc catched unknown (...) exception " << endl;
104 rc = 79;
105 }
106
107 cout << ">>>> specmfib.cc ------- END ----------- RC=" << rc << endl;
108 return rc;
109
110}
111
112
Note: See TracBrowser for help on using the repository browser.