Alexandria  2.25.0
SDC-CH common library for the Euclid project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PhotometryCatalogConfig.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
28 #include "ElementsKernel/Logging.h"
30 
31 namespace po = boost::program_options;
32 namespace fs = boost::filesystem;
33 
34 namespace Euclid {
35 namespace Configuration {
36 
37 static Elements::Logging logger = Elements::Logging::getLogger("PhotometryCatalogConfig");
38 
39 static const std::string MISSING_PHOTOMETRY_FLAG{"missing-photometry-flag"};
40 static const std::string ENABLE_UPPER_LIMIT{"enable-upper-limit"};
41 static const std::string UPPER_LIMIT_USE_THRESHOLD_FLAG{"upper-limit-use-threshod-flag"};
42 
44  declareDependency<CatalogConfig>();
45  declareDependency<PhotometricBandMappingConfig>();
46 }
47 
49  return {{"Input catalog options",
50  {{MISSING_PHOTOMETRY_FLAG.c_str(), po::value<double>(),
51  "The value passed in the flux indicating that the photometry is missing, if the flag is not provided "
52  "the functionality is disabled"},
53  {ENABLE_UPPER_LIMIT.c_str(), po::value<std::string>()->default_value("NO"),
54  "Define if the catalog contains flux upper limit (YES/NO by default NO)"},
55  {UPPER_LIMIT_USE_THRESHOLD_FLAG.c_str(), po::value<double>()->default_value(-99),
56  "Define a flag (in the flux error column) telling that the sigma has to be computed from "
57  "the flux and the Upper Limit threshold defined for each filter (must be <0 to trigger upper limit "
58  "functionality, by default -99)"}}}};
59 }
60 
62 
64  (args.find(ENABLE_UPPER_LIMIT) != args.end()) && args.at(ENABLE_UPPER_LIMIT).as<std::string>() == "YES";
65  logger.info() << "Upper limit functionality is " << (m_upper_limit_enabled ? "ENABLED" : "DISABLED");
66 
67  double upper_limit_threshold_flag = -99.;
68  if (args.find(UPPER_LIMIT_USE_THRESHOLD_FLAG) != args.end()) {
69  upper_limit_threshold_flag = args.at(UPPER_LIMIT_USE_THRESHOLD_FLAG).as<double>();
70  }
72  logger.info() << "Upper limit threshold flag is " << upper_limit_threshold_flag;
73  }
74 
75  double missing_photo_flag = -99.;
76  if (args.find(MISSING_PHOTOMETRY_FLAG) != args.end()) {
78  missing_photo_flag = args.at(MISSING_PHOTOMETRY_FLAG).as<double>();
79  }
80  logger.info() << "Missing photometry functionality is " << (m_missing_photometry_enabled ? "ENABLED" : "DISABLED");
81 
82  auto filter_name_mapping = getDependency<PhotometricBandMappingConfig>().getPhotometricBandMapping();
83  auto threshold_mapping = getDependency<PhotometricBandMappingConfig>().getUpperLimitThresholdMapping();
84  auto mag_mapping = getDependency<PhotometricBandMappingConfig>().getConvertFromMagMapping();
85  auto column_info = getDependency<CatalogConfig>().getColumnInfo();
86 
87  // Add the row handler to parse the photometries
89  column_info, std::move(filter_name_mapping), m_missing_photometry_enabled, missing_photo_flag,
90  m_upper_limit_enabled, threshold_mapping, upper_limit_threshold_flag, mag_mapping}};
91  getDependency<CatalogConfig>().addAttributeHandler(std::move(handler_ptr));
92 }
93 
95 
97  throw Elements::Exception() << "isMissingPhotometryEnabled() call to uninitialized PhotometryCatalogConfig";
98  }
99 
101 }
102 
104 
106  throw Elements::Exception() << "isUpperLimitEnabled() call to uninitialized PhotometryCatalogConfig";
107  }
108 
109  return m_upper_limit_enabled;
110 }
111 
112 } // namespace Configuration
113 } // namespace Euclid
static const std::string ENABLE_UPPER_LIMIT
Superclass of all configuration classes.
Definition: Configuration.h:45
void info(const std::string &logMessage)
T end(T...args)
State & getCurrentState()
Returns the current state of the configuration.
void initialize(const UserValues &args) override
Adds the PhotometryAttributeFromRow handler to the CatalogConfig.
static const std::string MISSING_PHOTOMETRY_FLAG
STL class.
STL class.
T at(T...args)
static Elements::Logging logger
T move(T...args)
T find(T...args)
Implementation of the AttributeFromRow for a photometry attribute. This class implements the createAt...
static const std::string UPPER_LIMIT_USE_THRESHOLD_FLAG
PhotometryCatalogConfig(long manager_id)
Constructs a new PhotometryCatalogConfig object.
T c_str(T...args)
static Logging getLogger(const std::string &name="")
The initialize() method has been called.
std::map< std::string, OptionDescriptionList > getProgramOptions() override
Returns the program options defined by the PhotometryCatalogConfig.