31#include "../../SourceCatalog/PhotometryParsingException.h"
37namespace SourceCatalog {
42 const bool missing_photometry_enabled,
const double missing_photometry_flag,
const bool upper_limit_enabled,
45 : m_missing_photometry_enabled(missing_photometry_enabled)
46 , m_missing_photometry_flag(missing_photometry_flag)
47 , m_upper_limit_enabled(upper_limit_enabled)
49 , m_n_upper_limit_flag(n_upper_limit_flag)
50 , m_convert_from_mag(convert_from_mag) {
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) {
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";
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
virtual ~PhotometryAttributeFromRow()
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
std::unique_ptr< std::size_t > find(const std::string &name) const
Returns the index of a column, given the name of it, or nullptr if there is no column with this name.
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.
bool isEqual(const RawType &left, const RawType &right)
static std::string getContextDescription(bool missing_photometry_enabled, bool upper_limit_enabled)