Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
FrequencySeries.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/data/FrequencySeries.h"
25 
26 namespace ska {
27 namespace cheetah {
28 namespace data {
29 
30 template <typename Arch, typename ValueType, typename Alloc>
32  : BaseT(0, alloc)
33  , _frequency_step(1.0 * hz)
34 {
35 }
36 
37 template <typename Arch, typename ValueType, typename Alloc>
39  : BaseT(size, alloc)
40  , _frequency_step(1.0 * hz)
41 {
42 }
43 
44 template <typename Arch, typename ValueType, typename Alloc>
45 template<typename OtherArch, typename OtherAlloc>
47  : BaseT(copy, allocator)
48  , _frequency_step(copy.frequency_step())
49 {
50 }
51 
52 template <typename Arch, typename ValueType, typename Alloc>
53 FrequencySeries<Arch, ValueType, Alloc>::FrequencySeries(FourierFrequencyType const& df, std::size_t size, Allocator const& allocator)
54  : BaseT(size, allocator)
55  , _frequency_step(df)
56 {
57 }
58 
59 template <typename Arch, typename ValueType, typename Alloc>
60 FrequencySeries<Arch, ValueType, Alloc>::FrequencySeries(FourierFrequencyType const& df, Allocator const& allocator)
61  : FrequencySeries(df, 0, allocator)
62 {
63 }
64 
65 template <typename Arch, typename ValueType, typename Alloc>
67 {
68 }
69 
70 template <typename Arch, typename ValueType, typename Alloc>
72 {
73  return _frequency_step;
74 }
75 
76 template <typename Arch, typename ValueType, typename Alloc>
77 void FrequencySeries<Arch, ValueType, Alloc>::frequency_step(FourierFrequencyType const& df)
78 {
79  _frequency_step = df;
80 }
81 
82 template <typename Arch, typename ValueType, typename Alloc>
83 data::FourierFrequencyType const FrequencySeries<Arch, ValueType, Alloc>::bin_to_frequency(std::size_t idx) const
84 {
85  return data::FourierFrequencyType(((idx * _frequency_step.value()) + (_frequency_step.value()/2.0f)) * data::hz);
86 }
87 
88 template <typename Arch, typename ValueType, typename Alloc>
89 data::TimeType const FrequencySeries<Arch, ValueType, Alloc>::bin_to_period(std::size_t idx) const
90 {
91  return data::TimeType((1.0f / bin_to_frequency(idx).value()) * data::seconds);
92 }
93 
94 template <typename Arch, typename ValueType, typename Alloc>
95 std::size_t FrequencySeries<Arch, ValueType, Alloc>::frequency_to_bin(data::FourierFrequencyType const& frequency) const
96 {
97  return (std::size_t)(frequency.value()/_frequency_step.value() + 0.5f);
98 }
99 
100 } // namespace data
101 } // namespace cheetah
102 } // namespace ska
FourierFrequencyType const & frequency_step() const
Retrieve the frequency step of the series.
A container of Fourier series data.
Some limits and constants for FLDO.
Definition: Brdz.h:35
FrequencySeries(Allocator const &allocator=Allocator())
Construct a default frequency series (of size 0)
std::size_t size() const
the size of the series
Definition: Series.cpp:109