25 #include <boost/algorithm/string.hpp>
39 namespace po = boost::program_options;
50 WeightImageConfig::WeightImageConfig(
long manager_id) :
52 m_weight_type(
WeightType::WEIGHT_TYPE_FROM_BACKGROUND),
53 m_absolute_weight(false),
55 m_weight_threshold(0),
56 m_symmetry_usage(true) {
58 declareDependency<DetectionImageConfig>();
62 return { {
"Weight image", {
64 "Path to a fits format image to be used as weight image."},
66 "Is the weight map provided as absolute values or relative to background."},
68 "Weight image type [none|background|rms|variance|weight]."},
70 "Weight map scaling factor."},
72 "Threshold for pixels to be considered bad pixels. In same units as weight map."},
74 "Use object symmetry to replace pixels above the weight threshold for photometry."},
81 switch (weight_type) {
83 case WeightType::WEIGHT_TYPE_FROM_BACKGROUND:
84 case WeightType::WEIGHT_TYPE_RMS:
85 return threshold * threshold;
86 case WeightType::WEIGHT_TYPE_VARIANCE:
88 case WeightType::WEIGHT_TYPE_WEIGHT:
90 return 1.0 / threshold;
108 if (weight_image_filename !=
"") {
113 auto weight_iter = WEIGHT_MAP.find(weight_type_name);
114 if (weight_iter == WEIGHT_MAP.end()) {
123 auto flux_scale = getDependency<DetectionImageConfig>().getOriginalFluxScale();
138 throw Elements::Exception() <<
"Please give an appropriate weight type for image: " << weight_image_filename;
140 throw Elements::Exception() <<
"Please give an appropriate weight type for image: " << weight_image_filename;
142 throw Elements::Exception() <<
"Setting absolute weight but providing *no* weight image does not make sense.";
159 auto image_chunk = image->getChunk(
x,
y, width, height);
179 auto& tile_image = *tile.
getImage();
180 for (
int iy = 0; iy < height; iy++) {
181 for (
int ix = 0; ix < width; ix++) {
184 tile_image.setValue(ix, iy, 1.0 / value);
195 auto& tile_image = *tile.
getImage();
196 for (
int iy = 0; iy < height; iy++) {
197 for (
int ix = 0; ix < width; ix++) {
199 tile_image.setValue(ix, iy, value);
206 auto& tile_image = *tile.
getImage();
207 for (
int iy = 0; iy < height; iy++) {
208 for (
int ix = 0; ix < width; ix++) {
210 tile_image.setValue(ix, iy, value * value);
233 std::make_shared<WeightMapImageSource>(weight_image, weight_type, scaling));
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y