SourceXtractorPlusPlus  0.13
Please provide a description of the project.
OutputConfig.cpp
Go to the documentation of this file.
1 
23 #include <sstream>
24 
25 #include <boost/algorithm/string.hpp>
26 
28 
31 
33 
34 using namespace Euclid::Configuration;
35 namespace po = boost::program_options;
36 
37 namespace SourceXtractor {
38 
39 static const std::string OUTPUT_FILE {"output-catalog-filename"};
40 static const std::string OUTPUT_FILE_FORMAT {"output-catalog-format"};
41 static const std::string OUTPUT_PROPERTIES {"output-properties"};
42 static const std::string OUTPUT_FLUSH_SIZE {"output-flush-size"};
43 
45  {"ASCII", OutputConfig::OutputFileFormat::ASCII},
46  {"FITS", OutputConfig::OutputFileFormat::FITS},
47  {"FITS_LDAC", OutputConfig::OutputFileFormat::FITS_LDAC}
48 };
49 
50 OutputConfig::OutputConfig(long manager_id) : Configuration(manager_id), m_format(OutputFileFormat::ASCII),
51  m_flush_size(100) {
52 }
53 
55  return { {"Output configuration", {
56  {OUTPUT_FILE.c_str(), po::value<std::string>()->default_value(""),
57  "The file to store the output catalog"},
58  {OUTPUT_FILE_FORMAT.c_str(), po::value<std::string>()->default_value("FITS"),
59  "The format of the output catalog, one of ASCII or FITS (default: FITS)"},
60  {OUTPUT_PROPERTIES.c_str(), po::value<std::string>()->default_value("PixelCentroid"),
61  "The output properties to add in the output catalog"},
62  {OUTPUT_FLUSH_SIZE.c_str(), po::value<int>()->default_value(100),
63  "Write to the catalog after this number of sources have been processed (0 means once at the end)"}
64  }}};
65 }
66 
68  auto format_name = boost::to_upper_copy(args.at(OUTPUT_FILE_FORMAT).as<std::string>());
69  if (format_map.count(format_name) == 0) {
70  throw Elements::Exception() << "Unknown output file format: " << format_name;
71  }
72 }
73 
75  m_out_file = args.at(OUTPUT_FILE).as<std::string>();
76 
77  std::stringstream properties_str {args.at(OUTPUT_PROPERTIES).as<std::string>()};
78  std::string name;
79  while (std::getline(properties_str, name, ',')) {
81  }
82 
83  auto format_name = boost::to_upper_copy(args.at(OUTPUT_FILE_FORMAT).as<std::string>());
84  m_format = format_map.at(format_name);
85 
86  int flush_size = args.at(OUTPUT_FLUSH_SIZE).as<int>();
87  m_flush_size = (flush_size >= 0) ? flush_size : 0;
88 }
89 
91  return m_out_file;
92 }
93 
95  return m_format;
96 }
97 
99  return m_output_properties;
100 }
101 
103  return m_flush_size;
104 }
105 
106 } // SEImplementation namespace
107 
108 
109 
PixelBoundaries.h
std::string
STL class.
SourceXtractor::OUTPUT_FLUSH_SIZE
static const std::string OUTPUT_FLUSH_SIZE
Definition: OutputConfig.cpp:42
SourceXtractor::OutputConfig::OutputFileFormat
OutputFileFormat
Definition: OutputConfig.h:40
std::vector< std::string >
SourceXtractor::OutputConfig::getOutputFile
std::string getOutputFile()
Definition: OutputConfig.cpp:90
SourceXtractor::OutputConfig::getFlushSize
size_t getFlushSize() const
Definition: OutputConfig.cpp:102
std::stringstream
STL class.
SourceXtractor::OutputConfig::m_output_properties
std::vector< std::string > m_output_properties
Definition: OutputConfig.h:68
Euclid::Configuration
SourceXtractor::OutputConfig::m_out_file
std::string m_out_file
Definition: OutputConfig.h:66
SourceXtractor::OutputConfig::getOutputFileFormat
OutputFileFormat getOutputFileFormat()
Definition: OutputConfig.cpp:94
SourceXtractor::OutputConfig::m_flush_size
size_t m_flush_size
Definition: OutputConfig.h:69
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::OutputConfig::initialize
void initialize(const UserValues &args) override
Definition: OutputConfig.cpp:74
std::map::at
T at(T... args)
SourceXtractor::OUTPUT_PROPERTIES
static const std::string OUTPUT_PROPERTIES
Definition: OutputConfig.cpp:41
Exception.h
std::string::c_str
T c_str(T... args)
SourceXtractor::format_map
static std::map< std::string, OutputConfig::OutputFileFormat > format_map
Definition: OutputConfig.cpp:44
Elements::Exception
std::map
STL class.
std::vector::emplace_back
T emplace_back(T... args)
SourceXtractor::OUTPUT_FILE
static const std::string OUTPUT_FILE
Definition: OutputConfig.cpp:39
OutputConfig.h
SourceXtractor::OutputConfig::preInitialize
void preInitialize(const UserValues &args) override
Definition: OutputConfig.cpp:67
std::getline
T getline(T... args)
SourceXtractor::OutputConfig::getProgramOptions
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
Definition: OutputConfig.cpp:54
Euclid::Configuration::Configuration
SourceXtractor::OutputConfig::getOutputProperties
const std::vector< std::string > getOutputProperties()
Definition: OutputConfig.cpp:98
SourceXtractor::OutputConfig::m_format
OutputFileFormat m_format
Definition: OutputConfig.h:67
PixelCentroid.h
SourceXtractor::OUTPUT_FILE_FORMAT
static const std::string OUTPUT_FILE_FORMAT
Definition: OutputConfig.cpp:40