Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Rfim.h
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef SKA_CHEETAH_RFIM_AMPP_RFIM_H
25 #define SKA_CHEETAH_RFIM_AMPP_RFIM_H
26 
27 #include "cheetah/rfim/ampp/Config.h"
28 #include "cheetah/rfim/ampp/Spectrum.h"
29 #include "cheetah/rfim/PolicyInfo.h"
30 #include "cheetah/rfim/policy/Policy.h"
31 #include "cheetah/utils/Architectures.h"
32 #include "cheetah/data/TimeFrequency.h"
33 #include <boost/circular_buffer.hpp>
34 #include <mutex>
35 
36 namespace ska {
37 namespace cheetah {
38 namespace rfim {
39 namespace ampp {
40 
129 template<typename RfimTraits>
130 class Rfim
131 {
132  typedef typename RfimTraits::NumericalRep NumericalRep;
133  typedef typename RfimTraits::Policy Policy;
134  typedef typename PolicyInfo<Policy>::AdapterType DataAdapter;
135  static_assert(!std::is_const<DataAdapter>::value, "DataAdapter cannot be const");
136  typedef typename PolicyInfo<Policy>::ReturnType ReturnType;
137 
138  public:
139  typedef cheetah::Cpu Architecture;
140 
141  public:
142  Rfim(Config const& config, typename RfimTraits::BandPassHandler const&);
143  Rfim(Rfim const&) = delete;
144  Rfim(Rfim&&);
145  ~Rfim();
146 
150  void set_max_history(unsigned length);
151 
155  ReturnType operator()(panda::PoolResource<Cpu>& thread, std::shared_ptr<data::TimeFrequency<Cpu, NumericalRep>> data);
156 
161 
162  private:
163  void run_impl(data::TimeFrequency<Cpu, NumericalRep> const& data_read, DataAdapter& data_write);
164 
165  private:
166  Config const& _config;
167  unsigned _zero_dm;
168  unsigned _bad_spectra;
169  boost::circular_buffer<float> _mean_buffer, _rms_buffer;
170  float _replacement_sample_mean, _replacement_sample_rms;
171  float _rms_run_ave, _mean_run_ave;
172  float _mean_over_rms;
173  float _fraction_bad_channels;
174  unsigned _sample_counter; // history pointer
175  unsigned _max_history; // max size of history buffer
176  // flag for removing median from each spectrum, equivalent to the zero-DMing technique
177  int _use_mean_over_rms;
178  std::shared_ptr<Spectrum<NumericalRep>> _bandpass_data_ptr;
179  double _bandpass_rms;
180  Spectrum<NumericalRep>& _bandpass_data;
181  std::vector<NumericalRep> _replacement_sample; // TODO move into policy
182  std::mutex _mutex;
183  typename RfimTraits::BandPassHandler _bandpass_handler;
184  policy::Policy<Policy> _policy;
185 };
186 
187 } // namespace ampp
188 } // namespace rfim
189 } // namespace cheetah
190 } // namespace ska
191 #include "detail/Rfim.cpp"
192 
193 #endif // SKA_CHEETAH_RFIM_AMPP_RFIM_H
std::conditional< std::is_same< void, AdapterDataReturnType >::value, DataArgumentType, AdapterDataReturnType >::type ReturnType
the data type the policy will return
Definition: PolicyInfo.h:67
Some limits and constants for FLDO.
Definition: Brdz.h:35
ReturnType operator()(panda::PoolResource< Cpu > &thread, std::shared_ptr< data::TimeFrequency< Cpu, NumericalRep >> data)
task interface warpper around run
ReturnType run(data::TimeFrequency< Cpu, NumericalRep > &data)
perform rfi clipping on the data
Definition: Rfim.cpp:504
Configuration Options for the ampp rfi clipping algorithm.
Definition: Config.h:40
AMPP alogrithm CPU based on a dynamic bandfilter.
Definition: Rfim.h:130
void set_max_history(unsigned length)
set the maximum history