SourceXtractorPlusPlus  0.11
Please provide a description of the project.
SE2BackgroundConfig.cpp
Go to the documentation of this file.
1 
17 /*
18  * @file BackgroundConfig.cpp
19  * @author nikoapos
20  */
21 
22 #include <algorithm>
26 
27 using namespace Euclid::Configuration;
28 namespace po = boost::program_options;
29 
30 namespace SourceXtractor {
31 
32 static const std::string CELLSIZE_VALUE {"background-cell-size" };
33 static const std::string SMOOTHINGBOX_VALUE {"smoothing-box-size" };
34 static const std::string LEGACY_BACKGROUND {"background-legacy"};
35 
36 SE2BackgroundConfig::SE2BackgroundConfig(long manager_id) :
37  Configuration(manager_id), m_cell_size(), m_smoothing_box(), m_legacy(false) {
38 }
39 
41  return { {"Background modelling", {
42  {CELLSIZE_VALUE.c_str(), po::value<std::string>()->default_value(std::string("64")),
43  "Background mesh cell size to determine a value."},
44  {SMOOTHINGBOX_VALUE.c_str(), po::value<std::string>()->default_value(std::string("3")),
45  "Background median filter size"},
46  {LEGACY_BACKGROUND.c_str(), po::bool_switch(),
47  "Use the legacy implementation"}
48  }}};
49 }
50 
52  auto cell_size_str = args.find(CELLSIZE_VALUE)->second.as<std::string>();
53  auto smoothing_box_str = args.find(SMOOTHINGBOX_VALUE)->second.as<std::string>();
54 
55  if (args.find(CELLSIZE_VALUE) != args.end()) {
56  m_cell_size = Euclid::stringToVector<int>(cell_size_str);
57  }
58  if (args.find(SMOOTHINGBOX_VALUE) != args.end()) {
59  m_smoothing_box = Euclid::stringToVector<int>(smoothing_box_str);
60  }
61 
62  auto less_eq_0 = [](int v) { return v <= 0; };
63  auto less_0 = [](int v) { return v < 0; };
64 
65  if (std::find_if(m_cell_size.begin(), m_cell_size.end(), less_eq_0) != m_cell_size.end()) {
66  throw Elements::Exception() << "There are value(s) < 1 in backgound-cell-size: " << cell_size_str;
67  }
69  throw Elements::Exception() << "There are value(s) < 0 in smoothing-box-size: " << smoothing_box_str;
70  }
71  if (args.find(LEGACY_BACKGROUND) != args.end()) {
72  m_legacy = args.at(LEGACY_BACKGROUND).as<bool>();
73  }
74 }
75 
76 } // SourceXtractor namespace
std::string
STL class.
SourceXtractor::SE2BackgroundConfig::initialize
void initialize(const UserValues &args) override
Definition: SE2BackgroundConfig.cpp:51
SourceXtractor::SMOOTHINGBOX_VALUE
static const std::string SMOOTHINGBOX_VALUE
Definition: SE2BackgroundConfig.cpp:33
std::map::find
T find(T... args)
Euclid::Configuration
SourceXtractor
Definition: Aperture.h:30
std::map::at
T at(T... args)
StringUtils.h
SourceXtractor::SE2BackgroundConfig::m_cell_size
std::vector< int > m_cell_size
Definition: SE2BackgroundConfig.h:55
std::string::c_str
T c_str(T... args)
SourceXtractor::SE2BackgroundConfig::getProgramOptions
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
Definition: SE2BackgroundConfig.cpp:40
Elements::Exception
ProcessedImage.h
std::map
STL class.
SourceXtractor::SE2BackgroundConfig::m_smoothing_box
std::vector< int > m_smoothing_box
Definition: SE2BackgroundConfig.h:56
SE2BackgroundConfig.h
std::vector::begin
T begin(T... args)
SourceXtractor::CELLSIZE_VALUE
static const std::string CELLSIZE_VALUE
Definition: SE2BackgroundConfig.cpp:32
Euclid::Configuration::Configuration
std::map::end
T end(T... args)
SourceXtractor::SE2BackgroundConfig::m_legacy
bool m_legacy
Definition: SE2BackgroundConfig.h:57
SourceXtractor::LEGACY_BACKGROUND
static const std::string LEGACY_BACKGROUND
Definition: SE2BackgroundConfig.cpp:34