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