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

Last change on this file since 1810 was 1810, checked in by cmv, 24 years ago

fits reader/writer possibilite de setImplicit cmv 4/12/01

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