Alexandria  2.18
Please provide a description of the project.
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 
63  m_upper_limit_enabled = (args.find(ENABLE_UPPER_LIMIT) != args.end()) && args.at(ENABLE_UPPER_LIMIT).as<std::string>() == "YES";
64  logger.info() << "Upper limit functionality is " << (m_upper_limit_enabled ? "ENABLED" : "DISABLED");
65 
66  double upper_limit_threshold_flag = -99.;
67  if (args.find(UPPER_LIMIT_USE_THRESHOLD_FLAG) != args.end()) {
68  upper_limit_threshold_flag = args.at(UPPER_LIMIT_USE_THRESHOLD_FLAG).as<double>();
69  }
71  logger.info() << "Upper limit threshold flag is " << upper_limit_threshold_flag;
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
87  column_info, std::move(filter_name_mapping), m_missing_photometry_enabled, missing_photo_flag, m_upper_limit_enabled,
88  threshold_mapping, upper_limit_threshold_flag}};
89  getDependency<CatalogConfig>().addAttributeHandler(std::move(handler_ptr));
90 }
91 
93 
95  throw Elements::Exception() << "isMissingPhotometryEnabled() call to uninitialized PhotometryCatalogConfig";
96  }
97 
99 }
100 
102 
104  throw Elements::Exception() << "isUpperLimitEnabled() call to uninitialized PhotometryCatalogConfig";
105  }
106 
107  return m_upper_limit_enabled;
108 }
109 
110 } // namespace Configuration
111 } // namespace Euclid
T at(T... args)
T c_str(T... args)
static Logging getLogger(const std::string &name="")
void info(const std::string &logMessage)
Superclass of all configuration classes.
Definition: Configuration.h:45
State & getCurrentState()
Returns the current state of the configuration.
@ INITIALIZED
The initialize() method has been called.
void initialize(const UserValues &args) override
Adds the PhotometryAttributeFromRow handler to the CatalogConfig.
PhotometryCatalogConfig(long manager_id)
Constructs a new PhotometryCatalogConfig object.
std::map< std::string, OptionDescriptionList > getProgramOptions() override
Returns the program options defined by the PhotometryCatalogConfig.
Implementation of the AttributeFromRow for a photometry attribute. This class implements the createAt...
T end(T... args)
T find(T... args)
T move(T... args)
static const std::string MISSING_PHOTOMETRY_FLAG
static Elements::Logging logger
static const std::string UPPER_LIMIT_USE_THRESHOLD_FLAG
static const std::string ENABLE_UPPER_LIMIT