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";
81 regex expr {
"\\s*([^\\s#]+)\\s+([^\\s#]+)\\s+([^\\s#]+)(\\s+[^\\s#]+\\s*$)?"};
88 if (!regex_match(line, match_res, expr)) {
89 logger.
error() <<
"Syntax error in " << filename <<
": " << line;
92 filter_name_mapping.emplace_back(match_res.str(1),
std::make_pair(match_res.str(2), match_res.str(3)));
94 if (match_res.str(4)==
""){
95 threshold_mapping.emplace_back(match_res.str(1), 3.0);
98 threshold_mapping.emplace_back(match_res.str(1), n);
109 auto all_filter_name_mapping = parsed.first;
110 auto all_threshold_mapping = parsed.second;
116 for (
auto& pair : all_threshold_mapping) {
117 if (exclude_filters.count(pair.first) <= 0) {
122 for (
auto& pair : all_filter_name_mapping) {
123 if (exclude_filters.count(pair.first) > 0) {
124 exclude_filters.erase(pair.first);
131 if (!exclude_filters.empty()) {
133 for (
auto& f : exclude_filters) {
134 wrong_filters << f <<
" ";
137 << wrong_filters.str();
144 throw Elements::Exception() <<
"setBaseDir() call to initialized PhotometricBandMappingConfig";
152 <<
"PhotometricBandMappingConfig";
161 <<
"PhotometricBandMappingConfig";