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."},
82 if (weight_image_filename !=
"") {
87 if (weight_type_name ==
"NONE") {
89 }
else if (weight_type_name ==
"BACKGROUND") {
91 }
else if (weight_type_name ==
"RMS") {
93 }
else if (weight_type_name ==
"VARIANCE") {
95 }
else if (weight_type_name ==
"WEIGHT") {
106 auto flux_scale = getDependency<DetectionImageConfig>().getOriginalFluxScale();
136 throw Elements::Exception() <<
"Please give an appropriate weight type for image: " << weight_image_filename;
138 throw Elements::Exception() <<
"Please give an appropriate weight type for image: " << weight_image_filename;
140 throw Elements::Exception() <<
"Setting absolute weight but providing *no* weight image does not make sense.";
158 for (
int iy =
y; iy <
y+height; iy++) {
159 for (
int ix =
x; ix <
x+width; ix++) {
160 auto value = image->getValue(ix, iy) *
m_scaling;
161 tile.
getImage()->setValue(ix -
x, iy -
y, value * value);
166 for (
int iy =
y; iy <
y+height; iy++) {
167 for (
int ix =
x; ix <
x+width; ix++) {
168 auto value = image->getValue(ix, iy) *
m_scaling;
169 tile.
getImage()->setValue(ix -
x, iy -
y, value);
174 for (
int iy =
y; iy <
y+height; iy++) {
175 for (
int ix =
x; ix <
x+width; ix++) {
176 auto value = image->getValue(ix, iy) *
m_scaling;
178 tile.
getImage()->setValue(ix -
x, iy -
y, 1.0 / value);