Alexandria  2.14.1
Please provide a description of the project.
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 
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 the functionality is disabled"},
52  {ENABLE_UPPER_LIMIT.c_str(), po::value<std::string>()->default_value("NO"),
53  "Define if the catalog contains flux upper limit (YES/NO by default NO)"}
54  }}};
55 }
56 
58 
59  m_upper_limit_enabled = (args.find(ENABLE_UPPER_LIMIT) != args.end()) && args.at(ENABLE_UPPER_LIMIT).as<std::string>() =="YES";
60  logger.info() << "Upper limit functionality is " << (m_upper_limit_enabled ? "ENABLED" : "DISABLED");
61 
62  double missing_photo_flag =-99.;
63  if ( args.find(MISSING_PHOTOMETRY_FLAG) != args.end() ) {
65  missing_photo_flag = args.at(MISSING_PHOTOMETRY_FLAG).as<double>();
66  }
67  logger.info() << "Missing photometry functionality is " << (m_missing_photometry_enabled ? "ENABLED" : "DISABLED");
68 
69  auto filter_name_mapping = getDependency<PhotometricBandMappingConfig>().getPhotometricBandMapping();
70  auto column_info = getDependency<CatalogConfig>().getColumnInfo();
71 
72  // Add the row handler to parse the photometries
75  std::move(filter_name_mapping),
77  missing_photo_flag,
79  };
80  getDependency<CatalogConfig>().addAttributeHandler(std::move(handler_ptr));
81 }
82 
83 
85 
87  throw Elements::Exception() << "isMissingPhotometryEnabled() call to uninitialized PhotometryCatalogConfig";
88  }
89 
91 
92 }
93 
95 
97  throw Elements::Exception() << "isUpperLimitEnabled() call to uninitialized PhotometryCatalogConfig";
98  }
99 
100  return m_upper_limit_enabled;
101 }
102 
103 } // Configuration namespace
104 } // Euclid namespace
105 
106 
107 
Euclid::Configuration::PhotometryCatalogConfig::m_upper_limit_enabled
bool m_upper_limit_enabled
Definition: PhotometryCatalogConfig.h:85
Euclid::Configuration::PhotometryCatalogConfig::getProgramOptions
std::map< std::string, OptionDescriptionList > getProgramOptions() override
Returns the program options defined by the PhotometryCatalogConfig.
Definition: PhotometryCatalogConfig.cpp:48
std::string
STL class.
std::shared_ptr
STL class.
std::move
T move(T... args)
Euclid::Configuration::ENABLE_UPPER_LIMIT
static const std::string ENABLE_UPPER_LIMIT
Definition: PhotometryCatalogConfig.cpp:41
Elements::Logging
std::map::find
T find(T... args)
Euclid::SourceCatalog::PhotometryAttributeFromRow
Implementation of the AttributeFromRow for a photometry attribute. This class implements the createAt...
Definition: PhotometryAttributeFromRow.h:50
Euclid::Configuration::logger
static Elements::Logging logger
Definition: CatalogConfig.cpp:39
PhotometryAttributeFromRow.h
Euclid::Configuration::PhotometryCatalogConfig::initialize
void initialize(const UserValues &args) override
Adds the PhotometryAttributeFromRow handler to the CatalogConfig.
Definition: PhotometryCatalogConfig.cpp:57
Euclid::Configuration::MISSING_PHOTOMETRY_FLAG
static const std::string MISSING_PHOTOMETRY_FLAG
Definition: PhotometryCatalogConfig.cpp:40
std::map::at
T at(T... args)
PhotometryCatalogConfig.h
std::string::c_str
T c_str(T... args)
Elements::Exception
std::map
STL class.
Euclid::Configuration::PhotometryCatalogConfig::m_missing_photometry_enabled
bool m_missing_photometry_enabled
Definition: PhotometryCatalogConfig.h:84
Euclid::Configuration::PhotometryCatalogConfig::isMissingPhotometryEnabled
bool isMissingPhotometryEnabled()
Definition: PhotometryCatalogConfig.cpp:84
Elements::Logging::info
void info(const std::string &logMessage)
Elements::Logging::getLogger
static Logging getLogger(const std::string &name="")
Euclid::Configuration::PhotometryCatalogConfig::isUpperLimitEnabled
bool isUpperLimitEnabled()
Definition: PhotometryCatalogConfig.cpp:94
Euclid::Configuration::PhotometryCatalogConfig::PhotometryCatalogConfig
PhotometryCatalogConfig(long manager_id)
Constructs a new PhotometryCatalogConfig object.
Definition: PhotometryCatalogConfig.cpp:43
Euclid::Configuration::Configuration
Superclass of all configuration classes.
Definition: Configuration.h:45
Logging.h
std::map::end
T end(T... args)
Euclid::Configuration::Configuration::getCurrentState
State & getCurrentState()
Returns the current state of the configuration.
Definition: Configuration.cpp:44
Euclid
Definition: InstOrRefHolder.h:29
Euclid::Configuration::Configuration::State::INITIALIZED
@ INITIALIZED
The initialize() method has been called.
PhotometricBandMappingConfig.h
CatalogConfig.h