24 #include "cheetah/sift/simple_sift/Sift.h" 25 #include "panda/Log.h" 31 namespace simple_sift {
34 : _config(algo_config.template config<simple_sift::
Config>())
40 return (candidate_one.
sigma() > candidate_two.
sigma());
43 std::shared_ptr<data::Scl>
Sift::operator()(ResourceType& resource, std::shared_ptr<data::Ccl>
const& ccl)
const 45 return (*
this)(resource, *ccl);
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;
57 auto scl = std::make_shared<data::Scl>();
60 std::sort(ccl.
begin(), ccl.
end(), sort_vector_by_sigma_asc);
64 for (std::size_t bottom = 1; bottom <= top; bottom++) {
65 harmonic_ratio.push_back((
double) top/bottom);
70 std::sort(harmonic_ratio.begin(), harmonic_ratio.end());
73 auto iter = unique(harmonic_ratio.begin(), harmonic_ratio.end());
74 harmonic_ratio.resize(distance(harmonic_ratio.begin(), iter));
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()) {
85 PANDA_LOG_DEBUG <<
"candidate_index = " << candidate_index;
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());
92 PANDA_LOG_DEBUG <<
"candidate_period = " << candidate_period <<
", candidate_dm = " << candidate_dm;
98 identified_as_harmonic[candidate_index] = 1;
101 for (test_candidate_index = candidate_index + 1; test_candidate_index < ccl.
size(); test_candidate_index++) {
103 if (identified_as_harmonic[test_candidate_index]) {
107 PANDA_LOG_DEBUG <<
"test_cand_index = " << test_candidate_index;
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());
113 PANDA_LOG_DEBUG <<
"test_period = " << test_period <<
", test_dm = " << test_dm;
116 if (candidate_period >= test_period) {
117 period_ratio = candidate_period/test_period;
119 period_ratio = test_period/candidate_period;
123 for (
auto iter = harmonic_ratio.begin(); iter != harmonic_ratio.end(); ++iter) {
124 if (std::abs(period_ratio - *iter) < (_config.match_factor() * *iter)) {
126 if (std::abs(candidate_dm - test_dm) < 10) {
128 identified_as_harmonic[test_candidate_index] = 2;
129 PANDA_LOG_DEBUG <<
"Harmonic found!";
Sift(sift::Config const &config)
Construct a new Sift instance.
Configuration for the simple_sift module.
std::shared_ptr< data::Scl > operator()(ResourceType &cpu, data::Ccl &ccl) const
Sift a candidate list to aggregate like signals.
std::size_t size() const
Retrieve the size of the underlying vector.
T const & sigma() const
access a reference to _sigma.
std::size_t num_candidate_harmonics() const
The max number of harmonics to search.
Some limits and constants for FLDO.
Configuration for the sift module.
void push_back(ValueType const &value)
Appends element to end of vector.
Iterator end()
An iterator pointing to the end of the vector.
A simple record to hold 'candidate' proprerties.
Dm const & dm() const
access a reference to dm.
MsecTimeType const & period() const
access a reference to pulsar period.
Iterator begin()
An iterator pointing to the start of the vector.