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

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

TOIsegmented remplace TOISeqBuffered cmv 27/10/01

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