Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
AccListGenConfig.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/tdas/AccListGenConfig.h"
25 #include <cmath>
26 
27 namespace ska {
28 namespace cheetah {
29 namespace tdas {
30 
31 static const double default_acc_lo = -5.0;
32 static const double default_acc_hi = 5.0;
33 static const double default_tol= 1.10;
34 static const double default_pulse_width = 0.000064;
35 static const double default_cfreq = 1400.0;
36 static const double default_bw = 700.0/4960.0;
37 
38 AccListGenConfig::AccListGenConfig()
39  : cheetah::utils::Config("acceleration_list_generator")
40  , _acc_lo(default_acc_lo)
41  , _acc_hi(default_acc_hi)
42  , _tol(default_tol)
43  , _pulse_width(default_pulse_width)
44  , _cfreq(default_cfreq)
45  , _bw(default_bw)
46 {
47 }
48 
49 AccListGenConfig::~AccListGenConfig()
50 {
51 }
52 
53 void AccListGenConfig::add_options(OptionsDescriptionEasyInit& add_options)
54 {
55  add_options
56  ("acc_lo", boost::program_options::value<double>(&_acc_lo)->default_value(default_acc_lo),
57  "acceleration start m/s/s")
58 
59  ("acc_hi", boost::program_options::value<double>(&_acc_hi)->default_value(default_acc_hi),
60  "acceleration end m/s/s/")
61 
62  ("tol", boost::program_options::value<double>(&_tol)->default_value(default_tol),
63  "acceleration smearing tolerance (1.11=10%)")
64 
65  ("pulse_width", boost::program_options::value<double>(&_pulse_width)->default_value(default_pulse_width),
66  "minimum pulse width for which acc_tol is valid (in seconds)")
67 
68  ("cfreq", boost::program_options::value<double>(&_cfreq)->default_value(default_cfreq),
69  "centre frequency of the data block (in MHz)")
70 
71  ("bw", boost::program_options::value<double>(&_bw)->default_value(default_bw),
72  "channel bandwidth (in MHz)");
73 }
74 
75 double AccListGenConfig::acc_lo() const
76 {
77  return _acc_lo;
78 }
79 
80 void AccListGenConfig::acc_lo(double acc_lo)
81 {
82  _acc_lo = acc_lo;
83 }
84 
85 double AccListGenConfig::acc_hi() const
86 {
87  return _acc_hi;
88 }
89 
90 void AccListGenConfig::acc_hi(double acc_hi)
91 {
92  _acc_hi = acc_hi;
93 }
94 
95 double AccListGenConfig::tolerance() const
96 {
97  return _tol;
98 }
99 
100 void AccListGenConfig::tolerance(double tol)
101 {
102  _tol = tol;
103 }
104 
105 double AccListGenConfig::pulse_width() const
106 {
107  return _pulse_width;
108 }
109 
110 void AccListGenConfig::pulse_width(double pulse_width)
111 {
112  _pulse_width = pulse_width;
113 }
114 
115 double AccListGenConfig::cfreq() const
116 {
117  return _cfreq;
118 }
119 
120 void AccListGenConfig::cfreq(double cfreq)
121 {
122  _cfreq = cfreq;
123 }
124 
125 double AccListGenConfig::bw() const
126 {
127  return _bw;
128 }
129 
130 void AccListGenConfig::bw(double bw)
131 {
132  _bw = bw;
133 }
134 
135 data::AccelerationType AccListGenConfig::magnitude() const
136 {
137  return std::max(std::abs(_acc_lo),std::abs(_acc_hi)) * data::meters_per_second_squared;
138 }
139 
140 std::vector<data::AccelerationType> AccListGenConfig::acceleration_list(
141  data::DedispersionMeasureType<float> dm,
142  std::size_t number_of_samples,
143  double sampling_interval) const
144 {
145  std::vector<data::AccelerationType> acc_list;
146  double _tobs = number_of_samples*sampling_interval;
147 
148  if (_acc_hi == _acc_lo) {
149  acc_list.push_back(_acc_lo * data::meters_per_second_squared);
150  return acc_list;
151  }
152  double tdm = (8.3 * std::abs(_bw) / std::pow(_cfreq,3.0) * dm.value());
153  double c = boost::units::si::constants::codata::c.value().value();
154  double ttdm = tdm*tdm;
155  double tpulse = _pulse_width*_pulse_width;
156  double ttsamp = sampling_interval*sampling_interval;
157  double ttobs = _tobs * _tobs;
158  double width = std::sqrt(ttdm+tpulse+ttsamp);
159  double alt_a = 2.0 * width * 24.0 * c/ttobs * std::sqrt((_tol*_tol)-1.0);
160  std::size_t naccels = std::size_t(((_acc_hi-_acc_lo)/alt_a));
161  acc_list.reserve(naccels+3);
162  acc_list.push_back(0.0 * data::meters_per_second_squared);
163  for (auto acc=_acc_lo; acc <= _acc_hi; acc+=alt_a)
164  {
165  acc_list.push_back(acc * data::meters_per_second_squared);
166  }
167  return acc_list;
168 }
169 
170 
171 } // namespace tdas
172 } // namespace cheetah
173 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35