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

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

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

File size: 6.9 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
[1810]38 <<" -I : sampleNum are implicit in fits files (def=no)"<<endl
[1520]39 <<" fitsin_point : fits file for pointing"<<endl
40 <<" fitsphere : fits file for input Healpix sphere"<<endl
41 <<" fitsout : fits file for output"<<endl;
[1463]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;
[1520]52char *label_coord1 = "coord1", *label_coord2 = "coord2", *label_bolomuv = "boloMuV";
[1809]53char *tcoorin="gdcdl", *tcoormap="g";
54double equi=2000.;
[1463]55long sdeb,sfin;
[1810]56bool snimplicit = false;
[1809]57int c;
[1810]58while((c = getopt(narg,arg,"hIp:s:w:a:d:b:i:m:e:")) != -1) {
[1463]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);
[1520]64 else {cout<<"Bad sample interval "<<endl; exit(1);}
[1463]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' :
[1520]76 label_coord1 = optarg;
[1463]77 break;
78 case 'd' :
[1520]79 label_coord2 = optarg;
[1463]80 break;
81 case 'b' :
82 label_bolomuv = optarg;
83 break;
[1520]84 case 'i' :
[1809]85 tcoorin = optarg;
[1520]86 break;
87 case 'm' :
[1809]88 tcoormap = optarg;
[1520]89 break;
[1809]90 case 'e' :
91 sscanf(optarg,"%lf",&equi);
92 break;
[1810]93 case 'I' :
94 snimplicit = true;
95 break;
[1463]96 case 'h' :
97 default:
[1520]98 usage(); exit(1);
[1463]99 }
100}
[1520]101if(optind+2>=narg) {usage(); exit(2);}
102char * fitsin_point = arg[optind];
[1463]103string const fitsphere = arg[optind+1];
104char * fitsout = arg[optind+2];
105
106cout<<">>>> tstmap2toi:"<<endl
[1520]107 <<"Pipe Window Size "<<width<<endl
108 <<"Fits OutFile "<<fitsout<<endl
[1463]109 <<" ...label_bolomuv "<<label_bolomuv<<endl;
[1520]110cout<<"Fits Infile Pointing "<<fitsin_point<<endl
111 <<" ...label_coord1 "<<label_coord1<<endl
112 <<" ...label_coord2 "<<label_coord2<<endl
[1809]113 <<" ...... ctype="<<tcoorin<<endl;
[1520]114cout<<"Fits Healpix Sphere "<<fitsphere<<endl
[1809]115 <<" ...... ctype="<<tcoormap<<endl;
116cout<<"Equinoxe "<<equi<<" years"<<endl;
[1463]117
118SophyaInit();
119InitTim();
120
121//--------------------------------------------------------------------
122try {
123//--------------------------------------------------------------------
124
125 // FITS reader et writer
[1520]126 FITSTOIReader rfits(fitsin_point);
[1810]127 if(snimplicit) rfits.setImplicitSN();
[1463]128 int ncol = rfits.getNOut();
[1520]129 cout<<"Number of columns in fits Infile Pointing : "<<ncol<<endl;
130 if(ncol<2) exit(3);
[1463]131
132 FITSTOIWriter wfits(fitsout);
[1810]133 if(snimplicit) wfits.setImplicitSN();
[1530]134 //wfits.setOutFlags(true);
[1463]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;
[1809]147 m2toi.SetEquinox(equi);
148 m2toi.SetCoorIn(tcoorin);
149 m2toi.SetCoorMap(tcoormap);
[1530]150 m2toi.Print(cout);
[1463]151
152 // Definition des tuyaux
[1723]153#ifdef TOISEQBUFFERED
154 cout<<">>>> Using TOISeqBuffered"<<endl;
[1520]155 TOISeqBuffered * toicoord1in = new TOISeqBuffered("toi_coord1_in",width);
[1723]156#else
157 cout<<">>>> Using TOISegmented"<<endl;
158 TOISegmented * toicoord1in = new TOISegmented("toi_coord1_in",width);
159#endif
[1520]160 // toicoord1in->setDebugLevel(1);
161 rfits.addOutput(label_coord1,toicoord1in);
162 m2toi.addInput("Coord1In",toicoord1in);
[1463]163
[1723]164#ifdef TOISEQBUFFERED
[1520]165 TOISeqBuffered * toicoord1out = new TOISeqBuffered("toi_coord1_out",width);
[1723]166#else
167 TOISegmented * toicoord1out = new TOISegmented("toi_coord1_out",width);
168#endif
[1520]169 m2toi.addOutput("Coord1Out",toicoord1out);
170 wfits.addInput(label_coord1,toicoord1out);
[1463]171
[1723]172#ifdef TOISEQBUFFERED
[1520]173 TOISeqBuffered * toicoord2in = new TOISeqBuffered("toi_coord2_in",width);
[1723]174#else
175 TOISegmented * toicoord2in = new TOISegmented("toi_coord2_in",width);
176#endif
[1520]177 // toicoord2in->setDebugLevel(1);
178 rfits.addOutput(label_coord2,toicoord2in);
179 m2toi.addInput("Coord2In",toicoord2in);
[1463]180
[1723]181#ifdef TOISEQBUFFERED
[1520]182 TOISeqBuffered * toicoord2out = new TOISeqBuffered("toi_coord2_out",width);
[1723]183#else
184 TOISegmented * toicoord2out = new TOISegmented("toi_coord2_out",width);
185#endif
[1520]186 m2toi.addOutput("Coord2Out",toicoord2out);
187 wfits.addInput(label_coord2,toicoord2out);
[1463]188
[1723]189#ifdef TOISEQBUFFERED
[1463]190 TOISeqBuffered * toibolout = new TOISeqBuffered("toi_bolo_out",width);
[1723]191#else
192 TOISegmented * toibolout = new TOISegmented("toi_bolo_out",width);
193#endif
[1520]194 // toibolout->setDebugLevel(1);
[1463]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
[1809]209 //if(lp>1) for(int jjjj=0;jjjj<5;jjjj++) {
210 // cout<<*toicoord1in;
211 // cout<<*toibolout;
212 // sleep(2);
213 //}
[1463]214
[1651]215 // Affichage de l'avancement des TOIProcessors
[1723]216 //ProcSampleCounter<FITSTOIReader> stats(rfits);
217 //stats.InfoMessage() = "tstmap2toi/Info";
218 //stats.PrintStats();
[1651]219
[1463]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.