26 #include <boost/regex.hpp>
30 using boost::regex_match;
32 #include <boost/algorithm/string.hpp>
38 namespace po = boost::program_options;
39 namespace fs = boost::filesystem;
42 namespace Configuration {
52 return {{
"Input catalog options",
54 "The file containing the photometry mapping of the catalog columns"},
56 "A list of filters to ignore"}}}};
61 if (mapping_file.is_relative()) {
62 mapping_file = base_dir / mapping_file;
64 if (!fs::exists(mapping_file)) {
65 throw Elements::Exception() <<
"Photometry mapping file " << mapping_file <<
" does not exist";
67 if (fs::is_directory(mapping_file)) {
68 throw Elements::Exception() <<
"Photometry mapping file " << mapping_file <<
" is not a file";
79 regex expr{
"\\s*([^\\s#]+)\\s+([^\\s#]+)\\s+([^\\s#]+)(\\s+[^\\s#]+\\s*$)?"};
86 if (!regex_match(line, match_res, expr)) {
87 logger.
error() <<
"Syntax error in " << filename <<
": " << line;
90 filter_name_mapping.emplace_back(match_res.str(1),
std::make_pair(match_res.str(2), match_res.str(3)));
92 if (match_res.str(4) ==
"") {
93 threshold_mapping.emplace_back(match_res.str(1), 3.0);
96 threshold_mapping.emplace_back(match_res.str(1), n);
107 auto all_filter_name_mapping = parsed.first;
108 auto all_threshold_mapping = parsed.second;
114 for (
auto& pair : all_threshold_mapping) {
115 if (exclude_filters.count(pair.first) <= 0) {
120 for (
auto& pair : all_filter_name_mapping) {
121 if (exclude_filters.count(pair.first) > 0) {
122 exclude_filters.erase(pair.first);
128 if (!exclude_filters.empty()) {
130 for (
auto& f : exclude_filters) {
131 wrong_filters << f <<
" ";
139 throw Elements::Exception() <<
"setBaseDir() call to initialized PhotometricBandMappingConfig";
147 <<
"PhotometricBandMappingConfig";
155 <<
"PhotometricBandMappingConfig";