[1442] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 |
|
---|
| 3 | #ifndef SIMTOIPR_H
|
---|
| 4 | #define SIMTOIPR_H
|
---|
| 5 |
|
---|
| 6 | #include "toiprocessor.h"
|
---|
[1454] | 7 | #include "tvector.h"
|
---|
[1442] | 8 |
|
---|
| 9 | // --------- Un deglitcheur simple
|
---|
| 10 | // Dans chaque fenetre de largeur de wsz
|
---|
| 11 | // if (val > Mean(Window)+ns*Sigma(Window)) val = Mean(Window)
|
---|
| 12 | // Si Pas plus de maxnpt points remplissants cette condition
|
---|
| 13 |
|
---|
| 14 | class SimpleDeglitcher : public TOIProcessor {
|
---|
| 15 | public:
|
---|
| 16 | SimpleDeglitcher(int wsz=64, double ns=3, int maxnpt=5);
|
---|
| 17 | virtual ~SimpleDeglitcher();
|
---|
| 18 |
|
---|
[1454] | 19 | inline void SetRange(double min, double max)
|
---|
| 20 | { range_min = min; range_max = max; }
|
---|
| 21 | inline void GetRange(double& min, double& max) const
|
---|
| 22 | { min = range_min; max = range_max; }
|
---|
| 23 |
|
---|
[1478] | 24 | inline void SetWSize(int wsz)
|
---|
| 25 | { wsize = (wsz < 5) ? 5 : wsz; }
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | void SetDetectionParam(double ns, double ns2, int maxnpt, int wszrec=0);
|
---|
| 29 |
|
---|
| 30 | inline void RepBadSamples(bool gl_samples, bool out_range_samples, bool use_wrec=true)
|
---|
| 31 | { rec_gl_samples = gl_samples; rec_out_range_samples = out_range_samples;
|
---|
| 32 | rec_use_wrec = use_wrec; }
|
---|
| 33 |
|
---|
[1442] | 34 | virtual void init();
|
---|
| 35 | virtual void run();
|
---|
| 36 |
|
---|
| 37 | inline int WSize() const { return wsize; }
|
---|
[1478] | 38 | inline int WRecSize() const { return wrecsize; }
|
---|
[1442] | 39 | inline double NbSigmas() const { return nsig; }
|
---|
[1478] | 40 | inline double NbSigmas2() const { return nsig2; }
|
---|
[1442] | 41 | inline int MaxPoints() const { return maxpoints; }
|
---|
| 42 |
|
---|
[1454] | 43 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 44 | inline int_8 GlitchCount() const { return glcount; }
|
---|
| 45 | inline int_8 GlitchSampleCount() const { return glnscount; }
|
---|
| 46 | inline int_8 OutOfRangeSampleCount() const { return out_range_nscount; }
|
---|
[1442] | 47 |
|
---|
[1443] | 48 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 49 |
|
---|
[1442] | 50 | protected:
|
---|
[1454] | 51 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
| 52 | int_8 glnscount; // Nombre total de glitch
|
---|
| 53 | int_8 glcount; // Nombre de glitch detecte
|
---|
| 54 | int_8 out_range_nscount; // Nombre de sample Out Of Range
|
---|
[1443] | 55 | bool deglitchdone; // Deglitch effectue
|
---|
[1442] | 56 |
|
---|
| 57 | int wsize; // Taille de fenetre de travail
|
---|
[1478] | 58 | int wrecsize; // Taille de fenetre de calcul pour reconstruite les mauvaises valeur
|
---|
| 59 | // pour valeur de glitch
|
---|
[1442] | 60 | double nsig; // Seuil en nb de sigmas
|
---|
[1478] | 61 | double nsig2; // Seuil en nb de sigmas, pour les points suivants le 1er
|
---|
[1442] | 62 | int maxpoints; // Nb maxi de points > ns sigmas
|
---|
[1454] | 63 | double range_min, range_max; // Range acceptable pour in
|
---|
[1478] | 64 |
|
---|
| 65 | bool rec_gl_samples; // if true, replace glitch sample values
|
---|
| 66 | bool rec_out_range_samples; // if true, replace out of range sample values
|
---|
| 67 | bool rec_use_wrec; // if true, use Mean[Window(wrecsize)] to replace bad samples
|
---|
| 68 | // else use sliding mean value for
|
---|
| 69 |
|
---|
[1442] | 70 | };
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | // Un filtre simple, dans le domaine temporel
|
---|
| 74 | // remplace val -> Somme(val(i)*coeff(i)) ds Fenetre
|
---|
| 75 |
|
---|
| 76 | class SimpleFilter : public TOIProcessor {
|
---|
| 77 | public:
|
---|
| 78 | enum FilterKind {
|
---|
| 79 | UserFilter=0, // User defined filter function
|
---|
| 80 | MeanFilter=1, // Replace sample by the window mean value (lowpass)
|
---|
| 81 | SumFilter=2, // Replace sample by the window sum (lowpass)
|
---|
| 82 | GaussFilter=3, // Apply a gaussian to the window samples
|
---|
| 83 | DiffFilter=4, // value -= MeanValue
|
---|
| 84 | };
|
---|
| 85 |
|
---|
[1454] | 86 | static string FilterKind2String(FilterKind fk);
|
---|
[1442] | 87 | SimpleFilter(int wsz=128,
|
---|
[1454] | 88 | FilterKind fk=SimpleFilter::MeanFilter,
|
---|
| 89 | double a=1., double s=1.);
|
---|
| 90 | SimpleFilter(Vector const & vc);
|
---|
[1442] | 91 | ~SimpleFilter();
|
---|
| 92 |
|
---|
| 93 | inline FilterKind Type() { return fkind; }
|
---|
| 94 |
|
---|
| 95 | inline int WSize() const { return wsize; }
|
---|
[1454] | 96 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 97 | Vector FilterCoefficients() const;
|
---|
[1442] | 98 |
|
---|
[1443] | 99 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 100 |
|
---|
[1442] | 101 | virtual void init();
|
---|
| 102 | virtual void run();
|
---|
| 103 |
|
---|
| 104 | protected:
|
---|
| 105 | FilterKind fkind;
|
---|
[1454] | 106 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
[1442] | 107 | int wsize; // Taille de fenetre de travail
|
---|
| 108 | double* coef; // Coefficients du filtre
|
---|
| 109 |
|
---|
| 110 | };
|
---|
| 111 |
|
---|
[1454] | 112 | // Classe SimpleAdder
|
---|
| 113 | // Calcule la sortie = Somme_Entree [ coeff[num] * entree[num] ]
|
---|
| 114 |
|
---|
| 115 | class SimpleAdder : public TOIProcessor {
|
---|
| 116 | public:
|
---|
| 117 | SimpleAdder(int nbinput);
|
---|
| 118 | ~SimpleAdder();
|
---|
| 119 |
|
---|
| 120 | void SetGain(int num, double g);
|
---|
| 121 | double Gain(int num);
|
---|
| 122 |
|
---|
| 123 | inline int NbInput() const { return nb_input; }
|
---|
| 124 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 125 |
|
---|
| 126 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 127 |
|
---|
| 128 | virtual void init();
|
---|
| 129 | virtual void run();
|
---|
| 130 |
|
---|
| 131 | protected:
|
---|
| 132 | int nb_input;
|
---|
| 133 | Vector gains;
|
---|
| 134 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
| 135 | };
|
---|
| 136 |
|
---|
| 137 |
|
---|
[1467] | 138 | // Classe SimpleFanOut
|
---|
| 139 | // Transforme recopie chaque entree sur M lignes de sortie
|
---|
| 140 |
|
---|
| 141 | class SimpleFanOut : public TOIProcessor {
|
---|
| 142 | public:
|
---|
| 143 | SimpleFanOut(int nbinput, int mfanout);
|
---|
| 144 | ~SimpleFanOut();
|
---|
| 145 |
|
---|
| 146 | inline int NbInput() const { return nb_input; }
|
---|
| 147 | inline int MFanOut() const { return m_fanout; }
|
---|
| 148 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 149 |
|
---|
| 150 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 151 |
|
---|
| 152 | virtual void init();
|
---|
| 153 | virtual void run();
|
---|
| 154 |
|
---|
| 155 | protected:
|
---|
| 156 | int nb_input;
|
---|
| 157 | int m_fanout;
|
---|
| 158 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
| 159 | };
|
---|
| 160 |
|
---|
[1442] | 161 | #endif
|
---|