source: Sophya/trunk/ArchTOIPipe/TestPipes/simtst.cc@ 1476

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

Correction coeff filtre gaussien ds simtst.cc - Reza 12/4/2001

File size: 8.5 KB
RevLine 
[1462]1#include "machdefs.h"
[1468]2#include <math.h>
[1462]3#include "array.h"
[1442]4#include <unistd.h>
5#include <stdexcept>
6#include "toi.h"
7#include "toiprocessor.h"
8#include "fitstoirdr.h"
9#include "fitstoiwtr.h"
10#include "toisqfilter.h"
11#include "toimanager.h"
12#include "simtoipr.h"
13#include "toiseqbuff.h"
14#include "timing.h"
15#include "sambainit.h"
16
17void Usage(bool fgerr)
18{
19 cout << endl;
20 if (fgerr) {
21 cout << " simtst : Argument Error ! tstrztoi -h for usage " << endl;
22 exit(1);
23 }
24 else {
[1467]25 cout << "\n Usage : simtst [-dbg] [-start snb] [-end sne] \n"
26 << " [-wtoi sz] [-w2 sz] inFitsName outFitsName ppfFileName \n"
[1442]27 << " -dbg : sets TOISeqBuffered debug level to 1 \n"
28 << " -start snb : sets the start sample num \n"
29 << " -end sne : sets the end sample num \n"
[1454]30 << " -range min,max : sets the acceptable range for intoi \n"
31 << " default= -16000,16000\n"
[1467]32 << " -intoi toiName : select input TOI name (def boloMuV_27)\n"
33 << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n"
34 << " -wdegli sz : sets deglitcher window size (def= 512) \n"
[1442]35 << endl;
36 exit(0);
37 }
38}
39
40int main(int narg, char** arg) {
41
42 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
43
44 cout << "simtst starting - Decoding arguments " << " narg=" << narg << endl;
45
46 bool fgdbg = false;
47 int w1 = 8192;
[1467]48 int w2 = 512;
[1442]49 int nmax = 10;
50 int istart = 104121000+w1*5;
51 int iend = 0;
[1454]52 double range_min = -16000;
53 double range_max = 16000.;
[1442]54 string infile;
55 string outfile;
56 string ppffile;
[1467]57 string intoi = "boloMuV_27";
[1442]58
59 if (narg < 4) Usage(true);
60 int ko=1;
61 // decoding arguments
62 for(int ia=1; ia<narg; ia++) {
63 if (strcmp(arg[ia],"-start") == 0) {
64 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
65 istart = atoi(arg[ia+1]); ia++;
66 }
67 else if (strcmp(arg[ia],"-end") == 0) {
68 if (ia == narg-1) Usage(true);
69 iend = atoi(arg[ia+1]); ia++;
70 }
[1467]71 else if (strcmp(arg[ia],"-wtoi") == 0) {
[1442]72 if (ia == narg-1) Usage(true);
73 w1 = atoi(arg[ia+1]); ia++;
74 }
[1467]75 else if (strcmp(arg[ia],"-wdegli") == 0) {
[1442]76 if (ia == narg-1) Usage(true);
77 w2 = atoi(arg[ia+1]); ia++;
78 }
[1454]79 else if (strcmp(arg[ia],"-range") == 0) {
80 if (ia == narg-1) Usage(true);
81 sscanf(arg[ia+1],"%lf,%lf",&range_min, &range_max);
82 ia++;
83 }
84 else if (strcmp(arg[ia],"-intoi") == 0) {
85 if (ia == narg-1) Usage(true);
86 intoi = arg[ia+1]; ia++;
87 }
[1442]88 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
89
90 else { ko = ia; break; } // Debut des noms
91 }
92
93 if (iend < istart) iend = istart+w1*(nmax+5);
94 if ((narg-ko) < 3) Usage(true);
95 infile = arg[ko];
96 outfile = arg[ko+1];
97 ppffile = arg[ko+2];
98
99 cout << " Initializing SOPHYA ... " << endl;
100 SophyaInit();
101 InitTim();
102
103 cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile
104 << " ppfFile= " << ppffile << endl;
105 cout << ">>>> Window Size W1= " << w1 << " W2= " << w2
106 << " iStart= " << istart << " iEnd= " << iend << endl;
[1454]107 cout << ">>>> InTOIName= " << intoi << endl;
[1442]108 try {
109 TOIManager* mgr = TOIManager::getManager();
110
111 // mgr->setRequestedSample(11680920,11710584);
112 // mgr->setRequestedSample(104121000, 104946120);
113
114 mgr->setRequestedSample(istart, iend);
115
116 // FITSTOIReader r("/data/Archeops/bolo11.fits);
117 FITSTOIReader r(infile);
118 cout << "reader created" << endl;
119 // FITSTOIWriter w("/data/Archeops/rz.fits");
120 FITSTOIWriter w(outfile);
121 cout << "fits writer created" << endl;
122
123
[1454]124 // char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
125 // char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"};
[1442]126 TOISeqBuffered * toiin = new TOISeqBuffered("f2in", w1);
127 if (fgdbg) toiin->setDebugLevel(1);
[1467]128 TOISeqBuffered * toidegli = new TOISeqBuffered("degli", w1);
129 if (fgdbg) toidegli->setDebugLevel(1);
[1442]130 TOISeqBuffered * toimean = new TOISeqBuffered("mean", w1);
131 if (fgdbg) toimean->setDebugLevel(1);
132 TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w1);
133 if (fgdbg) toisig->setDebugLevel(1);
[1443]134 TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
135 if (fgdbg) toiincopie->setDebugLevel(1);
[1442]136
137
138
139 // Connecting TOI to FITSTOIReader Processor
140 // for(kk=0; kk<5; kk++) {
141 // r.addOutput(colname[kk], toitab[kk]);
142 // }
143
[1454]144 // int kk = 2;
145 r.addOutput(intoi, toiin);
[1442]146 // toi->dbg=true;
147 // r.addOutput("boloMuV_11", toi);
148 cout << " connecting in/out to RzTOIProcessor ... " << endl;
149
150 // TOIProcessor * filt = NULL;
151
152 cout << " Creating SimpleDeglitcher() " << endl;
[1454]153 SimpleDeglitcher degl(w2);
154 cout << " Setting Range for deglitcher: " << range_min
155 << " - " << range_max << endl;
156 degl.SetRange(range_min, range_max);
[1442]157 degl.addInput("in", toiin);
[1467]158 degl.addOutput("out", toidegli);
[1442]159 degl.addOutput("mean", toimean);
160 degl.addOutput("sigma", toisig);
[1443]161 degl.addOutput("incopie", toiincopie);
[1467]162
163 cout << " Creating a FanOut SimpleFanOut Object " << endl;
164 SimpleFanOut fanout(2,2);
165 TOISeqBuffered * toidegli0 = new TOISeqBuffered("degli0", w1);
166 if (fgdbg) toidegli0->setDebugLevel(1);
167 TOISeqBuffered * toidegli1 = new TOISeqBuffered("degli1", w1);
[1442]168
[1467]169 TOISeqBuffered * toimean0 = new TOISeqBuffered("mean0", w1);
170 if (fgdbg) toimean0->setDebugLevel(1);
171 TOISeqBuffered * toimean1 = new TOISeqBuffered("mean1", w1);
172 if (fgdbg) toimean1->setDebugLevel(1);
173
174 fanout.addInput("in0", toidegli);
175 fanout.addOutput("out0_0", toidegli0);
176 fanout.addOutput("out0_1", toidegli1);
177 fanout.addInput("in1", toimean);
178 fanout.addOutput("out1_0", toimean0);
179 fanout.addOutput("out1_1", toimean1);
180
181 cout << " Creating an Adder SimpleAdder Object " << endl;
182 SimpleAdder adder(2);
183 adder.addInput("in0", toidegli0);
184 adder.addInput("in1", toimean0);
185 adder.SetGain(0, 1.);
186 adder.SetGain(1, -1.);
187 TOISeqBuffered * toideglioff = new TOISeqBuffered("deglioff", w1);
188 if (fgdbg) toideglioff->setDebugLevel(1);
189 adder.addOutput("out", toideglioff);
190
191 cout << " Creating a GaussianFilter SimpleFilter Object " << endl;
[1468]192 double G_sigma = 2.0;
193 double G_a = 1./(G_sigma*sqrt(M_PI*2.));
194 SimpleFilter filt(16, SimpleFilter::GaussFilter, G_a, G_sigma);
[1467]195
196 filt.addInput("in", toideglioff);
197 TOISeqBuffered * toiout = new TOISeqBuffered("out", w1);
198 if (fgdbg) toiout->setDebugLevel(1);
199 TOISeqBuffered * toideglioffcopie = new TOISeqBuffered("deglioffcopie", w1);
200 if (fgdbg) toideglioffcopie->setDebugLevel(1);
201 filt.addOutput("out", toiout);
202 filt.addOutput("incopie", toideglioffcopie);
203
204
205 cout << " Connecting to output (FitsWriter) " << endl;
206
[1442]207 w.setOutFlags(true);
[1443]208 w.addInput("in", toiincopie);
[1467]209 w.addInput("out", toiout);
210 w.addInput("degli", toidegli1);
211 w.addInput("deglioff", toideglioffcopie);
212 w.addInput("mean", toimean1);
[1442]213 w.addInput("sigma", toisig);
214
215 cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
216 r.PrintStatus(cout);
[1467]217 cout << " ------ FanOut::PrintStatus() : ----- " << endl;
218 fanout.PrintStatus(cout);
219 cout << " ------ Adder::PrintStatus() : ----- " << endl;
220 adder.PrintStatus(cout);
221 cout << " ------ Filter::PrintStatus() : ----- " << endl;
222 filt.PrintStatus(cout);
[1442]223 cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
224 w.PrintStatus(cout);
225
226 PrtTim("starting threads");
227 r.start();
228 degl.start();
[1467]229 fanout.start();
230 adder.start();
231 filt.start();
[1442]232 w.start();
233
[1467]234 /*
[1454]235 for(int jj=0; jj<3; jj++) {
236 cout << *toiin;
[1467]237 cout << *toimean;
238 cout << *toimean1;
[1454]239 cout << *toiout;
240 sleep(1);
241 }
[1467]242
[1454]243 */
244
[1442]245 mgr->joinAll();
246 PrtTim("End threads");
247
248 // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
249 // r.PrintStatus(cout);
250 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
251 // w.PrintStatus(cout);
252
[1467]253 cout << " ------ toiin, toidegli and toiout Status information ------- " << endl;
[1442]254 cout << *toiin;
[1467]255 cout << *toidegli;
[1442]256 cout << *toiout;
[1467]257
258 cout << degl;
259 cout << filt;
260 cout << adder;
261
[1442]262 }
263 catch (PThrowable & exc) {
264 cerr << "\nrztsttoi: Catched Exception \n" << (string)typeid(exc).name()
265 << " - Msg= " << exc.Msg() << endl;
266 }
267 catch (const std::exception & sex) {
268 cerr << "\nrztsttoi: Catched std::exception \n"
269 << (string)typeid(sex).name() << endl;
270 }
271 catch (...) {
272 cerr << "\nrztsttoi: some other exception was caught ! " << endl;
273 }
274
275 return(0);
276}
Note: See TracBrowser for help on using the repository browser.