Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
IqrmCpuTest.cpp
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 #include "cheetah/rfim/iqrmcpu/test/IqrmCpuTest.h"
25 #include "cheetah/rfim/iqrmcpu/Rfim.h"
26 #include "cheetah/rfim/test_utils/RfimTester.h"
27 
28 
29 namespace ska {
30 namespace cheetah {
31 namespace rfim {
32 namespace test {
33 
34 
35 IqrmCpuTest::IqrmCpuTest()
36  : ::testing::Test()
37 {
38 }
39 
40 IqrmCpuTest::~IqrmCpuTest()
41 {
42 }
43 
44 void IqrmCpuTest::SetUp()
45 {
46 }
47 
48 void IqrmCpuTest::TearDown()
49 {
50 }
51 
52 template<typename NumericalRepT>
53 struct IqrmCpuTestRfimTraits : public rfim::DefaultRfimTraits<data::TimeFrequency<Cpu, NumericalRepT>>
54 {
55  typedef NumericalRepT NumericalRep;
58  using typename BaseT::Policy;
59  using typename BaseT::BandPassHandler;
60 };
61 
62 template<typename NumericalRepT>
63 class IqrmCpuTraits : public RfimTesterTraits<NumericalRepT, typename rfim::iqrmcpu::Rfim<IqrmCpuTestRfimTraits<NumericalRepT>>::Architecture>
64 {
66 
67  public:
68  typedef typename BaseT::ResultType ResultType;
69  typedef typename BaseT::DataType DataType;
70 
71  public:
72  // return the iqrm specific configuration
73  static rfim::iqrmcpu::Config& config()
74  {
75  static rfim::iqrmcpu::Config config;
76  return config;
77  }
78 
79  // return the api for the iqrm algorithm
81  {
83  return algo_api;
84  }
85 
86  template<typename DeviceT>
87  ResultType apply_algorithm(DeviceT&& device, DataType& data)
88  {
89  return algo()(std::forward<DeviceT>(device), data.shared_from_this());
90  }
91 
92 };
93 
94 // non standard pass/fail criteria
95 template<typename NumericalRep>
96 struct EvaluateRfimMetrics<IqrmCpuTraits<NumericalRep>, cheetah::generators::RfiScenario<4, NumericalRep>>
97 {
98  static
99  void evaluate(rfim::Metrics const& m) {
100  EXPECT_LT(m.false_positives_percentage(), 25);
101  EXPECT_LT(m.false_negatives_percentage(), 24);
102  }
103 };
104 
105 template<typename NumericalRep>
106 struct EvaluateRfimMetrics<IqrmCpuTraits<NumericalRep>, cheetah::generators::RfiScenario<5, NumericalRep>>
107 {
108  static
109  void evaluate(rfim::Metrics const& m) {
110  EXPECT_LT(m.false_positives_percentage(), 80);
111  EXPECT_LT(m.false_negatives_percentage(), 25);
112  }
113 };
114 
115 template<typename NumericalRep>
116 struct EvaluateRfimMetrics<IqrmCpuTraits<NumericalRep>, cheetah::generators::RfiScenario<6, NumericalRep>>
117 {
118  static
119  void evaluate(rfim::Metrics const& m) {
120  EXPECT_LT(m.false_positives_percentage(), 75);
121  EXPECT_LT(m.false_negatives_percentage(), 30);
122  }
123 };
124 
125 template<typename NumericalRep>
126 struct EvaluateRfimMetrics<IqrmCpuTraits<NumericalRep>, cheetah::generators::RfiScenario<7, NumericalRep>>
127 {
128  static
129  void evaluate(rfim::Metrics const& m) {
130  EXPECT_LT(m.false_positives_percentage(), 15);
131  EXPECT_LT(m.false_negatives_percentage(), 33);
132  }
133 };
134 
135 template<typename NumericalRep>
136 struct EvaluateRfimMetrics<IqrmCpuTraits<NumericalRep>, cheetah::generators::RfiScenario<8, NumericalRep>>
137 {
138  static
139  void evaluate(rfim::Metrics const& m) {
140  EXPECT_LT(m.false_positives_percentage(), 14);
141  EXPECT_LT(m.false_negatives_percentage(), 34);
142  }
143 };
144 
145 template<typename NumericalRep>
146 struct EvaluateRfimMetrics<IqrmCpuTraits<NumericalRep>, cheetah::generators::RfiScenario<9, NumericalRep>>
147 {
148  static
149  void evaluate(rfim::Metrics const& m) {
150  EXPECT_LT(m.false_positives_percentage(), 14);
151  EXPECT_LT(m.false_negatives_percentage(), 35);
152  }
153 };
154 
155 template<typename NumericalRep>
156 struct EvaluateRfimMetrics<IqrmCpuTraits<NumericalRep>, cheetah::generators::RfiScenario<10, NumericalRep>>
157 {
158  static
159  void evaluate(rfim::Metrics const& m) {
160  EXPECT_LT(m.false_positives_percentage(), 5);
161  EXPECT_LT(m.false_negatives_percentage(), 70);
162  }
163 };
164 
165 // -- generate the tests
166 typedef ::testing::Types<IqrmCpuTraits<uint8_t>, IqrmCpuTraits<float>> IqrmCpuTraitsTypes;
167 INSTANTIATE_TYPED_TEST_CASE_P(IqrmCpu, RfimTester, IqrmCpuTraitsTypes);
168 
169 } // namespace test
170 } // namespace rfim
171 } // namespace cheetah
172 } // namespace ska
A CPU implementation of the iqrmcpu algorithm.
Definition: Rfim.h:27
Some limits and constants for FLDO.
Definition: Brdz.h:35
A class for analysing and storing the results of the difference between two sets of flags representin...
Definition: Metrics.h:39
Collection of RFI scenarios.
Definition: RfiScenario.h:43
Specialise to set non-standard pass/fail criteria.
Definition: RfimTester.h:116