source: Sophya/trunk/AddOn/TAcq/branap.cc@ 3691

Last change on this file since 3691 was 3688, checked in by ansari, 16 years ago

Introduction de la classe FitsCubeWriter - Reza 28/11/2009

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