SourceXtractorPlusPlus  0.10
Please provide a description of the project.
DetectionImageConfig.cpp
Go to the documentation of this file.
1 
23 
27 
29 
31 
32 using namespace Euclid::Configuration;
33 namespace po = boost::program_options;
34 
35 namespace SourceXtractor {
36 
37 static const std::string DETECTION_IMAGE { "detection-image" };
38 static const std::string DETECTION_IMAGE_GAIN { "detection-image-gain" };
39 static const std::string DETECTION_IMAGE_FLUX_SCALE {"detection-image-flux-scale"};
40 static const std::string DETECTION_IMAGE_SATURATION { "detection-image-saturation" };
41 static const std::string DETECTION_IMAGE_INTERPOLATION { "detection-image-interpolation" };
42 static const std::string DETECTION_IMAGE_INTERPOLATION_GAP { "detection-image-interpolation-gap" };
43 
44 DetectionImageConfig::DetectionImageConfig(long manager_id) : Configuration(manager_id),
45  m_gain(0), m_saturation(0), m_flux_scale(1.0), m_interpolation_gap(0) {
46 }
47 
49  return { {"Detection image", {
50  {DETECTION_IMAGE.c_str(), po::value<std::string>(),
51  "Path to a fits format image to be used as detection image."},
52  {DETECTION_IMAGE_GAIN.c_str(), po::value<double>(),
53  "Detection image gain in e-/ADU (0 = infinite gain)"},
54  {DETECTION_IMAGE_FLUX_SCALE.c_str(), po::value<double>(),
55  "Detection image flux scale"},
56  {DETECTION_IMAGE_SATURATION.c_str(), po::value<double>(),
57  "Detection image saturation level (0 = no saturation)"},
58  {DETECTION_IMAGE_INTERPOLATION.c_str(), po::value<bool>()->default_value(true),
59  "Interpolate bad pixels in detection image"},
60  {DETECTION_IMAGE_INTERPOLATION_GAP.c_str(), po::value<int>()->default_value(5),
61  "Maximum number if pixels to interpolate over"}
62  }}};
63 }
64 
66  // Normally we would define this one as required, but then --list-output-properties would be
67  // unusable unless we also specify --detection-image, which is not very intuitive.
68  // For this reason, we check for its existence here
69  if (args.find(DETECTION_IMAGE) == args.end()) {
70  throw Elements::Exception() << "'--" << DETECTION_IMAGE << "' is required but missing";
71  }
72 
74  auto fits_image_source = std::make_shared<FitsImageSource<DetectionImage::PixelType>>(m_detection_image_path);
76  m_coordinate_system = std::make_shared<WCS>(args.find(DETECTION_IMAGE)->second.as<std::string>(), fits_image_source->getHDU());
77 
78  double detection_image_gain = 0, detection_image_saturate = 0;
79  fits_image_source->readFitsKeyword("GAIN", detection_image_gain);
80  fits_image_source->readFitsKeyword("SATURATE", detection_image_saturate);
81 
82  if (args.find(DETECTION_IMAGE_FLUX_SCALE) != args.end()) {
83  m_flux_scale = args.find(DETECTION_IMAGE_FLUX_SCALE)->second.as<double>();
84  }
85  else {
86  fits_image_source->readFitsKeyword("FLXSCALE", m_flux_scale);
87  }
88 
89  if (args.find(DETECTION_IMAGE_GAIN) != args.end()) {
90  m_gain = args.find(DETECTION_IMAGE_GAIN)->second.as<double>();
91  }
92  else {
93  m_gain = detection_image_gain;
94  }
95 
96  if (args.find(DETECTION_IMAGE_SATURATION) != args.end()) {
97  m_saturation = args.find(DETECTION_IMAGE_SATURATION)->second.as<double>();
98  }
99  else {
100  m_saturation = detection_image_saturate;
101  }
102 
103  m_interpolation_gap = args.find(DETECTION_IMAGE_INTERPOLATION)->second.as<bool>() ?
104  std::max(0, args.find(DETECTION_IMAGE_INTERPOLATION_GAP)->second.as<int>()) : 0;
105 
106  // Adapt image and parameters to take flux_scale into consideration
107  if (m_flux_scale != 1.0) {
109  m_gain /= m_flux_scale;
111  }
112 }
113 
115  return m_detection_image_path;
116 }
117 
120  throw Elements::Exception() << "getDetectionImage() call on not initialized DetectionImageConfig";
121  }
122  return m_detection_image;
123 }
124 
127  throw Elements::Exception() << "getCoordinateSystem() call on not initialized DetectionImageConfig";
128  }
129  return m_coordinate_system;
130 }
131 
132 } // SourceXtractor namespace
133 
134 
135 
static const std::string DETECTION_IMAGE_INTERPOLATION
STL class.
static const std::string DETECTION_IMAGE_FLUX_SCALE
std::shared_ptr< CoordinateSystem > m_coordinate_system
static const std::string DETECTION_IMAGE_GAIN
T end(T... args)
static const std::string DETECTION_IMAGE_SATURATION
STL class.
static const std::string DETECTION_IMAGE_INTERPOLATION_GAP
STL class.
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
void initialize(const UserValues &args) override
T max(T... args)
T find(T... args)
std::shared_ptr< DetectionImage > getDetectionImage() const
T c_str(T... args)
static std::shared_ptr< BufferedImage< T > > create(std::shared_ptr< const ImageSource< T >> source, std::shared_ptr< TileManager > tile_manager=TileManager::getInstance())
std::shared_ptr< CoordinateSystem > getCoordinateSystem() const
static const std::string DETECTION_IMAGE
std::shared_ptr< DetectionImage > m_detection_image
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T >> image_a, std::shared_ptr< const Image< T >> image_b)