Changeset 1479 in Sophya
- Timestamp:
- Apr 27, 2001, 2:52:15 AM (24 years ago)
- Location:
- trunk/ArchTOIPipe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/ProcWSophya/simtoipr.cc
r1478 r1479 5 5 #include "pexceptions.h" 6 6 #include "ctimer.h" 7 8 SimpleDeglitcher::SimpleDeglitcher(int wsz, double ns, int maxnpt) 7 #include "fftpserver.h" 8 9 SimpleDeglitcher::SimpleDeglitcher(int wsz, double ns, int maxnpt, int minnpt) 9 10 { 10 11 SetWSize(wsz); 11 SetDetectionParam(ns, ns/2., maxnpt );12 SetDetectionParam(ns, ns/2., maxnpt, minnpt); 12 13 SetRange(-9.e39, 9.e39); 13 14 RepBadSamples(true, true); … … 24 25 } 25 26 26 void SimpleDeglitcher::SetDetectionParam(double ns, double ns2, int maxnpt, int wszrec) 27 void SimpleDeglitcher::SetDetectionParam(double ns, double ns2, int maxnpt, 28 int minnpt, int wszrec) 27 29 { 28 30 nsig = (ns > 0.01) ? ns : 1.; 29 31 nsig2 = (ns2 > 0.01) ? ns2 : nsig/2.; 30 32 maxpoints = ((maxnpt > 0) && (maxnpt <= wsize)) ? maxnpt : 5; 33 minpoints = ((minnpt > 0) && (minnpt <= maxpoints)) ? minnpt : maxpoints/2; 31 34 wrecsize = ((wszrec > 0) && (wszrec <= wsize)) ? wszrec : 2*maxpoints; 32 35 } … … 42 45 os << "\n ------------------------------------------------------ \n" 43 46 << " SimpleDeglitcher::PrintStatus() - WindowSize=" << WSize() 44 << " NbSigmas=" << NbSigmas() << " MaxPoints=" << MaxPoints() << endl; 45 os << " NbSigmas2=" << NbSigmas2() << " WRecSize= " << WRecSize() 47 << " MaxPoints=" << MaxPoints() << " MinPoints=" << MinPoints() << endl; 48 os << " NbSigmas=" << NbSigmas() 49 << " NbSigmas2=" << NbSigmas2() << " WRecSize= " << WRecSize() 46 50 << " Range_Min= " << range_min << " Range_Max= " << range_max << endl; 47 51 os << " RepOutOfRangeSamples: " << _Bool2YesNo(rec_out_range_samples) … … 117 121 getData(0, k+snb, vin(k), vfg(k)); 118 122 119 int nokdebut = 0 .;123 int nokdebut = 0; 120 124 double s = 0.; 121 125 double mean = 0.; … … 236 240 if (valcur < mean+curnsig*sigma) { // inferieur au seuil 237 241 if (fgglitch) { 238 if (k-kgl < maxpoints) { // On vient de detecter un glitch 242 if ( (k-kgl <= maxpoints) && (k-kgl >= minpoints) ) { 243 // On vient de detecter un glitch 239 244 glcount++; 240 245 if (rec_gl_samples) { // On change la valeur des samples … … 253 258 lastput = snb+k-1; 254 259 } // - Fin de detection de glitch 255 else { // Trop long - ce n'est pas un glitch ...260 else { // Trop long ou trop court - ce n'est pas un glitch ... 256 261 for(ii=kgl; ii<k; ii++) { 257 262 putData(0, ii+snb, vin(ii%wsize), vfg(ii%wsize)); … … 267 272 else { // Superieur au seuil 268 273 if (fgglitch) { 269 if (k-kgl+1 > =maxpoints) { // serie de points > seuil274 if (k-kgl+1 > maxpoints) { // serie de points > seuil 270 275 for(ii=kgl; ii<=k; ii++) // -> Donc pas glitch 271 276 putData(0, ii+snb, vin(ii%wsize), vfg(ii%wsize)); … … 600 605 } 601 606 607 // ---------------------------------------------------------------------- 608 // Classe SimpleFourierFilter : Filtre simple ds le domaine de Fourier 609 // ---------------------------------------------------------------------- 610 611 SimpleFourierFilter::SimpleFourierFilter(Vector const & vc) 612 { 613 ffcoef = vc; 614 wsize = (ffcoef.Size()-1)*2; 615 if (wsize < 16) 616 throw ParmError("SimpleFourierFilter::SimpleFourierFilter() WSize<16 !"); 617 KeepSpectra(0); 618 } 619 620 SimpleFourierFilter::~SimpleFourierFilter() 621 { 622 } 623 624 625 void SimpleFourierFilter::PrintStatus(ostream & os) 626 { 627 os << "\n ------------------------------------------------------ \n" 628 << " SimpleFourierFilter::PrintStatus() - WindowSize=" 629 << WSize() << endl; 630 TOIProcessor::PrintStatus(os); 631 os << " Coeff= " << ffcoef << endl; 632 os << " ProcessedSampleCount=" << ProcessedSampleCount() << endl; 633 os << " ------------------------------------------------------ " << endl; 634 } 635 636 void SimpleFourierFilter::init() { 637 cout << "SimpleFourierFFilter::init" << endl; 638 declareInput("in"); 639 declareOutput("out"); 640 declareOutput("incopie"); 641 name = "SimpleFourierFilter"; 642 // upExtra = 1; 643 } 644 645 646 void SimpleFourierFilter::run() { 647 // TOIManager* mgr = TOIManager::getManager(); 648 int snb = getMinIn(); 649 int sne = getMaxIn(); 650 651 bool fgout = checkOutputTOIIndex(0); 652 bool fgincopie = checkOutputTOIIndex(1); 653 654 if (!checkInputTOIIndex(0)) { 655 cerr << " SimpleFourierFilter::run() - Input TOI (in) not connected! " 656 << endl; 657 throw ParmError("SimpleFourierFilter::run() Input TOI (in) not connected!"); 658 } 659 if (!fgout) { 660 cerr << " SimpleFourierFilter::run() - No Output TOI connected! " 661 << endl; 662 throw ParmError("SimpleFourierFilter::run() No output TOI connected!"); 663 } 664 665 cout << " SimpleFourierFilter::run() SNRange=" << snb << " - " << sne << endl; 666 667 668 try { 669 Timer tm("SimpleFourierFilter::run()"); 670 // Le debut 671 Vector vin(wsize); 672 Vector vout(wsize); 673 TVector<int_8> vfg(wsize); 674 TVector< complex<r_8> > vfft; 675 TVector< complex<r_8> > zcoef(ffcoef.Size()); 676 zcoef = ffcoef; 677 678 679 FFTPackServer ffts; 680 ffts.setNormalize(true); 681 // Boucle sur les sampleNum 682 683 int k,i,klast; 684 int nks = 0; 685 686 klast = snb-1; 687 // 1er partie, on traite par paquets de wsize 688 for(k=snb;k<=sne-wsize+1;k+=wsize) { 689 for(i=0; i<wsize; i++) 690 getData(0, k+i, vin(i), vfg(i)); 691 ffts.FFTForward(vin, vfft); 692 if (nks < nb_keep) { 693 string dbgfile = "ffiltdbg" + (string)MuTyV(nks) + ".ppf"; 694 POutPersist po(dbgfile); 695 po << vfft; 696 nks++; 697 } 698 vfft.MulElt(zcoef); 699 ffts.FFTBackward(vfft, vout); 700 for(i=0; i<wsize; i++) 701 putData(0,k+i,vout(i),vfg(i)); 702 if (fgincopie) 703 for(i=0; i<wsize; i++) 704 putData(1, k+i, vin(i), vfg(i)); 705 klast+=wsize; 706 totnscount+=wsize; 707 } 708 709 710 // 2eme partie, on traite la fin du bloc d'echantillons si necessaire 711 double inval; 712 int_8 inflg; 713 if (klast < sne) 714 for(k=klast+1; k<=sne; k++) { 715 getData(0, k, inval, inflg); 716 putData(0, k, inval, inflg); 717 if (fgincopie) 718 putData(1, k, inval, inflg); 719 totnscount++; 720 } 721 cout << " SimpleFourierFilter::run() - End of processing " << endl; 722 } // Bloc try 723 724 catch (PException & exc) { 725 cerr << "SimpleFourierFilter: Catched Exception " << (string)typeid(exc).name() 726 << "\n .... Msg= " << exc.Msg() << endl; 727 } 728 } 602 729 603 730 // --------------------------------------------------------------- … … 659 786 out_index = -1; 660 787 int nbconin = 0; 661 bool fggin = false;662 788 char buff[64]; 663 789 for(int ki=0;ki<nb_input;ki++) { -
trunk/ArchTOIPipe/ProcWSophya/simtoipr.h
r1478 r1479 14 14 class SimpleDeglitcher : public TOIProcessor { 15 15 public: 16 SimpleDeglitcher(int wsz=64, double ns=3, int maxnpt=5); 16 SimpleDeglitcher(int wsz=64, double ns=3, 17 int maxnpt=5, int minnpt=2); 17 18 virtual ~SimpleDeglitcher(); 18 19 … … 26 27 27 28 28 void SetDetectionParam(double ns, double ns2, int maxnpt, int wszrec=0); 29 void SetDetectionParam(double ns, double ns2, int maxnpt, 30 int minnpt, int wszrec=0); 29 31 30 32 inline void RepBadSamples(bool gl_samples, bool out_range_samples, bool use_wrec=true) … … 40 42 inline double NbSigmas2() const { return nsig2; } 41 43 inline int MaxPoints() const { return maxpoints; } 44 inline int MinPoints() const { return minpoints; } 42 45 43 46 inline int_8 ProcessedSampleCount() const { return totnscount; } … … 61 64 double nsig2; // Seuil en nb de sigmas, pour les points suivants le 1er 62 65 int maxpoints; // Nb maxi de points > ns sigmas 66 int minpoints; // Nb mini de points > ns sigmas pour avoir un glitch 63 67 double range_min, range_max; // Range acceptable pour in 64 68 … … 136 140 137 141 142 // Un filtre simple, dans le domaine de Fourier 143 // InverseFFT ( FFT(Vecteur(in)) * FilterCoefficient ) 144 145 class SimpleFourierFilter : public TOIProcessor { 146 public: 147 SimpleFourierFilter(Vector const & vc); 148 ~SimpleFourierFilter(); 149 150 inline int WSize() const { return wsize; } 151 inline int_8 ProcessedSampleCount() const { return totnscount; } 152 inline Vector FilterCoefficients() const 153 { Vector rcv; rcv = ffcoef; return(rcv); } 154 155 virtual void PrintStatus(ostream & os) ; // const plus tard 156 157 virtual void init(); 158 virtual void run(); 159 160 inline void KeepSpectra(int nb=0) 161 { nb_keep = nb; } 162 protected: 163 int_8 totnscount; // Nombre total d'echantillon processe 164 int wsize; // Taille de fenetre de travail 165 Vector ffcoef; // Coefficients du filtre 166 int nb_keep; 167 }; 168 169 138 170 // Classe SimpleFanOut 139 // Transforme recopie chaque entree sur M lignes de sortie171 // Recopie chaque entree sur M lignes de sortie 140 172 141 173 class SimpleFanOut : public TOIProcessor { … … 159 191 }; 160 192 193 161 194 #endif -
trunk/ArchTOIPipe/TestPipes/simtst.cc
r1478 r1479 33 33 else { 34 34 cout << "\n Usage : simtst [-dbg] [-start snb] [-end sne] \n" 35 << " [-wtoi sz] [-w2 sz] inFitsName outFitsName ppfFileName \n" 35 << " [-wtoi sz] [-wdegli sz] [-wfft sz] [-keepfft n] \n" 36 << " inFitsName outFitsName \n" 36 37 << " -dbg : sets TOISeqBuffered debug level to 1 \n" 37 38 << " -start snb : sets the start sample num \n" … … 42 43 << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n" 43 44 << " -wdegli sz : sets deglitcher window size (def= 512) \n" 45 << " -wfft sz : Activate Fourier filter and sets its width \n" 46 << " -keepfft n : Keeps n spectra (if Fourier filter activated) \n" 44 47 << endl; 45 48 exit(0); … … 54 57 55 58 bool fgdbg = false; 56 int w1 = 8192; 57 int w2 = 512; 59 int wtoi = 8192; 60 int wdegli = 512; 61 int wfft = 4096; 62 int keepfft = 0; 58 63 int nmax = 10; 59 int istart = 104121000+w 1*5;64 int istart = 104121000+wtoi*5; 60 65 int iend = 0; 61 66 double range_min = -16000; … … 63 68 string infile; 64 69 string outfile; 65 string ppffile;66 70 string intoi = "boloMuV_27"; 71 bool fg_f_filt = false; 67 72 68 73 if (narg < 4) Usage(true); … … 80 85 else if (strcmp(arg[ia],"-wtoi") == 0) { 81 86 if (ia == narg-1) Usage(true); 82 w 1= atoi(arg[ia+1]); ia++;87 wtoi = atoi(arg[ia+1]); ia++; 83 88 } 84 89 else if (strcmp(arg[ia],"-wdegli") == 0) { 85 90 if (ia == narg-1) Usage(true); 86 w2 = atoi(arg[ia+1]); ia++; 91 wdegli = atoi(arg[ia+1]); ia++; 92 } 93 else if (strcmp(arg[ia],"-wfft") == 0) { 94 if (ia == narg-1) Usage(true); 95 wfft = atoi(arg[ia+1]); ia++; 96 fg_f_filt = true; 97 } 98 else if (strcmp(arg[ia],"-keepfft") == 0) { 99 if (ia == narg-1) Usage(true); 100 keepfft = atoi(arg[ia+1]); ia++; 87 101 } 88 102 else if (strcmp(arg[ia],"-range") == 0) { … … 100 114 } 101 115 102 if (iend < istart) iend = istart+w 1*(nmax+5);103 if ((narg-ko) < 3) Usage(true);116 if (iend < istart) iend = istart+wtoi*(nmax+5); 117 if ((narg-ko) < 2) Usage(true); 104 118 infile = arg[ko]; 105 119 outfile = arg[ko+1]; 106 ppffile = arg[ko+2];107 120 108 121 cout << " Initializing SOPHYA ... " << endl; … … 110 123 InitTim(); 111 124 112 cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile113 << " ppfFile= " << ppffile << endl;114 cout << ">>>> Window Size W 1= " << w1 << " W2= " << w2125 cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" 126 << outfile << endl; 127 cout << ">>>> Window Size WTOI= " << wtoi << " WDEGLI= " << wdegli 115 128 << " iStart= " << istart << " iEnd= " << iend << endl; 116 129 cout << ">>>> InTOIName= " << intoi << endl; 130 117 131 try { 118 132 TOIManager* mgr = TOIManager::getManager(); … … 131 145 132 146 147 int w1 = wtoi; 148 int w2 = (fg_f_filt && (wfft > w1)) ? wfft : w1; 149 133 150 // char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"}; 134 151 // char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"}; … … 139 156 TOISeqBuffered * toimean = new TOISeqBuffered("mean", w1); 140 157 if (fgdbg) toimean->setDebugLevel(1); 141 TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w 1);158 TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w2); 142 159 if (fgdbg) toisig->setDebugLevel(1); 143 160 TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1); … … 160 177 161 178 cout << " Creating SimpleDeglitcher() " << endl; 162 SimpleDeglitcher degl(w2); 179 SimpleDeglitcher degl(wdegli); 180 degl.SetDetectionParam(3.,1.5, 4, 2, 10); 163 181 cout << " Setting Range for deglitcher: " << range_min 164 182 << " - " << range_max << endl; 183 165 184 degl.SetRange(range_min, range_max); 166 185 degl.addInput("in", toiin); … … 174 193 TOISeqBuffered * toidegli0 = new TOISeqBuffered("degli0", w1); 175 194 if (fgdbg) toidegli0->setDebugLevel(1); 176 TOISeqBuffered * toidegli1 = new TOISeqBuffered("degli1", w 1);195 TOISeqBuffered * toidegli1 = new TOISeqBuffered("degli1", w2); 177 196 178 197 TOISeqBuffered * toimean0 = new TOISeqBuffered("mean0", w1); 179 198 if (fgdbg) toimean0->setDebugLevel(1); 180 TOISeqBuffered * toimean1 = new TOISeqBuffered("mean1", w 1);199 TOISeqBuffered * toimean1 = new TOISeqBuffered("mean1", w2); 181 200 if (fgdbg) toimean1->setDebugLevel(1); 182 201 … … 206 225 TOISeqBuffered * toiout = new TOISeqBuffered("out", w1); 207 226 if (fgdbg) toiout->setDebugLevel(1); 208 TOISeqBuffered * toideglioffcopie = new TOISeqBuffered("deglioffcopie", w 1);227 TOISeqBuffered * toideglioffcopie = new TOISeqBuffered("deglioffcopie", w2); 209 228 if (fgdbg) toideglioffcopie->setDebugLevel(1); 210 229 filt.addOutput("out", toiout); 211 230 filt.addOutput("incopie", toideglioffcopie); 212 231 232 Vector fcoef(wfft/2); 233 fcoef = RegularSequence(1., -2./wfft); 234 cout << " Creating Fourier Filter ... " << endl; 235 SimpleFourierFilter sfft(fcoef); 236 sfft.KeepSpectra(keepfft); 237 TOISeqBuffered * toifft = NULL; 238 TOISeqBuffered * toifiltcopie = NULL; 239 240 if (fg_f_filt) { 241 cout << " Connecting Fourier Filter ... " << endl; 242 toifft = new TOISeqBuffered("fftout", w1); 243 toifiltcopie = new TOISeqBuffered("filtcopie", w1); 244 sfft.addInput("in",toiout); 245 sfft.addOutput("out", toifft); 246 sfft.addOutput("incopie", toifiltcopie); 247 } 213 248 214 249 cout << " Connecting to output (FitsWriter) " << endl; … … 216 251 w.setOutFlags(true); 217 252 w.addInput("in", toiincopie); 218 w.addInput("out", toiout); 253 if (fg_f_filt) { 254 w.addInput("filtout", toifiltcopie); 255 w.addInput("fftout", toifft); 256 } 257 else w.addInput("out", toiout); 219 258 w.addInput("degli", toidegli1); 220 259 w.addInput("deglioff", toideglioffcopie); … … 239 278 adder.start(); 240 279 filt.start(); 280 if (fg_f_filt) sfft.start(); 241 281 w.start(); 242 282 … … 268 308 cout << filt; 269 309 cout << adder; 310 if (fg_f_filt) cout << sfft ; 270 311 271 312 }
Note:
See TracChangeset
for help on using the changeset viewer.