31 #include "../../SourceCatalog/PhotometryParsingException.h"
37 namespace SourceCatalog {
42 const bool missing_photometry_enabled,
const double missing_photometry_flag,
const bool upper_limit_enabled,
44 : m_missing_photometry_enabled(missing_photometry_enabled)
45 , m_missing_photometry_flag(missing_photometry_flag)
46 , m_upper_limit_enabled(upper_limit_enabled)
48 , m_n_upper_limit_flag(n_upper_limit_flag)
49 , m_convert_from_mag(convert_from_mag){
54 for (
auto filter_name_pair : filter_name_mapping) {
55 flux_column_index_ptr = column_info_ptr->
find(filter_name_pair.second.first);
56 error_column_index_ptr = column_info_ptr->
find(filter_name_pair.second.second);
58 if (flux_column_index_ptr ==
nullptr) {
59 throw Elements::Exception() <<
"Column info does not have the flux column " << filter_name_pair.second.first;
61 if (error_column_index_ptr ==
nullptr) {
62 throw Elements::Exception() <<
"Column info does not have the flux error column " << filter_name_pair.second.second;
69 for (
auto a_filter_name_map : filter_name_mapping) {
97 double flux = 3.631e9*
std::pow(10, -0.4 * mag);
118 if (convert_from_mag_iter->second) {
120 flux = converted.first;
121 error = converted.second;
124 bool missing_data =
false;
125 bool upper_limit =
false;
139 "Zero error encountered when parsing the Photometry with 'missing data' and 'upper limit' enabled", flux, error);
144 error = flux / n_threshod_iter->second;
149 "Negative or Zero flux encountered when parsing the Photometry in the context of an 'upper limit'", flux, error);
152 error = std::abs(error);
158 "Negative or Zero error encountered when parsing the Photometry with 'missing data' enabled "
159 "and 'upper limit' disabled",
168 "NAN flux encountered when parsing the Photometry with 'missing data' disabled", flux, error);
175 "Zero error encountered when parsing the Photometry with 'missing data' disabled and 'upper limit' enabled", flux,
182 error = flux / n_threshod_iter->second;
186 "Negative or Zero flux encountered when parsing the Photometry in the context of an 'upper limit'", flux, error);
188 error = std::abs(error);
194 "Negative or Zero error encountered when parsing the Photometry with 'missing data' "
195 "and 'upper limit' disabled",
201 photometry_vector.push_back(
FluxErrorPair{flux, error, missing_data, upper_limit});
203 ++convert_from_mag_iter;
208 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)