source: Sophya/trunk/ArchTOIPipe/TestPipes/tsttoi2toi_addsp.cc@ 4080

Last change on this file since 4080 was 2104, checked in by cmv, 23 years ago

gestion Info_src en vector<> cmv 16/7/2002

File size: 7.2 KB
Line 
1//#define TOISEQBUFFERED
2
3#include <iostream.h>
4#include <string>
5#include <unistd.h>
6#include <stdlib.h>
7#include <stdio.h>
8#include "toi.h"
9#include "cgt.h"
10#include "toiprocessor.h"
11#include "fitstoirdr.h"
12#include "fitstoiwtr.h"
13#include "toimanager.h"
14#include "toisegment.h"
15#include "toiseqbuff.h"
16#include "sambainit.h"
17#include "toi2toi_addsp.h"
18#include "timing.h"
19
20#include <stdexcept>
21#include <vector>
22
23void usage(void) {
24 cout<<"tsttoi2toi_addsp [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
25 <<" [-a label_coord1] [-d label_coord2] [-b label_bolomuv]"<<endl
26 <<" [-n nlat] [-i c,h] [-o c,h]"<<endl
27 <<" [-m vmin] [-M vmax] [-f flag]"<<endl
28 <<" fitsin_point fitsin_bolo fitsphout [fitsphwout]"<<endl
29 <<" -p lp : print level (def=0)"<<endl
30 <<" -s samplemin,samplemax : sample range to be treated (def=all)"<<endl
31 <<" -w data_window_size : window size for pipe (def=8192)"<<endl
32 <<" -a label_coord1 : label fits for alpha/gLong (def=coord1)"<<endl
33 <<" -d label_coord2 : label fits for delta/gLat (def=coord2)"<<endl
34 <<" coord1 = alpha or gLong ; coord2 = delta or gLat"<<endl
35 <<" -b label_bolo_in : label fits for bolo value (def=boloMuV)"<<endl
36 <<" -n label_bolo_out : label fits for bolo value (def=boloMuV_sp)"<<endl
37 <<" -u label_out : label fits for utc (def=UTC)"<<endl
38 <<" -l label_out : label fits for longitude (def=longitude)"<<endl
39 <<" -L label_out : label fits for latitude (def=latitude)"<<endl
40 <<" -m vmin : samples are good if sample value >= vmin"<<endl
41 <<" -M vmax : samples are good if sample value <= vmax"<<endl
42 <<" -f flag : samples are bad if match flag"<<endl
43 <<" fitsin_point : fits file for pointing"<<endl
44 <<" fitsin_bolo : fits file for bolo values"<<endl
45 <<" fitsin_utc : fits file for UTC values"<<endl
46 <<" fitsin_lon : fits file for longitude values"<<endl
47 <<" fitsin_lat : fits file for latitude values"<<endl
48 <<" fitsout_bolo : fits file for output bolo value"<<endl;
49}
50
51////////////////////////////////////////////////////////////////
52int main(int narg, char** arg) {
53
54int_4 ns = 10;
55
56TOIManager* mgr = TOIManager::getManager();
57int wsize = 512; /// Segment size for TOISegmented
58bool fgsegmented = true;
59
60//-- Decodage arguments
61int lp = 0, width = 8192;
62bool tflg=false, tmin=false, tmax=false;
63r_8 vmin=-1.e30, vmax=1.e30; uint_8 badflg=0;
64char * label_coord1 = "coord1";
65char * label_coord2 = "coord2";
66char * label_bolo_in = "boloMuV";
67char * label_bolo_out = "boloMuV_sp";
68char * label_utc= "UTC";
69char * label_lon = "longitude";
70char * label_lat = "latitude";
71double equi=2000.;
72char *tcoorin="gdcdl", *tcoormap="g";
73long sdeb,sfin;
74
75int c;
76while((c = getopt(narg,arg,"hIp:s:w:a:d:b:n:i:o:m:M:f:e:")) != -1) {
77 switch (c) {
78 case 's' :
79 sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
80 cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
81 if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
82 //else {cout<<"Bad sample interval "<<endl; exit(2);}
83 break;
84 case 'w' :
85 sscanf(optarg,"%d",&width);
86 if(width<=0) width=8192;
87 cout<<"Data window size "<<width<<endl;
88 break;
89 case 'p' :
90 sscanf(optarg,"%d",&lp);
91 if(lp<0) lp=0;
92 break;
93 case 'a' :
94 label_coord1 = optarg;
95 break;
96 case 'd' :
97 label_coord2 = optarg;
98 break;
99 case 'b' :
100 label_bolo_in = optarg;
101 break;
102 case 'n' :
103 label_bolo_out = optarg;
104 break;
105 case 'u' :
106 label_utc = optarg;
107 break;
108 case 'l' :
109 label_lon = optarg;
110 break;
111 case 'L' :
112 label_lat = optarg;
113 break;
114 case 'i' :
115 tcoorin=optarg;
116 break;
117 case 'o' :
118 tcoormap=optarg;
119 break;
120 case 'e' :
121 sscanf(optarg,"%lf",&equi);
122 break;
123 case 'm' :
124 sscanf(optarg,"%lf",&vmin);
125 tmin = true;
126 break;
127 case 'M' :
128 sscanf(optarg,"%lf",&vmax);
129 tmax = true;
130 break;
131 case 'f' :
132 sscanf(optarg,"%ul",&badflg);
133 tflg = true;
134 break;
135 case 'h' :
136 default:
137 usage(); exit(1);
138 break;
139 }
140}
141if(optind+5>=narg) {usage(); exit(3);}
142
143char * fitsin_point = arg[optind];
144char * fitsin_bolo = arg[optind+1];
145char * fitsin_utc = arg[optind+2];
146char * fitsin_lon = arg[optind+3];
147char * fitsin_lat = arg[optind+4];
148char * fitsout = arg[optind+5];
149
150cout<<">>>> tsttoi2toi_addsp:"<<endl
151 <<"Pipe Window Size "<<width<<endl
152 <<"Fits Infile Bolo "<<fitsin_bolo<<endl
153 <<" ...label_bolo_in "<<label_bolo_in<<endl
154 <<"Fits Infile Utc "<<fitsin_utc<<endl
155 <<" ...label_utc "<<label_utc<<endl
156 <<"Fits Infile Lon "<<fitsin_lon<<endl
157 <<" ...label_lon "<<label_lon<<endl
158 <<"Fits Infile Lat "<<fitsin_lat<<endl
159 <<" ...label_lat "<<label_lat<<endl;
160cout<<"Fits Infile Pointing "<<fitsin_point<<endl
161 <<" ...label_coord1 "<<label_coord1<<endl
162 <<" ...label_coord2 "<<label_coord2<<endl
163 <<" ...... ctype="<<tcoorin<<endl;
164cout<<"Fits Outfile Bolo "<<fitsout<<endl
165 <<" ...label_bolo_out "<<label_bolo_out<<endl;
166
167SophyaInit();
168InitTim();
169
170//--------------------------------------------------------------------
171try {
172//--------------------------------------------------------------------
173 cout << wsize << " ok ! " << endl;
174
175 CGT plombier(fgsegmented,wsize);
176 plombier.SetDebugLevel(99);
177
178 // FITS reader
179 FITSTOIReader rfitsb(fitsin_bolo);
180 FITSTOIReader rfitsp(fitsin_point);
181 FITSTOIReader rfitsu(fitsin_utc);
182 FITSTOIReader rfitsl(fitsin_lon);
183 FITSTOIReader rfitsL(fitsin_lat);
184 FITSTOIWriter wfits(fitsout);
185
186 // TOI Processor
187// Toi2toi_Addsp toi2t_sp(ns);
188// cout<<"Toi2toi_Addsp created"<<endl;
189
190// toi2t_sp.SetEquinox(equi);
191// toi2t_sp.SetCoorIn(tcoorin);
192// toi2t_sp.SetCoorMap(tcoormap);
193// toi2t_sp.SetTestFlag(tflg,badflg);
194// toi2t_sp.SetTestMin(tmin,vmin);
195// toi2t_sp.SetTestMax(tmax,vmax);
196// toi2t_sp.Print(cout);
197
198 // Definition des tuyaux
199
200 // pb dans prout.addOutput(out, toi);
201 cout << " tout va bien " <<label_coord2 << endl;
202
203 plombier.Connect(rfitsp,label_coord1,wfits,label_bolo_out);
204
205 //pb dans chkinit(); dans afterinit()
206// plombier.Connect(rfitsp,label_coord2,toi2t_sp,"Coord2In");
207// plombier.Connect(rfitsp,label_coord1,toi2t_sp,"Coord1In");
208
209// plombier.Connect(rfitsb,label_bolo_in,toi2t_sp,"BoloIn");
210
211// plombier.Connect(rfitsu,label_utc,toi2t_sp,"utc");
212// plombier.Connect(rfitsl,label_lon,toi2t_sp,"lon");
213// plombier.Connect(rfitsL,label_lat,toi2t_sp,"lat");
214
215// plombier.Connect(toi2t_sp,"BoloOut",wfits,label_bolo_out);
216 // plombier.Connect(rfitsp,label_coord1,wfits,label_bolo_out);
217 cout << " tout va bien " <<label_coord2 << endl;
218
219 // Run
220 cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
221
222 plombier.Start();
223 plombier.ListTOIs(cout, 1);
224 cout << "Joining ..." << endl;
225 mgr->joinAll();
226 PrtTim("End threads");
227
228
229
230//--------------------------------------------------------------------
231} catch (PThrowable & exc) {
232 cout<<"\ntsttoi2toi_addsp: Catched Exception \n"<<(string)typeid(exc).name()
233 <<" - Msg= "<<exc.Msg()<<endl;
234} catch (const std::exception & sex) {
235 cout<<"\ntsttoi2toi_addsp: Catched std::exception \n"
236 <<(string)typeid(sex).name()<<endl;
237} catch (...) {
238 cout<<"\ntsttoi2toi_addsp: some other exception was caught ! "<<endl;
239}
240//--------------------------------------------------------------------
241
242exit(0);
243}
244
Note: See TracBrowser for help on using the repository browser.