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
RevLine 
[1723]1//#define TOISEQBUFFERED
2
[1463]3#include <unistd.h>
4#include "toi.h"
5#include "toiprocessor.h"
6#include "fitstoirdr.h"
7#include "fitstoiwtr.h"
8#include "toimanager.h"
[1723]9#ifdef TOISEQBUFFERED
[1463]10#include "toiseqbuff.h"
[1723]11#else
12#include "toisegment.h"
13#endif
[1463]14
15#include "sambainit.h"
16#include "map2toi.h"
17#include "fitsspherehealpix.h"
18#include "timing.h"
19
[1760]20#include <stdexcept>
21
[1463]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
[1809]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
[1520]38 <<" fitsin_point : fits file for pointing"<<endl
39 <<" fitsphere : fits file for input Healpix sphere"<<endl
40 <<" fitsout : fits file for output"<<endl;
[1463]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;
[1520]51char *label_coord1 = "coord1", *label_coord2 = "coord2", *label_bolomuv = "boloMuV";
[1809]52char *tcoorin="gdcdl", *tcoormap="g";
53double equi=2000.;
[1463]54long sdeb,sfin;
[1809]55int c;
56while((c = getopt(narg,arg,"hp:s:w:a:d:b:i:m:e:")) != -1) {
[1463]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);
[1520]62 else {cout<<"Bad sample interval "<<endl; exit(1);}
[1463]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' :
[1520]74 label_coord1 = optarg;
[1463]75 break;
76 case 'd' :
[1520]77 label_coord2 = optarg;
[1463]78 break;
79 case 'b' :
80 label_bolomuv = optarg;
81 break;
[1520]82 case 'i' :
[1809]83 tcoorin = optarg;
[1520]84 break;
85 case 'm' :
[1809]86 tcoormap = optarg;
[1520]87 break;
[1809]88 case 'e' :
89 sscanf(optarg,"%lf",&equi);
90 break;
[1463]91 case 'h' :
92 default:
[1520]93 usage(); exit(1);
[1463]94 }
95}
[1520]96if(optind+2>=narg) {usage(); exit(2);}
97char * fitsin_point = arg[optind];
[1463]98string const fitsphere = arg[optind+1];
99char * fitsout = arg[optind+2];
100
101cout<<">>>> tstmap2toi:"<<endl
[1520]102 <<"Pipe Window Size "<<width<<endl
103 <<"Fits OutFile "<<fitsout<<endl
[1463]104 <<" ...label_bolomuv "<<label_bolomuv<<endl;
[1520]105cout<<"Fits Infile Pointing "<<fitsin_point<<endl
106 <<" ...label_coord1 "<<label_coord1<<endl
107 <<" ...label_coord2 "<<label_coord2<<endl
[1809]108 <<" ...... ctype="<<tcoorin<<endl;
[1520]109cout<<"Fits Healpix Sphere "<<fitsphere<<endl
[1809]110 <<" ...... ctype="<<tcoormap<<endl;
111cout<<"Equinoxe "<<equi<<" years"<<endl;
[1463]112
113SophyaInit();
114InitTim();
115
116//--------------------------------------------------------------------
117try {
118//--------------------------------------------------------------------
119
120 // FITS reader et writer
[1520]121 FITSTOIReader rfits(fitsin_point);
[1463]122 int ncol = rfits.getNOut();
[1520]123 cout<<"Number of columns in fits Infile Pointing : "<<ncol<<endl;
124 if(ncol<2) exit(3);
[1463]125
126 FITSTOIWriter wfits(fitsout);
[1530]127 //wfits.setOutFlags(true);
[1463]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;
[1809]140 m2toi.SetEquinox(equi);
141 m2toi.SetCoorIn(tcoorin);
142 m2toi.SetCoorMap(tcoormap);
[1530]143 m2toi.Print(cout);
[1463]144
145 // Definition des tuyaux
[1723]146#ifdef TOISEQBUFFERED
147 cout<<">>>> Using TOISeqBuffered"<<endl;
[1520]148 TOISeqBuffered * toicoord1in = new TOISeqBuffered("toi_coord1_in",width);
[1723]149#else
150 cout<<">>>> Using TOISegmented"<<endl;
151 TOISegmented * toicoord1in = new TOISegmented("toi_coord1_in",width);
152#endif
[1520]153 // toicoord1in->setDebugLevel(1);
154 rfits.addOutput(label_coord1,toicoord1in);
155 m2toi.addInput("Coord1In",toicoord1in);
[1463]156
[1723]157#ifdef TOISEQBUFFERED
[1520]158 TOISeqBuffered * toicoord1out = new TOISeqBuffered("toi_coord1_out",width);
[1723]159#else
160 TOISegmented * toicoord1out = new TOISegmented("toi_coord1_out",width);
161#endif
[1520]162 m2toi.addOutput("Coord1Out",toicoord1out);
163 wfits.addInput(label_coord1,toicoord1out);
[1463]164
[1723]165#ifdef TOISEQBUFFERED
[1520]166 TOISeqBuffered * toicoord2in = new TOISeqBuffered("toi_coord2_in",width);
[1723]167#else
168 TOISegmented * toicoord2in = new TOISegmented("toi_coord2_in",width);
169#endif
[1520]170 // toicoord2in->setDebugLevel(1);
171 rfits.addOutput(label_coord2,toicoord2in);
172 m2toi.addInput("Coord2In",toicoord2in);
[1463]173
[1723]174#ifdef TOISEQBUFFERED
[1520]175 TOISeqBuffered * toicoord2out = new TOISeqBuffered("toi_coord2_out",width);
[1723]176#else
177 TOISegmented * toicoord2out = new TOISegmented("toi_coord2_out",width);
178#endif
[1520]179 m2toi.addOutput("Coord2Out",toicoord2out);
180 wfits.addInput(label_coord2,toicoord2out);
[1463]181
[1723]182#ifdef TOISEQBUFFERED
[1463]183 TOISeqBuffered * toibolout = new TOISeqBuffered("toi_bolo_out",width);
[1723]184#else
185 TOISegmented * toibolout = new TOISegmented("toi_bolo_out",width);
186#endif
[1520]187 // toibolout->setDebugLevel(1);
[1463]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
[1809]202 //if(lp>1) for(int jjjj=0;jjjj<5;jjjj++) {
203 // cout<<*toicoord1in;
204 // cout<<*toibolout;
205 // sleep(2);
206 //}
[1463]207
[1651]208 // Affichage de l'avancement des TOIProcessors
[1723]209 //ProcSampleCounter<FITSTOIReader> stats(rfits);
210 //stats.InfoMessage() = "tstmap2toi/Info";
211 //stats.PrintStats();
[1651]212
[1463]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.