Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
DmTrials.cpp
1 #include "cheetah/data/DmTrials.h"
2 #include "panda/Error.h"
3 #include "panda/Log.h"
4 #include <chrono>
5 
6 namespace ska {
7 namespace cheetah {
8 namespace data {
9 
10 
11 template <typename Arch, typename T, typename Alloc>
12 DmTrials<Arch,T,Alloc>::DmTrials(std::shared_ptr<DmTrialsMetadata> metadata, Mjd start, Alloc const& allocator)
13  : _metadata(std::move(metadata))
14  , _data((_metadata?_metadata->total_data_size():0), allocator)
15  , _start_time(std::move(start))
16 {
17  if (!_metadata || _metadata->size() == 0)
18  throw panda::Error("Empty DmTrialsMetadata passed to DmTrials constructor.");
19  _trials.reserve(_metadata->size());
20  auto it = _data.begin();
21  for (auto const& trial: *_metadata)
22  {
23  std::size_t const size = trial.size();
24  _trials.emplace_back(trial,it,it+size);
25  it+=size;
26  }
27 }
28 
29 template <typename Arch, typename T, typename Alloc>
30 template<typename OtherArch, typename OtherT, typename OtherAlloc>
32  : _metadata(std::make_shared<DmTrialsMetadata>(copy.metadata()))
33  , _data(copy._data, allocator)
34  , _start_time(copy.start_time())
35  , _duration(copy.duration())
36 {
37  _trials.reserve(_metadata->size());
38  auto it = _data.begin();
39  for (auto const& trial: *_metadata)
40  {
41  std::size_t const size = trial.size();
42  _trials.emplace_back(trial,it,it+size);
43  it+=size;
44  }
45 }
46 
47 template <typename Arch, typename T, typename Alloc>
49 {
50 }
51 
52 template <typename Arch, typename T, typename Alloc>
54 {
55  return *_metadata;
56 }
57 
58 template <typename Arch, typename T, typename Alloc>
59 typename DmTrials<Arch,T,Alloc>::Mjd const& DmTrials<Arch,T,Alloc>::start_time() const
60 {
61  return _start_time;
62 }
63 
64 template <typename Arch, typename T, typename Alloc>
66 {
67  _start_time = start;
68 }
69 
70 template <typename Arch, typename T, typename Alloc>
72 {
73  return _trials[n];
74 }
75 
76 template <typename Arch, typename T, typename Alloc>
78 {
79  return _trials[n];
80 }
81 
82 template <typename Arch, typename T, typename Alloc>
83 typename DmTrials<Arch,T,Alloc>::Iterator DmTrials<Arch,T,Alloc>::begin()
84 {
85  return _trials.begin();
86 }
87 
88 template <typename Arch, typename T, typename Alloc>
89 typename DmTrials<Arch,T,Alloc>::ConstIterator DmTrials<Arch,T,Alloc>::begin() const
90 {
91  return _trials.cbegin();
92 }
93 
94 template <typename Arch, typename T, typename Alloc>
95 typename DmTrials<Arch,T,Alloc>::ConstIterator DmTrials<Arch,T,Alloc>::cbegin() const
96 {
97  return _trials.cbegin();
98 }
99 
100 template <typename Arch, typename T, typename Alloc>
101 typename DmTrials<Arch,T,Alloc>::Iterator DmTrials<Arch,T,Alloc>::end()
102 {
103  return _trials.end();
104 }
105 
106 template <typename Arch, typename T, typename Alloc>
107 typename DmTrials<Arch,T,Alloc>::ConstIterator DmTrials<Arch,T,Alloc>::end() const
108 {
109  return _trials.end();
110 }
111 
112 template <typename Arch, typename T, typename Alloc>
113 typename DmTrials<Arch,T,Alloc>::ConstIterator DmTrials<Arch,T,Alloc>::cend() const
114 {
115  return _trials.cend();
116 }
117 
118 template <typename Arch, typename T, typename Alloc>
119 std::size_t DmTrials<Arch,T,Alloc>::size() const
120 {
121  return _trials.size();
122 }
123 
124 template <typename Arch, typename T, typename Alloc>
126 {
127  return *_metadata == *(other._metadata);
128 }
129 
130 template <typename Arch, typename T, typename Alloc>
132 {
133 
134  TimeType diff(pss::astrotypes::units::duration_cast<TimeType>(next._start_time - (_start_time + std::chrono::duration<double>(this->duration().value()))));
135  return diff < _metadata->fundamental_sampling_interval();
136 }
137 
138 template <typename Arch, typename T, typename Alloc>
139 typename DmTrials<Arch,T,Alloc>::TimeType DmTrials<Arch,T,Alloc>::duration() const
140 {
141  return _metadata->duration();
142 }
143 
144 
145 } // namespace data
146 } // namespace cheetah
147 } // namespace ska
148 
DmTrialsMetadata const & metadata() const
Return the trials meta data object.
Definition: DmTrials.cpp:53
bool is_compatible(DmTrials const &other) const
Determines if another DmTrials object is compatible with this one.
Definition: DmTrials.cpp:125
Iterator begin()
Return an iterator pointing to the start of the DM trials container.
Definition: DmTrials.cpp:83
bool is_contiguous(DmTrials const &other) const
Determines if another DmTrials object is contiguous in time after this one.
Definition: DmTrials.cpp:131
Some limits and constants for FLDO.
Definition: Brdz.h:35
ConstIterator begin() const
Iterators to device memory.
Definition: Series.cpp:67
Container for metadata that describes a set of dispersion measure trials.
Mjd const & start_time() const
Definition: DmTrials.cpp:59
Iterator end()
Return an iterator pointing to the end of the DM trials container.
Definition: DmTrials.cpp:101
TimeType duration() const
Return the time duration of the DmTrials.
Definition: DmTrials.cpp:139
DmTrialType & operator[](std::size_t n)
Return reference to DmTrial instance.
Definition: DmTrials.cpp:71
A continuous memory container for dispersion measure trials of varying downsamplings.
Definition: DmTrials.h:62
std::size_t size() const
Return the number of DmTrials.
Definition: DmTrials.cpp:119
A wrapper class that presents a SeriesSlice object as a trial dispersion measure time series...
Definition: DmTrial.h:31
~DmTrials()
empty object constructor
Definition: DmTrials.cpp:48