Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
SinglePulseTest.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/pipeline/test/SinglePulseTest.h"
25 #include "cheetah/pipeline/SinglePulse.h"
26 #include "cheetah/pipeline/CheetahConfig.h"
27 #include "cheetah/ddtr/DedispersionConfig.h"
28 #include "cheetah/generators/GaussianNoise.h"
29 #include "cheetah/generators/GaussianNoiseConfig.h"
30 #include <memory>
31 
32 
33 namespace ska {
34 namespace cheetah {
35 namespace pipeline {
36 namespace test {
37 
38 
39 SinglePulseTest::SinglePulseTest()
40  : ::testing::Test()
41 {
42 }
43 
44 SinglePulseTest::~SinglePulseTest()
45 {
46 }
47 
48 void SinglePulseTest::SetUp()
49 {
50 }
51 
52 void SinglePulseTest::TearDown()
53 {
54 }
55 
56 template<typename NumericalType>
57 using TestSinglePulsePipeline = SinglePulse<NumericalType>;
58 
59 template<typename NumericalT>
61 {
62  static void run()
63  {
67  typedef typename data::TimeFrequency<Cpu, NumericalT>::TimePointType TimePointType;
68  typedef typename data::TimeFrequency<Cpu, NumericalT>::DataType DataType;
69 
70 
75 
76  //Configure high density low DMs
77  ddtr::DedispersionConfig dd_config_low;
78  config.sps_config().dedispersion_config(dd_config_low);
79  dd_config_low.dm_start(ddtr::DedispersionConfig::Dm(0.0 * data::parsecs_per_cube_cm));
80  dd_config_low.dm_end(ddtr::DedispersionConfig::Dm(100.0 * data::parsecs_per_cube_cm));
81  dd_config_low.dm_step(ddtr::DedispersionConfig::Dm(0.1 * data::parsecs_per_cube_cm));
82 
83  //Configure low density high DMs
84  /*
85  ddtr::DedispersionConfig dd_config_high;
86  config.sps_config().dedispersion_config(dd_config_high);
87  dd_config_high.dm_start(ddtr::DedispersionConfig::Dm(200.0 * data::parsecs_per_cube_cm));
88  dd_config_high.dm_end(ddtr::DedispersionConfig::Dm(300.0 * data::parsecs_per_cube_cm));
89  dd_config_high.dm_step(ddtr::DedispersionConfig::Dm(1.0 * data::parsecs_per_cube_cm));
90 */
91 
92  //Set sps priority
93  config.sps_config().set_priority(0);
94 
95  //Set the size of the dedispersion buffer
96  config.sps_config().set_dedispersion_samples(1<<18);
97 
98  //Set up noise parameters for data to be passed through
99  //the pipeline
100  generators::GaussianNoiseConfig noise_config;
101  noise_config.mean(96.0);
102  noise_config.std_deviation(10.0);
103  generators::GaussianNoise<DataType> noise(noise_config);
104  BeamConfig<uint8_t> beam_config;
105 
106  //Start epoch
107  typename utils::ModifiedJulianClock::time_point epoch(utils::julian_day(50000.0));
108  TestSinglePulsePipeline<NumericalT> pipeline(config, beam_config);
109 
110  double tsamp_us = 64.0;
111  double f_low = 1.2;
112  double f_high = 1.8;
113  std::size_t total_nsamps = std::size_t(10.0 / (tsamp_us * 1e-6));
114  data::DimensionSize<data::Time> number_of_samples(1<<15);
115  data::DimensionSize<data::Frequency> number_of_channels(1024);
116  std::size_t loop_count = total_nsamps/number_of_samples + 10;
117  for (std::size_t ii=0; ii<loop_count; ++ii)
118  {
119  std::cout << "Building next time frequency block..." << std::endl;
120  auto tf = std::make_shared<data::TimeFrequency<Cpu, uint8_t>>(number_of_samples, number_of_channels);
121  auto f1 = data::TimeFrequency<Cpu, uint8_t>::FrequencyType(f_high * boost::units::si::giga * boost::units::si::hertz);
122  auto f2 = data::TimeFrequency<Cpu, uint8_t>::FrequencyType(f_low * boost::units::si::giga * boost::units::si::hertz);
123  auto delta = (f2 - f1)/ (double)number_of_channels;
124  tf->set_channel_frequencies_const_width( f1, delta );
125  tf->sample_interval(typename data::TimeFrequency<Cpu, uint8_t>::TimeType(tsamp_us * boost::units::si::micro * data::seconds));
126  tf->start_time(epoch);
127  epoch += std::chrono::duration<double>(tf->sample_interval().value()*number_of_samples);
128  std::cout << "Time frequency block " << ii << " dispatched to pipeline." << std::endl;
129  noise.next(*tf);
130  pipeline(*tf);
131  }
132  }
133 };
134 
135 TEST_F(SinglePulseTest, uint8_t_run_test)
136 {
138 }
139 
140 } // namespace test
141 } // namespace pipeline
142 } // namespace cheetah
143 } // namespace ska
Dm dm_start() const
the first dm condidate to try
describes dedispersion configuration
Some limits and constants for FLDO.
Definition: Brdz.h:35
NumericalT DataType
the underlying data storage type for the amplitude of the signal
Definition: TimeFrequency.h:96
Dm dm_end() const
the last dm condidate to try
sps::ConfigType< PoolManagerType > const & sps_config() const
return the sps module specific configuration parameters
Parse configuration parameters for a single beam in the pipeline instance of cheetah.
Definition: BeamConfig.h:48
A Single Pulse Search Pipeline.
Definition: SinglePulse.h:46
Dm dm_step() const
the step size to take in generating dm trials between start and end