28 #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 {
53 return {{
"Input catalog options", {
55 "The file containing the photometry mapping of the catalog columns"},
57 "A list of filters to ignore"}
62 const fs::path& base_dir) {
64 if (mapping_file.is_relative()) {
65 mapping_file = base_dir / mapping_file;
67 if (!fs::exists(mapping_file)) {
68 throw Elements::Exception() <<
"Photometry mapping file " << mapping_file <<
" does not exist";
70 if (fs::is_directory(mapping_file)) {
71 throw Elements::Exception() <<
"Photometry mapping file " << mapping_file <<
" is not a file";
80 regex expr {
"\\s*([^\\s#]+)\\s+([^\\s#]+)\\s+([^\\s#]+)\\s*(#.*)?"};
87 if (!regex_match(line, match_res, expr)) {
88 logger.
error() <<
"Syntax error in " << filename <<
": " << line;
91 filter_name_mapping.emplace_back(match_res.str(1),
std::make_pair(match_res.str(2), match_res.str(3)));
93 return filter_name_mapping;
100 auto all_filter_name_mapping =
parseFile(filename);
105 for (
auto& pair : all_filter_name_mapping) {
106 if (exclude_filters.count(pair.first) > 0) {
107 exclude_filters.erase(pair.first);
113 if (!exclude_filters.empty()) {
115 for (
auto& f : exclude_filters) {
116 wrong_filters << f <<
" ";
119 << wrong_filters.str();
126 throw Elements::Exception() <<
"setBaseDir() call to initialized PhotometricBandMappingConfig";
134 <<
"PhotometricBandMappingConfig";