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