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

Last change on this file since 3698 was 3692, checked in by ansari, 16 years ago

Calcul visibilites presque complet (classe BRVisibilityCalculator) Reza 29/11/2009

File size: 5.1 KB
Line 
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;
16 nbloc_=1;
17 imin_=imax_=0;
18 istep_=1;
19 freqmin_=freqmax_=0;
20 nbinfreq_=1;
21 paqsize_=16424;
22 nzones_=nzon;
23 npaqinzone_=npaqz;
24 prtlevel_=0;
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)) {
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];
42 size_t lenp=outpath_.size();
43 if ((lenp>0)&&(outpath_[lenp-1]!='/')) outpath_+='/';
44 ka+=2;
45 }
46 else if (strcmp(arg[ka],"-nmean")==0) {
47 nmean_=atoi(arg[ka+1]);
48 ka+=2;
49 }
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 }
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 }
65 else if (strcmp(arg[ka],"-prtlev")==0) {
66 prtlevel_=atoi(arg[ka+1]);
67 ka+=2;
68 }
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;
75 while(ka<(narg-1)) {
76 string inpath = arg[ka];
77 size_t lenp=inpath.size();
78 if (lenp<1) inpath="./";
79 if ((lenp>0)&&(inpath[lenp-1]!='/')) inpath+='/';
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 }
92 else ka++;
93 }
94
95 if (!okarg) {
96 cout << " BRAnaParam::DecodeArgs() / Argument error " << endl;
97 return Usage(true);
98 }
99 return 0;
100}
101
102/* --Methode-- */
103int 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"
107 << " [-nbloc NBloc] [-freq NumFreqMin,NumFreqMax,NBinFreq] \n"
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 }
113 cout << " -act Action: cube3d or vis \n"
114 << " -out OutPath: Output directory name \n"
115 << " -nmean NMean: Number of packet used for spectra/visibility computation \n"
116 << " -nbloc NBloc: Number of MemMgr blocs in output file\n"
117 << " -zones NZones,NbPaqinZone : Number of Zones and number of paquets in one zone \n"
118 << " -freq NumFreqMin,NumFreqMax,NBinFreq : Frequency zone and number of bins \n"
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-- */
127int 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-- */
136ostream& 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;
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;
147 return os;
148}
149
150/* --Fonction-- */
151int 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
Note: See TracBrowser for help on using the repository browser.