27#include "ElementsKernel/Real.h"
32#include "ElementsKernel/Exception.h"
33#include "ElementsKernel/Real.h"
42 const bool missing_photometry_enabled,
const double missing_photometry_flag,
const bool upper_limit_enabled,
55 for (
auto filter_name_pair : filter_name_mapping) {
56 flux_column_index_ptr = column_info_ptr->find(filter_name_pair.second.first);
57 error_column_index_ptr = column_info_ptr->find(filter_name_pair.second.second);
59 if (flux_column_index_ptr ==
nullptr) {
60 throw Elements::Exception() <<
"Column info does not have the flux column " << filter_name_pair.second.first;
62 if (error_column_index_ptr ==
nullptr) {
64 << filter_name_pair.second.second;
71 for (
auto a_filter_name_map : filter_name_mapping) {
77 m_convert_from_mag = std::vector<std::pair<std::string, bool>>();
78 for (auto m_n_pair : m_n_map) {
79 m_convert_from_mag.push_back(std::make_pair(m_n_pair.first, false));
84PhotometryAttributeFromRow::~PhotometryAttributeFromRow() =
default;
95 double flux = 3.631e9 *
std::pow(10, -0.4 * mag);
105 if (missing_photometry_enabled && upper_limit_enabled) {
106 setup_desc +=
"'missing data' and 'upper limit' enabled";
107 }
else if (missing_photometry_enabled) {
108 setup_desc +=
"'missing data' and 'upper limit' disabled";
109 }
else if (upper_limit_enabled) {
110 setup_desc +=
"'missing data' disabled and 'upper limit' enabled";
112 setup_desc +=
"'missing data' and 'upper limit' disabled";
122 auto n_threshod_iter =
m_n_map.begin();
131 if (convert_from_mag_iter->second) {
133 flux = converted.first;
134 error = converted.second;
137 bool upper_limit =
false;
147 context_desc.c_str(), flux, error);
152 context_desc.c_str(), flux, error);
157 error = flux / n_threshod_iter->second;
162 "Negative or Zero flux encountered when parsing the Photometry ", context_desc.c_str(), flux, error);
165 error = std::abs(error);
171 "Negative or Zero error encountered when parsing the Photometry ", context_desc.c_str(), flux, error);
175 photometry_vector.push_back(
FluxErrorPair{flux, error, missing_data, upper_limit});
177 ++convert_from_mag_iter;
182 return photometry_ptr;
std::vector< std::pair< size_t, size_t > > m_table_index_vector
std::unique_ptr< Attribute > createAttribute(const Euclid::Table::Row &row) override
Create a photometricAttribute from a Table row.
std::pair< double, double > convertFromMag(const double mag, const double mag_err) const
double m_n_upper_limit_flag
double m_missing_photometry_flag
std::vector< std::pair< std::string, bool > > m_convert_from_mag
std::shared_ptr< std::vector< std::string > > m_filter_name_vector_ptr
bool m_missing_photometry_enabled
bool m_upper_limit_enabled
PhotometryAttributeFromRow(std::shared_ptr< Euclid::Table::ColumnInfo > column_info_ptr, const std::vector< std::pair< std::string, std::pair< std::string, std::string > > > &filter_name_mapping, const bool missing_photometry_enabled, const double missing_photometry_flag, const bool upper_limit_enabled, const std::vector< std::pair< std::string, float > > &n_map, const double n_upper_limit_flag, const std::vector< std::pair< std::string, bool > > &convert_from_mag={})
Create a PhotometryAttributeFromRow object.
std::vector< std::pair< std::string, float > > m_n_map
Represents one row of a Table.
boost::variant< bool, int32_t, int64_t, float, double, std::string, std::vector< bool >, std::vector< int32_t >, std::vector< int64_t >, std::vector< float >, std::vector< double >, NdArray::NdArray< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > cell_type
The possible cell types.
ELEMENTS_API bool almostEqual2sComplement(ELEMENTS_UNUSED const FloatType &a, ELEMENTS_UNUSED const FloatType &b, ELEMENTS_UNUSED const std::size_t &max_ulps=0)
static std::string getContextDescription(bool missing_photometry_enabled, bool upper_limit_enabled)