[1462] | 1 | #include "machdefs.h"
|
---|
| 2 | #include "array.h"
|
---|
[1437] | 3 | #include <unistd.h>
|
---|
| 4 | #include "toi.h"
|
---|
| 5 | #include "toiprocessor.h"
|
---|
| 6 | #include "fitstoirdr.h"
|
---|
| 7 | #include "fitstoiwtr.h"
|
---|
| 8 | #include "toisqfilter.h"
|
---|
| 9 | #include "toimanager.h"
|
---|
| 10 | #include "rztoi.h"
|
---|
| 11 | #include "toiseqbuff.h"
|
---|
[1464] | 12 | #include "toiregwindow.h"
|
---|
[1437] | 13 | #include "timing.h"
|
---|
| 14 | #include "sambainit.h"
|
---|
[1760] | 15 | #include <stdexcept>
|
---|
[1437] | 16 |
|
---|
| 17 | void Usage(bool fgerr)
|
---|
| 18 | {
|
---|
| 19 | cout << endl;
|
---|
| 20 | if (fgerr) {
|
---|
| 21 | cout << " tstrztoi : Argument Error ! tstrztoi -h for usage " << endl;
|
---|
| 22 | exit(1);
|
---|
| 23 | }
|
---|
| 24 | else {
|
---|
| 25 | cout << "\n Usage : tstrztoi [-sproc] [-rwtoi] [-dbg] [-start snb] [-end sne] \n"
|
---|
| 26 | << " [-w1 sz] [-w2 sz] inFitsName outFitsName ppfFileName \n"
|
---|
| 27 | << " -sproc : Run RzSimpleTOIProc (default RzTOIProc) \n"
|
---|
| 28 | << " -rwtoi : Use Regular Window TOI (default TOISeqBuffered) \n"
|
---|
| 29 | << " -dbg : sets TOISeqBuffered debug level to 1 \n"
|
---|
| 30 | << " -start snb : sets the start sample num \n"
|
---|
| 31 | << " -end sne : sets the end sample num \n"
|
---|
| 32 | << " -w1 sz : sets main data window size (def= 8192)\n"
|
---|
| 33 | << " -w2 sz : sets secondary window size (def= 512) \n"
|
---|
| 34 | << endl;
|
---|
| 35 | exit(0);
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | int main(int narg, char** arg) {
|
---|
| 40 |
|
---|
| 41 | if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
|
---|
| 42 |
|
---|
| 43 | cout << "tstrztoi starting - Decoding arguments " << " narg=" << narg << endl;
|
---|
| 44 |
|
---|
| 45 | bool fgsimple = false;
|
---|
| 46 | bool fgrwtoi = false;
|
---|
| 47 | bool fgdbg = false;
|
---|
| 48 | int w1 = 8192;
|
---|
| 49 | int w2 = 512;
|
---|
| 50 | int nmax = 10;
|
---|
| 51 | int istart = 104121000+w1*5;
|
---|
| 52 | int iend = 0;
|
---|
| 53 | string infile;
|
---|
| 54 | string outfile;
|
---|
| 55 | string ppffile;
|
---|
| 56 |
|
---|
| 57 | if (narg < 4) Usage(true);
|
---|
| 58 | int ko=1;
|
---|
| 59 | // decoding arguments
|
---|
| 60 | for(int ia=1; ia<narg; ia++) {
|
---|
| 61 | if (strcmp(arg[ia],"-start") == 0) {
|
---|
| 62 | if (ia == narg-1) Usage(true); // -start est suivi d'un argument
|
---|
| 63 | istart = atoi(arg[ia+1]); ia++;
|
---|
| 64 | }
|
---|
| 65 | else if (strcmp(arg[ia],"-end") == 0) {
|
---|
| 66 | if (ia == narg-1) Usage(true);
|
---|
| 67 | iend = atoi(arg[ia+1]); ia++;
|
---|
| 68 | }
|
---|
| 69 | else if (strcmp(arg[ia],"-w1") == 0) {
|
---|
| 70 | if (ia == narg-1) Usage(true);
|
---|
| 71 | w1 = atoi(arg[ia+1]); ia++;
|
---|
| 72 | }
|
---|
| 73 | else if (strcmp(arg[ia],"-w2") == 0) {
|
---|
| 74 | if (ia == narg-1) Usage(true);
|
---|
| 75 | w2 = atoi(arg[ia+1]); ia++;
|
---|
| 76 | }
|
---|
| 77 | else if (strcmp(arg[ia],"-sproc") == 0) fgsimple = true;
|
---|
| 78 | else if (strcmp(arg[ia],"-rwtoi") == 0) fgrwtoi = true;
|
---|
| 79 | else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
|
---|
| 80 |
|
---|
| 81 | else { ko = ia; break; } // Debut des noms
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | if (iend < istart) iend = istart+w1*(nmax+5);
|
---|
| 85 | if ((narg-ko) < 3) Usage(true);
|
---|
| 86 | infile = arg[ko];
|
---|
| 87 | outfile = arg[ko+1];
|
---|
| 88 | ppffile = arg[ko+2];
|
---|
| 89 |
|
---|
| 90 | cout << " Initializing SOPHYA ... " << endl;
|
---|
| 91 | SophyaInit();
|
---|
| 92 | InitTim();
|
---|
| 93 |
|
---|
| 94 | cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile
|
---|
| 95 | << " ppfFile= " << ppffile << endl;
|
---|
| 96 | cout << ">>>> Window Size W1= " << w1 << " W2= " << w2
|
---|
| 97 | << " iStart= " << istart << " iEnd= " << iend << endl;
|
---|
| 98 | try {
|
---|
| 99 | TOIManager* mgr = TOIManager::getManager();
|
---|
| 100 |
|
---|
| 101 | // mgr->setRequestedSample(11680920,11710584);
|
---|
| 102 | // mgr->setRequestedSample(104121000, 104946120);
|
---|
| 103 |
|
---|
| 104 | mgr->setRequestedSample(istart, iend);
|
---|
| 105 |
|
---|
| 106 | // FITSTOIReader r("/data/Archeops/bolo11.fits);
|
---|
| 107 | FITSTOIReader r(infile);
|
---|
| 108 | cout << "reader created" << endl;
|
---|
| 109 | // FITSTOIWriter w("/data/Archeops/rz.fits");
|
---|
| 110 | FITSTOIWriter w(outfile);
|
---|
| 111 | cout << "fits writer created" << endl;
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
|
---|
[1439] | 115 | char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"};
|
---|
[1437] | 116 | TOI* toitab[5];
|
---|
| 117 | TOI* toi2;
|
---|
| 118 | int kk;
|
---|
| 119 | if (fgrwtoi) {
|
---|
| 120 | cout << " Using TOIRegularWindow TOI's ... " << endl;
|
---|
| 121 | for(kk=0; kk<5; kk++) {
|
---|
[1439] | 122 | toitab[kk] = new TOIRegularWindow(toiname[kk]);
|
---|
[1437] | 123 | }
|
---|
| 124 | toi2 = new TOIRegularWindow("t2");
|
---|
| 125 | }
|
---|
| 126 | else {
|
---|
| 127 | cout << " Using TOISeqBuffered TOI's ... " << endl;
|
---|
| 128 | for(kk=0; kk<5; kk++) {
|
---|
[1439] | 129 | TOISeqBuffered * toisb = new TOISeqBuffered(toiname[kk], w1);
|
---|
[1437] | 130 | toitab[kk] = toisb;
|
---|
| 131 | if (fgdbg) toisb->setDebugLevel(1);
|
---|
| 132 | }
|
---|
| 133 | TOISeqBuffered * toisb = new TOISeqBuffered("t2", w1);
|
---|
| 134 | if (fgdbg) toisb->setDebugLevel(1);
|
---|
| 135 | toi2 = toisb;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | // Connecting TOI to FITSTOIReader Processor
|
---|
| 139 | // for(kk=0; kk<5; kk++) {
|
---|
| 140 | // r.addOutput(colname[kk], toitab[kk]);
|
---|
| 141 | // }
|
---|
| 142 |
|
---|
| 143 | kk = 2;
|
---|
| 144 | TOI* toi = toitab[kk];
|
---|
| 145 | r.addOutput(colname[kk], toi);
|
---|
| 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 Rz TOIProcessors: RzTOIProc () " << endl;
|
---|
[1442] | 153 | RzSimpleTOIProc rzs(w2, 3.);
|
---|
[1437] | 154 | RzTOIProc rzp(w1, w2, nmax);
|
---|
| 155 | if (fgsimple) {
|
---|
| 156 | cout << " Using Simple TOIProcessor: RzSimpleTOIProc () " << endl;
|
---|
[1442] | 157 | rzs.addInput("in", toi);
|
---|
| 158 | rzs.addOutput("out", toi2);
|
---|
[1437] | 159 | }
|
---|
| 160 | else {
|
---|
| 161 | cout << " Using Rz TOIProcessor: RzTOIProc () " << endl;
|
---|
| 162 | // rzp.setOutPPF("/data/Archeops/toto.ppf");
|
---|
| 163 | rzp.setOutPPF(ppffile);
|
---|
[1442] | 164 | rzp.addInput("in", toi);
|
---|
| 165 | rzp.addOutput("out", toi2);
|
---|
[1437] | 166 | }
|
---|
| 167 |
|
---|
| 168 |
|
---|
[1439] | 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 | }
|
---|