[3704] | 1 | #include <stdlib.h>
|
---|
| 2 | #include <string.h>
|
---|
| 3 |
|
---|
[3687] | 4 | #include "branap.h"
|
---|
| 5 | #include "minifits.h"
|
---|
| 6 | #include "strutilxx.h"
|
---|
| 7 | #include "sopnamsp.h"
|
---|
| 8 |
|
---|
| 9 | //--------------------------------------------------------------
|
---|
| 10 | // Projet BAORadio - (C) LAL/IRFU 2008-2010
|
---|
| 11 | // Classe de gestion des parametres programmes d'analyse
|
---|
| 12 | //--------------------------------------------------------------
|
---|
| 13 |
|
---|
| 14 | /* --Methode-- */
|
---|
| 15 | BRAnaParam::BRAnaParam(uint_4 nmean, uint_4 nzon, uint_4 npaqz)
|
---|
| 16 | {
|
---|
| 17 | outpath_="./";
|
---|
| 18 | nmean_=nmean;
|
---|
[3688] | 19 | nbloc_=1;
|
---|
[3687] | 20 | imin_=imax_=0;
|
---|
| 21 | istep_=1;
|
---|
[3688] | 22 | freqmin_=freqmax_=0;
|
---|
| 23 | nbinfreq_=1;
|
---|
[3687] | 24 | paqsize_=16424;
|
---|
| 25 | nzones_=nzon;
|
---|
| 26 | npaqinzone_=npaqz;
|
---|
[3688] | 27 | prtlevel_=0;
|
---|
[3687] | 28 | }
|
---|
| 29 |
|
---|
| 30 | /* --Methode-- */
|
---|
| 31 | int BRAnaParam::DecodeArgs(int narg, char* arg[])
|
---|
| 32 | {
|
---|
| 33 | if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false);
|
---|
| 34 | if (narg<5) return Usage(true);
|
---|
| 35 |
|
---|
| 36 | bool okarg=false;
|
---|
| 37 | int ka=1;
|
---|
| 38 | while (ka<(narg-1)) {
|
---|
| 39 | if (strcmp(arg[ka],"-act")==0) {
|
---|
| 40 | action_=arg[ka+1];
|
---|
| 41 | ka+=2;
|
---|
| 42 | }
|
---|
| 43 | else if (strcmp(arg[ka],"-out")==0) {
|
---|
| 44 | outpath_=arg[ka+1];
|
---|
[3688] | 45 | size_t lenp=outpath_.size();
|
---|
| 46 | if ((lenp>0)&&(outpath_[lenp-1]!='/')) outpath_+='/';
|
---|
[3687] | 47 | ka+=2;
|
---|
| 48 | }
|
---|
| 49 | else if (strcmp(arg[ka],"-nmean")==0) {
|
---|
| 50 | nmean_=atoi(arg[ka+1]);
|
---|
| 51 | ka+=2;
|
---|
| 52 | }
|
---|
[3688] | 53 | else if (strcmp(arg[ka],"-nbloc")==0) {
|
---|
| 54 | nbloc_=atoi(arg[ka+1]);
|
---|
| 55 | ka+=2;
|
---|
| 56 | }
|
---|
| 57 | else if (strcmp(arg[ka],"-freq")==0) {
|
---|
| 58 | sscanf(arg[ka+1],"%d,%d,%d",&freqmin_,&freqmax_,&nbinfreq_);
|
---|
| 59 | ka+=2;
|
---|
| 60 | }
|
---|
[3687] | 61 | else if (strcmp(arg[ka],"-zones")==0) {
|
---|
| 62 | int nzon=4;
|
---|
| 63 | int npaqz=128;
|
---|
| 64 | sscanf(arg[ka+1],"%d,%d",&nzon,&npaqz);
|
---|
| 65 | nzones_=nzon; npaqinzone_=npaqz;
|
---|
| 66 | ka+=2;
|
---|
| 67 | }
|
---|
[3688] | 68 | else if (strcmp(arg[ka],"-prtlev")==0) {
|
---|
| 69 | prtlevel_=atoi(arg[ka+1]);
|
---|
| 70 | ka+=2;
|
---|
| 71 | }
|
---|
[3687] | 72 | else if (strcmp(arg[ka],"-in")==0) {
|
---|
| 73 | if ((narg-ka)<4) {
|
---|
| 74 | cout << " BRAnaParam::DecodeArgs() / Argument error " << endl;
|
---|
| 75 | return Usage(true);
|
---|
| 76 | }
|
---|
| 77 | sscanf(arg[ka+1],"%d,%d,%d",&imin_,&imax_,&istep_); ka+=2;
|
---|
[3688] | 78 | while(ka<(narg-1)) {
|
---|
[3687] | 79 | string inpath = arg[ka];
|
---|
[3688] | 80 | size_t lenp=inpath.size();
|
---|
| 81 | if (lenp<1) inpath="./";
|
---|
| 82 | if ((lenp>0)&&(inpath[lenp-1]!='/')) inpath+='/';
|
---|
[3687] | 83 | vector<string> fiblist;
|
---|
| 84 | string sa1 = arg[ka+1];
|
---|
| 85 | FillVStringFrString(sa1, fiblist, ',');
|
---|
| 86 | char dbuff[32];
|
---|
| 87 | for(size_t i=0; i<fiblist.size(); i++) {
|
---|
| 88 | sprintf(dbuff,"Fiber%d/",(int)atoi(fiblist[i].c_str()));
|
---|
| 89 | dirlist_.push_back(inpath+dbuff);
|
---|
| 90 | }
|
---|
| 91 | ka += 2;
|
---|
| 92 | }
|
---|
| 93 | okarg=true;
|
---|
| 94 | }
|
---|
[3688] | 95 | else ka++;
|
---|
[3687] | 96 | }
|
---|
[3688] | 97 |
|
---|
[3687] | 98 | if (!okarg) {
|
---|
| 99 | cout << " BRAnaParam::DecodeArgs() / Argument error " << endl;
|
---|
| 100 | return Usage(true);
|
---|
| 101 | }
|
---|
| 102 | return 0;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | /* --Methode-- */
|
---|
| 106 | int BRAnaParam::Usage(bool fgshort)
|
---|
| 107 | {
|
---|
| 108 | cout << " --- BRAnaParam : Reading/Processing BAORadio FITS files parameters " << endl;
|
---|
| 109 | cout << " Usage: prgname [-act ACT] [-out OutPath] [-nmean NMean] [-zones NZones,nPaqinZone] \n"
|
---|
[3700] | 110 | << " [-nbloc NBloc] [-freq NumFreqMin,NumFreqMax,NBinFreq] [-prtlev lev] \n"
|
---|
[3687] | 111 | << " -in Imin,Imax,Istep InPath FiberList [InPath2 FiberList2 InPath3 FiberList3 ...] \n" << endl;
|
---|
| 112 | if (fgshort) {
|
---|
| 113 | cout << " prgname -h for detailed instructions" << endl;
|
---|
| 114 | return 5;
|
---|
| 115 | }
|
---|
[3705] | 116 | cout << " -act Action: cube3d or vis or viscktt \n"
|
---|
| 117 | << " cube3d: create 3D fits cubes, vis: compute visibilites, \n"
|
---|
[3706] | 118 | << " viscktt: compute visibilities and check TimeTag/FrameCounter\n "
|
---|
[3687] | 119 | << " -out OutPath: Output directory name \n"
|
---|
| 120 | << " -nmean NMean: Number of packet used for spectra/visibility computation \n"
|
---|
[3688] | 121 | << " -nbloc NBloc: Number of MemMgr blocs in output file\n"
|
---|
[3687] | 122 | << " -zones NZones,NbPaqinZone : Number of Zones and number of paquets in one zone \n"
|
---|
[3688] | 123 | << " -freq NumFreqMin,NumFreqMax,NBinFreq : Frequency zone and number of bins \n"
|
---|
[3700] | 124 | << " -prtlev lev : Print level (0,1,2...) \n"
|
---|
[3687] | 125 | << " -in : input files/directory definition : \n"
|
---|
| 126 | << " Imin,Imax,Istep: fits files signalII.fits Imin<=II<=Imax Istep=increment \n"
|
---|
| 127 | << " InPath: Input directerory fits files in InPath/FiberJJ directory \n"
|
---|
| 128 | << " FiberList: List of fiber numbers (JJ - Ex: 2,1,4 ) \n" << endl;
|
---|
| 129 | return 1;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | /* --Fonction-- */
|
---|
| 133 | int BRAnaParam::PaqSizeFromFits()
|
---|
| 134 | {
|
---|
| 135 | uint_4 paqsz, npaqf;
|
---|
| 136 | char flnm[1024];
|
---|
| 137 | sprintf(flnm,"%s/signal%d.fits",dirlist_[0].c_str(),imin_);
|
---|
[3707] | 138 | return DecodeMiniFitsHeader(flnm,paqsize_, npaqinfile_);
|
---|
[3687] | 139 | }
|
---|
| 140 |
|
---|
| 141 | /* --Fonction-- */
|
---|
| 142 | ostream& BRAnaParam::Print(ostream& os)
|
---|
| 143 | {
|
---|
| 144 | os << " BRAnaParam::Print() dirlist_.size()=" << dirlist_.size() << " Input directories: " << endl;
|
---|
| 145 | for(size_t k=0; k< dirlist_.size(); k++)
|
---|
| 146 | cout << k+1 << " : " << dirlist_[k] << endl;
|
---|
| 147 | cout << " IMin= " << imin_ << " IMax= " << imax_ << " IStep= " << istep_ << endl;
|
---|
| 148 | cout << " OutPath= " << outpath_ << endl;
|
---|
[3688] | 149 | cout << " Action=" << action_ << " NMean=" << nmean_ << " NBloc=" << nbloc_ << endl;
|
---|
| 150 | cout << " FreqMin= " << freqmin_ << " FreqMax= " << freqmax_ << " NBinFreq= " << nbinfreq_ << endl;
|
---|
| 151 | cout << " PaqSize=" << paqsize_ << " - NZones=" << nzones_ << " NPaqZone=" << npaqinzone_
|
---|
| 152 | << " PrtLevel=" << prtlevel_ << endl;
|
---|
[3687] | 153 | return os;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | /* --Fonction-- */
|
---|
| 157 | int BRAnaParam::DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq)
|
---|
| 158 | {
|
---|
| 159 | cout << " DecodeMiniFitsHeader - Opening file: " << filename << endl;
|
---|
| 160 | MiniFITSFile mff(filename, MF_Read);
|
---|
| 161 | cout << "DecodeMiniFitsHeader()... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1()
|
---|
| 162 | << " NAxis2=" << mff.NAxis2() << endl;
|
---|
| 163 | paqsz = mff.NAxis1();
|
---|
| 164 | npaq = mff.NAxis2();
|
---|
| 165 | return 0;
|
---|
| 166 | }
|
---|
| 167 |
|
---|