Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Spectrum.h
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 #ifndef SKA_CHEETAH_DATA_SPECTRUM_H
25 #define SKA_CHEETAH_DATA_SPECTRUM_H
26 
27 #include "cheetah/data/TimeFrequency.h"
28 #include "pss/astrotypes/multiarray/MultiArray.h"
29 
30 namespace ska {
31 namespace cheetah {
32 namespace data {
33 
34 template<typename SliceType>
35 class SpectrumInterface : public SliceType
36 {
37  public:
38  typedef typename SliceType::template OperatorSliceType<data::Frequency>::type Channel;
39  typedef typename SliceType::template ConstOperatorSliceType<data::Frequency>::type ConstChannel;
40 
41  using SliceType::SliceType;
42 
44  Channel channel(std::size_t channel_number);
45  ConstChannel channel(std::size_t channel_number) const;
46 
48  // @details a synonym for dimension<Frequency>()
49  std::size_t number_of_channels() const;
50 };
51 
57 template<typename DerivedType, typename NumericalRep, typename Alloc=std::allocator<NumericalRep>>
58 class SpectrumBase : public SpectrumInterface<pss::astrotypes::multiarray::MultiArray<Alloc, NumericalRep, SpectrumInterface, data::Frequency>>
59  , public panda::DataChunk<DerivedType>
60 {
62 
63  public:
64  typedef typename BaseT::Channel Channel;
65  typedef typename BaseT::ConstChannel ConstChannel;
66  typedef cheetah::utils::ModifiedJulianClock::time_point TimePointType;
67 
68  public:
69  SpectrumBase(pss::astrotypes::DimensionSize<data::Frequency> size = pss::astrotypes::DimensionSize<data::Frequency>(0));
70  ~SpectrumBase();
71 
75  TimePointType const& start_time() const;
76 
80  void start_time(TimePointType offset);
81 
82  private:
83  TimePointType _start_time;
84 };
85 
86 template<typename NumericalRep, typename Alloc=std::allocator<NumericalRep>>
87 class Spectrum : public SpectrumBase<Spectrum<NumericalRep, Alloc>, NumericalRep, Alloc>
88 {
89  typedef SpectrumBase<Spectrum<NumericalRep, Alloc>, NumericalRep, Alloc> BaseT;
90 
91  public:
92  Spectrum(pss::astrotypes::DimensionSize<data::Frequency> size = pss::astrotypes::DimensionSize<data::Frequency>(0));
93  ~Spectrum();
94 };
95 
96 } // namespace data
97 } // namespace cheetah
98 } // namespace ska
99 
100 namespace pss {
101 namespace astrotypes {
102 
103 template<typename T, typename Alloc>
104 struct has_exact_dimensions<ska::cheetah::data::Spectrum<T, Alloc>, units::Frequency> : public std::true_type
105 {
106 };
107 
108 template<typename T, typename Alloc, typename DerivedType>
109 struct has_exact_dimensions<ska::cheetah::data::SpectrumBase<DerivedType, T, Alloc>, units::Frequency> : public std::true_type
110 {
111 };
112 
113 } // namespace pss
114 } // namespace astrotypes
115 
116 #include "detail/Spectrum.cpp"
117 
118 #endif // SKA_CHEETAH_DATA_SPECTRUM_H
A single dimension representation of a Spectrum.
Definition: Spectrum.h:58
Some limits and constants for FLDO.
Definition: Brdz.h:35
std::size_t number_of_channels() const
return the number of channels in the data structure