SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
GroupingConfig.cpp
Go to the documentation of this file.
1
17/*
18 * GroupingConfig.cpp
19 *
20 * Created on: Jul 3, 2018
21 * Author: mschefer
22 */
23
24#include <boost/algorithm/string.hpp>
25
26#include "ElementsKernel/Exception.h"
27#include "Configuration/ConfigManager.h"
28
30
31using namespace Euclid::Configuration;
32namespace po = boost::program_options;
33
34namespace SourceXtractor {
35
36static const std::string GROUPING_ALGORITHM {"grouping-algorithm" };
37static const std::string GROUPING_HARD_LIMIT {"grouping-hard-limit" };
38static const std::string GROUPING_MOFFAT_THRESHOLD {"grouping-moffat-threshold" };
39static const std::string GROUPING_MOFFAT_MAX_DISTANCE {"grouping-moffat-max-distance" };
40
41static const std::string GROUPING_ALGORITHM_NONE {"NONE" };
42static const std::string GROUPING_ALGORITHM_OVERLAP {"OVERLAP" };
43static const std::string GROUPING_ALGORITHM_SPLIT {"SPLIT" };
44static const std::string GROUPING_ALGORITHM_MOFFAT {"MOFFAT" };
45static const std::string GROUPING_ALGORITHM_ASSOC {"ASSOC" };
46
48 : Configuration(manager_id),
50}
51
53 return { {"Grouping", {
54 {GROUPING_ALGORITHM.c_str(), po::value<std::string>()->default_value(GROUPING_ALGORITHM_SPLIT),
55 "Grouping algorithm to be used [none|overlap|split|moffat]."},
56 {GROUPING_HARD_LIMIT.c_str(), po::value<unsigned int>()->default_value(0),
57 "Maximum number of sources in a single group (0 = unlimited)"},
58 {GROUPING_MOFFAT_THRESHOLD.c_str(), po::value<double>()->default_value(0.02),
59 "Threshold used for Moffat grouping."},
60 {GROUPING_MOFFAT_MAX_DISTANCE.c_str(), po::value<double>()->default_value(300),
61 "Maximum distance (in pixels) to be considered for grouping"},
62 }}};
63}
64
66 auto algorithm_name = boost::to_upper_copy(args.at(GROUPING_ALGORITHM).as<std::string>());
67 if (algorithm_name == GROUPING_ALGORITHM_NONE) {
69 } else if (algorithm_name == GROUPING_ALGORITHM_OVERLAP) {
71 } else if (algorithm_name == GROUPING_ALGORITHM_SPLIT) {
73 } else if (algorithm_name == GROUPING_ALGORITHM_MOFFAT) {
75 } else if (algorithm_name == GROUPING_ALGORITHM_ASSOC) {
77 } else {
78 throw Elements::Exception() << "Unknown grouping algorithm : " << algorithm_name;
79 }
80
81 if (args.find(GROUPING_MOFFAT_THRESHOLD) != args.end()) {
82 m_moffat_threshold = args.find(GROUPING_MOFFAT_THRESHOLD)->second.as<double>();
83 }
84 if (args.find(GROUPING_MOFFAT_MAX_DISTANCE) != args.end()) {
85 m_moffat_max_distance = args.find(GROUPING_MOFFAT_MAX_DISTANCE)->second.as<double>();
86 }
87 if (args.find(GROUPING_HARD_LIMIT) != args.end()) {
88 m_hard_limit = args.find(GROUPING_HARD_LIMIT)->second.as<unsigned int>();
89 }
90}
91
92} // SourceXtractor namespace
93
94
95
T at(T... args)
std::map< std::string, boost::program_options::variable_value > UserValues
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
GroupingConfig(long manager_id)
Constructs a new GroupingConfig object.
void initialize(const UserValues &args) override
T end(T... args)
T find(T... args)
static const std::string GROUPING_HARD_LIMIT
static const std::string GROUPING_ALGORITHM_OVERLAP
static const std::string GROUPING_MOFFAT_THRESHOLD
static const std::string GROUPING_ALGORITHM_NONE
static const std::string GROUPING_ALGORITHM_SPLIT
static const std::string GROUPING_ALGORITHM
static const std::string GROUPING_ALGORITHM_MOFFAT
static const std::string GROUPING_MOFFAT_MAX_DISTANCE
static const std::string GROUPING_ALGORITHM_ASSOC