Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
BrdzTester.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/brdz/test_utils/BrdzTester.h"
25 #include "cheetah/data/FrequencySeries.h"
26 #include "cheetah/utils/Architectures.h"
27 
28 namespace ska {
29 namespace cheetah {
30 namespace brdz {
31 namespace test {
32 
33 template<typename ArchitectureTag, typename ArchitectureCapability>
34 BrdzTesterTraits<ArchitectureTag,ArchitectureCapability>::BrdzTesterTraits()
35  : _api(_config)
36 {
37 }
38 
39 template<typename ArchitectureTag, typename ArchitectureCapability>
40 brdz::Brdz& BrdzTesterTraits<ArchitectureTag,ArchitectureCapability>::api()
41 {
42  return _api;
43 }
44 
45 template<typename ArchitectureTag, typename ArchitectureCapability>
46 brdz::Config& BrdzTesterTraits<ArchitectureTag,ArchitectureCapability>::config()
47 {
48  return _config;
49 }
50 
51 template <typename DeviceType, typename Arch, typename T >
53 {
54  inline static void test(DeviceType& device, brdz::Brdz& api, brdz::Config& config)
55  {
56  typedef typename data::ComplexTypeTraits<Arch,T>::type ComplexType;
58  auto fill_value = ComplexType(1.0, 1.0);
59  auto replace_value = ComplexType(0.0, 0.0);
60  DataType input(0.001 * data::hz);
61  input.resize(1<<23,fill_value);
62  std::vector<data::Birdie> birdies;
63  data::FourierFrequencyType width(5 * 0.001 * data::hz);
64  for (int ii=100;ii<(1<<23);ii+=10000)
65  {
66  auto freq = input.bin_to_frequency(ii);
67  birdies.push_back(data::Birdie(freq,width));
68  }
69  config.birdies(birdies.begin(),birdies.end());
70  api.process<Arch,T,typename DataType::AllocatorType>(device,input);
71  for (auto& birdie: birdies)
72  {
73  std::size_t lower = input.frequency_to_bin(birdie.frequency()-birdie.width()/2.0);
74  std::size_t upper = input.frequency_to_bin(birdie.frequency()+birdie.width()/2.0);
75  lower = std::max(std::size_t(0),lower);
76  upper = std::min(upper,input.size());
77  for (std::size_t bin = lower; bin < upper; ++bin)
78  {
79  ComplexType x = input[bin];
80  ASSERT_EQ(x,replace_value);
81  }
82  }
83  }
84 };
85 
86 template <typename TestTraits>
89 {
90 }
91 
92 template <typename TestTraits>
94 {
95 }
96 
97 template<typename TestTraits>
99 {
100 }
101 
102 template<typename TestTraits>
104 {
105 }
106 
107 ALGORITHM_TYPED_TEST_P(BrdzTester, test_excision)
108 {
109  TypeParam traits;
112 }
113 
114 // each test defined by ALGORITHM_TYPED_TEST_P must be added to the
115 // test register (each one as an element of the comma seperated list)
116 REGISTER_TYPED_TEST_CASE_P(BrdzTester, test_excision);
117 
118 } // namespace test
119 } // namespace brdz
120 } // namespace cheetah
121 } // namespace ska
void process(panda::PoolResource< Arch > &resource, data::FrequencySeries< Arch, typename data::ComplexTypeTraits< Arch, T >::type, Alloc > &input, Args &&... args)
Excise the power for birdie frequencies in a spectrum.
Definition: Brdz.cpp:32
Configuration for the BRDZ module.
Definition: Config.h:43
A container of Fourier series data.
A helper class to determine the type of complex data for different architectures. ...
Some limits and constants for FLDO.
Definition: Brdz.h:35
Class for storing birdies (known RFI periodicities/frequencies)
Definition: Birdie.h:41
std::vector< data::Birdie > const & birdies() const
Get the birdie list.
Definition: Config.cpp:50
Class for performing birdie zapping.
Definition: Brdz.h:47