31 #include "../../SourceCatalog/PhotometryParsingException.h" 40 namespace SourceCatalog {
42 PhotometryAttributeFromRow::PhotometryAttributeFromRow(
43 std::shared_ptr<Euclid::Table::ColumnInfo> column_info_ptr,
44 const vector<pair<
string, std::pair<string, string>>>& filter_name_mapping,
45 const bool missing_photometry_enabled,
46 const double missing_photometry_flag,
47 const bool upper_limit_enabled,
48 const std::vector<std::pair<std::string, float>> n_map,
49 const double n_upper_limit_flag) :
50 m_missing_photometry_enabled(missing_photometry_enabled),
51 m_missing_photometry_flag(missing_photometry_flag),
52 m_upper_limit_enabled(upper_limit_enabled),
54 m_n_upper_limit_flag(n_upper_limit_flag) {
56 unique_ptr<size_t> flux_column_index_ptr;
57 unique_ptr<size_t> error_column_index_ptr;
59 for (
auto filter_name_pair : filter_name_mapping) {
60 flux_column_index_ptr = column_info_ptr->find(filter_name_pair.second.first);
61 error_column_index_ptr = column_info_ptr->find(filter_name_pair.second.second);
63 if (flux_column_index_ptr ==
nullptr) {
65 << filter_name_pair.second.first;
67 if (error_column_index_ptr ==
nullptr) {
69 << filter_name_pair.second.second;
76 for(
auto a_filter_name_map: filter_name_mapping) {
89 vector<FluxErrorPair> photometry_vector {};
91 auto n_threshod_iter =
m_n_map.begin();
99 bool missing_data =
false;
100 bool upper_limit =
false;
101 if (std::isinf(flux)){
103 "Infinite flux encountered when parsing the Photometry",
117 "Zero error encountered when parsing the Photometry with 'missing data' and 'upper limit' enabled",
124 error = flux / n_threshod_iter->second;
129 "Negative or Zero flux encountered when parsing the Photometry in the context of an 'upper limit'",
134 error=std::abs(error);
140 "Negative or Zero error encountered when parsing the Photometry with 'missing data' enabled and 'upper limit' disabled",
149 if (std::isnan(flux)){
151 "NAN flux encountered when parsing the Photometry with 'missing data' disabled",
160 "Zero error encountered when parsing the Photometry with 'missing data' disabled and 'upper limit' enabled",
168 error = flux / n_threshod_iter->second;
172 "Negative or Zero flux encountered when parsing the Photometry in the context of an 'upper limit'",
176 error=std::abs(error);
184 "Negative or Zero error encountered when parsing the Photometry with 'missing data' and 'upper limit' disabled",
194 photometry_vector.push_back(
FluxErrorPair{flux, error, missing_data, upper_limit});
200 return photometry_ptr;
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< bool >, NdArray::NdArray< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > cell_type
The possible cell types.
std::unique_ptr< Attribute > createAttribute(const Euclid::Table::Row &row) override
Create a photometricAttribute from a Table row.
bool m_missing_photometry_enabled
double m_n_upper_limit_flag
std::vector< std::pair< size_t, size_t > > m_table_index_vector
Represents one row of a Table.
double m_missing_photometry_flag
std::shared_ptr< std::vector< std::string > > m_filter_name_vector_ptr
virtual ~PhotometryAttributeFromRow()
bool isEqual(const RawType &left, const RawType &right)
std::vector< std::pair< std::string, float > > m_n_map
bool m_upper_limit_enabled