21 #include <boost/algorithm/string.hpp>
23 #include <CCfits/CCfits>
34 namespace po = boost::program_options;
62 std::make_pair(
"UNMATCHED", AssocModeConfig::AssocFilter::UNMATCHED)
72 for (
auto& part : parts) {
73 column_list.
emplace_back(boost::lexical_cast<int>(part));
88 declareDependency<PartitionStepConfig>();
93 return { {
"Assoc config", {
95 "Assoc catalog file"},
98 {
ASSOC_MODE.
c_str(), po::value<std::string>()->default_value(
"NEAREST"),
103 "Assoc catalog filter setting: ALL, MATCHED, UNMATCHED"},
105 "List of assoc catalog columns to copy on match"},
112 if (assoc_filter_table.find(filter) != assoc_filter_table.end()) {
113 auto assoc_filter = assoc_filter_table.at(filter);
115 getDependency<PartitionStepConfig>().addPartitionStepCreator(
117 return std::make_shared<AssocModePartitionStep>(
true);
121 getDependency<PartitionStepConfig>().addPartitionStepCreator(
123 return std::make_shared<AssocModePartitionStep>(
false);
134 if (columns.size() < 2) {
135 throw Elements::Exception() <<
"At least 2 columns must be specified for x,y coordinates in the assoc catalog";
137 if (columns.size() > 3) {
138 throw Elements::Exception() <<
"Maximum 3 columns for x, y and weight must be specified in the assoc catalog";
145 if (assoc_mode_table.find(assoc_mode) != assoc_mode_table.end()) {
158 reader = std::make_shared<Euclid::Table::FitsReader>(
filename);
161 reader = std::make_shared<Euclid::Table::AsciiReader>(
filename);
163 auto table = reader->read();
174 for (
auto& row : table) {
177 ImageCoordinate { boost::get<double>(row[columns.
at(0)]) - 1.0, boost::get<double>(row[columns.
at(1)]) - 1.0 };
179 if (columns.
size() == 3 && columns.
at(2) >= 0) {
180 m_catalog.back().weight = boost::get<double>(row[columns.
at(2)]);
182 for (
auto column : copy_columns) {
183 if (row[column].type() ==
typeid(
int)) {
184 m_catalog.back().assoc_columns.emplace_back(boost::get<int>(row[column]));
185 }
else if (row[column].type() ==
typeid(
double)) {
186 m_catalog.back().assoc_columns.emplace_back(boost::get<double>(row[column]));
void registerDependency()
static ConfigManager & getInstance(long id)
T emplace_back(T... args)
ELEMENTS_API auto split(Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...))