Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
SpCandidateTest.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/SpCandidateTest.h"
25 #include "cheetah/data/SpCandidate.h"
26 
27 namespace ska {
28 namespace cheetah {
29 namespace data {
30 namespace test {
31 
32 
33 SpCandidateTest::SpCandidateTest() : ::testing::Test()
34 {
35 }
36 
37 SpCandidateTest::~SpCandidateTest()
38 {
39 }
40 
41 void SpCandidateTest::SetUp()
42 {
43 }
44 
45 void SpCandidateTest::TearDown()
46 {
47 }
48 
49 // test_input_data
50 // Sets the input data and re-read them
51 //
52 TEST_F(SpCandidateTest, test_input_data)
53 {
54  typedef SpCandidate<Cpu, double> SpCandidateType;
55 
56  //set single pulse candidate dispersion measure
57  typename SpCandidateType::Dm dm = 10. * parsecs_per_cube_cm;
58  //set single pulse candidate ident
59  std::size_t ident = 4;
60  //set the single pulse candidate width to 1.24 ms
61  SpCandidateType::MsecTimeType width(0.00124 * boost::units::si::seconds);
62  //set the single pulse start time to 2.23 seconds
63  SpCandidateType::MsecTimeType tstart(2.23 * boost::units::si::seconds);
64  //set the candidate significance
65  double sigma = 15.0;
66  SpCandidateType::FrequencyType f_high(1700 * boost::units::si::mega * boost::units::si::hertz);
67  SpCandidateType::FrequencyType f_low(1400 *boost::units::si::mega * boost::units::si::hertz);
68 
69  // generate a single pulse candidate with the specified parameters
70  SpCandidateType candidate(dm, tstart, width, sigma, ident) ;
71  ASSERT_NO_THROW(candidate.dm_with_duration_end(f_high,f_low,dm));
72  // real check
73  ASSERT_EQ(dm, candidate.dm());
74  ASSERT_EQ(tstart, candidate.tstart());
75  ASSERT_EQ(width, candidate.width());
76  ASSERT_EQ(sigma, candidate.sigma());
77  ASSERT_EQ(ident, candidate.ident());
78 }
79 
80 TEST_F(SpCandidateTest, test_candidate_copy)
81 {
82  typedef SpCandidate<Cpu, double> SpCandidateType;
83 
84  //set single pulse candidate dispersion measure
85  typename SpCandidateType::Dm dm = 10. * parsecs_per_cube_cm;
86  //set single pulse candidate ident
87  std::size_t ident = 4;
88  //set the single pulse candidate width to 1.24 ms
89  SpCandidateType::MsecTimeType width(0.00124 * boost::units::si::seconds);
90  //set the single pulse start time to 2.23 seconds
91  SpCandidateType::MsecTimeType tstart(2.23 * boost::units::si::seconds);
92  //set the candidate significance
93  double sigma = 15.0;
94  //set the end time
95  SpCandidateType::MsecTimeType tend(2000 * boost::units::si::milli * boost::units::si::seconds);
96 
97  // generate a single pulse candidate with the specified parameters
98  SpCandidateType candidate(dm, tstart, width, sigma, ident);
99 
100  // set tend
101  candidate.duration_end(tend);
102  // copy candidate
103  SpCandidateType candidate_copy(candidate);
104 
105  // real check
106  ASSERT_EQ(dm, candidate_copy.dm());
107  ASSERT_EQ(tstart, candidate_copy.tstart());
108  ASSERT_EQ(width, candidate_copy.width());
109  ASSERT_EQ(sigma, candidate_copy.sigma());
110  ASSERT_EQ(ident, candidate_copy.ident());
111  ASSERT_EQ(tend + tstart, candidate_copy.tend());
112 }
113 
114 } // namespace test
115 } // namespace data
116 } // namespace cheetah
117 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35