source: Sophya/trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc@ 1809

Last change on this file since 1809 was 1809, checked in by cmv, 24 years ago
  • map2toi et toi2map avec nouvelle interface sys coor et unites.
  • les modifs map2toi (LocalMap) de EA sont introduites + certains bugs corriges.

cmv 3/12/01

File size: 6.7 KB
Line 
1//#define TOISEQBUFFERED
2
3#include <unistd.h>
4#include "toi.h"
5#include "toiprocessor.h"
6#include "fitstoirdr.h"
7#include "fitstoiwtr.h"
8#include "toimanager.h"
9#ifdef TOISEQBUFFERED
10#include "toiseqbuff.h"
11#else
12#include "toisegment.h"
13#endif
14
15#include "sambainit.h"
16#include "map2toi.h"
17#include "fitsspherehealpix.h"
18#include "timing.h"
19
20#include <stdexcept>
21
22void usage(void);
23void usage(void) {
24 cout<<"tstmap2toi [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
25 <<" [-a label_coord1In] [-d label_coord2In] [-b label_bolomuv]"<<endl
26 <<" [-i c,h] [-m c,h]"<<endl
27 <<" fitsin_point fitsphere fitsout"<<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_bolomuv : label fits for bolo value (def=boloMuV)"<<endl
35 <<" -i cin : coordIn caracteristics (def=\"gdcdl\")"<<endl
36 <<" -m cmap : idem -i for Sphere (def=\"g\")"<<endl
37 <<" -e equi : equinoxe en annee (def=2000.)"<<endl
38 <<" fitsin_point : fits file for pointing"<<endl
39 <<" fitsphere : fits file for input Healpix sphere"<<endl
40 <<" fitsout : fits file for output"<<endl;
41 return;
42}
43
44////////////////////////////////////////////////////////////////
45int main(int narg, char** arg) {
46
47TOIManager* mgr = TOIManager::getManager();
48
49//-- Decodage arguments
50int lp = 0, width = 8192;
51char *label_coord1 = "coord1", *label_coord2 = "coord2", *label_bolomuv = "boloMuV";
52char *tcoorin="gdcdl", *tcoormap="g";
53double equi=2000.;
54long sdeb,sfin;
55int c;
56while((c = getopt(narg,arg,"hp:s:w:a:d:b:i:m:e:")) != -1) {
57 switch (c) {
58 case 's' :
59 sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
60 cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
61 if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
62 else {cout<<"Bad sample interval "<<endl; exit(1);}
63 break;
64 case 'w' :
65 sscanf(optarg,"%d",&width);
66 if(width<=0) width=8192;
67 cout<<"Data window size "<<width<<endl;
68 break;
69 case 'p' :
70 sscanf(optarg,"%d",&lp);
71 if(lp<0) lp=0;
72 break;
73 case 'a' :
74 label_coord1 = optarg;
75 break;
76 case 'd' :
77 label_coord2 = optarg;
78 break;
79 case 'b' :
80 label_bolomuv = optarg;
81 break;
82 case 'i' :
83 tcoorin = optarg;
84 break;
85 case 'm' :
86 tcoormap = optarg;
87 break;
88 case 'e' :
89 sscanf(optarg,"%lf",&equi);
90 break;
91 case 'h' :
92 default:
93 usage(); exit(1);
94 }
95}
96if(optind+2>=narg) {usage(); exit(2);}
97char * fitsin_point = arg[optind];
98string const fitsphere = arg[optind+1];
99char * fitsout = arg[optind+2];
100
101cout<<">>>> tstmap2toi:"<<endl
102 <<"Pipe Window Size "<<width<<endl
103 <<"Fits OutFile "<<fitsout<<endl
104 <<" ...label_bolomuv "<<label_bolomuv<<endl;
105cout<<"Fits Infile Pointing "<<fitsin_point<<endl
106 <<" ...label_coord1 "<<label_coord1<<endl
107 <<" ...label_coord2 "<<label_coord2<<endl
108 <<" ...... ctype="<<tcoorin<<endl;
109cout<<"Fits Healpix Sphere "<<fitsphere<<endl
110 <<" ...... ctype="<<tcoormap<<endl;
111cout<<"Equinoxe "<<equi<<" years"<<endl;
112
113SophyaInit();
114InitTim();
115
116//--------------------------------------------------------------------
117try {
118//--------------------------------------------------------------------
119
120 // FITS reader et writer
121 FITSTOIReader rfits(fitsin_point);
122 int ncol = rfits.getNOut();
123 cout<<"Number of columns in fits Infile Pointing : "<<ncol<<endl;
124 if(ncol<2) exit(3);
125
126 FITSTOIWriter wfits(fitsout);
127 //wfits.setOutFlags(true);
128 cout << "fits reader and writer created"<<endl;
129
130 // Lecture de la sphere Healpix
131 SphereHEALPix<r_8> sph;
132 FitsInFile sfits(fitsphere);
133 sfits >> sph;
134 cout<<"SphereHEALPix: Type de map : "<<sph.TypeOfMap()<<endl
135 <<" Nombre de pixels : "<<sph.NbPixels()<<endl;
136
137 // TOI Processor
138 Map2TOI m2toi(sph);
139 cout<<"Map2TOI created"<<endl;
140 m2toi.SetEquinox(equi);
141 m2toi.SetCoorIn(tcoorin);
142 m2toi.SetCoorMap(tcoormap);
143 m2toi.Print(cout);
144
145 // Definition des tuyaux
146#ifdef TOISEQBUFFERED
147 cout<<">>>> Using TOISeqBuffered"<<endl;
148 TOISeqBuffered * toicoord1in = new TOISeqBuffered("toi_coord1_in",width);
149#else
150 cout<<">>>> Using TOISegmented"<<endl;
151 TOISegmented * toicoord1in = new TOISegmented("toi_coord1_in",width);
152#endif
153 // toicoord1in->setDebugLevel(1);
154 rfits.addOutput(label_coord1,toicoord1in);
155 m2toi.addInput("Coord1In",toicoord1in);
156
157#ifdef TOISEQBUFFERED
158 TOISeqBuffered * toicoord1out = new TOISeqBuffered("toi_coord1_out",width);
159#else
160 TOISegmented * toicoord1out = new TOISegmented("toi_coord1_out",width);
161#endif
162 m2toi.addOutput("Coord1Out",toicoord1out);
163 wfits.addInput(label_coord1,toicoord1out);
164
165#ifdef TOISEQBUFFERED
166 TOISeqBuffered * toicoord2in = new TOISeqBuffered("toi_coord2_in",width);
167#else
168 TOISegmented * toicoord2in = new TOISegmented("toi_coord2_in",width);
169#endif
170 // toicoord2in->setDebugLevel(1);
171 rfits.addOutput(label_coord2,toicoord2in);
172 m2toi.addInput("Coord2In",toicoord2in);
173
174#ifdef TOISEQBUFFERED
175 TOISeqBuffered * toicoord2out = new TOISeqBuffered("toi_coord2_out",width);
176#else
177 TOISegmented * toicoord2out = new TOISegmented("toi_coord2_out",width);
178#endif
179 m2toi.addOutput("Coord2Out",toicoord2out);
180 wfits.addInput(label_coord2,toicoord2out);
181
182#ifdef TOISEQBUFFERED
183 TOISeqBuffered * toibolout = new TOISeqBuffered("toi_bolo_out",width);
184#else
185 TOISegmented * toibolout = new TOISegmented("toi_bolo_out",width);
186#endif
187 // toibolout->setDebugLevel(1);
188 m2toi.addOutput("BoloOut",toibolout);
189 wfits.addInput(label_bolomuv,toibolout);
190
191 // Run
192 cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
193 rfits.PrintStatus(cout);
194 cout<<"----- FITSWriterTOI::PrintStatus() : -----"<<endl;
195 wfits.PrintStatus(cout);
196
197 PrtTim("starting threads");
198 rfits.start();
199 m2toi.start();
200 wfits.start();
201
202 //if(lp>1) for(int jjjj=0;jjjj<5;jjjj++) {
203 // cout<<*toicoord1in;
204 // cout<<*toibolout;
205 // sleep(2);
206 //}
207
208 // Affichage de l'avancement des TOIProcessors
209 //ProcSampleCounter<FITSTOIReader> stats(rfits);
210 //stats.InfoMessage() = "tstmap2toi/Info";
211 //stats.PrintStats();
212
213 mgr->joinAll();
214 PrtTim("End threads");
215
216//--------------------------------------------------------------------
217} catch (PThrowable & exc) {
218 cout<<"\ntstmap2toi: Catched Exception \n"<<(string)typeid(exc).name()
219 <<" - Msg= "<<exc.Msg()<<endl;
220} catch (const std::exception & sex) {
221 cout<<"\ntstmap2toi: Catched std::exception \n"
222 <<(string)typeid(sex).name()<<endl;
223} catch (...) {
224 cout<<"\ntstmap2toi: some other exception was caught ! "<<endl;
225}
226//--------------------------------------------------------------------
227
228exit(0);
229}
Note: See TracBrowser for help on using the repository browser.