SourceXtractorPlusPlus  0.8
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestImage.cpp
Go to the documentation of this file.
1 
17 /*
18  * TestImage.cpp
19  *
20  * Created on: Jul 12, 2017
21  * Author: mschefer
22  */
23 
25 
26 
27 #include <iostream>
28 #include <fstream>
29 #include <tuple>
30 #include <vector>
31 #include <valarray>
32 #include <numeric>
33 
34 #include <cstdlib>
35 #include <ctime>
36 
37 #include <boost/any.hpp>
38 #include <boost/random.hpp>
39 
40 #include <CCfits/CCfits>
42 
49 
51 
52 #include "ModelFitting/utils.h"
64 
65 
66 namespace po = boost::program_options;
67 namespace fs = boost::filesystem;
68 
69 using namespace SourceXtractor;
70 using namespace ModelFitting;
71 
72 const double pixel_scale = 1.0;
73 
74 const double gal_exp_min_i0 = 100000;
75 const double gal_exp_max_i0 = 100001;
76 const double gal_dev_min_i0 = 100000;
77 const double gal_dev_max_i0 = 100001;
78 
80  double x, y;
81  double exp_flux, exp_rad, exp_aspect, exp_rot;
82  double dev_flux, dev_rad, dev_aspect, dev_rot;
83  double point_flux;
84 };
85 
86 //
87 class DummyWCS : public CoordinateSystem {
88 public:
89  DummyWCS(int image_width, int image_height, double rotation, double scale, double shift_x, double shift_y)
90  : m_image_width(image_width), m_image_height(image_height),
91  m_rotation(rotation), m_scale(1.0/scale), m_shift_x(shift_x), m_shift_y(shift_y) {}
92  virtual ~DummyWCS() {}
93 
94  WorldCoordinate imageToWorld(ImageCoordinate image_coordinate) const override {
95  return WorldCoordinate(image_coordinate.m_x, image_coordinate.m_y);
96  }
97 
98  ImageCoordinate worldToImage(WorldCoordinate world_coordinate) const override {
99  return ImageCoordinate(world_coordinate.m_alpha, world_coordinate.m_delta);
100  }
101 
103  auto c = cos(m_rotation);
104  auto s = sin(m_rotation);
105 
106  return {
107  {"CTYPE1", "'RA---TAN'"},
108  {"CTYPE2", "'DEC--TAN'"},
109  {"CUNIT1", "'deg'"},
110  {"CUNIT2", "'deg'"},
111  {"RADSYS", "'ICRS'"},
112  {"WCSAXES", "2"},
113  {"LATPOLE", std::to_string(10.0)},
114  {"LONPOLE", std::to_string(180.0)},
115  {"CDELT1", std::to_string(1.0)},
116  {"CDELT2", std::to_string(1.0)},
117  {"CRVAL1", std::to_string(10.0)},
118  {"CRVAL2", std::to_string(10.0)},
119  {"CRPIX1", std::to_string(m_image_width / 2.0 + 1.5 + m_shift_x)},
120  {"CRPIX2", std::to_string(m_image_height / 2.0 + 1.5 + m_shift_y)},
121 
122  {"PC1_1", std::to_string(0.001 * c * m_scale)},
123  {"PC1_2", std::to_string(0.001 * s * m_scale)},
124  {"PC2_1", std::to_string(0.001 * -s * m_scale)},
125  {"PC2_2", std::to_string(0.001 * c * m_scale)}
126  };
127  }
128 
129 private:
130  int m_image_width, m_image_height;
131  double m_rotation = 0.0;
132  double m_scale = 1.0;
133  double m_shift_x = 0.0;
134  double m_shift_y = 0.0;
135 };
136 
137 template <typename ImageType>
138 class DummyPsf {
139 public:
140  DummyPsf() : m_kernel(VectorImage<SeFloat>::create(1, 1)) {}
141 
142  double getPixelScale() const {
143  return 1.0;
144  }
145 
147  return 1;
148  }
149 
151  return m_kernel;
152  }
153 
154  void convolve(ImageType& /*image*/) const {
155  }
156 
157 private:
159 
160 };
161 
162 class TestImage : public Elements::Program {
163 
164 public:
165 
166  po::options_description defineSpecificProgramOptions() override {
167  po::options_description config_options { "TestImage options" };
168 
169  // Add the specific program options
170  config_options.add_options()
171  ("output", po::value<string>()->required(), "filename to save the created test image")
172  ("output-weight", po::value<string>()->default_value(""), "filename to save the created weight map image")
173  ("size", po::value<double>()->default_value(512.0), "image size")
174  ("bg-level", po::value<double>()->default_value(0.0), "background level")
175  ("bg-sigma", po::value<double>()->default_value(20.0), "standard deviation of background gaussian noise")
176  ("gain", po::value<double>()->default_value(0.0), "gain in e-/adu, 0 for infinite gain")
177  ("saturation", po::value<double>()->default_value(0.0), "image saturation level, 0 for no saturation")
178  ("psf-file", po::value<string>()->default_value(""), "Psf file for convolution")
179  ("psf-fwhm", po::value<double>()->default_value(5.0),
180  "Full width half maximum for generated gaussian psf (used when no psf file is provided)")
181  ("psf-scale", po::value<double>()->default_value(0.2), "Pixel scale for generated gaussian psf")
182  ("disable-psf", po::bool_switch(), "Disable psf convolution")
183  ("random-sources", po::value<int>()->default_value(0), "Nb of random sources to add")
184  ("source-list", po::value<string>()->default_value(""), "Use sources from file")
185  ("source-catalog", po::value<string>()->default_value(""), "Use sources from file (skymaker format)")
186  ("zero-point", po::value<double>()->default_value(0.0), "Zero point for magnitudes in catalog")
187  ("exposure-time", po::value<double>()->default_value(300.), "Exposure time for objects in catalog")
188  ("save-sources", po::value<string>()->default_value(""), "Filename to save final list of sources")
189  ("bad-pixels", po::value<double>()->default_value(0.0), "Probability for a pixel to be a bad pixel")
190  ("bad-columns", po::value<double>()->default_value(0.0), "Probability for a column of pixels to be bad")
191  ("rotation", po::value<double>()->default_value(0.0), "Rotate sources around middle point")
192  ("scale", po::value<double>()->default_value(1.0), "Scale factor")
193  ("shift-x", po::value<double>()->default_value(0.0), "Shift X")
194  ("shift-y", po::value<double>()->default_value(0.0), "Shift Y")
195  ("model-size", po::value<double>()->default_value(0.0), "Model size for the rasterization of sources, defaults to size")
196  ("max-tile-memory", po::value<int>()->default_value(512), "Maximum memory used for image tiles cache in megabytes")
197  ("tile-size", po::value<int>()->default_value(256), "Image tiles size in pixels")
198  ("copy-coordinate-system", po::value<string>()->default_value(""), "Copy the coordinate system from another FITS file")
199  ;
200 
201  return config_options;
202  }
203 
204  void addSource(std::vector<PointModel>& point_models, std::vector<TransformedModel>& extended_models, double size, const TestImageSource& source, std::tuple<double, double, double, double> jacobian) {
205  auto x_param = std::make_shared<ManualParameter>(source.x);
206  auto y_param = std::make_shared<ManualParameter>(source.y);
207 
208  if (source.exp_flux > 0.0) {
209  // Exponential component
210 
211  // Parameters
212  auto xs = std::make_shared<ManualParameter>(1);
213  auto ys = std::make_shared<ManualParameter>(source.exp_aspect);
214  auto rot = std::make_shared<ManualParameter>(source.exp_rot);
215  auto exp_n = std::make_shared<ManualParameter>(1);
216 
217  auto exp_k = std::make_shared<ManualParameter>(1.7 / source.exp_rad);
218  auto exp_i0 = std::make_shared<ManualParameter>(
219  source.exp_flux / (M_PI * 2.0 * 0.346 * source.exp_rad * source.exp_rad * source.exp_aspect));
220 
221  // Model
223  auto exp = make_unique<SersicModelComponent>(make_unique<OldSharp>(), exp_i0, exp_n, exp_k);
224  component_list.clear();
225  component_list.emplace_back(std::move(exp));
226  extended_models.emplace_back(std::move(component_list), xs, ys, rot, size, size, x_param, y_param, jacobian);
227  }
228 
229  if (source.dev_flux > 0.0) {
230  // Devaucouleurs component
231  auto xs = std::make_shared<ManualParameter>(1);
232  auto ys = std::make_shared<ManualParameter>(source.dev_aspect);
233  auto rot = std::make_shared<ManualParameter>(source.dev_rot);
234  auto dev_n = std::make_shared<ManualParameter>(4);
235 
236  auto dev_k = std::make_shared<ManualParameter>(pow(3459.0 / source.dev_rad, .25));
237  auto dev_i0 = std::make_shared<ManualParameter>(
238  source.dev_flux * pow(10, 3.33) / (7.2 * M_PI * source.dev_rad * source.dev_rad * source.dev_aspect));
239 
241  auto exp = make_unique<SersicModelComponent>(make_unique<OldSharp>(), dev_i0, dev_n, dev_k);
242  component_list.clear();
243  component_list.emplace_back(std::move(exp));
244  extended_models.emplace_back(std::move(component_list), xs, ys, rot, size, size, x_param, y_param, jacobian);
245  }
246 
247  if (source.point_flux > 0.0) {
248  auto flux_param = std::make_shared<ManualParameter>(source.point_flux);
249  point_models.emplace_back(x_param, y_param, flux_param);
250  }
251  }
252 
253  void addPointSource(std::vector<PointModel>& point_models, double x, double y, double flux) {
254  auto x_param = std::make_shared<ManualParameter>(x);
255  auto y_param = std::make_shared<ManualParameter>(y);
256  auto flux_param = std::make_shared<ManualParameter>(flux);
257 
258  point_models.emplace_back(x_param, y_param, flux_param);
259  }
260 
261  void addBackgroundNoise(std::shared_ptr<WriteableImage<SeFloat>> image, double background_level, double background_sigma) {
262  // Add noise
263  boost::random::normal_distribution<> bg_noise_dist(background_level, background_sigma);
264  for (int y=0; y < image->getHeight(); y++) {
265  for (int x=0; x < image->getWidth(); x++) {
266  // background (gaussian) noise
267  image->setValue(x, y, image->getValue(x, y) + bg_noise_dist(m_rng));
268  }
269  }
270  }
271 
273  // Add noise
274  if (gain > 0.0) {
275  for (int y=0; y < image->getHeight(); y++) {
276  for (int x=0; x < image->getWidth(); x++) {
277  auto pixel_value = image->getValue(x, y);
278  if (pixel_value > 0.) {
279  image->setValue(x, y, boost::random::poisson_distribution<>(pixel_value * gain)(m_rng) / gain);
280  }
281  }
282  }
283  }
284  }
285 
286  void saturate(std::shared_ptr<WriteableImage<SeFloat>> image, double saturation_level) {
287  if (saturation_level > 0.0) {
288  for (int y=0; y < image->getHeight(); y++) {
289  for (int x=0; x < image->getWidth(); x++) {
290  image->setValue(x, y, std::min(image->getValue(x, y), (float) saturation_level));
291  }
292  }
293  }
294  }
295 
296  void addBadPixels(std::shared_ptr<WriteableImage<SeFloat>> weight_map, double probability) {
297  if (probability>0) {
298  for (int y=0; y < weight_map->getHeight(); y++) {
299  for (int x=0; x < weight_map->getWidth(); x++) {
300  if (boost::random::uniform_01<double>()(m_rng) < probability) {
301  weight_map->setValue(x, y, 0);
302  }
303  }
304  }
305  }
306  }
307 
308  void addBadColumns(std::shared_ptr<WriteableImage<SeFloat>> weight_map, double probability) {
309  if (probability>0) {
310  for (int x=0; x < weight_map->getWidth(); x++) {
311  if (boost::random::uniform_01<double>()(m_rng) < probability) {
312  for (int y=0; y < weight_map->getHeight(); y++) {
313  weight_map->setValue(x, y, 0);
314  }
315  }
316  }
317  }
318  }
319 
321  double x_min, double y_min, double x_max, double y_max) {
323 
324 // std::cout << x_min << " " << x_max << " " << y_min << " " << y_max << "\n";
325 //
326  boost::random::uniform_real_distribution<> random_x(x_min, x_max);
327  boost::random::uniform_real_distribution<> random_y(y_min, y_max);
328  boost::random::uniform_real_distribution<> gal_exp_random_i0(gal_exp_min_i0, gal_exp_max_i0);
329  boost::random::uniform_real_distribution<> gal_dev_random_i0(gal_dev_min_i0, gal_dev_max_i0);
330 
331  for (int i = 0; i < number_of_sources; i++) {
332  //auto total_flux = gal_exp_random_i0(rng);
333  sources.push_back({
334  random_x(m_rng), random_y(m_rng),
335 
336  gal_exp_random_i0(m_rng),
337  boost::random::uniform_real_distribution<>(.5, 6)(m_rng),
338  boost::random::uniform_real_distribution<>(.2, .8)(m_rng),
339  boost::random::uniform_real_distribution<>(-M_PI/2, M_PI/2)(m_rng),
340 
341  0,0,1,0,
342 // gal_dev_random_i0(m_rng),
343 // boost::random::uniform_real_distribution<>(.1, .5)(m_rng),
344 // boost::random::uniform_real_distribution<>(.8, 1)(m_rng),
345 // boost::random::uniform_real_distribution<>(-M_PI/2, M_PI/2)(m_rng),
346 
347  0
348  });
349  }
350 
351  return sources;
352  }
353 
356 
357  std::ifstream file;
358  file.open(filename);
359 
360  while (file.good()) {
361  std::string line;
362  std::getline(file, line);
363 // line = std::regex_replace(line, std::regex("\\s+#.*"), std::string(""));
364 // line = std::regex_replace(line, std::regex("\\s+$"), std::string(""));
365  if (line.size() == 0) {
366  continue;
367  }
368 
369  std::stringstream linestream(line);
370 
371  TestImageSource source;
372  linestream >> source.x >> source.y
373  >> source.exp_flux >> source.exp_rad >> source.exp_aspect >> source.exp_rot
374  >> source.dev_flux >> source.dev_rad >> source.dev_aspect >> source.dev_rot
375  >> source.point_flux;
376 
377  source.exp_rot *= -M_PI / 180.0;
378  source.dev_rot *= -M_PI / 180.0;
379 
380  sources.emplace_back(std::move(source));
381  }
382 
383  return sources;
384  }
385 
387  std::ofstream file;
388  file.open(filename);
389 
390  for (const auto& source : sources) {
391  file << source.x << " " << source.y << " "
392  << source.exp_flux << " " << source.exp_rad << " " << source.exp_aspect << " " << (source.exp_rot * -180.0 / M_PI) << " "
393  << source.dev_flux << " " << source.dev_rad << " " << source.dev_aspect << " " << (source.dev_rot * -180.0 / M_PI) << " "
394  << source.point_flux << "\n";
395  }
396  }
397 
398  void transformSources(std::vector<TestImageSource>& sources, int image_size, double rot_angle, double scale, double shift_x, double shift_y) {
399  auto center = image_size / 2.0;
400  auto c = cos(rot_angle);
401  auto s = sin(rot_angle);
402  for (auto& source : sources) {
403  source.x -= center;
404  source.y -= center;
405  double x = (source.x * c - source.y * s) * scale + shift_x;
406  double y = (source.x * s + source.y * c) * scale + shift_y;
407  source.x = x + center;
408  source.y = y + center;
409 
410  source.exp_rot -= rot_angle;
411  source.dev_rot -= rot_angle;
412  }
413  }
414 
417 
418  //std::cout << "^^\n";
419 
420  std::ifstream file;
421  file.open(filename);
422 
423  while (file.good()) {
424  std::string line;
425  std::getline(file, line);
426 // line = std::regex_replace(line, std::regex("\\s+#.*"), std::string(""));
427 // line = std::regex_replace(line, std::regex("\\s+$"), std::string(""));
428  if (line.size() == 0) {
429  continue;
430  }
431 
432  std::stringstream linestream(line);
433  int source_type;
434  linestream >> source_type;
435 
436  //std::cout << source_type << "\n";
437 
438  TestImageSource source;
439  if (source_type == 200) {
440  double magnitude, bt, exp_angle_degree, dev_angle_degree;
441 
442  linestream >> source.x >> source.y >> magnitude
443  >> bt
444  >> source.dev_rad >> source.dev_aspect >> dev_angle_degree
445  >> source.exp_rad >> source.exp_aspect >> exp_angle_degree;
446 
447  // FIXME should change sign?
448  source.dev_rot = dev_angle_degree * M_PI / 180.0;
449  source.exp_rot = exp_angle_degree * M_PI / 180.0;
450 
451  auto total_flux = pow(10, (magnitude - m_zero_point) / -2.5);
452  source.exp_flux = total_flux * (1.0 - bt);
453  source.dev_flux = total_flux * bt;
454 
455 // source.dev_rad *= 2;
456 // source.exp_rad *= 2;
457 
458  source.point_flux = 0;
459  } else if (source_type == 100) {
460  double magnitude;
461  linestream >> source.x >> source.y >> magnitude;
462  source.point_flux = pow(10, (magnitude - m_zero_point) / -2.5) * m_exp_time;
463 
464  source.exp_flux = source.exp_rot = source.dev_flux = source.dev_rot = 0;
465  source.exp_aspect = source.exp_rad = source.dev_aspect = source.dev_rad = 1;
466  }
467 
468  source.x -= 1.5;
469  source.y -= 1.5;
470 
471  sources.emplace_back(std::move(source));
472  }
473 
474  return sources;
475  }
476 
477 
480 
481  auto max_tile_memory = args["max-tile-memory"].as<int>();
482  auto tile_size = args["tile-size"].as<int>();
483  TileManager::getInstance()->setOptions(tile_size, tile_size, max_tile_memory);
484 
485  auto image_size = args["size"].as<double>();
486  auto rot_angle = args["rotation"].as<double>() / 180.0 * M_PI;
487  auto scale = args["scale"].as<double>();
488  auto shift_x = args["shift-x"].as<double>();
489  auto shift_y = args["shift-y"].as<double>();
490  auto model_size = args["model-size"].as<double>();
491  if (model_size <= 0.) {
492  model_size = image_size;
493  }
494 
495  m_zero_point = args["zero-point"].as<double>();
496  m_exp_time = args["exposure-time"].as<double>();
497 
498  std::vector<ConstantModel> constant_models;
499  std::vector<TransformedModel> extended_models;
500  std::vector<PointModel> point_models;
501 
503 
504  auto psf_filename = args["psf-file"].as<std::string>();
505  if (psf_filename != "") {
506  logger.info() << "Loading psf file: " << psf_filename;
507  vpsf = PsfPluginConfig::readPsf(psf_filename);
508  } else {
509  vpsf = PsfPluginConfig::generateGaussianPsf(args["psf-fwhm"].as<double>(), args["psf-scale"].as<double>());
510  }
511 
512  std::shared_ptr<CoordinateSystem> coordinate_system;
513  auto copy_coordinate_system = args["copy-coordinate-system"].as<std::string>();
514  if (copy_coordinate_system != "") {
515  coordinate_system = std::make_shared<WCS>(copy_coordinate_system);
516  } else {
517  coordinate_system = std::make_shared<DummyWCS>(image_size, image_size, rot_angle, scale, shift_x, shift_y);
518  }
519 
520  auto raster_model_size = model_size / vpsf->getPixelSampling() + std::max(vpsf->getWidth(), vpsf->getHeight());
521  if (raster_model_size * raster_model_size > std::numeric_limits<int>::max()) {
522  logger.fatal() << "The expected required memory for model rasterization exceeds the maximum size for an integer";
523  logger.fatal() << "Please, either reduce the model size, the image size, or increase the PSF pixel scale";
524  logger.fatal() << raster_model_size * raster_model_size << " > " << std::numeric_limits<int>::max();
526  }
527 
528  // Generate a single PSF for the image
529  const auto& vpsf_components = vpsf->getComponents();
530  std::vector<double> psf_vals(vpsf_components.size());
531  for (auto i = 0u; i < psf_vals.size(); ++i) {
532  if (vpsf_components[i].name == "X_IMAGE" || vpsf_components[i].name == "Y_IMAGE") {
533  psf_vals[i] = image_size / 2 - 1;
534  }
535  else {
536  throw Elements::Exception() << "Unknown PSF component " << vpsf_components[i].name;
537  }
538  }
539 
540  // Generate and normalize the PSF
541  auto p = vpsf->getPsf(psf_vals);
542  auto psf_sum = std::accumulate(p->getData().begin(), p->getData().end(), 0.);
544  auto psf = std::make_shared<ImagePsf>(vpsf->getPixelSampling(), p);
545 
547 
548  std::string sources_filename = args["source-list"].as<std::string>();
549  if (sources_filename != "") {
550  logger.info() << "Loading sources from < " << sources_filename << " >...";
551  auto loaded_sources = loadSourcesFromFile(sources_filename);
552  sources.insert(sources.end(), loaded_sources.begin(), loaded_sources.end());
553  }
554 
555  std::string sources_cat_filename = args["source-catalog"].as<std::string>();
556  if (sources_cat_filename != "") {
557  logger.info() << "Loading source catalog from < " << sources_cat_filename << " >...";
558  auto loaded_sources = loadSourcesFromCatalog(sources_cat_filename);
559  sources.insert(sources.end(), loaded_sources.begin(), loaded_sources.end());
560  }
561 
562  int nb_of_random_sources = args["random-sources"].as<int>();
563  if (nb_of_random_sources > 0) {
564  logger.info() << "Adding " << nb_of_random_sources << " random source" << (nb_of_random_sources>1 ? "s" : "") << "...";
565  auto random_sources = generateRandomSources(nb_of_random_sources, image_size * .1, image_size * .1, image_size * .9, image_size * .9);
566  sources.insert(sources.end(), random_sources.begin(), random_sources.end());
567  }
568 
569  std::string sources_save_filename = args["save-sources"].as<std::string>();
570  if (sources_save_filename != "") {
571  logger.info() << "Saving sources to < " << sources_save_filename << " >...";
572  saveSources(sources, sources_save_filename);
573  }
574 
575  logger.info("Transforming sources...");
576  transformSources(sources, image_size, rot_angle, scale, shift_x, shift_y);
577 
578  logger.info("Creating source models...");
579  for (const auto& source : sources) {
580  addSource(point_models, extended_models, model_size, source, std::make_tuple(scale, 0, 0, scale));
581  }
582 
583  logger.info("Rendering...");
584 
585  auto filename = args["output"].as<std::string>();
586  auto target_image_source = std::make_shared<FitsImageSource<SeFloat>>(filename, image_size, image_size, coordinate_system);
588 
589  if (args["disable-psf"].as<bool>()) {
591  pixel_scale,
592  (std::size_t) image_size, (std::size_t) image_size,
593  std::move(constant_models),
594  std::move(point_models),
595  std::move(extended_models),
596  };
597  frame_model.rasterToImage(target_image);
598  } else {
600  pixel_scale,
601  (std::size_t) image_size, (std::size_t) image_size,
602  std::move(constant_models),
603  std::move(point_models),
604  std::move(extended_models),
605  *psf
606  };
607  frame_model.rasterToImage(target_image);
608  }
609 
610 
611  logger.info("Adding noise...");
612 
613  addPoissonNoise(target_image, args["gain"].as<double>());
614  addBackgroundNoise(target_image, args["bg-level"].as<double>(), args["bg-sigma"].as<double>());
615 
616  logger.info("Adding saturation...");
617 
618  auto saturation_level = args["saturation"].as<double>();
619  saturate(target_image, saturation_level);
620 
621  logger.info("Creating weight map...");
622 
623  auto weight_filename = args["output-weight"].as<std::string>();
624  if (weight_filename != "") {
625  auto weight_map_source = std::make_shared<FitsImageSource<SeFloat>>(weight_filename, image_size, image_size);
626  auto weight_map = WriteableBufferedImage<SeFloat>::create(weight_map_source);
627  for (int y = 0; y < image_size; ++y) {
628  for (int x = 0; x < image_size; ++x) {
629  weight_map->setValue(x, y, 1);
630  }
631  }
632 
633  logger.info("Adding bad pixels...");
634 
635  addBadPixels(weight_map, args["bad-pixels"].as<double>());
636  addBadColumns(weight_map, args["bad-columns"].as<double>());
637 
638  for (int y = 0; y < target_image->getHeight(); y++) {
639  for (int x = 0; x < target_image->getWidth(); x++) {
640  if (weight_map->getValue(x, y) == 0) {
641  target_image->setValue(x, y, saturation_level);
642  }
643  }
644  }
645  }
646 
647  logger.info("All done ^__^");
648  return Elements::ExitCode::OK;
649  }
650 
651 private:
652  boost::random::mt19937 m_rng { (unsigned int) time(NULL) } ;
653  double m_zero_point = 0.0, m_exp_time = 300.;
654 
655 };
656 
658 
std::vector< TestImageSource > generateRandomSources(int number_of_sources, double x_min, double y_min, double x_max, double y_max)
Definition: TestImage.cpp:320
static Elements::Logging logger
T open(T...args)
static std::shared_ptr< TileManager > getInstance()
Definition: TileManager.h:137
T good(T...args)
T exp(T...args)
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< VectorImage< SourceXtractor::SeFloat > > getScaledKernel(double) const
Definition: TestImage.cpp:150
std::vector< TestImageSource > loadSourcesFromFile(const std::string &filename)
Definition: TestImage.cpp:354
double dev_aspect
Definition: TestImage.cpp:82
constexpr double s
T getline(T...args)
T to_string(T...args)
void info(const std::string &logMessage)
SeFloat32 SeFloat
Definition: Types.h:32
double point_flux
Definition: TestImage.cpp:83
T make_tuple(T...args)
static std::shared_ptr< VectorImage< T > > create(Args &&...args)
Definition: VectorImage.h:89
DummyWCS(int image_width, int image_height, double rotation, double scale, double shift_x, double shift_y)
Definition: TestImage.cpp:89
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
T time(T...args)
Elements::ExitCode mainMethod(std::map< std::string, po::variable_value > &args) override
Definition: TestImage.cpp:478
void addPointSource(std::vector< PointModel > &point_models, double x, double y, double flux)
Definition: TestImage.cpp:253
static std::shared_ptr< WriteableBufferedImage< T > > create(std::shared_ptr< const ImageSource< T >> source, std::shared_ptr< TileManager > tile_manager=TileManager::getInstance())
STL class.
T min(T...args)
T sin(T...args)
const double gal_dev_max_i0
Definition: TestImage.cpp:77
T push_back(T...args)
STL class.
void addBadColumns(std::shared_ptr< WriteableImage< SeFloat >> weight_map, double probability)
Definition: TestImage.cpp:308
double exp_aspect
Definition: TestImage.cpp:81
Image implementation which keeps the pixel values in memory.
Definition: VectorImage.h:53
#define MAIN_FOR(ELEMENTS_PROGRAM_NAME)
void saveSources(const std::vector< TestImageSource > &sources, const std::string &filename)
Definition: TestImage.cpp:386
string filename
Definition: conf.py:63
std::shared_ptr< VectorImage< SourceXtractor::SeFloat > > m_kernel
Definition: TestImage.cpp:158
const double gal_exp_max_i0
Definition: TestImage.cpp:75
int m_image_width
Definition: TestImage.cpp:130
const double gal_dev_min_i0
Definition: TestImage.cpp:76
void convolve(ImageType &) const
Definition: TestImage.cpp:154
virtual ~DummyWCS()
Definition: TestImage.cpp:92
T cos(T...args)
void fatal(const std::string &logMessage)
T max(T...args)
T move(T...args)
std::size_t getSize() const
Definition: TestImage.cpp:146
void addBackgroundNoise(std::shared_ptr< WriteableImage< SeFloat >> image, double background_level, double background_sigma)
Definition: TestImage.cpp:261
void addSource(std::vector< PointModel > &point_models, std::vector< TransformedModel > &extended_models, double size, const TestImageSource &source, std::tuple< double, double, double, double > jacobian)
Definition: TestImage.cpp:204
void addBadPixels(std::shared_ptr< WriteableImage< SeFloat >> weight_map, double probability)
Definition: TestImage.cpp:296
T size(T...args)
STL class.
WorldCoordinate imageToWorld(ImageCoordinate image_coordinate) const override
Definition: TestImage.cpp:94
std::vector< TestImageSource > loadSourcesFromCatalog(const std::string &filename)
Definition: TestImage.cpp:415
static std::shared_ptr< VariablePsf > generateGaussianPsf(SeFloat fwhm, SeFloat pixel_sampling)
static std::shared_ptr< VariablePsf > readPsf(const std::string &filename, int hdu_number=1)
T pow(T...args)
double getPixelScale() const
Definition: TestImage.cpp:142
void addPoissonNoise(std::shared_ptr< WriteableImage< SeFloat >> image, double gain)
Definition: TestImage.cpp:272
ImageCoordinate worldToImage(WorldCoordinate world_coordinate) const override
Definition: TestImage.cpp:98
void transformSources(std::vector< TestImageSource > &sources, int image_size, double rot_angle, double scale, double shift_x, double shift_y)
Definition: TestImage.cpp:398
T accumulate(T...args)
po::options_description defineSpecificProgramOptions() override
Definition: TestImage.cpp:166
static Logging getLogger(const std::string &name="")
void saturate(std::shared_ptr< WriteableImage< SeFloat >> image, double saturation_level)
Definition: TestImage.cpp:286
const double pixel_scale
Definition: TestImage.cpp:72
std::map< std::string, std::string > getFitsHeaders() const override
Definition: TestImage.cpp:102
STL class.
Processes two images to create a third combining them by using any function.
const double gal_exp_min_i0
Definition: TestImage.cpp:74
T emplace_back(T...args)