26#include <boost/algorithm/string.hpp>
27#include <boost/python/extract.hpp>
28#include <boost/tokenizer.hpp>
30#include <ElementsKernel/Logging.h>
32#include <Pyston/GIL.h>
72 if (!fs::exists(image.file)) {
73 throw Elements::Exception() <<
"File " << image.file <<
" does not exist";
75 if (image.weight_file !=
"" && !fs::exists(image.weight_file)) {
76 throw Elements::Exception() <<
"File " << image.weight_file <<
" does not exist";
78 if (image.psf_file !=
"" && boost::to_upper_copy(fs::path(image.psf_file).filename().string())!=
"NOPSF" && !fs::exists(image.psf_file)) {
79 throw Elements::Exception() <<
"File " << image.psf_file <<
" does not exist";
86 if (flux_scale != 1.) {
94 auto weight_type_name = boost::to_upper_copy(type_string);
95 if (weight_type_map.
find(weight_type_name) == weight_type_map.
end()) {
96 throw Elements::Exception() <<
"Unknown weight map type for measurement weight image " << file_name <<
": "<< type_string;
99 return weight_type_map[weight_type_name];
103 auto weight_type = getWeightType(py_image.weight_type, py_image.weight_file);
106 if (py_image.weight_file ==
"") {
109 throw Elements::Exception() <<
"Weight type '" << py_image.weight_type <<
"' is meaningless without a weight image";
117 throw Elements::Exception() <<
"Please give an appropriate weight type for image: " << py_image.weight_file;
120 auto weight_image_source =
123 if (py_image.is_data_cube) {
124 weight_image_source->setLayer(py_image.weight_layer);
127 logger.debug() <<
"w: " << weight_map->getWidth() <<
" h: " << weight_map->getHeight()
128 <<
" t: " << py_image.weight_type <<
" s: " << py_image.weight_scaling;
135 if (!py_image.has_weight_threshold) {
139 auto weight_type_name = boost::to_upper_copy(py_image.weight_type);
140 switch (weight_type_map[weight_type_name]) {
144 threshold = threshold * threshold;
150 threshold = 1.0 / threshold;
164 if (images.size() > 0) {
165 for (
auto& p : images) {
167 validateImagePaths(py_image);
169 logger.debug() <<
"Loading measurement image: " << py_image.
file <<
" HDU: " << py_image.
image_hdu;
173 logger.debug() <<
"\tGain: " << py_image.
gain;
188 auto fits_image_source =
208 auto weight_map = createWeightMap(py_image);
210 if (weight_map !=
nullptr && flux_scale != 1. && py_image.
weight_absolute) {
231 if (detection_image.getExtensionsNb() < 1) {
235 logger.debug() <<
"No measurement image provided, using the detection image for measurements";
239 detection_image.getDetectionImagePath(),
242 detection_image.getDetectionImage(),
243 detection_image.getCoordinateSystem(),
244 weight_image.getWeightImage(),
245 weight_image.getWeightType(),
247 weight_image.isWeightAbsolute(),
248 weight_image.getWeightThreshold(),
249 (
SeFloat) detection_image.getGain(),
250 (
SeFloat) detection_image.getSaturation(),
static Logging getLogger(const std::string &name="")
Configuration(long manager_id)
std::map< std::string, boost::program_options::variable_value > UserValues
static Elements::Logging logger