[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;
|
---|
| 16 | imin_=imax_=0;
|
---|
| 17 | istep_=1;
|
---|
| 18 | paqsize_=16424;
|
---|
| 19 | nzones_=nzon;
|
---|
| 20 | npaqinzone_=npaqz;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | /* --Methode-- */
|
---|
| 24 | int BRAnaParam::DecodeArgs(int narg, char* arg[])
|
---|
| 25 | {
|
---|
| 26 | if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false);
|
---|
| 27 | if (narg<5) return Usage(true);
|
---|
| 28 |
|
---|
| 29 | bool okarg=false;
|
---|
| 30 | int ka=1;
|
---|
| 31 | while (ka<(narg-1)) {
|
---|
| 32 | if (strcmp(arg[ka],"-act")==0) {
|
---|
| 33 | action_=arg[ka+1];
|
---|
| 34 | ka+=2;
|
---|
| 35 | }
|
---|
| 36 | else if (strcmp(arg[ka],"-out")==0) {
|
---|
| 37 | outpath_=arg[ka+1];
|
---|
| 38 | ka+=2;
|
---|
| 39 | }
|
---|
| 40 | else if (strcmp(arg[ka],"-nmean")==0) {
|
---|
| 41 | nmean_=atoi(arg[ka+1]);
|
---|
| 42 | ka+=2;
|
---|
| 43 | }
|
---|
| 44 | else if (strcmp(arg[ka],"-zones")==0) {
|
---|
| 45 | int nzon=4;
|
---|
| 46 | int npaqz=128;
|
---|
| 47 | sscanf(arg[ka+1],"%d,%d",&nzon,&npaqz);
|
---|
| 48 | nzones_=nzon; npaqinzone_=npaqz;
|
---|
| 49 | ka+=2;
|
---|
| 50 | }
|
---|
| 51 | else if (strcmp(arg[ka],"-in")==0) {
|
---|
| 52 | if ((narg-ka)<4) {
|
---|
| 53 | cout << " BRAnaParam::DecodeArgs() / Argument error " << endl;
|
---|
| 54 | return Usage(true);
|
---|
| 55 | }
|
---|
| 56 | sscanf(arg[ka+1],"%d,%d,%d",&imin_,&imax_,&istep_); ka+=2;
|
---|
| 57 | while(ka<(narg-3)) {
|
---|
| 58 | string inpath = arg[ka];
|
---|
| 59 | if (inpath.size()<1) inpath="./";
|
---|
| 60 | if (inpath[inpath.size()-1]!='/') inpath[inpath.size()-1]='/';
|
---|
| 61 | vector<string> fiblist;
|
---|
| 62 | string sa1 = arg[ka+1];
|
---|
| 63 | FillVStringFrString(sa1, fiblist, ',');
|
---|
| 64 | char dbuff[32];
|
---|
| 65 | for(size_t i=0; i<fiblist.size(); i++) {
|
---|
| 66 | sprintf(dbuff,"Fiber%d/",(int)atoi(fiblist[i].c_str()));
|
---|
| 67 | dirlist_.push_back(inpath+dbuff);
|
---|
| 68 | }
|
---|
| 69 | ka += 2;
|
---|
| 70 | }
|
---|
| 71 | okarg=true;
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 | if (!okarg) {
|
---|
| 75 | cout << " BRAnaParam::DecodeArgs() / Argument error " << endl;
|
---|
| 76 | return Usage(true);
|
---|
| 77 | }
|
---|
| 78 | return 0;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | /* --Methode-- */
|
---|
| 82 | int BRAnaParam::Usage(bool fgshort)
|
---|
| 83 | {
|
---|
| 84 | cout << " --- BRAnaParam : Reading/Processing BAORadio FITS files parameters " << endl;
|
---|
| 85 | cout << " Usage: prgname [-act ACT] [-out OutPath] [-nmean NMean] [-zones NZones,nPaqinZone] \n"
|
---|
| 86 | << " -in Imin,Imax,Istep InPath FiberList [InPath2 FiberList2 InPath3 FiberList3 ...] \n" << endl;
|
---|
| 87 | if (fgshort) {
|
---|
| 88 | cout << " prgname -h for detailed instructions" << endl;
|
---|
| 89 | return 5;
|
---|
| 90 | }
|
---|
| 91 | cout << " -act Action: Not YET used \n"
|
---|
| 92 | << " -out OutPath: Output directory name \n"
|
---|
| 93 | << " -nmean NMean: Number of packet used for spectra/visibility computation \n"
|
---|
| 94 | << " -zones NZones,NbPaqinZone : Number of Zones and number of paquets in one zone \n"
|
---|
| 95 | << " -in : input files/directory definition : \n"
|
---|
| 96 | << " Imin,Imax,Istep: fits files signalII.fits Imin<=II<=Imax Istep=increment \n"
|
---|
| 97 | << " InPath: Input directerory fits files in InPath/FiberJJ directory \n"
|
---|
| 98 | << " FiberList: List of fiber numbers (JJ - Ex: 2,1,4 ) \n" << endl;
|
---|
| 99 | return 1;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | /* --Fonction-- */
|
---|
| 103 | int BRAnaParam::PaqSizeFromFits()
|
---|
| 104 | {
|
---|
| 105 | uint_4 paqsz, npaqf;
|
---|
| 106 | char flnm[1024];
|
---|
| 107 | sprintf(flnm,"%s/signal%d.fits",dirlist_[0].c_str(),imin_);
|
---|
| 108 | return DecodeMiniFitsHeader(flnm,paqsize_, npaqf);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /* --Fonction-- */
|
---|
| 112 | ostream& BRAnaParam::Print(ostream& os)
|
---|
| 113 | {
|
---|
| 114 | os << " BRAnaParam::Print() dirlist_.size()=" << dirlist_.size() << " Input directories: " << endl;
|
---|
| 115 | for(size_t k=0; k< dirlist_.size(); k++)
|
---|
| 116 | cout << k+1 << " : " << dirlist_[k] << endl;
|
---|
| 117 | cout << " IMin= " << imin_ << " IMax= " << imax_ << " IStep= " << istep_ << endl;
|
---|
| 118 | cout << " OutPath= " << outpath_ << endl;
|
---|
| 119 | cout << " NMean=" << nmean_ << " PaqSize=" << paqsize_ << " - NZones=" << nzones_
|
---|
| 120 | << " NPaqZone=" << npaqinzone_ << endl;
|
---|
| 121 | return os;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | /* --Fonction-- */
|
---|
| 125 | int BRAnaParam::DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq)
|
---|
| 126 | {
|
---|
| 127 | cout << " DecodeMiniFitsHeader - Opening file: " << filename << endl;
|
---|
| 128 | MiniFITSFile mff(filename, MF_Read);
|
---|
| 129 | cout << "DecodeMiniFitsHeader()... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1()
|
---|
| 130 | << " NAxis2=" << mff.NAxis2() << endl;
|
---|
| 131 | paqsz = mff.NAxis1();
|
---|
| 132 | npaq = mff.NAxis2();
|
---|
| 133 | return 0;
|
---|
| 134 | }
|
---|
| 135 |
|
---|