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