21 #include <boost/algorithm/string.hpp>
23 #include <CCfits/CCfits>
33 using namespace Euclid::Configuration;
34 namespace po = boost::program_options;
36 namespace SourceXtractor {
62 std::make_pair(
"UNMATCHED", AssocModeConfig::AssocFilter::UNMATCHED)
72 for (
auto& part : parts) {
73 column_list.
emplace_back(boost::lexical_cast<int>(part));
87 AssocModeConfig::AssocModeConfig(
long manager_id) :
89 declareDependency<PartitionStepConfig>();
94 return { {
"Assoc config", {
96 "Assoc catalog file"},
99 {
ASSOC_MODE.
c_str(), po::value<std::string>()->default_value(
"NEAREST"),
104 "Assoc catalog filter setting: ALL, MATCHED, UNMATCHED"},
106 "List of assoc catalog columns to copy on match"},
113 if (assoc_filter_table.find(filter) != assoc_filter_table.end()) {
114 auto assoc_filter = assoc_filter_table.at(filter);
116 getDependency<PartitionStepConfig>().addPartitionStepCreator(
118 return std::make_shared<AssocModePartitionStep>(
true);
122 getDependency<PartitionStepConfig>().addPartitionStepCreator(
124 return std::make_shared<AssocModePartitionStep>(
false);
135 if (columns.size() < 2) {
136 throw Elements::Exception() <<
"At least 2 columns must be specified for x,y coordinates in the assoc catalog";
138 if (columns.size() > 3) {
139 throw Elements::Exception() <<
"Maximum 3 columns for x, y and weight must be specified in the assoc catalog";
146 if (assoc_mode_table.find(assoc_mode) != assoc_mode_table.end()) {
159 reader = std::make_shared<Euclid::Table::FitsReader>(
filename);
162 reader = std::make_shared<Euclid::Table::AsciiReader>(
filename);
164 auto table = reader->read();
175 for (
auto& row : table) {
178 ImageCoordinate { boost::get<double>(row[columns.
at(0)]) - 1.0, boost::get<double>(row[columns.
at(1)]) - 1.0 };
180 if (columns.
size() == 3 && columns.
at(2) >= 0) {
181 m_catalog.back().weight = boost::get<double>(row[columns.
at(2)]);
183 for (
auto column : copy_columns) {
184 if (row[column].type() ==
typeid(int)) {
185 m_catalog.back().assoc_columns.emplace_back(boost::get<int>(row[column]));
186 }
else if (row[column].type() ==
typeid(
double)) {
187 m_catalog.back().assoc_columns.emplace_back(boost::get<double>(row[column]));
ELEMENTS_API auto split(Args &&...args) -> decltype(splitPath(std::forward< Args >(args)...))
static ConfigManager & getInstance(long id)
void registerDependency()