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

Last change on this file since 2102 was 2102, checked in by cecile, 23 years ago

* empty log message *

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