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