Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Public Member Functions | List of all members
ska::cheetah::data::detail::DmTimeDm< DmTimeSliceType > Class Template Reference

Class that wraps a single DM trial from a DmTime object. More...

#include <cheetah/data/detail/DmTimeDm.h>

Collaboration diagram for ska::cheetah::data::detail::DmTimeDm< DmTimeSliceType >:
Collaboration graph

Public Member Functions

 DmTimeDm (std::size_t const dm_idx, std::shared_ptr< SliceType const > parent)
 Create a new instance. More...
 
template<typename TimeSeriesType >
TimeSeriesType::Iterator copy_to (TimeSeriesType &timeseries) const
 Copy the given DM trial to an arbitrary timeseries. More...
 
std::size_t number_of_samples () const
 Get the number of time samples in the associated DM trial. More...
 
data::DedispersionMeasureType< float > dm () const
 
TimeType sampling_interval () const
 

Detailed Description

template<typename DmTimeSliceType>
class ska::cheetah::data::detail::DmTimeDm< DmTimeSliceType >

Class that wraps a single DM trial from a DmTime object.

This class provides an interface that allows for single DM trials to be extracted from a DmTime object and sent to an arbitrary memory location on an arbitrary device.

This class is not intended to be used directly, but should instead only be returned from a dereferenced DmTimeSliceIterator.

Definition at line 47 of file DmTimeDm.h.

Constructor & Destructor Documentation

◆ DmTimeDm()

template<typename DmTimeType >
ska::cheetah::data::detail::DmTimeDm< DmTimeType >::DmTimeDm ( std::size_t const  dm_idx,
std::shared_ptr< SliceType const >  parent 
)

Create a new instance.

Parameters
[in]dm_idxThe dm index
[in]parentThe parent DmTimeSlice object

Definition at line 17 of file DmTimeDm.cpp.

18  : _dm_idx(dm_idx)
19  , _parent(std::move(parent))
20 {
21 }

Member Function Documentation

◆ copy_to()

template<typename DmTimeType >
template<typename TimeSeriesType >
TimeSeriesType::Iterator ska::cheetah::data::detail::DmTimeDm< DmTimeType >::copy_to ( TimeSeriesType &  timeseries) const

Copy the given DM trial to an arbitrary timeseries.

The copy_to method will copy only up to the size of the timeseries provided. For objects using this method, it is necessary to check that the iterator returned by copy_to() matches the end() iterator of the timeseries. When they do not match, the timeseries should likely be resized or padded to ensure that all of the data it contains remains valid.

Parameters
timeseriesThe timeseries to be copied to
Template Parameters
TimeSeriesTypeThe type of the timeseries
Returns
An iterator pointing to the last copied element in the time series

Definition at line 59 of file DmTimeDm.cpp.

60 {
61  if ( _parent->blocks().empty())
62  {
63  throw std::runtime_error("Requested copy from empty DmTime object.");
64  }
65  timeseries.sampling_interval(_parent->blocks().front()->operator[](_dm_idx).sampling_interval());
66  std::size_t count = timeseries.size();
67  std::size_t copied = 0;
68  typename TimeSeriesType::Iterator it;
69  for (auto const& block: _parent->blocks())
70  {
71  auto dmtrial = block->operator[](_dm_idx);
72  std::size_t copy_count = std::min(dmtrial.size(),count-copied);
73  PANDA_LOG_DEBUG << "Copying "<<copy_count<<" samples from DmTime block to timeseries";
74  auto device_it = panda::make_device_iterator<typename TimeSeriesType::ArchitectureType>(timeseries.begin()+copied);
75  it = panda::copy(dmtrial.begin(), dmtrial.begin()+copy_count, device_it);
76  copied = std::distance(timeseries.begin(),it);
77  if (copied == count)
78  break;
79  }
80  return it;
81 }

◆ number_of_samples()

template<typename DmTimeType >
std::size_t ska::cheetah::data::detail::DmTimeDm< DmTimeType >::number_of_samples ( ) const

Get the number of time samples in the associated DM trial.

Returns
The number of samples in the DM trial

Definition at line 29 of file DmTimeDm.cpp.

30 {
31  std::size_t sample_count = 0;
32  for (auto const& block: _parent->blocks())
33  sample_count += block->operator[](_dm_idx).size();
34  return sample_count;
35 }

The documentation for this class was generated from the following files: