Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Public Types | Public Member Functions | List of all members
ska::cheetah::sift::simple_sift::Sift Class Reference

simple_sift algorithm for the Sift module More...

#include <cheetah/sift/simple_sift/Sift.h>

Collaboration diagram for ska::cheetah::sift::simple_sift::Sift:
Collaboration graph

Public Types

typedef cheetah::Cpu Architecture
 
typedef cheetah::Cpu ArchitectureCapability
 
typedef simple_sift::Config Config
 
typedef panda::PoolResource< Architecture > ResourceType
 

Public Member Functions

 Sift (sift::Config const &config)
 Construct a new Sift instance. More...
 
 Sift (Sift const &)=delete
 
 Sift (Sift &&)=default
 
std::shared_ptr< data::Scloperator() (ResourceType &cpu, data::Ccl &ccl) const
 Sift a candidate list to aggregate like signals. More...
 
std::shared_ptr< data::Scloperator() (ResourceType &cpu, std::shared_ptr< data::Ccl > const &ccl) const
 

Detailed Description

simple_sift algorithm for the Sift module

Definition at line 43 of file Sift.h.

Constructor & Destructor Documentation

◆ Sift()

ska::cheetah::sift::simple_sift::Sift::Sift ( sift::Config const &  config)

Construct a new Sift instance.

Parameters
configThe implementation configuration
algo_configThe algorithm configuration

Definition at line 33 of file Sift.cpp.

34  : _config(algo_config.template config<simple_sift::Config>())
35 {
36 }
Here is the call graph for this function:

Member Function Documentation

◆ operator()()

std::shared_ptr< data::Scl > ska::cheetah::sift::simple_sift::Sift::operator() ( ResourceType &  cpu,
data::Ccl ccl 
) const

Sift a candidate list to aggregate like signals.

Parameters
cpuUse the cpu for processing
dataThe Ccl list to sift
Returns
A shared pointer to a list of sifted candidate signals

Definition at line 48 of file Sift.cpp.

49 {
50  double candidate_period, test_period, candidate_dm, test_dm, period_ratio;
51  std::vector<bool> identified_as_harmonic(ccl.size(), {false});
52  std::vector<double> harmonic_ratio;
53  std::size_t candidate_index, test_candidate_index;
54  data::Ccl::CandidateType candidate, test_candidate;
55 
56  // Shared pointer to structure in which to store sifted periodicity candidates
57  auto scl = std::make_shared<data::Scl>();
58 
59  // Sort the list by S/N, highest to lowest
60  std::sort(ccl.begin(), ccl.end(), sort_vector_by_sigma_asc);
61 
62  // Calculate harmonic ratios (1/1, 2/2, 3/2, 4/2, ..., 8/7, 8/8)
63  for (std::size_t top = 1; top <= _config.num_candidate_harmonics(); top++) {
64  for (std::size_t bottom = 1; bottom <= top; bottom++) {
65  harmonic_ratio.push_back((double) top/bottom);
66  }
67  }
68 
69  // Sort the vector of ratios
70  std::sort(harmonic_ratio.begin(), harmonic_ratio.end());
71 
72  // Remove duplicate ratios and resize the vector
73  auto iter = unique(harmonic_ratio.begin(), harmonic_ratio.end());
74  harmonic_ratio.resize(distance(harmonic_ratio.begin(), iter));
75 
76  // Loop until all candidates have been dealt with
77  while (true) {
78 
79  // Find the candidate with the highest sigma that has not been sifted
80  candidate_index = std::find(identified_as_harmonic.begin(), identified_as_harmonic.end(), 0) - identified_as_harmonic.begin();
81  if (candidate_index >= identified_as_harmonic.size()) { // If the index is greater than the vector size, it means it has not found any zeros
82  break;
83  }
84 
85  PANDA_LOG_DEBUG << "candidate_index = " << candidate_index;
86 
87  // Start with the highest S/N candidate and check to see if any of the other candidates are related
88  candidate = ccl[candidate_index];
89  candidate_period = boost::units::quantity_cast<double>(candidate.period());
90  candidate_dm = boost::units::quantity_cast<double>(candidate.dm());
91 
92  PANDA_LOG_DEBUG << "candidate_period = " << candidate_period << ", candidate_dm = " << candidate_dm;
93 
94  // Put this candidate into the sifted candidate list
95  scl->push_back(candidate);
96 
97  // Mark that this candidate has been added to the scl
98  identified_as_harmonic[candidate_index] = 1;
99 
100  // Go through every remaining signal in the list to check for related signals
101  for (test_candidate_index = candidate_index + 1; test_candidate_index < ccl.size(); test_candidate_index++) {
102 
103  if (identified_as_harmonic[test_candidate_index]) {
104  continue;
105  } else {
106 
107  PANDA_LOG_DEBUG << "test_cand_index = " << test_candidate_index;
108 
109  test_candidate = ccl[test_candidate_index];
110  test_period = boost::units::quantity_cast<double>(test_candidate.period());
111  test_dm = boost::units::quantity_cast<double>(test_candidate.dm());
112 
113  PANDA_LOG_DEBUG << "test_period = " << test_period << ", test_dm = " << test_dm;
114 
115  // Since all of the ratios generated to test for harmonics are greater than one, make sure the ratio of the periods is greater than one
116  if (candidate_period >= test_period) {
117  period_ratio = candidate_period/test_period;
118  } else {
119  period_ratio = test_period/candidate_period;
120  }
121 
122  // Go through each ratio and test whether this period is some harmonic of the candidate
123  for (auto iter = harmonic_ratio.begin(); iter != harmonic_ratio.end(); ++iter) {
124  if (std::abs(period_ratio - *iter) < (_config.match_factor() * *iter)) {
125  // Test whether this DM is within +-10 of the DM of the candidate
126  if (std::abs(candidate_dm - test_dm) < 10) {
127  // Mark this test_candidate as a harmonic
128  identified_as_harmonic[test_candidate_index] = 2;
129  PANDA_LOG_DEBUG << "Harmonic found!";
130  break;
131  }
132  }
133  }
134 
135  }
136 
137  }
138 
139  }
140 
141  return scl;
142 
143 }
std::size_t num_candidate_harmonics() const
The max number of harmonics to search.
Definition: Config.cpp:45
Here is the call graph for this function:

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