SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
OutputConfig.cpp
Go to the documentation of this file.
1
23#include <sstream>
24
25#include <boost/algorithm/string.hpp>
26
27#include "ElementsKernel/Exception.h"
28
31
33
34using namespace Euclid::Configuration;
35namespace po = boost::program_options;
36
37namespace SourceXtractor {
38
39static const std::string OUTPUT_FILE {"output-catalog-filename"};
40static const std::string OUTPUT_FILE_FORMAT {"output-catalog-format"};
41static const std::string OUTPUT_PROPERTIES {"output-properties"};
42static const std::string OUTPUT_FLUSH_SIZE {"output-flush-size"};
43static const std::string OUTPUT_SORTED {"output-flush-sorted"};
44
50
52 m_flush_size(100), m_unsorted(false) {
53}
54
56 return { {"Output configuration", {
57 {OUTPUT_FILE.c_str(), po::value<std::string>()->default_value(""),
58 "The file to store the output catalog"},
59 {OUTPUT_FILE_FORMAT.c_str(), po::value<std::string>()->default_value("FITS"),
60 "The format of the output catalog, one of ASCII, FITS or FITS_LDAC (default: FITS)"},
61 {OUTPUT_PROPERTIES.c_str(), po::value<std::string>()->default_value("PixelCentroid"),
62 "The output properties to add in the output catalog"},
63 {OUTPUT_FLUSH_SIZE.c_str(), po::value<int>()->default_value(100),
64 "Write to the catalog after this number of sources have been processed (0 means once at the end)"},
65 {OUTPUT_SORTED.c_str(), po::value<bool>()->default_value(true),
66 "Delay the output of some sources to ensure a deterministic order"}
67 }}};
68}
69
71 auto format_name = boost::to_upper_copy(args.at(OUTPUT_FILE_FORMAT).as<std::string>());
72 if (format_map.count(format_name) == 0) {
73 throw Elements::Exception() << "Unknown output file format: " << format_name;
74 }
75}
76
79
81 std::string name;
82 while (std::getline(properties_str, name, ',')) {
84 }
85
86 auto format_name = boost::to_upper_copy(args.at(OUTPUT_FILE_FORMAT).as<std::string>());
88
89 int flush_size = args.at(OUTPUT_FLUSH_SIZE).as<int>();
90 m_flush_size = (flush_size >= 0) ? flush_size : 0;
91
92 m_unsorted = !args.at(OUTPUT_SORTED).as<bool>();
93}
94
98
102
106
108 return m_flush_size;
109}
110
112 return m_unsorted;
113}
114
115} // SEImplementation namespace
116
117
118
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
void preInitialize(const UserValues &args) override
OutputFileFormat getOutputFileFormat()
OutputConfig(long manager_id)
Constructor.
const std::vector< std::string > getOutputProperties()
void initialize(const UserValues &args) override
std::vector< std::string > m_output_properties
T emplace_back(T... args)
T getline(T... args)
static const std::string OUTPUT_FILE_FORMAT
static const std::string OUTPUT_FLUSH_SIZE
static const std::string OUTPUT_SORTED
static const std::string OUTPUT_FILE
static std::map< std::string, OutputConfig::OutputFileFormat > format_map
static const std::string OUTPUT_PROPERTIES