[1442] | 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 |
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | // Connecting TOI to FITSTOIReader Processor
|
---|
| 125 | // for(kk=0; kk<5; kk++) {
|
---|
| 126 | // r.addOutput(colname[kk], toitab[kk]);
|
---|
| 127 | // }
|
---|
| 128 |
|
---|
| 129 | int kk = 2;
|
---|
| 130 | r.addOutput(colname[kk], toiin);
|
---|
| 131 | // toi->dbg=true;
|
---|
| 132 | // r.addOutput("boloMuV_11", toi);
|
---|
| 133 | cout << " connecting in/out to RzTOIProcessor ... " << endl;
|
---|
| 134 |
|
---|
| 135 | // TOIProcessor * filt = NULL;
|
---|
| 136 |
|
---|
| 137 | cout << " Creating SimpleDeglitcher() " << endl;
|
---|
| 138 | SimpleDeglitcher degl;
|
---|
| 139 | degl.addInput("in", toiin);
|
---|
| 140 | degl.addOutput("out", toiout);
|
---|
| 141 | degl.addOutput("mean", toimean);
|
---|
| 142 | degl.addOutput("sigma", toisig);
|
---|
| 143 |
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | w.setOutFlags(true);
|
---|
| 147 | w.addInput("degli", toiout);
|
---|
| 148 | w.addInput("mean", toimean);
|
---|
| 149 | w.addInput("sigma", toisig);
|
---|
| 150 |
|
---|
| 151 | cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
|
---|
| 152 | r.PrintStatus(cout);
|
---|
| 153 | cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
|
---|
| 154 | w.PrintStatus(cout);
|
---|
| 155 |
|
---|
| 156 | PrtTim("starting threads");
|
---|
| 157 | r.start();
|
---|
| 158 | degl.start();
|
---|
| 159 | w.start();
|
---|
| 160 |
|
---|
| 161 | // for(int jj=0; jj<3; jj++) {
|
---|
| 162 | // sleep(2);
|
---|
| 163 | // cout << *toi;
|
---|
| 164 | // }
|
---|
| 165 |
|
---|
| 166 | mgr->joinAll();
|
---|
| 167 | PrtTim("End threads");
|
---|
| 168 |
|
---|
| 169 | // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
|
---|
| 170 | // r.PrintStatus(cout);
|
---|
| 171 | // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
|
---|
| 172 | // w.PrintStatus(cout);
|
---|
| 173 |
|
---|
| 174 | cout << " ------ toiin and toiout Status information ------- " << endl;
|
---|
| 175 | cout << *toiin;
|
---|
| 176 | cout << *toiout;
|
---|
| 177 | }
|
---|
| 178 | catch (PThrowable & exc) {
|
---|
| 179 | cerr << "\nrztsttoi: Catched Exception \n" << (string)typeid(exc).name()
|
---|
| 180 | << " - Msg= " << exc.Msg() << endl;
|
---|
| 181 | }
|
---|
| 182 | catch (const std::exception & sex) {
|
---|
| 183 | cerr << "\nrztsttoi: Catched std::exception \n"
|
---|
| 184 | << (string)typeid(sex).name() << endl;
|
---|
| 185 | }
|
---|
| 186 | catch (...) {
|
---|
| 187 | cerr << "\nrztsttoi: some other exception was caught ! " << endl;
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | return(0);
|
---|
| 191 | }
|
---|