Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
DedispersionPlan.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/ddtr/astroaccelerate/DedispersionPlan.h"
25 
26 namespace ska {
27 namespace cheetah {
28 namespace ddtr {
29 namespace astroaccelerate {
30 
31 template <typename DdtrTraits>
32 DedispersionPlan<DdtrTraits>::DedispersionPlan(ConfigType const& config, std::size_t memory)
33  : _algo_config(config)
34  , _memory(memory)
35 {
36 }
37 
38 template <typename DdtrTraits>
39 DedispersionPlan<DdtrTraits>::~DedispersionPlan()
40 {
41 }
42 
43 template <typename DdtrTraits>
44 data::DimensionSize<data::Time> DedispersionPlan<DdtrTraits>::reset(TimeFrequencyType const& data)
45 {
46  _strategy = std::make_shared<DedispersionStrategy<NumericalT>>(data, _algo_config, _memory);
47  //Dm max_dm = _strategy->max_dm();
48  _max_delay = _strategy->maxshift();
49  FrequencyListType const& channel_freqs = data.channel_frequencies();
50  auto freq_pair = data.low_high_frequencies();
51  FrequencyType freq_top = freq_pair.second;
52  //FrequencyType freq_bottom = freq_pair.first;
53 
54  for (auto freq: channel_freqs)
55  {
56  double factor = (this->_algo_config.dm_constant().value() * (1.0/(freq*freq) - 1.0/(freq_top*freq_top)) / data.sample_interval()).value();
57  PANDA_LOG_DEBUG << "Frequency: " << freq << " Reference: " << freq_top << " DM constant: "
58  << this->_algo_config.dm_constant() << " Sampling interval: " << data.sample_interval() << " DM factor: " << factor;
59  _dm_factors.push_back(factor);
60  }
61 
62  _dedispersion_samples = this->_algo_config.dedispersion_samples();
63  if (_dedispersion_samples < 2 * _max_delay)
64  {
65  PANDA_LOG_WARN << "Requested number of samples to dedisperse ("
66  << this->_algo_config.dedispersion_samples()
67  << ") is less than twice the max dispersion delay ("
68  << 2 * _max_delay << "): Setting number of samples to dedisperse to "
69  << 2 * _max_delay;
70  _dedispersion_samples = 2 * _max_delay;
71  }
72  //_dm_trial_metadata = this->_algo_config.generate_dmtrials_metadata(data.sample_interval(), _dedispersion_samples, _max_delay);
73  return data::DimensionSize<data::Time>(_dedispersion_samples);
74 }
75 
76 template <typename DdtrTraits>
77 data::DimensionSize<data::Time> DedispersionPlan<DdtrTraits>::buffer_overlap() const
78 {
79  return data::DimensionSize<data::Time>(_max_delay);
80 }
81 
82 template <typename DdtrTraits>
83 void DedispersionPlan<DdtrTraits>::reset(data::DimensionSize<data::Time> const& spectra)
84 {
85  _number_of_spectra = spectra;
86 }
87 
88 template <typename DdtrTraits>
89 data::DimensionSize<data::Time> DedispersionPlan<DdtrTraits>::number_of_spectra() const
90 {
91  return data::DimensionSize<data::Time>(_number_of_spectra);
92 }
93 
94 } // namespace astroaccelerate
95 } // namespace ddtr
96 } // namespace cheetah
97 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35