Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
RfiExcision.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_SPS_RFIEXCISION_H
25 #define SKA_CHEETAH_SPS_RFIEXCISION_H
26 #include "cheetah/data/TimeFrequencyFlags.h"
27 #include "cheetah/data/TimeFrequency.h"
28 #include "cheetah/data/RfimFlaggedData.h"
29 #include <random>
30 
31 namespace ska {
32 namespace cheetah {
33 namespace sps{
34 
39 template<typename TimeFrequencyType, typename RfiFlagDataType>
41 {
42  private:
43  typedef typename std::conditional<std::is_const<TimeFrequencyType>::value
44  ,typename TimeFrequencyType::const_iterator
45  ,typename TimeFrequencyType::iterator>::type iterator;
46 
47  typedef typename std::conditional<std::is_const<RfiFlagDataType>::value
48  ,typename RfiFlagDataType::TimeFrequencyFlagsType::const_iterator
49  ,typename RfiFlagDataType::TimeFrequencyFlagsType::iterator>::type FlaggedIterator;
50 
51 
52  public:
53  typedef typename TimeFrequencyType::NumericalRep NumericalRep;
54 
55  typedef typename std::conditional<std::is_const<TimeFrequencyType>::value
56  , NumericalRep const&, NumericalRep&>::type reference;
57 
58  typedef NumericalRep const& const_reference;
59 
60  public:
61  RfiExcision(RfiFlagDataType& data, size_t offset, float ideal_rms, float threshold, bool active);
62  ~RfiExcision();
63 
64  bool operator==(RfiExcision const& iterator) const;
65  bool operator!=(RfiExcision const& iterator) const;
66 
67  RfiExcision& operator++();
68 
69  const_reference operator*() const;
70 
71  private:
72  FlaggedIterator _flag_it;
73  iterator _tf_it;
74  std::size_t _wrapindex;
75  NumericalRep _value;
76  NumericalRep _replacement_value;
77  float _ideal_rms;
78  float _threshold;
79  bool _active;
80  typename TimeFrequencyType::const_iterator _tf_end_it;
81  std::vector<float> _noise;
82 };
83 
84 } // namespace rfim
85 } // namespace cheetah
86 } // namespace ska
87 #include "cheetah/sps/detail/RfiExcision.cpp"
88 #endif // SKA_CHEETAH_SPS_RFIEXCISION_H
Some limits and constants for FLDO.
Definition: Brdz.h:35