| 1 | // Utilisation de SOPHYA pour faciliter les tests ... | 
|---|
| 2 | #include "sopnamsp.h" | 
|---|
| 3 | #include "machdefs.h" | 
|---|
| 4 |  | 
|---|
| 5 | /* ---------------------------------------------------------- | 
|---|
| 6 | Programme de lecture / calcul de visibilite multi-canaux | 
|---|
| 7 | BAORadio -   LAL/IRFU      R. Ansari, C. Magneville | 
|---|
| 8 | 2009-2011 | 
|---|
| 9 | ---------------------------------------------------------- */ | 
|---|
| 10 | /*! | 
|---|
| 11 | \ingroup TAcq | 
|---|
| 12 | \file vismfib.cc | 
|---|
| 13 |  | 
|---|
| 14 | \brief Computation of visibilities from FITS raw of fft data files. | 
|---|
| 15 |  | 
|---|
| 16 | This program uses the BRVisCalcGroup / BRVisibilityCalculator and BRMultiFitsReader classes | 
|---|
| 17 | to compute visibility matrices for raw or FFT data from FITS files containing data in BRPaquet | 
|---|
| 18 | format. The BRFFTCalculator class is used to compute fourier coefficients on raw data and | 
|---|
| 19 | BRAnaParam class is used for defining and decoding the program run parameters. | 
|---|
| 20 |  | 
|---|
| 21 | \verbatim | 
|---|
| 22 | csh> vismfib | 
|---|
| 23 | ===> visimfib.cc: decoding command line arguments | 
|---|
| 24 | --- BRAnaParam : Reading/Processing BAORadio FITS files parameters | 
|---|
| 25 | Usage:  prgname [-act ACT] [-out OutPath] [-fitsout] | 
|---|
| 26 | [-nmean NMean] [-tmint dtime] [-zones NZones,nPaqinZone] | 
|---|
| 27 | [-nbloc NBloc] [-freq NumFreqMin,NumFreqMax,NBinFreq] | 
|---|
| 28 | [-prt lev,modulo,mod2] [-nvcal n] [-nthr n] [-nosfc] | 
|---|
| 29 | [-singlechan] [-twochan] [-fftdata] [-rawdata] | 
|---|
| 30 | [-freqfilter medhw] [-gain filename] [-varcut min,max] [-nband nband,first,last] | 
|---|
| 31 | [-freqfilter] [-gain filename] [-varcut min,max] [-nband nband,first,last] | 
|---|
| 32 | [-tmproc hh:mm:ss,nseconds] [-fdtpaq] [-fdtms] [-tspwin wsz,extsz,nfiles] | 
|---|
| 33 | -in Imin,Imax,Istep InPath FiberList [InPath2 FiberList2 InPath3 FiberList3 ...] | 
|---|
| 34 |  | 
|---|
| 35 | prgname -h for detailed instructions | 
|---|
| 36 |  | 
|---|
| 37 | \endverbatim | 
|---|
| 38 | */ | 
|---|
| 39 |  | 
|---|
| 40 | // include standard c/c++ | 
|---|
| 41 | #include <iostream> | 
|---|
| 42 | #include <string> | 
|---|
| 43 | #include <exception> | 
|---|
| 44 |  | 
|---|
| 45 | // include sophya mesure ressource CPU/memoire ... | 
|---|
| 46 | #include "resusage.h" | 
|---|
| 47 | #include "ctimer.h" | 
|---|
| 48 | #include "timing.h" | 
|---|
| 49 | #include "timestamp.h" | 
|---|
| 50 | #include "strutilxx.h" | 
|---|
| 51 | #include "tarrinit.h" | 
|---|
| 52 | #include "histinit.h" | 
|---|
| 53 |  | 
|---|
| 54 | #include "brpaqu.h" | 
|---|
| 55 | #include "brfitsrd.h" | 
|---|
| 56 | #include "brproc.h" | 
|---|
| 57 | #include "brviscalc.h" | 
|---|
| 58 | #include "brdiskw.h" | 
|---|
| 59 |  | 
|---|
| 60 | #include "branap.h" | 
|---|
| 61 |  | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 | //---------------------------------------------------- | 
|---|
| 65 | //---------------------------------------------------- | 
|---|
| 66 | int main(int narg, char* arg[]) | 
|---|
| 67 | { | 
|---|
| 68 |  | 
|---|
| 69 | TArrayInitiator  _inia; | 
|---|
| 70 |  | 
|---|
| 71 | int rc = 0; | 
|---|
| 72 | try { | 
|---|
| 73 | // Decodage parametres | 
|---|
| 74 | BRAnaParam par; | 
|---|
| 75 | cout << " ===> visimfib.cc: decoding command line arguments " << endl; | 
|---|
| 76 | rc = par.DecodeArgs(narg, arg); | 
|---|
| 77 | if (rc) return rc; | 
|---|
| 78 | rc = par.PaqSizeFromFits(); | 
|---|
| 79 | if (rc) return rc; | 
|---|
| 80 | par.Print(cout); | 
|---|
| 81 | if ((par.action_!="cube3d")&&(par.action_!="vis")&&(par.action_!="viscktt")) { | 
|---|
| 82 | cout << " !!! visimfib.cc  BAD action = " << par.action_ << " possible values: vis,viscktt,cube3d" << endl; | 
|---|
| 83 | return 5; | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 | cout << " ---------- visimfib.cc Start - Action= " << par.action_ << " ------------- " << endl; | 
|---|
| 87 | ResourceUsage resu; | 
|---|
| 88 |  | 
|---|
| 89 | BRPaquet paq(par.paqsize_); | 
|---|
| 90 | uint_4 procsz=sizeof(float)*(paq.DataSize()+4); | 
|---|
| 91 | if ((par.fgdatafft_)||(par.action_=="cube3d")) procsz = 0; | 
|---|
| 92 | cout << " visimfib: Creating MemZoneMgr/processing threads - PaqSz= " << par.paqsize_ | 
|---|
| 93 | << " ProcPaqSz=" << procsz << endl; | 
|---|
| 94 |  | 
|---|
| 95 | RAcqMemZoneMgr mmgr(par.nzones_, par.dirlist_.size(), par.npaqinzone_, par.paqsize_, procsz); | 
|---|
| 96 |  | 
|---|
| 97 | BRMultiFitsReader reader(mmgr, par.dirlist_, par.rdsamefc_, par.imin_, par.imax_, par.istep_); | 
|---|
| 98 | reader.SetPrintLevel(par.prtlevel_,par.prtmodulo_); | 
|---|
| 99 |  | 
|---|
| 100 | /*    BRVisibilityCalculator proc(mmgr, par.outpath_, par.nmean_, par.nthreads_); | 
|---|
| 101 | proc.SelectFreqBinning(par.freqmin_, par.freqmax_, par.nbinfreq_);  */ | 
|---|
| 102 | BRVisCalcGroup procg(par.nbcalgrp_, mmgr, par.outpath_, par.nmean_, 0, 999999999, false, par.nthreads_); | 
|---|
| 103 | procg.SelectFreqBinning(par.freqmin_, par.freqmax_, par.nbinfreq_); | 
|---|
| 104 |  | 
|---|
| 105 | if (par.action_ == "viscktt")  procg.ActivateTimeTagCheck(par.TotalNPaquets()); | 
|---|
| 106 | if (par.fgfitsout_) procg.SetFitsOutput(); | 
|---|
| 107 | if (par.fgtimeinterval_)  procg.SetTimeIntervalMode(par.timeinterval_); | 
|---|
| 108 | procg.SetPrintLevel(par.prtlevel_,par.prtmodulo2_); | 
|---|
| 109 | BRFFTCalculator procfft(mmgr, par.fgsinglechannel_); | 
|---|
| 110 |  | 
|---|
| 111 | // On determine MemZaction pour chaque processeur et le finalizemask en fonction du traitement demande | 
|---|
| 112 | if (par.action_ == "cube3d")  mmgr.SetFinalizedMask((uint_4)MemZS_Saved); | 
|---|
| 113 | else { | 
|---|
| 114 | MemZStatus mfmask=MemZS_ProcA; | 
|---|
| 115 | if (par.fgdatafft_) mfmask=procg.SetMemZAction(MemZA_ProcA); | 
|---|
| 116 | else { | 
|---|
| 117 | mfmask=procg.SetMemZAction(MemZA_ProcB); | 
|---|
| 118 | procg.SetRawData(); | 
|---|
| 119 | } | 
|---|
| 120 | mmgr.SetFinalizedMask((uint_4)mfmask); | 
|---|
| 121 | } | 
|---|
| 122 |  | 
|---|
| 123 | FitsCubeWriter wrt(mmgr, par.outpath_, par.nbloc_); | 
|---|
| 124 | //    BRBaseProcessor proc(mmgr); | 
|---|
| 125 |  | 
|---|
| 126 | cout << " visimfib: Starting threads (reader procVisi) ... " << endl; | 
|---|
| 127 | reader.start(); | 
|---|
| 128 | if (par.action_ == "cube3d")   wrt.start(); | 
|---|
| 129 | else  { | 
|---|
| 130 | if (!par.fgdatafft_)  procfft.start(); | 
|---|
| 131 | procg.start(); | 
|---|
| 132 | } | 
|---|
| 133 | usleep(200000); | 
|---|
| 134 | reader.join(); | 
|---|
| 135 | if (par.action_ == "cube3d")  wrt.join(); | 
|---|
| 136 | else { | 
|---|
| 137 | if (!par.fgdatafft_)  procfft.join(); | 
|---|
| 138 | procg.join(); | 
|---|
| 139 | } | 
|---|
| 140 | mmgr.Print(cout); | 
|---|
| 141 | cout << resu ; | 
|---|
| 142 | } | 
|---|
| 143 | catch (std::exception& sex) { | 
|---|
| 144 | cerr << "\n visimfib.cc std::exception :"  << (string)typeid(sex).name() | 
|---|
| 145 | << "\n msg= " << sex.what() << endl; | 
|---|
| 146 | rc = 78; | 
|---|
| 147 | } | 
|---|
| 148 | catch (...) { | 
|---|
| 149 | cerr << " visimfib.cc catched unknown (...) exception  " << endl; | 
|---|
| 150 | rc = 79; | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 | cout << ">>>> visimfib.cc ------- END ----------- RC=" << rc << endl; | 
|---|
| 154 | return rc; | 
|---|
| 155 |  | 
|---|
| 156 | } | 
|---|
| 157 |  | 
|---|
| 158 |  | 
|---|