[3872] | 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
|
---|
[3939] | 8 | Septembre 2010 - 2011
|
---|
[3872] | 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"
|
---|
[3943] | 28 |
|
---|
| 29 | //JEC 19/1/11 START
|
---|
| 30 | #include "brprocGain.h"
|
---|
| 31 | //JEC END
|
---|
| 32 |
|
---|
[3872] | 33 | #include "brdiskw.h"
|
---|
| 34 |
|
---|
| 35 | #include "branap.h"
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | //----------------------------------------------------
|
---|
| 40 | //----------------------------------------------------
|
---|
| 41 | int main(int narg, char* arg[])
|
---|
| 42 | {
|
---|
| 43 |
|
---|
| 44 | TArrayInitiator _inia;
|
---|
| 45 |
|
---|
| 46 | int rc = 0;
|
---|
| 47 | try {
|
---|
| 48 | // Decodage parametres
|
---|
| 49 | BRAnaParam par;
|
---|
| 50 | par.action_="mspec";
|
---|
| 51 | cout << " ===> specmfib.cc: decoding command line arguments " << endl;
|
---|
| 52 | rc = par.DecodeArgs(narg, arg);
|
---|
| 53 | if (rc) return rc;
|
---|
| 54 | rc = par.PaqSizeFromFits();
|
---|
| 55 | if (rc) return rc;
|
---|
| 56 | par.Print(cout);
|
---|
[3943] | 57 | if ((par.action_!="cube3d")
|
---|
| 58 | &&(par.action_!="mspec")
|
---|
| 59 | &&(par.action_!="gain") //JEC 19/1/11 add gain action
|
---|
| 60 | &&(par.action_!="bproc")
|
---|
| 61 | ) {
|
---|
[3938] | 62 | cout << " !!! specmfib.cc BAD action = " << par.action_ << " possible values: mspec,cube3d,bproc" << endl;
|
---|
[3872] | 63 | return 5;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | cout << " ---------- specmfib.cc Start - Action= " << par.action_ << " ------------- " << endl;
|
---|
| 67 | ResourceUsage resu;
|
---|
| 68 | BRPaquet paq(par.paqsize_);
|
---|
| 69 | uint_4 procsz=sizeof(float)*(paq.DataSize()+4);
|
---|
[3905] | 70 | // if ((par.fgdatafft_)||(par.action_=="cube3d")) procsz = 0;
|
---|
[3872] | 71 | cout << " specmfib: Creating MemZoneMgr/threads - PaqSz= " << par.paqsize_
|
---|
| 72 | << " ProcPaqSz=" << procsz << endl;
|
---|
| 73 | RAcqMemZoneMgr mmgr(par.nzones_, par.dirlist_.size(), par.npaqinzone_, par.paqsize_, procsz);
|
---|
| 74 | if (par.action_ == "cube3d") mmgr.SetFinalizedMask((uint_4)MemZS_Saved);
|
---|
| 75 | else {
|
---|
| 76 | if (par.fgdatafft_) mmgr.SetFinalizedMask((uint_4)MemZS_ProcA);
|
---|
| 77 | else mmgr.SetFinalizedMask((uint_4)MemZS_ProcB);
|
---|
| 78 | }
|
---|
[3883] | 79 | BRMultiFitsReader reader(mmgr, par.dirlist_, par.rdsamefc_, par.imin_, par.imax_, par.istep_);
|
---|
| 80 | reader.SetPrintLevel(par.prtlevel_,par.prtmodulo_);
|
---|
[3872] | 81 |
|
---|
| 82 | BRMeanSpecCalculator procms(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
|
---|
[3886] | 83 | procms.SetVarianceLimits(par.vmin_, par.vmax_);
|
---|
[3943] | 84 | if (par.nbands_>0) procms.SetNumberOfBands(par.nbands_,par.bandfirst_,par.bandlast_);
|
---|
| 85 | //JEC 27/1/11 see below if (par.gainfile_.length()>0) procms.ReadGainFitsFile(par.gainfile_);
|
---|
[3938] | 86 | procms.SetPrintLevel(par.prtlevel_,par.prtmodulo_);
|
---|
[3943] | 87 | if (par.fgdt_) procms.DefineDataTable();
|
---|
[3888] | 88 |
|
---|
[3943] | 89 | BRGainCalculator* procgain_p=NULL;
|
---|
| 90 | if (par.action_=="gain") {
|
---|
| 91 | procgain_p =
|
---|
| 92 | new BRGainCalculator(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
|
---|
| 93 | procgain_p->SetPrintLevel(par.prtlevel_,par.prtmodulo_);
|
---|
[3946] | 94 | if(par.fgfreqfilter_) procgain_p->SetOnMedianFreqFilt();
|
---|
[3943] | 95 | }
|
---|
| 96 |
|
---|
| 97 |
|
---|
[3872] | 98 | BRFFTCalculator procfft(mmgr, par.fgsinglechannel_);
|
---|
[3943] | 99 | if (!par.fgdatafft_) {
|
---|
| 100 | procms.SetMemZAction(MemZA_ProcB);
|
---|
| 101 | if(procgain_p) procgain_p->SetMemZAction(MemZA_ProcB);
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[3905] | 104 | if (par.spec_win_sz_>0) {
|
---|
| 105 | procms.SetSpectraWindowSize(par.spec_win_sz_, par.spw_ext_sz_);
|
---|
[3943] | 106 | procms.SetMaxNbSpecWinFiles(par.nbmax_specwfiles_);
|
---|
| 107 | if(procgain_p){
|
---|
| 108 | procgain_p->SetSpectraWindowSize(par.spec_win_sz_, par.spw_ext_sz_);
|
---|
| 109 | procgain_p->SetMaxNbSpecWinFiles(par.nbmax_specwfiles_);
|
---|
| 110 | }
|
---|
[3905] | 111 | }
|
---|
[3943] | 112 | //JEC 27/1/11 should be done after SetSpectraWindowSize to perform x-checking
|
---|
[3972] | 113 | if (par.gainfile_.length()>0) {
|
---|
| 114 | procms.ReadGainFitsFile(par.gainfile_);
|
---|
| 115 | if(procgain_p){ //JEC 5/4/2011 we can load previous gain...
|
---|
| 116 | procgain_p->ReadGainFitsFile(par.gainfile_);
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
[3943] | 119 |
|
---|
[3872] | 120 | FitsCubeWriter wrt(mmgr, par.outpath_, par.nbloc_);
|
---|
| 121 |
|
---|
[3938] | 122 | BRBaseProcessor* bproc_p=NULL;
|
---|
| 123 | if (par.action_=="bproc") {
|
---|
| 124 | bproc_p = new BRBaseProcessor(mmgr);
|
---|
| 125 | bproc_p->SetPrintLevel(par.prtlevel_,par.prtmodulo_);
|
---|
| 126 | if (!par.fgdatafft_) bproc_p->SetMemZAction(MemZA_ProcB);
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[3943] | 129 | cout << " specmfib: Starting threads (reader + "<< par.action_ << ")" << endl;
|
---|
[3872] | 130 | reader.start();
|
---|
| 131 | if (par.action_ == "cube3d") wrt.start();
|
---|
| 132 | else { // Calcul spectre moyenne
|
---|
| 133 | if (!par.fgdatafft_) procfft.start();
|
---|
[3943] | 134 | //JEC 19/1/11 START add the gain process alternative
|
---|
[3938] | 135 | if (par.action_=="bproc") bproc_p->start();
|
---|
[3943] | 136 | else if (par.action_=="gain") procgain_p->start();
|
---|
[3938] | 137 | else procms.start();
|
---|
[3943] | 138 | //JEC END
|
---|
[3872] | 139 | }
|
---|
| 140 | usleep(200000);
|
---|
| 141 | reader.join();
|
---|
| 142 | if (par.action_ == "cube3d") wrt.join();
|
---|
| 143 | else {
|
---|
| 144 | if (!par.fgdatafft_) procfft.join();
|
---|
[3943] | 145 |
|
---|
| 146 | //JEC 19/1/11 START add the gain process alternative
|
---|
[3938] | 147 | if (par.action_=="bproc") bproc_p->join();
|
---|
[3943] | 148 | else if (par.action_=="gain") procgain_p->join();
|
---|
[3938] | 149 | else procms.join();
|
---|
[3943] | 150 | //JEC END
|
---|
[3872] | 151 | }
|
---|
| 152 | mmgr.Print(cout);
|
---|
[3938] | 153 | if (bproc_p) delete bproc_p;
|
---|
[3943] | 154 | if (procgain_p) delete procgain_p;
|
---|
[3872] | 155 | cout << resu ;
|
---|
| 156 | }
|
---|
| 157 | catch (std::exception& sex) {
|
---|
| 158 | cerr << "\n specmfib.cc std::exception :" << (string)typeid(sex).name()
|
---|
| 159 | << "\n msg= " << sex.what() << endl;
|
---|
| 160 | rc = 78;
|
---|
| 161 | }
|
---|
| 162 | catch (...) {
|
---|
| 163 | cerr << " specmfib.cc catched unknown (...) exception " << endl;
|
---|
| 164 | rc = 79;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | cout << ">>>> specmfib.cc ------- END ----------- RC=" << rc << endl;
|
---|
| 168 | return rc;
|
---|
| 169 |
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 |
|
---|