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

Last change on this file since 3827 was 3776, checked in by ansari, 15 years ago

Ajout classes / modification pour permettre le calcul des visibilites ave plusieurs objets BRVisibilityCalculator s'executant en parallele, Reza 18/05/2010

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