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

Last change on this file since 1497 was 1476, checked in by ansari, 24 years ago

compil/portage SGI-CC - Reza 23/4/2001

File size: 4.6 KB
Line 
1#include <unistd.h>
2#include <stdexcept>
3
4#include "toi.h"
5#include "toiprocessor.h"
6#include "fitstoirdr.h"
7#include "fitstoiwtr.h"
8#include "toimanager.h"
9#include "toiseqbuff.h"
10
11#include "sambainit.h"
12#include "map2toi.h"
13#include "fitsspherehealpix.h"
14#include "timing.h"
15
16void usage(void);
17void usage(void) {
18 cout<<"tstmap2toi [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
19 <<" [-a label_alpha] [-d label_delta] [-b label_bolomuv]"<<endl
20 <<" fitsin fitsphere fitsout"<<endl;
21 return;
22}
23
24////////////////////////////////////////////////////////////////
25int main(int narg, char** arg) {
26
27TOIManager* mgr = TOIManager::getManager();
28
29//-- Decodage arguments
30int lp = 0, width = 8192;
31char *label_alpha = "alpha", *label_delta = "delta", *label_bolomuv = "boloMuV";
32long sdeb,sfin;
33int c;
34while((c = getopt(narg,arg,"hp:s:w:a:d:b:")) != -1) {
35 switch (c) {
36 case 's' :
37 sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
38 cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
39 if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
40 else {cout<<"Bad sample interval "<<endl; exit(-2);}
41 break;
42 case 'w' :
43 sscanf(optarg,"%d",&width);
44 if(width<=0) width=8192;
45 cout<<"Data window size "<<width<<endl;
46 break;
47 case 'p' :
48 sscanf(optarg,"%d",&lp);
49 if(lp<0) lp=0;
50 break;
51 case 'a' :
52 label_alpha = optarg;
53 break;
54 case 'd' :
55 label_delta = optarg;
56 break;
57 case 'b' :
58 label_bolomuv = optarg;
59 break;
60 case 'h' :
61 usage(); exit(-1);
62 break;
63 default:
64 usage(); exit(-1);
65 }
66}
67if(optind+2>=narg) {usage(); exit(-2);}
68char * fitsin = arg[optind];
69string const fitsphere = arg[optind+1];
70char * fitsout = arg[optind+2];
71
72cout<<">>>> tstmap2toi:"<<endl
73 <<"Fits Infile(snum,alpha,delta)= "<<fitsin<<endl
74 <<" ...label_alpha "<<label_alpha<<" , label_delta "<<label_delta<<endl
75 <<"Fits Sphere Healpix"<<fitsphere<<endl
76 <<"Fits Outfile(snum,[alpha,delta],boloMuV)"<<fitsout<<endl
77 <<" ...label_bolomuv "<<label_bolomuv<<endl;
78
79SophyaInit();
80InitTim();
81
82//--------------------------------------------------------------------
83try {
84//--------------------------------------------------------------------
85
86 // FITS reader et writer
87 FITSTOIReader rfits(fitsin);
88 int ncol = rfits.getNOut();
89 cout<<"Number of columns in fits Infile : "<<ncol<<endl;
90 if(ncol<2) exit(-3);
91
92 FITSTOIWriter wfits(fitsout);
93 wfits.setOutFlags(true);
94 cout << "fits reader and writer created"<<endl;
95
96 // Lecture de la sphere Healpix
97 SphereHEALPix<r_8> sph;
98 FitsInFile sfits(fitsphere);
99 sfits >> sph;
100 cout<<"SphereHEALPix: Type de map : "<<sph.TypeOfMap()<<endl
101 <<" Nombre de pixels : "<<sph.NbPixels()<<endl;
102
103 // TOI Processor
104 Map2TOI m2toi(sph);
105 cout<<"Map2TOI created"<<endl;
106
107 // Definition des tuyaux
108 TOISeqBuffered * toialphain = new TOISeqBuffered("toi_alpha_in",width);
109 if(lp) toialphain->setDebugLevel(1);
110 rfits.addOutput(label_alpha,toialphain);
111 m2toi.addInput("AlphaIn",toialphain);
112
113 TOISeqBuffered * toialphaout = new TOISeqBuffered("toi_alpha_out",width);
114 m2toi.addOutput("AlphaOut",toialphaout);
115 wfits.addInput(label_alpha,toialphaout);
116
117 TOISeqBuffered * toideltain = new TOISeqBuffered("toi_delta_in",width);
118 if(lp) toideltain->setDebugLevel(1);
119 rfits.addOutput(label_delta,toideltain);
120 m2toi.addInput("DeltaIn",toideltain);
121
122 TOISeqBuffered * toideltaout = new TOISeqBuffered("toi_delta_out",width);
123 m2toi.addOutput("DeltaOut",toideltaout);
124 wfits.addInput(label_delta,toideltaout);
125
126 TOISeqBuffered * toibolout = new TOISeqBuffered("toi_bolo_out",width);
127 if(lp) toibolout->setDebugLevel(1);
128 m2toi.addOutput("BoloOut",toibolout);
129 wfits.addInput(label_bolomuv,toibolout);
130
131 // Run
132 cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
133 rfits.PrintStatus(cout);
134 cout<<"----- FITSWriterTOI::PrintStatus() : -----"<<endl;
135 wfits.PrintStatus(cout);
136
137 PrtTim("starting threads");
138 rfits.start();
139 m2toi.start();
140 wfits.start();
141
142 if(lp>1)
143 for(int jjjj=0;jjjj<5;jjjj++) {
144 cout<<*toialphain;
145 cout<<*toibolout;
146 sleep(2);
147 }
148
149 mgr->joinAll();
150 PrtTim("End threads");
151
152//--------------------------------------------------------------------
153} catch (PThrowable & exc) {
154 cout<<"\ntstmap2toi: Catched Exception \n"<<(string)typeid(exc).name()
155 <<" - Msg= "<<exc.Msg()<<endl;
156} catch (const std::exception & sex) {
157 cout<<"\ntstmap2toi: Catched std::exception \n"
158 <<(string)typeid(sex).name()<<endl;
159} catch (...) {
160 cout<<"\ntstmap2toi: some other exception was caught ! "<<endl;
161}
162//--------------------------------------------------------------------
163
164exit(0);
165}
Note: See TracBrowser for help on using the repository browser.