Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
TdrtTester.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/tdrt/test_utils/TdrtTester.h"
25 #include "cheetah/data/TimeSeries.h"
26 #include "cheetah/utils/Architectures.h"
27 
28 namespace ska {
29 namespace cheetah {
30 namespace tdrt {
31 namespace test {
32 
33 template<typename ArchitectureTag, typename ArchitectureCapability>
34 TdrtTesterTraits<ArchitectureTag,ArchitectureCapability>::TdrtTesterTraits()
35  : _api(_config)
36 {
37 }
38 
39 template<typename ArchitectureTag, typename ArchitectureCapability>
40 tdrt::Tdrt& TdrtTesterTraits<ArchitectureTag,ArchitectureCapability>::api()
41 {
42  return _api;
43 }
44 
45 
46 template <typename DeviceType, typename DataType>
48 {
49  inline static void test(DeviceType& device, tdrt::Tdrt& api)
50  {
51  std::size_t size = 1000;
52  DataType input(0.001 * data::seconds);
53  input.resize(size);
54  DataType output;
55  api.process(device,input,output,10.0 * data::metres_per_second_squared);
56  ASSERT_EQ(output.sampling_interval(),input.sampling_interval());
57  ASSERT_EQ(output.size(),size);
58  }
59 };
60 
61 template <typename DeviceType, typename DataType>
63 {
64  inline static void test(DeviceType& device, tdrt::Tdrt& api, double acceleration)
65  {
66  double const size = 1<<23;
67  std::size_t const idx = size/2;
68  double const tsamp = 0.000064;
69  DataType input(tsamp * data::seconds);
70  input.resize(size,0);
71  input[idx] = 1;
72  DataType output;
73  api.process(device, input, output, acceleration * data::metres_per_second_squared);
74  double const accel_fact = -1 * acceleration * tsamp / (2.0 * 299792458.0);
75  std::size_t new_idx = idx+idx*accel_fact*(idx-size);
76  bool pass = false;
77  //We know there can be fairly extreme rounding issues for large data sets
78  //so we check three samples either side for the pulse.
79  for (std::size_t ii = new_idx-3; ii < new_idx+3; ++ii)
80  {
81  if (output[ii] == 1)
82  pass = true;
83  }
84  ASSERT_TRUE(pass);
85  }
86 };
87 
88 template <typename TestTraits>
91 {
92 }
93 
94 template <typename TestTraits>
96 {
97 }
98 
99 template<typename TestTraits>
101 {
102 }
103 
104 template<typename TestTraits>
106 {
107 }
108 
109 ALGORITHM_TYPED_TEST_P(TdrtTester, test_sampling_time_propagation)
110 {
111  TypeParam traits;
114 }
115 
116 ALGORITHM_TYPED_TEST_P(TdrtTester, test_resampling_mapping)
117 {
118  TypeParam traits;
119  for (double acceleration=-1000.0; acceleration<=1000.0; acceleration+=300.0)
120  {
123  }
126 }
127 
128 // each test defined by ALGORITHM_TYPED_TEST_P must be added to the
129 // test register (each one as an element of the comma seperated list)
130 REGISTER_TYPED_TEST_CASE_P(TdrtTester, test_sampling_time_propagation, test_resampling_mapping);
131 
132 } // namespace test
133 } // namespace tdrt
134 } // namespace cheetah
135 } // namespace ska
Time Domain Resampler CUDA version / Transform / Module.
Definition: Tdrt.h:44
void process(panda::PoolResource< Arch > &resource, data::TimeSeries< Arch, T, Alloc >const &input, data::TimeSeries< Arch, T, Alloc > &output, data::AccelerationType acceleration, Args &&... args)
Resample a time series to a given acceleration.
Definition: Tdrt.cpp:31
Some limits and constants for FLDO.
Definition: Brdz.h:35