SourceXtractorPlusPlus
0.19.2
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Configuration
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
29
#include "
SEImplementation/Configuration/GroupingConfig.h
"
30
31
using namespace
Euclid::Configuration
;
32
namespace
po = boost::program_options;
33
34
namespace
SourceXtractor
{
35
36
static
const
std::string
GROUPING_ALGORITHM
{
"grouping-algorithm"
};
37
static
const
std::string
GROUPING_HARD_LIMIT
{
"grouping-hard-limit"
};
38
static
const
std::string
GROUPING_MOFFAT_THRESHOLD
{
"grouping-moffat-threshold"
};
39
static
const
std::string
GROUPING_MOFFAT_MAX_DISTANCE
{
"grouping-moffat-max-distance"
};
40
41
static
const
std::string
GROUPING_ALGORITHM_NONE
{
"NONE"
};
42
static
const
std::string
GROUPING_ALGORITHM_OVERLAP
{
"OVERLAP"
};
43
static
const
std::string
GROUPING_ALGORITHM_SPLIT
{
"SPLIT"
};
44
static
const
std::string
GROUPING_ALGORITHM_MOFFAT
{
"MOFFAT"
};
45
46
GroupingConfig::GroupingConfig
(
long
manager_id
)
47
:
Configuration
(
manager_id
),
48
m_selected_algorithm(
Algorithm
::SPLIT_SOURCES), m_moffat_threshold(0.02), m_moffat_max_distance(300), m_hard_limit(0) {
49
}
50
51
std::map<std::string, Configuration::OptionDescriptionList>
GroupingConfig::getProgramOptions
() {
52
return
{ {
"Grouping"
, {
53
{
GROUPING_ALGORITHM
.c_str(), po::value<std::string>()->default_value(
GROUPING_ALGORITHM_SPLIT
),
54
"Grouping algorithm to be used [none|overlap|split|moffat]."
},
55
{
GROUPING_HARD_LIMIT
.c_str(), po::value<unsigned int>()->default_value(0),
56
"Maximum number of sources in a single group (0 = unlimited)"
},
57
{
GROUPING_MOFFAT_THRESHOLD
.c_str(), po::value<double>()->default_value(0.02),
58
"Threshold used for Moffat grouping."
},
59
{
GROUPING_MOFFAT_MAX_DISTANCE
.c_str(), po::value<double>()->default_value(300),
60
"Maximum distance (in pixels) to be considered for grouping"
},
61
}}};
62
}
63
64
void
GroupingConfig::initialize
(
const
UserValues
&
args
) {
65
auto
algorithm_name
= boost::to_upper_copy(
args
.at(
GROUPING_ALGORITHM
).as<
std::string
>());
66
if
(
algorithm_name
==
GROUPING_ALGORITHM_NONE
) {
67
m_selected_algorithm
=
Algorithm::NO_GROUPING
;
68
}
else
if
(
algorithm_name
==
GROUPING_ALGORITHM_OVERLAP
) {
69
m_selected_algorithm
=
Algorithm::OVERLAPPING
;
70
}
else
if
(
algorithm_name
==
GROUPING_ALGORITHM_SPLIT
) {
71
m_selected_algorithm
=
Algorithm::SPLIT_SOURCES
;
72
}
else
if
(
algorithm_name
==
GROUPING_ALGORITHM_MOFFAT
) {
73
m_selected_algorithm
=
Algorithm::MOFFAT
;
74
}
else
{
75
throw
Elements::Exception
() <<
"Unknown grouping algorithm : "
<<
algorithm_name
;
76
}
77
78
if
(
args
.find(
GROUPING_MOFFAT_THRESHOLD
) !=
args
.end()) {
79
m_moffat_threshold
=
args
.find(
GROUPING_MOFFAT_THRESHOLD
)->second.as<
double
>();
80
}
81
if
(
args
.find(
GROUPING_MOFFAT_MAX_DISTANCE
) !=
args
.end()) {
82
m_moffat_max_distance
=
args
.find(
GROUPING_MOFFAT_MAX_DISTANCE
)->second.as<
double
>();
83
}
84
if
(
args
.find(
GROUPING_HARD_LIMIT
) !=
args
.end()) {
85
m_hard_limit
=
args
.find(
GROUPING_HARD_LIMIT
)->second.as<
unsigned
int
>();
86
}
87
}
88
89
}
// SourceXtractor namespace
90
91
92
ConfigManager.h
Exception.h
GroupingConfig.h
std::string
Elements::Exception
Euclid::Configuration::Configuration
SourceXtractor::GroupingConfig::m_moffat_max_distance
double m_moffat_max_distance
Definition
GroupingConfig.h:76
SourceXtractor::GroupingConfig::m_selected_algorithm
Algorithm m_selected_algorithm
Definition
GroupingConfig.h:74
SourceXtractor::GroupingConfig::getProgramOptions
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
Definition
GroupingConfig.cpp:51
SourceXtractor::GroupingConfig::GroupingConfig
GroupingConfig(long manager_id)
Constructs a new GroupingConfig object.
Definition
GroupingConfig.cpp:46
SourceXtractor::GroupingConfig::Algorithm
Algorithm
Definition
GroupingConfig.h:39
SourceXtractor::GroupingConfig::Algorithm::NO_GROUPING
@ NO_GROUPING
SourceXtractor::GroupingConfig::Algorithm::MOFFAT
@ MOFFAT
SourceXtractor::GroupingConfig::Algorithm::OVERLAPPING
@ OVERLAPPING
SourceXtractor::GroupingConfig::Algorithm::SPLIT_SOURCES
@ SPLIT_SOURCES
SourceXtractor::GroupingConfig::m_moffat_threshold
double m_moffat_threshold
Definition
GroupingConfig.h:75
SourceXtractor::GroupingConfig::m_hard_limit
unsigned int m_hard_limit
Definition
GroupingConfig.h:77
SourceXtractor::GroupingConfig::initialize
void initialize(const UserValues &args) override
Definition
GroupingConfig.cpp:64
std::function
std::map
Euclid::Configuration
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::GROUPING_HARD_LIMIT
static const std::string GROUPING_HARD_LIMIT
Definition
GroupingConfig.cpp:37
SourceXtractor::GROUPING_ALGORITHM_OVERLAP
static const std::string GROUPING_ALGORITHM_OVERLAP
Definition
GroupingConfig.cpp:42
SourceXtractor::GROUPING_MOFFAT_THRESHOLD
static const std::string GROUPING_MOFFAT_THRESHOLD
Definition
GroupingConfig.cpp:38
SourceXtractor::GROUPING_ALGORITHM_NONE
static const std::string GROUPING_ALGORITHM_NONE
Definition
GroupingConfig.cpp:41
SourceXtractor::GROUPING_ALGORITHM_SPLIT
static const std::string GROUPING_ALGORITHM_SPLIT
Definition
GroupingConfig.cpp:43
SourceXtractor::GROUPING_ALGORITHM
static const std::string GROUPING_ALGORITHM
Definition
GroupingConfig.cpp:36
SourceXtractor::GROUPING_ALGORITHM_MOFFAT
static const std::string GROUPING_ALGORITHM_MOFFAT
Definition
GroupingConfig.cpp:44
SourceXtractor::GROUPING_MOFFAT_MAX_DISTANCE
static const std::string GROUPING_MOFFAT_MAX_DISTANCE
Definition
GroupingConfig.cpp:39
Generated by
1.9.8