source: Sophya/trunk/ArchTOIPipe/TestPipes/tstrztoi.cc@ 1463

Last change on this file since 1463 was 1462, checked in by cmv, 24 years ago

changement getData... intermediaire NE COMPILE PAS cmv+rz 10/4/2001

File size: 6.0 KB
RevLine 
[1462]1#include "machdefs.h"
2#include "array.h"
[1437]3#include <unistd.h>
[1439]4#include <stdexcept>
[1437]5#include "toi.h"
6#include "toiprocessor.h"
7#include "fitstoirdr.h"
8#include "fitstoiwtr.h"
9#include "toisqfilter.h"
10#include "toimanager.h"
11#include "rztoi.h"
12#include "toiseqbuff.h"
13#include "timing.h"
14#include "sambainit.h"
15
16void Usage(bool fgerr)
17{
18 cout << endl;
19 if (fgerr) {
20 cout << " tstrztoi : Argument Error ! tstrztoi -h for usage " << endl;
21 exit(1);
22 }
23 else {
24 cout << "\n Usage : tstrztoi [-sproc] [-rwtoi] [-dbg] [-start snb] [-end sne] \n"
25 << " [-w1 sz] [-w2 sz] inFitsName outFitsName ppfFileName \n"
26 << " -sproc : Run RzSimpleTOIProc (default RzTOIProc) \n"
27 << " -rwtoi : Use Regular Window TOI (default TOISeqBuffered) \n"
28 << " -dbg : sets TOISeqBuffered debug level to 1 \n"
29 << " -start snb : sets the start sample num \n"
30 << " -end sne : sets the end sample num \n"
31 << " -w1 sz : sets main data window size (def= 8192)\n"
32 << " -w2 sz : sets secondary window size (def= 512) \n"
33 << endl;
34 exit(0);
35 }
36}
37
38int main(int narg, char** arg) {
39
40 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
41
42 cout << "tstrztoi starting - Decoding arguments " << " narg=" << narg << endl;
43
44 bool fgsimple = false;
45 bool fgrwtoi = false;
46 bool fgdbg = false;
47 int w1 = 8192;
48 int w2 = 512;
49 int nmax = 10;
50 int istart = 104121000+w1*5;
51 int iend = 0;
52 string infile;
53 string outfile;
54 string ppffile;
55
56 if (narg < 4) Usage(true);
57 int ko=1;
58 // decoding arguments
59 for(int ia=1; ia<narg; ia++) {
60 if (strcmp(arg[ia],"-start") == 0) {
61 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
62 istart = atoi(arg[ia+1]); ia++;
63 }
64 else if (strcmp(arg[ia],"-end") == 0) {
65 if (ia == narg-1) Usage(true);
66 iend = atoi(arg[ia+1]); ia++;
67 }
68 else if (strcmp(arg[ia],"-w1") == 0) {
69 if (ia == narg-1) Usage(true);
70 w1 = atoi(arg[ia+1]); ia++;
71 }
72 else if (strcmp(arg[ia],"-w2") == 0) {
73 if (ia == narg-1) Usage(true);
74 w2 = atoi(arg[ia+1]); ia++;
75 }
76 else if (strcmp(arg[ia],"-sproc") == 0) fgsimple = true;
77 else if (strcmp(arg[ia],"-rwtoi") == 0) fgrwtoi = true;
78 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
79
80 else { ko = ia; break; } // Debut des noms
81 }
82
83 if (iend < istart) iend = istart+w1*(nmax+5);
84 if ((narg-ko) < 3) Usage(true);
85 infile = arg[ko];
86 outfile = arg[ko+1];
87 ppffile = arg[ko+2];
88
89 cout << " Initializing SOPHYA ... " << endl;
90 SophyaInit();
91 InitTim();
92
93 cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile
94 << " ppfFile= " << ppffile << endl;
95 cout << ">>>> Window Size W1= " << w1 << " W2= " << w2
96 << " iStart= " << istart << " iEnd= " << iend << endl;
97 try {
98 TOIManager* mgr = TOIManager::getManager();
99
100 // mgr->setRequestedSample(11680920,11710584);
101 // mgr->setRequestedSample(104121000, 104946120);
102
103 mgr->setRequestedSample(istart, iend);
104
105 // FITSTOIReader r("/data/Archeops/bolo11.fits);
106 FITSTOIReader r(infile);
107 cout << "reader created" << endl;
108 // FITSTOIWriter w("/data/Archeops/rz.fits");
109 FITSTOIWriter w(outfile);
110 cout << "fits writer created" << endl;
111
112
113 char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
[1439]114 char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"};
[1437]115 TOI* toitab[5];
116 TOI* toi2;
117 int kk;
118 if (fgrwtoi) {
119 cout << " Using TOIRegularWindow TOI's ... " << endl;
120 for(kk=0; kk<5; kk++) {
[1439]121 toitab[kk] = new TOIRegularWindow(toiname[kk]);
[1437]122 }
123 toi2 = new TOIRegularWindow("t2");
124 }
125 else {
126 cout << " Using TOISeqBuffered TOI's ... " << endl;
127 for(kk=0; kk<5; kk++) {
[1439]128 TOISeqBuffered * toisb = new TOISeqBuffered(toiname[kk], w1);
[1437]129 toitab[kk] = toisb;
130 if (fgdbg) toisb->setDebugLevel(1);
131 }
132 TOISeqBuffered * toisb = new TOISeqBuffered("t2", w1);
133 if (fgdbg) toisb->setDebugLevel(1);
134 toi2 = toisb;
135 }
136
137 // Connecting TOI to FITSTOIReader Processor
138 // for(kk=0; kk<5; kk++) {
139 // r.addOutput(colname[kk], toitab[kk]);
140 // }
141
142 kk = 2;
143 TOI* toi = toitab[kk];
144 r.addOutput(colname[kk], toi);
145 // toi->dbg=true;
146 // r.addOutput("boloMuV_11", toi);
147 cout << " connecting in/out to RzTOIProcessor ... " << endl;
148
149 // TOIProcessor * filt = NULL;
150
151 cout << " Creating Rz TOIProcessors: RzTOIProc () " << endl;
[1442]152 RzSimpleTOIProc rzs(w2, 3.);
[1437]153 RzTOIProc rzp(w1, w2, nmax);
154 if (fgsimple) {
155 cout << " Using Simple TOIProcessor: RzSimpleTOIProc () " << endl;
[1442]156 rzs.addInput("in", toi);
157 rzs.addOutput("out", toi2);
[1437]158 }
159 else {
160 cout << " Using Rz TOIProcessor: RzTOIProc () " << endl;
161 // rzp.setOutPPF("/data/Archeops/toto.ppf");
162 rzp.setOutPPF(ppffile);
[1442]163 rzp.addInput("in", toi);
164 rzp.addOutput("out", toi2);
[1437]165 }
166
167
[1439]168 w.setOutFlags(true);
169 w.addInput("bolodrift", toi2);
[1437]170
[1439]171 cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
172 r.PrintStatus(cout);
173 cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
174 w.PrintStatus(cout);
175
[1437]176 PrtTim("starting threads");
177 r.start();
178 if (fgsimple) rzs.start();
179 else rzp.start();
180 w.start();
181
[1439]182 // for(int jj=0; jj<3; jj++) {
183 // sleep(2);
184 // cout << *toi;
185 // }
[1437]186
187 mgr->joinAll();
188 PrtTim("End threads");
[1439]189
190 // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
191 // r.PrintStatus(cout);
192 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
193 // w.PrintStatus(cout);
194
[1437]195 cout << " ------ toi and toi2 Status information ------- " << endl;
196 cout << *toi;
197 cout << *toi2;
198 }
199 catch (PThrowable & exc) {
[1439]200 cerr << "\nrztsttoi: Catched Exception \n" << (string)typeid(exc).name()
[1437]201 << " - Msg= " << exc.Msg() << endl;
202 }
[1439]203 catch (const std::exception & sex) {
204 cerr << "\nrztsttoi: Catched std::exception \n"
205 << (string)typeid(sex).name() << endl;
206 }
[1437]207 catch (...) {
[1439]208 cerr << "\nrztsttoi: some other exception was caught ! " << endl;
[1437]209 }
210
211 return(0);
212}
Note: See TracBrowser for help on using the repository browser.