Changeset 1479 in Sophya for trunk/ArchTOIPipe/ProcWSophya
- Timestamp:
- Apr 27, 2001, 2:52:15 AM (24 years ago)
- Location:
- trunk/ArchTOIPipe/ProcWSophya
- Files:
-
- 2 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
Note:
See TracChangeset
for help on using the changeset viewer.