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;