Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
TimeFrequencyCommon.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 <iostream>
25 namespace ska {
26 namespace cheetah {
27 namespace data {
28 
29 template <class DerivedType>
30 TimeFrequencyCommon<DerivedType>::TimeFrequencyCommon()
31 {
32 }
33 
34 template <class DerivedType>
35 template <typename OtherDerivedType>
36 TimeFrequencyCommon<DerivedType>::TimeFrequencyCommon(TimeFrequencyCommon<OtherDerivedType> const& tfc)
37  : _metadata(tfc.metadata())
38 {
39 }
40 
41 template <class DerivedType>
42 inline
43 typename TimeFrequencyCommon<DerivedType>::TimePointType const& TimeFrequencyCommon<DerivedType>::start_time() const
44 {
45  return this->_metadata.start_time();
46 }
47 
48 template <class DerivedType>
49 inline
50 typename TimeFrequencyCommon<DerivedType>::TimePointType TimeFrequencyCommon<DerivedType>::start_time(std::size_t offset) const
51 {
52  return this->_metadata.start_time(offset);
53 }
54 
55 template <class DerivedType>
56 void TimeFrequencyCommon<DerivedType>::start_time(TimePointType const& start_time)
57 {
58  this->_metadata.start_time(start_time);
59 }
60 
61 template <class DerivedType>
62 typename TimeFrequencyCommon<DerivedType>::TimePointType TimeFrequencyCommon<DerivedType>::end_time() const
63 {
64  auto derived = static_cast<DerivedType const&>(*this);
65  return this->start_time() + (derived.number_of_spectra() - 1) * sample_interval();
66 }
67 
68 template <class DerivedType>
69 inline
70 typename TimeFrequencyCommon<DerivedType>::TimeType TimeFrequencyCommon<DerivedType>::sample_interval() const
71 {
72  return this->_metadata.sample_interval();
73 }
74 
75 template <class DerivedType>
76 inline
77 void TimeFrequencyCommon<DerivedType>::sample_interval(TimeFrequencyCommon<DerivedType>::TimeType dt)
78 {
79  this->_metadata.sample_interval(dt);
80 }
81 
82 template <class DerivedType>
83 std::vector<typename TimeFrequencyCommon<DerivedType>::FrequencyType> const& TimeFrequencyCommon<DerivedType>::channel_frequencies() const
84 {
85  return this->_metadata.channel_frequencies();
86 }
87 
88 template <class DerivedType>
89 std::pair<FrequencyType, FrequencyType> TimeFrequencyCommon<DerivedType>::low_high_frequencies() const
90 {
91  return this->_metadata.low_high_frequencies();
92 }
93 
94 template <class DerivedType>
95 void TimeFrequencyCommon<DerivedType>::set_channel_frequencies_const_width(TimeFrequencyCommon<DerivedType>::FrequencyType const& start,
96  TimeFrequencyCommon<DerivedType>::FrequencyType const& delta)
97 {
98  auto derived = static_cast<DerivedType const&>(*this);
99  this->_metadata.channel_frequencies_const_width(start, delta, data::DimensionSize<Frequency>(derived.number_of_channels()));
100 }
101 
102 template <class DerivedType>
103 template<class InputIterator>
104 void TimeFrequencyCommon<DerivedType>::set_channel_frequencies(InputIterator begin, InputIterator const end)
105 {
106  this->_metadata.channel_frequencies(begin, end);
107 }
108 
109 template <class DerivedType>
111 {
112  return _metadata;
113 }
114 
115 template <class DerivedType>
117 {
118  _metadata = metadata;
119 }
120 
121 } // namespace data
122 } // namespace cheetah
123 } // namespace ska
std::pair< FrequencyType, FrequencyType > low_high_frequencies() const
void metadata(TimeFrequencyMetadata const &metadata)
set the metadata
TimePointType const & start_time() const
Some limits and constants for FLDO.
Definition: Brdz.h:35
std::vector< FrequencyType > const & channel_frequencies() const
Metadata for TimeFrequency and FrequencyTime classes.