SKDetector.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2010 by Andrew Jameson
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __SKDetector_h
10 #define __SKDetector_h
11 
12 #include "dsp/Transformation.h"
13 #include "dsp/TimeSeries.h"
14 #include "dsp/BitSeries.h"
15 #include "Reference.h"
16 #include "MJD.h"
17 
18 namespace dsp {
19 
20  class IOManager;
21  class TimeSeries;
22 
24  class SKDetector: public Transformation<TimeSeries,BitSeries> {
25 
26  public:
27 
30 
32  ~SKDetector ();
33 
35  void set_thresholds (unsigned _M, float _n_std_devs);
36 
38  void set_channel_range (unsigned start, unsigned end);
39 
41  void set_options (bool disable_fscr, bool disable_tscr, bool disable_ft);
42 
44  void set_input_tscr (TimeSeries * _input_tscr);
45 
47  unsigned get_M () const { return M; }
48 
50  float get_excision_threshold () const { return n_std_devs; }
51 
53  void get_filtered_sum (std::vector<float>& sum) const
54  { sum = filtered_sum; }
55 
57  void get_filtered_hits (std::vector<uint64_t>& hits) const
58  { hits = filtered_hits; }
59 
61  void get_unfiltered_sum (std::vector<float>& sum) const
62  { sum = unfiltered_sum; }
63 
65  uint64_t get_unfiltered_hits () const { return unfiltered_hits; }
66 
68  void reset_count () { unfiltered_hits = 0; }
69 
71  class Engine;
72 
73  void set_engine (Engine*);
74 
75  protected:
76 
78  void reserve();
79 
81  void transformation ();
82 
85 
86  void reset_mask ();
87 
88  void detect_tscr ();
89 
90  void detect_skfb ();
91 
92  void detect_fscr();
93 
94  void count_zapped ();
95 
97  std::vector<float> filtered_sum;
98 
100  std::vector<uint64_t> filtered_hits;
101 
103  std::vector<float> unfiltered_sum;
104 
106  uint64_t unfiltered_hits;
107 
110 
112  unsigned tscr_M;
113 
114  float tscr_upper;
115  float tscr_lower;
116 
118  unsigned M;
119 
120  float one_sigma;
121 
122  float n_std_devs;
123 
124  float upper_thresh;
125 
126  float lower_thresh;
127 
128  float mega_upper_thresh;
129 
130  float mega_lower_thresh;
131 
132  unsigned s_chan;
133 
134  unsigned e_chan;
135 
136  uint64_t ndat_zapped;
137 
138  uint64_t ndat_zapped_skfb;
139 
140  uint64_t ndat_zapped_mega;
141 
142  uint64_t ndat_zapped_fscr;
143 
144  uint64_t ndat_zapped_tscr;
145 
146  uint64_t ndat_total;
147 
148  bool disable_fscr;
149 
150  bool disable_tscr;
151 
152  bool disable_ft;
153 
154  unsigned debugd;
155 
156  private:
157 
158  };
159 
160  class SKDetector::Engine : public Reference::Able
161  {
162  public:
163 
164  virtual void setup () = 0;
165 
166  virtual void reset_mask (dsp::BitSeries* output) = 0;
167 
168  virtual void detect_ft (const dsp::TimeSeries* input, dsp::BitSeries* output,
169  float upper_thresh, float lower_thresh) = 0;
170 
171  virtual void detect_fscr (const dsp::TimeSeries* input, dsp::BitSeries* output,
172  const float mu2, const float std_devs,
173  unsigned s_chan, unsigned e_chan) = 0;
174 
175  virtual void detect_tscr (const dsp::TimeSeries* input,
176  const dsp::TimeSeries * input_tscr,
178  float upper_thresh, float lower_thresh) = 0;
179 
180  virtual int count_mask (const dsp::BitSeries* output) = 0;
181 
182  virtual float * get_estimates (const TimeSeries* input) = 0;
183 
184  virtual unsigned char * get_zapmask (const BitSeries* input) = 0;
185 
186  };
187 
188 
189 }
190 
191 #endif
SKDetector()
Default constructor.
Definition: SKDetector.C:19
Computes the upper and lower bounds on estimates of the generalized spectral kurtosis.
Definition: SKLimits.h:35
void set_input_tscr(TimeSeries *_input_tscr)
Set the tsrunched SKFilterbank input.
Definition: SKDetector.C:98
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
Defines the interface by which Transformations are performed on data.
Definition: Transformation.h:54
void set_options(bool disable_fscr, bool disable_tscr, bool disable_ft)
Set various options for SKDetector.
Definition: SKDetector.C:90
std::vector< float > filtered_sum
Total SK statistic for each poln/channel, post filtering.
Definition: SKDetector.h:102
void get_filtered_hits(std::vector< uint64_t > &hits) const
Hits on filtered average for each channel.
Definition: SKDetector.h:62
std::vector< float > unfiltered_sum
Total SK statistic for each poln/channel, before filtering.
Definition: SKDetector.h:108
uint64_t unfiltered_hits
Hits on unfiltered SK statistic, same for each channel.
Definition: SKDetector.h:111
unsigned tscr_M
Number of time samples integrated into tscr SK estimates.
Definition: SKDetector.h:117
Reference::To< TimeSeries > input_tscr
Tsrunched SK statistic timeseries for the current block.
Definition: SKDetector.h:114
void reserve()
Reserve the required amount of output space required.
Definition: SKDetector.C:104
const ScalarMath sqrt(const ScalarMath &x)
void get_unfiltered_sum(std::vector< float > &sum) const
Total SK statistic for each poln/channel, before filtering.
Definition: SKDetector.h:66
uint64_t get_unfiltered_hits() const
Hits on unfiltered SK statistic, same for each channel.
Definition: SKDetector.h:70
void transformation()
Perform the transformation on the input time series.
Definition: SKDetector.C:115
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
std::vector< uint64_t > filtered_hits
Hits on filtered average for each channel.
Definition: SKDetector.h:105
void set_thresholds(unsigned _M, float _n_std_devs)
Set the RFI thresholds with the specified factor.
Definition: SKDetector.C:65
~SKDetector()
Destructor.
Definition: SKDetector.C:46
A container for storing digitized (generally not floating point) data
Definition: BitSeries.h:35
void get_filtered_sum(std::vector< float > &sum) const
Total SK statistic for each poln/channel, post filtering.
Definition: SKDetector.h:58
void set_channel_range(unsigned start, unsigned end)
Set the channel range to conduct detection.
Definition: SKDetector.C:84
float get_excision_threshold() const
The excision threshold in number of standard deviations.
Definition: SKDetector.h:55
unsigned M
The number of adjacent blocks to be used in SK estimator.
Definition: SKDetector.h:123
void reset_count()
The arrays will be reset when count_zapped is next called.
Definition: SKDetector.h:73
Reference::To< Engine > engine
Interface to alternate processing engine (e.g. GPU)
Definition: SKDetector.h:89
unsigned get_M() const
The number of time samples used to calculate the SK statistic.
Definition: SKDetector.h:52
Reference::To< const TimeSeries > input
Container from which input data will be read.
Definition: HasInput.h:49
Reference::To< BitSeries > output
Container into which output data will be written.
Definition: HasOutput.h:49

Generated using doxygen 1.8.17