Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
TimeFrequencyTest.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/data/test/TimeFrequencyTest.h"
25 #include "cheetah/data/TimeFrequency.h"
26 #include "cheetah/data/Units.h"
27 #include "cheetah/data/test_utils/TimeFrequencyTester.h"
28 #include "cheetah/utils/ModifiedJulianClock.h"
29 #include <boost/units/systems/si/prefixes.hpp>
30 #include <chrono>
31 
32 namespace ska {
33 namespace cheetah {
34 namespace data {
35 namespace test {
36 
37 
38 TimeFrequencyTest::TimeFrequencyTest()
39  : ::testing::Test()
40 {
41 }
42 
43 TimeFrequencyTest::~TimeFrequencyTest()
44 {
45 }
46 
47 void TimeFrequencyTest::SetUp()
48 {
49 }
50 
51 void TimeFrequencyTest::TearDown()
52 {
53 }
54 
55 TEST_F(TimeFrequencyTest, test_copy)
56 {
57 
58  data::DimensionSize<data::Time> number_of_spectra(1U);
59  data::DimensionSize<data::Frequency> number_of_channels(5U);
60 
61  data::TimeFrequency<Cpu, uint8_t> tf(number_of_spectra, number_of_channels);
62  auto f1 = data::TimeFrequency<Cpu, uint8_t>::FrequencyType(5.0 * boost::units::si::hertz);
63  auto f2 = data::TimeFrequency<Cpu, uint8_t>::FrequencyType(12.0 * boost::units::si::hertz);
64  auto delta = (f2 - f1)/ (double)number_of_channels;
65 
66  tf.set_channel_frequencies_const_width( f1, delta );
67  data::TimeFrequency<Cpu, uint8_t> tf2(tf); // the copy
68 
69  ASSERT_EQ(tf2.number_of_channels(), tf.number_of_channels());
70  ASSERT_EQ(tf2.number_of_spectra(), tf.number_of_spectra());
71  ASSERT_EQ(tf2.channel_frequencies().size(), tf.channel_frequencies().size());
72  for(std::size_t i = 0U; i < number_of_channels; ++i) {
73  ASSERT_EQ(tf2.channel_frequencies()[i], tf.channel_frequencies()[i]);
74  }
75 }
76 
77 // use the TimeFrequencyTester to test most interfaces
78 typedef ::testing::Types<TimeFrequencyTesterTraits<data::TimeFrequency<Cpu, uint8_t>>
79  ,TimeFrequencyTesterTraits<data::TimeFrequency<Cpu, float>>> TimeFrequencyDataTypes;
80 INSTANTIATE_TYPED_TEST_CASE_P(TimeFrequenceyTests, TimeFrequencyTester, TimeFrequencyDataTypes);
81 
82 // check dimension query structs work
83 static_assert(pss::astrotypes::has_dimensions<TimeFrequency<Cpu, uint8_t>, data::Time, data::Frequency>::value, "expecting true");
84 static_assert(pss::astrotypes::has_exact_dimensions<TimeFrequency<Cpu, uint8_t>, data::Time, data::Frequency>::value, "expecting true");
85 static_assert(!pss::astrotypes::has_exact_dimensions<TimeFrequency<Cpu, uint8_t>, data::Frequency, data::Time>::value, "expecting false");
86 
87 } // namespace test
88 } // namespace data
89 } // namespace cheetah
90 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35