Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
AmppTest.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/ampp/test/AmppTest.h"
25 #include "cheetah/rfim/ampp/Rfim.h"
26 #include "cheetah/rfim/DefaultRfimTraits.h"
27 #include "cheetah/rfim/test_utils/RfimTester.h"
28 #include <memory>
29 
30 
31 namespace ska {
32 namespace cheetah {
33 namespace rfim {
34 namespace test {
35 
36 template<typename NumericalRepT>
37 struct AmppTestRfimTraits : public rfim::DefaultRfimTraits<data::TimeFrequency<Cpu, NumericalRepT>>
38 {
39  typedef NumericalRepT NumericalRep;
43  using typename BaseT::Policy;
44  using typename BaseT::BandPassHandler;
45 };
46 
47 struct AmppTraits : public RfimTesterTraits<uint8_t, rfim::ampp::Rfim<AmppTestRfimTraits<uint8_t>>::Architecture> {
48 
49  private:
50  typedef uint8_t NumericalRep;
52 
53  public:
54  AmppTraits();
55 
56  ResultType apply_algorithm(DeviceType&, DataType& data);
57 
58  // return the api for the ampp algorithm
60 
61  // return the configuration for this api
62  static rfim::ampp::Config& config();
63 
64  protected:
65  bool _initial;
66 
67 };
68 
69 AmppTraits::AmppTraits()
70  : _initial(true)
71 {
72  // initialise the object
73 }
74 
75 
76 rfim::ampp::Config& AmppTraits::config()
77 {
78  static rfim::ampp::Config config;
79  auto& bp_config=config.bandpass();
80  bp_config.mean(0.0);
81 
82  return config;
83 }
84 
86 {
88  return algo_api;
89 }
90 
91 AmppTraits::ResultType AmppTraits::apply_algorithm(DeviceType&, DataType& data)
92 {
93  if(_initial) {
94  std::size_t samples=0U;
95  while(samples < 16384) {
96  std::shared_ptr<DataType> data_copy(new DataType(data));
97  algo().run(*data_copy); // send a copy of data to allow generation of model
98  samples += data.dimension<data::Time>();
99  }
100  _initial = false;
101  }
102  return algo().run(data);
103 }
104 
105 AmppTest::AmppTest()
106  : ::testing::Test()
107 {
108 }
109 
110 AmppTest::~AmppTest()
111 {
112 }
113 
114 void AmppTest::SetUp()
115 {
116 }
117 
118 void AmppTest::TearDown()
119 {
120 }
121 
122 typedef ::testing::Types<AmppTraits> AmppTraitsTypes;
123 INSTANTIATE_TYPED_TEST_CASE_P(Ampp, RfimTester, AmppTraitsTypes);
124 
125 } // namespace test
126 } // namespace rfim
127 } // namespace cheetah
128 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35
Configuration Options for the ampp rfi clipping algorithm.
Definition: Config.h:40
AMPP alogrithm CPU based on a dynamic bandfilter.
Definition: Rfim.h:130