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

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

amelioration deglitcher - Reza 26/4/2001

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