Changeset 1502 in Sophya for trunk/ArchTOIPipe/TestPipes
- Timestamp:
- May 18, 2001, 7:29:04 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/TestPipes/tgenw.cc
r1497 r1502 1 1 /* Test de GenWindowTOIProcessor (generic processor with window) 2 3 2 ---------------- Exemple d'appel --------------------- 4 csh> time ./tgenw -intoi bolo -start 1 -end 50000 -wgen 128,1,256 \ 5 bols.fits xx.fits 6 // CMV tester wgen 16,64,... 3 csh> time ./tgenw -intoi bolo -start 1 -end 50000 -wgen 16,1,64 -wlcr 0,0,0 \ 4 -dbg 0 toto.fits xx.fits 7 5 */ 8 9 10 6 11 7 #include "machdefs.h" … … 27 23 class TGenWProc : public GenWindowTOIProcessor { 28 24 public: 29 TGenWProc(int wsz, int step, int wt);25 TGenWProc(int ntoiout, int wsz, int step, int wt); 30 26 virtual void UserInit(int_8 kstart); 31 27 virtual void UserProc(int_8 ks); 32 28 virtual void UserEnd(int_8 kend); 33 29 protected: 30 int_8 SNRunning; 34 31 }; 35 32 36 TGenWProc::TGenWProc(int wsz, int step, int wt) 37 : GenWindowTOIProcessor(1,1,wsz,step,wt) 38 { 33 TGenWProc::TGenWProc(int ntoiout,int wsz, int step, int wt) 34 : GenWindowTOIProcessor(1,ntoiout,wsz,step,wt) 35 { 36 SNRunning = 1; 39 37 } 40 38 void TGenWProc::UserInit(int_8 kstart) … … 49 47 void TGenWProc::UserProc(int_8 ks) 50 48 { 51 if ( (ks == StartSampleNum()) || (ks >= EndSampleNum()-1) || (ks%1000 == 0) ) 52 cout << "TGenWProc::UserProc(" << ks << ") CenterSample=" << GetCenterSample() << endl; 53 if (GetWStep() > 1) { 49 if( ks==StartSampleNum() || ks>=EndSampleNum()-1 || ks%1000==0 ) 50 cout<<"TGenWProc::UserProc("<<ks<<") CenterSample="<<GetWCenterSample()<<endl; 51 52 // Test pour fichier cmv toto.fits (sn=100000+i, bolo=i) 53 r_8 * datatest = GetWDataPointer(); 54 for(int_4 i=0;i<WSize;i++) { 55 int_8 k=ks-WSize/2+i; 56 if(k<SNbegin || k>SNend) continue; 57 if(datatest[i]!=k-100000) {cout<<"PROBLEME ks="<<ks<<endl; break;} 58 } 59 60 if(!NbOutput) return; 61 62 if(GetWStep()==1) { 63 // Cas ou on a un step de 1 64 r_8 data; 65 int_8 flag; 66 GetData(ks,data,flag); 67 PutWData(ks,data,flag); 68 69 } else if(GetWStep()<GetWSize()) { 70 // Cas ou on a un step plus petit que la fenetre: 71 // on peut donc reconstituer le TOI original en sortie 72 // (ca marche aussi pour WStep==1 mais test different) 73 // ATTENTION: l'ordre d'ecriture depend de la taille relative 74 // de WSize et WStep. 75 // Il faut en plus faire attention au premier echantillon et au dernier 76 // Visiblement il faut ecrire autant de donnees en sortie que lues en entree (??) 77 // ===> Conduit a une logique d'une simplicite extreme: 78 // ATTENTION: dans certains cas ca bloque car il peut arriver que 79 // SNend ne soit jamais atteint selon les valeurs de WSize/WStep ! 80 // et on ne peut donc pas ecrire autant de valeurs en sortie que lues en entree 54 81 TVector<r_8> data; 55 82 TVector<int_8> flag; 56 data = GetWData()(Range(GetWSize()/2,0,GetWStep())); 57 flag = GetWFlag()(Range(GetWSize()/2,0,GetWStep())); 58 PutWData(GetCenterSample(), data, flag); 59 } 60 else { 61 // PutWData(GetCenterSample(), GetWData()(GetWSize()/2), GetWFlag()(GetWSize()/2)); 62 r_8 data; 63 int_8 flag; 64 GetData(GetCenterSample(), data, flag); 65 PutWData(GetCenterSample(), data, flag); 66 } 83 int_4 ideb,ifin,isndeb; 84 if(GetWStep()<=GetWSize()/2+1) { 85 // ------|------ 86 // ------|------ 87 // : : 88 // WStep 89 // : : 90 // d..f 91 ideb = GetWCenterIndex(); 92 isndeb = GetWCenterSample(); 93 ifin = ideb + GetWStep()-1; 94 } else { 95 // ------|------ 96 // ------|------ 97 // : : 98 // WStep 99 // : : 100 // d.........f 101 ifin = GetWSize()-1; 102 ideb = ifin - GetWStep()+1; 103 isndeb = GetWStartSample() + ideb; 104 } 105 if(isndeb<StartSampleNum()) { 106 cout<<"........ ideb="<<ideb<<" isndeb="<<isndeb<<endl; 107 ideb = StartSampleNum() - GetWStartSample(); 108 isndeb = StartSampleNum(); 109 } 110 if(GetWStartSample()+ifin>EndSampleNum()) { 111 cout<<"........ ifin="<<ifin<<endl; 112 ifin = EndSampleNum() - GetWStartSample(); 113 } 114 cout<<".... ideb="<<ideb<<" ifin="<<ifin<<" isndeb="<<isndeb<<endl; 115 data = GetWData()(Range(ideb,ifin)); 116 flag = GetWFlag()(Range(ideb,ifin)); 117 PutWData(isndeb,data,flag); 118 } else { 119 // Cas ou on ne peut reproduire le TOI initial 120 // On renumerote les samples 121 // ATTENTION: faut en mettre autant en sortie que lu en entree (???) 122 // ATTENTION: dans certains cas ca bloque car il peut arriver que 123 // SNend ne soit jamais atteint selon les valeurs de WSize/WStep ! 124 // et on ne peut donc pas ecrire autant de valeurs en sortie que lues en entree 125 // CA NE MARCHE PAS DANS CE CAS 126 TVector<r_8> data; 127 TVector<int_8> flag; 128 int_4 ideb=0, ifin=GetWSize()-1; 129 int_8 ilen = EndSampleNum() - StartSampleNum() + 1; 130 if(GetWStartSample()+ideb<StartSampleNum()) { 131 cout<<"........ ideb="<<ideb<<endl; 132 ideb = StartSampleNum() - GetWStartSample(); 133 } 134 if(GetWStartSample()+ifin>EndSampleNum()) { 135 cout<<"........ ifin="<<ifin<<endl; 136 ifin = EndSampleNum() - GetWStartSample(); 137 } 138 data = GetWData()(Range(ideb,ifin)); 139 flag = GetWFlag()(Range(ideb,ifin)); 140 cout<<".... ideb="<<ideb<<" ifin="<<ifin<<" SNRunning="<<SNRunning<<endl; 141 PutWData(SNRunning,data,flag); 142 SNRunning += ifin-ideb+1; 143 if(SNRunning<=ilen && GetWStep()-GetWSize()>0) { 144 for(int_4 i=0;i<GetWStep()-GetWSize() && SNRunning<=ilen;i++) 145 {PutWData(SNRunning,0.,0); SNRunning++;} 146 // De toute facon impossible a faire puisque 147 // ce putwdata efface le vecteur du putwdata precedent 148 } 149 cout<<".................... SNRunning="<<SNRunning<<endl; 150 } 151 // Oh que voila une logique simple et utilisable par tout un chacun !!! 67 152 } 68 153 … … 75 160 } 76 161 else { 77 cout << "\n Usage : tgenw [- dbg] [-start snb] [-end sne] [-intoi name] \n"162 cout << "\n Usage : tgenw [-prt] [-dbg dbg] [-start snb] [-end sne] [-intoi name] \n" 78 163 << " [-wtoi sz] [-wgen sz,step,szt] inFitsName outFitsName \n" 79 << " -dbg : sets TOISeqBuffered debug level to 1 \n" 164 << " -prt : sets TOISeqBuffered debug level to 1 \n" 165 << " -dbg : debug level for GenWProc \n" 80 166 << " -start snb : sets the start sample num \n" 81 167 << " -end sne : sets the end sample num \n" … … 83 169 << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n" 84 170 << " -wgen sz,step,szt : sets GenWProc window size, step total size \n" 171 << " -wlcr szl,szc,szr : sets LCR Window \n" 85 172 << endl; 86 173 exit(0); … … 96 183 bool fgdbg = false; 97 184 bool fgsetstart = false; 185 int dbglevel = 0; 98 186 int wtoi = 8192; 99 187 int wgen = 16; 100 188 int stepgen = 1; 189 int wgl = 0, wgc = 0, wgr = 0; 101 190 int wtotgen = 0; 102 191 int istart = 0; 103 192 int iend = 0; 104 193 string infile; 105 string outfile ;194 string outfile = ""; 106 195 string outppfname; 107 196 string intoi = "boloMuV_27"; 108 197 109 if (narg < 3) Usage(true);198 if (narg < 2) Usage(true); 110 199 int ko=1; 111 200 // decoding arguments … … 128 217 sscanf(arg[ia+1],"%d,%d,%d",&wgen,&stepgen,&wtotgen); ia++; 129 218 } 219 else if (strcmp(arg[ia],"-wlcr") == 0) { 220 if (ia == narg-1) Usage(true); 221 sscanf(arg[ia+1],"%d,%d,%d",&wgl,&wgc,&wgr); ia++; 222 } 130 223 else if (strcmp(arg[ia],"-intoi") == 0) { 131 224 if (ia == narg-1) Usage(true); 132 225 intoi = arg[ia+1]; ia++; 133 226 } 134 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true; 227 else if (strcmp(arg[ia],"-dbg") == 0) { 228 if (ia == narg-1) Usage(true); 229 sscanf(arg[ia+1],"%d",&dbglevel); ia++; 230 } 231 else if (strcmp(arg[ia],"-prt") == 0) fgdbg = true; 135 232 136 233 else { ko = ia; break; } // Debut des noms … … 138 235 139 236 if (iend < istart) iend = istart+wtoi*10; 140 if ((narg-ko) < 2) Usage(true);237 if ((narg-ko) < 1) Usage(true); 141 238 infile = arg[ko]; 142 outfile = arg[ko+1];143 // 239 if(ko+1<narg) outfile = arg[ko+1]; 240 // outppfname = arg[ko+2]; 144 241 145 242 cout << " Initializing SOPHYA ... " << endl; … … 150 247 << outfile << endl; 151 248 cout << ">>> Window Size WTOI= " << wtoi << " WGenSz= " << wgen 152 << " StepGen=" << stepgen << " WTot=" << wtotgen << endl; 249 << " StepGen=" << stepgen << " WTot=" << wtotgen 250 << " Wglcr=" << wgl << "," << wgc << "," << wgr << endl; 153 251 cout << ">>>> InTOIName= " << intoi 154 252 << " iStart= " << istart << " iEnd= " << iend << endl; … … 159 257 // mgr->setRequestedSample(11680920,11710584); 160 258 // mgr->setRequestedSample(104121000, 104946120); 161 if (fgsetstart) 259 if (fgsetstart) 162 260 mgr->setRequestedSample(istart, iend); 163 261 164 262 FITSTOIReader r(infile); 165 263 cout << "reader created" << endl; 166 FITSTOIWriter w(outfile); 167 cout << "fits writer created" << endl; 168 264 265 int ntoiout=0; 266 FITSTOIWriter* w=NULL; 267 if(outfile.size()>0) { 268 ntoiout=1; 269 w = new FITSTOIWriter(outfile); 270 w->setOutFlags(true); 271 cout << "fits writer created" << endl; 272 } 169 273 170 274 TOISeqBuffered * toiin = new TOISeqBuffered("f2in", wtoi); 171 275 if (fgdbg) toiin->setDebugLevel(1); 172 276 277 TOISeqBuffered * toiout = NULL; 278 if(w) { 279 toiout = new TOISeqBuffered("genout", wtoi); 280 if (fgdbg) toiout->setDebugLevel(1); 281 } 282 283 TGenWProc tgenp(ntoiout, wgen, stepgen, wtotgen); 284 tgenp.SetWSizeLCR(wgl,wgc,wgr); 285 tgenp.SetDbgLevel(dbglevel); 286 173 287 cout << " Connecting to FitsReader ... " << endl; 174 288 r.addOutput(intoi, toiin); 175 289 176 TOISeqBuffered * toiout = new TOISeqBuffered("genout", wtoi); 177 if (fgdbg) toiout->setDebugLevel(1); 178 TGenWProc tgenp(wgen, stepgen, wtotgen); 290 if(w && toiout) { 291 cout << " Connecting to FitsWriter ... " << endl; 292 w->addInput("genout",toiout); 293 } 179 294 180 295 cout << " Connecting TGenWProc ... " << endl; 181 296 tgenp.addInput("in0",toiin); 182 tgenp.addOutput("out0",toiout); 183 184 cout << tgenp; 185 186 w.addInput("genout", toiout); 297 if(toiout) tgenp.addOutput("out0",toiout); 298 tgenp.PrintStatus(cout,1); 187 299 188 300 PrtTim("starting threads"); 189 301 r.start(); 190 302 tgenp.start(); 191 w.start(); 192 303 if(w) w->start(); 193 304 194 305 /* 195 306 for(int jj=0; jj<3; jj++) { 196 307 cout << *toiin; 197 cout << *toiout;308 if(toiout) cout << *toiout; 198 309 sleep(1); 199 310 } 200 311 */ 201 202 203 204 312 205 313 mgr->joinAll(); … … 209 317 // r.PrintStatus(cout); 210 318 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl; 211 // w .PrintStatus(cout);319 // w->PrintStatus(cout); 212 320 213 321 cout << " ------ toiin, toiout Status information ------- " << endl; 214 322 cout << *toiin; 215 cout << *toiout; 216 217 cout << tgenp; 218 323 if(toiout) cout << *toiout; 324 tgenp.PrintStatus(cout); 325 326 // Fermeture du fitswriter 327 if(w) delete w;; 328 219 329 } 220 330 catch (PThrowable & exc) {
Note:
See TracChangeset
for help on using the changeset viewer.