Alexandria  2.16
Please provide a description of the 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-2020 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 
25 #include "ElementsKernel/Logging.h"
30 
31 
32 namespace po = boost::program_options;
33 namespace fs = boost::filesystem;
34 
35 namespace Euclid {
36 namespace Configuration {
37 
38 static Elements::Logging logger = Elements::Logging::getLogger("PhotometryCatalogConfig");
39 
40 static const std::string MISSING_PHOTOMETRY_FLAG {"missing-photometry-flag"};
41 static const std::string ENABLE_UPPER_LIMIT {"enable-upper-limit"};
42 static const std::string UPPER_LIMIT_USE_THRESHOLD_FLAG {"upper-limit-use-threshod-flag"};
43 
45  declareDependency<CatalogConfig>();
46  declareDependency<PhotometricBandMappingConfig>();
47 }
48 
50  return {{"Input catalog options", {
51  {MISSING_PHOTOMETRY_FLAG.c_str(), po::value<double>(),
52  "The value passed in the flux indicating that the photometry is missing, if the flag is not provided 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 the flux and the Upper Limit threshold defined for each filter (must be <0 to trigger upper limit functionality, by default -99)"}
57  }}};
58 }
59 
61 
62  m_upper_limit_enabled = (args.find(ENABLE_UPPER_LIMIT) != args.end()) && args.at(ENABLE_UPPER_LIMIT).as<std::string>() =="YES";
63  logger.info() << "Upper limit functionality is " << (m_upper_limit_enabled ? "ENABLED" : "DISABLED");
64 
65  double upper_limit_threshold_flag =-99.;
66  if ( args.find(UPPER_LIMIT_USE_THRESHOLD_FLAG) != args.end() ) {
67  upper_limit_threshold_flag = args.at(UPPER_LIMIT_USE_THRESHOLD_FLAG).as<double>();
68  }
70  logger.info() << "Upper limit threshold flag is " << upper_limit_threshold_flag;
71  }
72 
73 
74  double missing_photo_flag =-99.;
75  if ( args.find(MISSING_PHOTOMETRY_FLAG) != args.end() ) {
77  missing_photo_flag = args.at(MISSING_PHOTOMETRY_FLAG).as<double>();
78  }
79  logger.info() << "Missing photometry functionality is " << (m_missing_photometry_enabled ? "ENABLED" : "DISABLED");
80 
81  auto filter_name_mapping = getDependency<PhotometricBandMappingConfig>().getPhotometricBandMapping();
82  auto threshold_mapping = getDependency<PhotometricBandMappingConfig>().getUpperLimitThresholdMapping();
83  auto column_info = getDependency<CatalogConfig>().getColumnInfo();
84 
85  // Add the row handler to parse the photometries
88  std::move(filter_name_mapping),
90  missing_photo_flag,
92  threshold_mapping,
93  upper_limit_threshold_flag
94  }
95  };
96  getDependency<CatalogConfig>().addAttributeHandler(std::move(handler_ptr));
97 }
98 
99 
101 
103  throw Elements::Exception() << "isMissingPhotometryEnabled() call to uninitialized PhotometryCatalogConfig";
104  }
105 
107 
108 }
109 
111 
113  throw Elements::Exception() << "isUpperLimitEnabled() call to uninitialized PhotometryCatalogConfig";
114  }
115 
116  return m_upper_limit_enabled;
117 }
118 
119 } // Configuration namespace
120 } // Euclid namespace
121 
122 
123 
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.