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