Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
TdasAccelerationSearchTest.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/TdasAccelerationSearchTest.h"
25 #include "cheetah/pipeline/AccelerationSearch.h"
26 #include "cheetah/pipeline/TdasAccelerationSearchTraits.h"
27 #include "cheetah/data/TimeFrequency.h"
28 #include "cheetah/data/Units.h"
29 #include "cheetah/data/DedispersionMeasure.h"
30 #include "cheetah/ddtr/DedispersionConfig.h"
31 #include "cheetah/generators/GaussianNoise.h"
32 #include "cheetah/generators/GaussianNoiseConfig.h"
33 #include <memory>
34 #include <chrono>
35 #include <thread>
36 
37 namespace ska {
38 namespace cheetah {
39 namespace pipeline {
40 namespace test {
41 
42 TdasAccelerationSearchTest::TdasAccelerationSearchTest()
43  : ::testing::Test()
44 {
45 }
46 
47 TdasAccelerationSearchTest::~TdasAccelerationSearchTest()
48 {
49 }
50 
51 void TdasAccelerationSearchTest::SetUp()
52 {
53 }
54 
55 void TdasAccelerationSearchTest::TearDown()
56 {
57 }
58 
59 template<typename NumericalT>
61 {
62  static void run()
63  {
64  // Search ~600 seconds of data at standard resoluton
65  typedef data::TimeFrequency<Cpu, NumericalT> TimeFrequencyType;
66  typedef typename TimeFrequencyType::DataType DataType;
67 
68 
69  // Configure components
71 
72  // Configure high-density low DMs
73  ddtr::DedispersionConfig dd_config_low;
74  config.sps_config().dedispersion_config(dd_config_low);
75  dd_config_low.dm_start(ddtr::DedispersionConfig::Dm(0.0 * data::parsecs_per_cube_cm));
76  dd_config_low.dm_end(ddtr::DedispersionConfig::Dm(100.0 * data::parsecs_per_cube_cm));
77  dd_config_low.dm_step(ddtr::DedispersionConfig::Dm(0.1 * data::parsecs_per_cube_cm));
78 
79 /*
80  // Configure low-density high DMs
81  ddtr::DedispersionConfig dd_config_high;
82  config.sps_config().dedispersion_config(dd_config_high);
83  dd_config_high.dm_start(ddtr::DedispersionConfig::Dm(200.0 * data::parsecs_per_cube_cm));
84  dd_config_high.dm_end(ddtr::DedispersionConfig::Dm(300.0 * data::parsecs_per_cube_cm));
85  dd_config_high.dm_step(ddtr::DedispersionConfig::Dm(1.0 * data::parsecs_per_cube_cm));
86 */
87 
88  // Set sps priority
89  config.sps_config().set_priority(0);
90 
91  // Set the size of the dedispersion buffer
92  config.sps_config().set_dedispersion_samples(1<<18);
93 
94  // Set the psbc config
95  config.psbc_config().dump_time(1 * data::seconds);
96 
97  // Set tdas priority
98  config.acceleration_search_config().tdas_config().set_priority(1);
99 
100  // Set up tdas general parameters
101  config.acceleration_search_config().tdas_config().minimum_size(1<<19);
102  config.acceleration_search_config().tdas_config().size(1<<23);
103  config.acceleration_search_config().tdas_config().number_of_harmonic_sums(4);
104  config.acceleration_search_config().tdas_config().dm_trials_per_task(200);
105 
106  // Set up CUDA implementation specific configuration arguments
107  auto& cuda_algo_config = config.acceleration_search_config().tdas_config().cuda_config();
108  cuda_algo_config.tdao_config().significance_threshold(7.0);
109  cuda_algo_config.tdao_config().minimum_frequency(0.1 * data::hz);
110  cuda_algo_config.tdao_config().maximum_frequency(2000.0 * data::hz);
111  cuda_algo_config.dred_config().oversmoothing_factor(5);
112  // Birdies configuration would go here
113 
114  // Set up acceleration parameters
115  auto& acc_config = config.acceleration_search_config().tdas_config().acceleration_list_generator();
116  BeamConfig<NumericalT> beam_config;
117  acc_config.acc_lo(-10.0);
118  acc_config.acc_hi(10.0);
119  acc_config.tolerance(1.25);
120 
121  // select the sift algo
122  config.sift_config().template config<sift::simple_sift::Config>().active(true);
123 
124  // select the fldo algo
125  config.fldo_config().template config<fldo::cuda::Config>().active(true);
126 
128  AccelerationSearchType pipeline(config, beam_config);
129 
130  // Set up noise parameters for data to be passed through the pipeline
131  generators::GaussianNoiseConfig noise_config;
132  generators::GaussianNoise<DataType> noise(noise_config);
133  noise_config.mean(96.0);
134  noise_config.std_deviation(10.0);
135 
136  // Start epoch
137  typename utils::ModifiedJulianClock::time_point epoch(utils::julian_day(50000.0));
138 
139  double tsamp_us = 64.0;
140  double f_low = 1.2;
141  double f_high = 1.8;
142  std::size_t total_nsamps = std::size_t(1.0 / (tsamp_us * 1e-6));
143  data::DimensionSize<data::Time> number_of_samples(1000);
144  data::DimensionSize<data::Frequency> number_of_channels(1024);
145  std::size_t loop_count = total_nsamps/number_of_samples + 10;
146  for (std::size_t ii=0; ii<loop_count; ++ii)
147  {
148  auto tf = std::make_shared<TimeFrequencyType>(number_of_samples, number_of_channels);
149  auto f1 = typename TimeFrequencyType::FrequencyType(f_high * boost::units::si::giga * boost::units::si::hertz);
150  auto f2 = typename TimeFrequencyType::FrequencyType(f_low * boost::units::si::giga * boost::units::si::hertz);
151  auto delta = (f2 - f1)/ (double)number_of_channels;
152  tf->set_channel_frequencies_const_width( f1, delta );
153  tf->sample_interval(typename TimeFrequencyType::TimeType(tsamp_us * boost::units::si::micro * data::seconds));
154  tf->start_time(epoch);
155  epoch += std::chrono::duration<double>(tf->sample_interval().value()*number_of_samples);
156  noise.next(*tf);
157  pipeline(*tf);
158  }
159 
160  }
161 };
162 
163 TEST_F(TdasAccelerationSearchTest, run_tdas_test_uint8)
164 {
166 }
167 
168 /*
169 TEST_F(TdasAccelerationSearchTest, run_tdas_test_uint16)
170 {
171  TdasAccelerationSearchTests<uint16_t>::run();
172 }
173 */
174 
175 } // namespace test
176 } // namespace pipeline
177 } // namespace cheetah
178 } // namespace ska
sift::ConfigType const & sift_config() const
return the sift module specific configuration parameters
tdas::ConfigType const & tdas_config() const
return the tdas module-specific configuration parameters
The acceleration search pipeline.
Dm dm_start() const
the first dm condidate to try
describes dedispersion configuration
psbc::Config const & psbc_config() const
return the psbc module specific configuration parameters
AccelerationSearchAlgoConfig & acceleration_search_config()
return the templated acceleration search configuration
Some limits and constants for FLDO.
Definition: Brdz.h:35
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
fldo::ConfigType const & fldo_config() const
return the fldo module specific configuration parameters
Dm dm_step() const
the step size to take in generating dm trials between start and end