SourceXtractorPlusPlus  0.17
SourceXtractor++, the next generation SExtractor
SE2BackgroundConfig.cpp
Go to the documentation of this file.
1 
17 /*
18  * @file BackgroundConfig.cpp
19  * @author nikoapos
20  */
21 
22 #include <algorithm>
23 #include <ElementsKernel/Logging.h>
27 
28 using namespace Euclid::Configuration;
29 namespace po = boost::program_options;
30 
31 namespace SourceXtractor {
32 
34 
35 static const std::string CELLSIZE_VALUE {"background-cell-size" };
36 static const std::string SMOOTHINGBOX_VALUE {"smoothing-box-size" };
37 static const std::string LEGACY_BACKGROUND {"background-legacy"};
38 
39 SE2BackgroundConfig::SE2BackgroundConfig(long manager_id) :
40  Configuration(manager_id), m_cell_size(), m_smoothing_box() {
41 }
42 
44  return { {"Background modelling", {
45  {CELLSIZE_VALUE.c_str(), po::value<std::string>()->default_value(std::string("64")),
46  "Background mesh cell size to determine a value."},
47  {SMOOTHINGBOX_VALUE.c_str(), po::value<std::string>()->default_value(std::string("3")),
48  "Background median filter size"},
49  {LEGACY_BACKGROUND.c_str(), po::bool_switch(),
50  "Deprecated, kept for compatibility"}
51  }}};
52 }
53 
55  auto cell_size_str = args.find(CELLSIZE_VALUE)->second.as<std::string>();
56  auto smoothing_box_str = args.find(SMOOTHINGBOX_VALUE)->second.as<std::string>();
57 
58  if (args.find(CELLSIZE_VALUE) != args.end()) {
59  m_cell_size = Euclid::stringToVector<int>(cell_size_str);
60  }
61  if (args.find(SMOOTHINGBOX_VALUE) != args.end()) {
62  m_smoothing_box = Euclid::stringToVector<int>(smoothing_box_str);
63  }
64 
65  auto less_eq_0 = [](int v) { return v <= 0; };
66  auto less_0 = [](int v) { return v < 0; };
67 
68  if (std::find_if(m_cell_size.begin(), m_cell_size.end(), less_eq_0) != m_cell_size.end()) {
69  throw Elements::Exception() << "There are value(s) < 1 in backgound-cell-size: " << cell_size_str;
70  }
72  throw Elements::Exception() << "There are value(s) < 0 in smoothing-box-size: " << smoothing_box_str;
73  }
74  if (args.find(LEGACY_BACKGROUND) != args.end()) {
75  logger.warn() << "The option "
76  << LEGACY_BACKGROUND << " is deprecated and has no effect starting at version 0.17";
77  }
78 }
79 
80 } // SourceXtractor namespace
T begin(T... args)
T c_str(T... args)
static Logging getLogger(const std::string &name="")
void initialize(const UserValues &args) override
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
T end(T... args)
T find(T... args)
static Elements::Logging logger
static auto logger
Definition: WCS.cpp:44
static const std::string CELLSIZE_VALUE
static const std::string SMOOTHINGBOX_VALUE
static const std::string LEGACY_BACKGROUND