Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
PulsarProfile.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 "../PulsarProfile.h"
25 #include <algorithm>
26 #include <numeric>
27 
28 
29 namespace ska {
30 namespace cheetah {
31 namespace generators {
32 
33 PulsarProfile::PulsarProfile(std::initializer_list<double> list)
34  : _profile(list)
35 {
36 }
37 
38 PulsarProfile::PulsarProfile()
39 {
40 }
41 
42 PulsarProfile::~PulsarProfile()
43 {
44 }
45 
46 PulsarProfile::Iterator PulsarProfile::begin()
47 {
48  return _profile.begin();
49 }
50 
51 PulsarProfile::ConstIterator PulsarProfile::cbegin() const
52 {
53  return _profile.cbegin();
54 }
55 
56 PulsarProfile::Iterator PulsarProfile::end()
57 {
58  return _profile.end();
59 }
60 
61 PulsarProfile::ConstIterator PulsarProfile::cend() const
62 {
63  return _profile.cend();
64 }
65 
66 void PulsarProfile::add(double value)
67 {
68  //FrequencyType f = (_profile.size()?(_profile.back().first + _delta):_start);
69  //_profile.emplace_back(std::make_pair(std::move(f), value));
70  _profile.emplace_back(value);
71 }
72 
73 
74 PulsarProfile& operator<<(PulsarProfile& p, double value)
75 {
76  p.add(value);
77  return p;
78 }
79 
80 double PulsarProfile::sum() const {
81  return std::accumulate(cbegin(), cend(), 0.0);
82  //, [](double val, ProfileDataPoint const& spec) { return spec.second + val; });
83 }
84 
85 std::size_t PulsarProfile::size() const
86 {
87  return _profile.size();
88 }
89 
90 } // namespace generators
91 } // namespace cheetah
92 } // namespace ska
std::size_t size() const
return the number of data points in the profile
Iterator begin()
the start of the profile spectrum
A simple intensity profile representing a pulse shape.
Definition: PulsarProfile.h:43
Some limits and constants for FLDO.
Definition: Brdz.h:35
Iterator end()
the end of the profile spectrum
void add(double)
add a value to the profile
double sum() const
return the sum of all frequencies