SourceXtractorPlusPlus  0.13
Please provide a description of the project.
FlexibleModelFittingTask.cpp
Go to the documentation of this file.
1 
17 /*
18  * FlexibleModelFittingTask.cpp
19  *
20  * Created on: Sep 17, 2018
21  * Author: mschefer
22  */
23 
24 #include <mutex>
25 
35 
37 
39 
42 
46 
47 
53 
57 
59 
60 namespace SourceXtractor {
61 
62 using namespace ModelFitting;
63 
64 static auto logger = Elements::Logging::getLogger("FlexibleModelFitting");
65 
66 namespace {
67 
68 __attribute__((unused))
69 void printLevmarInfo(std::array<double, 10> info) {
70  std::cerr << "\nMinimization info:\n";
71  std::cerr << " ||e||_2 at initial p: " << info[0] << '\n';
72  std::cerr << " ||e||_2: " << info[1] << '\n';
73  std::cerr << " ||J^T e||_inf: " << info[2] << '\n';
74  std::cerr << " ||Dp||_2: " << info[3] << '\n';
75  std::cerr << " mu/max[J^T J]_ii: " << info[4] << '\n';
76  std::cerr << " # iterations: " << info[5] << '\n';
77  switch ((int) info[6]) {
78  case 1:
79  std::cerr << " stopped by small gradient J^T e\n";
80  break;
81  case 2:
82  std::cerr << " stopped by small Dp\n";
83  break;
84  case 3:
85  std::cerr << " stopped by itmax\n";
86  break;
87  case 4:
88  std::cerr << " singular matrix. Restart from current p with increased mu\n";
89  break;
90  case 5:
91  std::cerr << " no further error reduction is possible. Restart with increased mu\n";
92  break;
93  case 6:
94  std::cerr << " stopped by small ||e||_2\n";
95  break;
96  case 7:
97  std::cerr << " stopped by invalid (i.e. NaN or Inf) func values; a user error\n";
98  break;
99  }
100  std::cerr << " # function evaluations: " << info[7] << '\n';
101  std::cerr << " # Jacobian evaluations: " << info[8] << '\n';
102  std::cerr << " # linear systems solved: " << info[9] << "\n\n";
103 }
104 
105 }
106 
108  unsigned int max_iterations, double modified_chi_squared_scale,
112  double scale_factor)
113  : m_least_squares_engine(least_squares_engine),
114  m_max_iterations(max_iterations), m_modified_chi_squared_scale(modified_chi_squared_scale),
115  m_parameters(parameters), m_frames(frames), m_priors(priors), m_scale_factor(scale_factor) {}
116 
118  auto stamp_rect = group.getProperty<MeasurementFrameGroupRectangle>(frame_index);
119  return stamp_rect.getWidth() > 0 && stamp_rect.getHeight() > 0;
120 }
121 
123  SourceGroupInterface& group, int frame_index) const {
124  const auto& frame_images = group.begin()->getProperty<MeasurementFrameImages>(frame_index);
125  auto rect = group.getProperty<MeasurementFrameGroupRectangle>(frame_index);
126  auto image = VectorImage<SeFloat>::create(frame_images.getImageChunk(
127  LayerSubtractedImage, rect.getTopLeft().m_x, rect.getTopLeft().m_y, rect.getWidth(), rect.getHeight()));
128 
129  return image;
130 }
131 
133  SourceGroupInterface& group, int frame_index) const {
134  const auto& frame_images = group.begin()->getProperty<MeasurementFrameImages>(frame_index);
135 
136  auto frame_image = frame_images.getLockedImage(LayerSubtractedImage);
137  auto frame_image_thresholded = frame_images.getLockedImage(LayerThresholdedImage);
138  auto variance_map = frame_images.getLockedImage(LayerVarianceMap);
139 
140  const auto& frame_info = group.begin()->getProperty<MeasurementFrameInfo>(frame_index);
141  SeFloat gain = frame_info.getGain();
142  SeFloat saturation = frame_info.getSaturation();
143 
144  auto rect = group.getProperty<MeasurementFrameGroupRectangle>(frame_index);
145  auto weight = VectorImage<SeFloat>::create(rect.getWidth(), rect.getHeight());
146  std::fill(weight->getData().begin(), weight->getData().end(), 1);
147 
148  for (int y = 0; y < rect.getHeight(); y++) {
149  for (int x = 0; x < rect.getWidth(); x++) {
150  auto back_var = variance_map->getValue(rect.getTopLeft().m_x + x, rect.getTopLeft().m_y + y);
151  if (saturation > 0 && frame_image->getValue(rect.getTopLeft().m_x + x, rect.getTopLeft().m_y + y) > saturation) {
152  weight->at(x, y) = 0;
153  } else if (weight->at(x, y) > 0) {
154  if (gain > 0.0) {
155  weight->at(x, y) = sqrt(
156  1.0 / (back_var + frame_image->getValue(rect.getTopLeft().m_x + x, rect.getTopLeft().m_y + y) / gain));
157  } else {
158  weight->at(x, y) = sqrt(1.0 / back_var); // infinite gain
159  }
160  }
161  }
162  }
163 
164  return weight;
165 }
166 
168  SourceGroupInterface& group,
171 
172  int frame_index = frame->getFrameNb();
173 
174  auto frame_coordinates =
175  group.begin()->getProperty<MeasurementFrameCoordinates>(frame_index).getCoordinateSystem();
176  auto ref_coordinates =
177  group.begin()->getProperty<DetectionFrameCoordinates>().getCoordinateSystem();
178 
179  auto stamp_rect = group.getProperty<MeasurementFrameGroupRectangle>(frame_index);
180  auto psf_property = group.getProperty<PsfProperty>(frame_index);
181  auto jacobian = group.getProperty<JacobianGroup>(frame_index).asTuple();
182 
183  // The model fitting module expects to get a PSF with a pixel scale, but we have the pixel sampling step size
184  // It will be used to compute the rastering grid size, and after convolving with the PSF the result will be
185  // downscaled before copied into the frame image.
186  // We can multiply here then, as the unit is pixel/pixel, rather than "/pixel or similar
187  auto group_psf = ImagePsf(pixel_scale * psf_property.getPixelSampling(), psf_property.getPsf());
188 
189  std::vector<ConstantModel> constant_models;
190  std::vector<PointModel> point_models;
192 
193  for (auto& source : group) {
194  for (auto model : frame->getModels()) {
195  model->addForSource(manager, source, constant_models, point_models, extended_models, jacobian, ref_coordinates, frame_coordinates,
196  stamp_rect.getTopLeft());
197  }
198  }
199 
200  // Full frame model with all sources
202  pixel_scale, (size_t) stamp_rect.getWidth(), (size_t) stamp_rect.getHeight(),
203  std::move(constant_models), std::move(point_models), std::move(extended_models), group_psf);
204 
205  return frame_model;
206 }
207 
208 
210  double pixel_scale = 1 / m_scale_factor;
211  FlexibleModelFittingParameterManager parameter_manager;
212  ModelFitting::EngineParameterManager engine_parameter_manager{};
213  int n_free_parameters = 0;
214 
215  {
217 
218  // Prepare parameters
219  for (auto& source : group) {
220  for (auto parameter : m_parameters) {
221  if (std::dynamic_pointer_cast<FlexibleModelFittingFreeParameter>(parameter)) {
222  ++n_free_parameters;
223  }
224  parameter_manager.addParameter(source, parameter,
225  parameter->create(parameter_manager, engine_parameter_manager, source));
226  }
227  }
228  }
229 
230  try {
231  // Reset access checks, as a dependent parameter could have triggered it
232  parameter_manager.clearAccessCheck();
233 
234  // Add models for all frames
235  ResidualEstimator res_estimator{};
236 
237  int valid_frames = 0;
238  int n_good_pixels = 0;
239  for (auto frame : m_frames) {
240  int frame_index = frame->getFrameNb();
241  // Validate that each frame covers the model fitting region
242  if (isFrameValid(group, frame_index)) {
243  valid_frames++;
244 
245  auto frame_model = createFrameModel(group, pixel_scale, parameter_manager, frame);
246 
247  auto image = createImageCopy(group, frame_index);
248  auto weight = createWeightImage(group, frame_index);
249 
250  for (int y = 0; y < weight->getHeight(); ++y) {
251  for (int x = 0; x < weight->getWidth(); ++x) {
252  n_good_pixels += (weight->at(x, y) != 0.);
253  }
254  }
255 
256  // Setup residuals
257  auto data_vs_model =
258  createDataVsModelResiduals(image, std::move(frame_model), weight,
259  //LogChiSquareComparator(m_modified_chi_squared_scale));
261  res_estimator.registerBlockProvider(std::move(data_vs_model));
262  }
263  }
264 
265  // Check that we had enough data for the fit
266  Flags group_flags = Flags::NONE;
267  if (valid_frames == 0) {
268  group_flags = Flags::OUTSIDE;
269  }
270  else if (n_good_pixels < n_free_parameters) {
271  group_flags = Flags::INSUFFICIENT_DATA;
272  }
273 
274  if (group_flags != Flags::NONE) {
275  setDummyProperty(group, parameter_manager, group_flags);
276  return;
277  }
278 
279  // Add priors
280  for (auto& source : group) {
281  for (auto prior : m_priors) {
282  prior->setupPrior(parameter_manager, source, res_estimator);
283  }
284  }
285 
286  // Model fitting
287 
288  // FIXME we can no longer specify different settings with LeastSquareEngineManager!!
289  // LevmarEngine engine{m_max_iterations, 1E-3, 1E-6, 1E-6, 1E-6, 1E-4};
291  auto solution = engine->solveProblem(engine_parameter_manager, res_estimator);
292  size_t iterations = (size_t) boost::any_cast<std::array<double, 10>>(solution.underlying_framework_info)[5];
293 
294  int total_data_points = 0;
295  SeFloat avg_reduced_chi_squared = computeChiSquared(group, pixel_scale, parameter_manager, total_data_points);
296 
297  int nb_of_free_parameters = 0;
298  for (auto& source : group) {
299  for (auto parameter : m_parameters) {
300  bool is_free_parameter = std::dynamic_pointer_cast<FlexibleModelFittingFreeParameter>(parameter).get();
301  bool accessed_by_modelfitting = parameter_manager.isParamAccessed(source, parameter);
302  if (is_free_parameter && accessed_by_modelfitting) {
303  nb_of_free_parameters++;
304  }
305  }
306  }
307  avg_reduced_chi_squared /= (total_data_points - nb_of_free_parameters);
308 
309  // Collect parameters for output
310  for (auto& source : group) {
311  std::unordered_map<int, double> parameter_values, parameter_sigmas;
312  auto source_flags = Flags::NONE;
313 
314  for (auto parameter : m_parameters) {
315  bool is_dependent_parameter = std::dynamic_pointer_cast<FlexibleModelFittingDependentParameter>(parameter).get();
316  bool accessed_by_modelfitting = parameter_manager.isParamAccessed(source, parameter);
317  auto modelfitting_parameter = parameter_manager.getParameter(source, parameter);
318 
319  if (is_dependent_parameter || accessed_by_modelfitting) {
320  parameter_values[parameter->getId()] = modelfitting_parameter->getValue();
321  parameter_sigmas[parameter->getId()] = parameter->getSigma(parameter_manager, source, solution.parameter_sigmas);
322  }
323  else {
324  // Need to cascade the NaN to any potential dependent parameter
325  auto engine_parameter = std::dynamic_pointer_cast<EngineParameter>(modelfitting_parameter);
326  if (engine_parameter) {
327  engine_parameter->setEngineValue(std::numeric_limits<double>::quiet_NaN());
328  }
329  parameter_values[parameter->getId()] = std::numeric_limits<double>::quiet_NaN();
330  parameter_sigmas[parameter->getId()] = std::numeric_limits<double>::quiet_NaN();
331  source_flags |= Flags::PARTIAL_FIT;
332  }
333  }
334  source.setProperty<FlexibleModelFitting>(iterations, avg_reduced_chi_squared, source_flags, parameter_values,
335  parameter_sigmas);
336  }
337  updateCheckImages(group, pixel_scale, parameter_manager);
338 
339  }
340  catch (const Elements::Exception& e) {
341  logger.error() << "An exception occured during model fitting: " << e.what();
342  setDummyProperty(group, parameter_manager, Flags::ERROR);
343  }
344 }
345 
346 // Used to set a dummy property in case of error that contains no result but just an error flag
348  for (auto& source : group) {
349  std::unordered_map<int, double> dummy_values;
350  for (auto parameter : m_parameters) {
351  auto modelfitting_parameter = parameter_manager.getParameter(source, parameter);
352  auto manual_parameter = std::dynamic_pointer_cast<ManualParameter>(modelfitting_parameter);
353  if (manual_parameter) {
354  manual_parameter->setValue(std::numeric_limits<double>::quiet_NaN());
355  }
356  dummy_values[parameter->getId()] = std::numeric_limits<double>::quiet_NaN();
357  }
358  source.setProperty<FlexibleModelFitting>(0, std::numeric_limits<double>::quiet_NaN(), flags,
359  dummy_values, dummy_values);
360  }
361 }
362 
364  double pixel_scale, FlexibleModelFittingParameterManager& manager) const {
365 
366  int frame_id = 0;
367  for (auto frame : m_frames) {
368  int frame_index = frame->getFrameNb();
369  // Validate that each frame covers the model fitting region
370  if (isFrameValid(group, frame_index)) {
371  auto frame_model = createFrameModel(group, pixel_scale, manager, frame);
372  auto final_stamp = frame_model.getImage();
373 
374  auto stamp_rect = group.getProperty<MeasurementFrameGroupRectangle>(frame_index);
375 
376  auto debug_image = CheckImages::getInstance().getModelFittingImage(frame_index);
377  if (debug_image) {
378  for (int x = 0; x < final_stamp->getWidth(); x++) {
379  for (int y = 0; y < final_stamp->getHeight(); y++) {
380  auto x_coord = stamp_rect.getTopLeft().m_x + x;
381  auto y_coord = stamp_rect.getTopLeft().m_y + y;
382  debug_image->setValue(x_coord, y_coord,
383  debug_image->getValue(x_coord, y_coord) + final_stamp->getValue(x, y));
384  }
385  }
386  }
387  }
388  frame_id++;
389  }
390 }
391 
393  std::shared_ptr<const Image<SeFloat>> model, std::shared_ptr<const Image<SeFloat>> weights, int& data_points) const {
394  double reduced_chi_squared = 0.0;
395  data_points = 0;
396  for (int y=0; y < image->getHeight(); y++) {
397  for (int x=0; x < image->getWidth(); x++) {
398  double tmp = image->getValue(x, y) - model->getValue(x, y);
399  reduced_chi_squared += tmp * tmp * weights->getValue(x, y) * weights->getValue(x, y);
400  if (weights->getValue(x, y) > 0) {
401  data_points++;
402  }
403  }
404  }
405  return reduced_chi_squared;
406 }
407 
409  double pixel_scale, FlexibleModelFittingParameterManager& manager, int& total_data_points) const {
410 
411  SeFloat total_chi_squared = 0;
412  total_data_points = 0;
413  int valid_frames = 0;
414  for (auto frame : m_frames) {
415  int frame_index = frame->getFrameNb();
416  // Validate that each frame covers the model fitting region
417  if (isFrameValid(group, frame_index)) {
418  valid_frames++;
419  auto frame_model = createFrameModel(group, pixel_scale, manager, frame);
420  auto final_stamp = frame_model.getImage();
421 
422  auto stamp_rect = group.getProperty<MeasurementFrameGroupRectangle>(frame_index);
423  auto image = createImageCopy(group, frame_index);
424  auto weight = createWeightImage(group, frame_index);
425 
426  int data_points = 0;
427  SeFloat chi_squared = computeChiSquaredForFrame(
428  image, final_stamp, weight, data_points);
429 
430  total_data_points += data_points;
431  total_chi_squared += chi_squared;
432  }
433  }
434 
435  return total_chi_squared;
436 }
437 
439 }
440 
441 }
DetectionFrameCoordinates.h
ModelFitting::ResidualEstimator
Provides to the LeastSquareEngine the residual values.
Definition: ResidualEstimator.h:50
SourceXtractor::FlexibleModelFittingParameterManager::clearAccessCheck
void clearAccessCheck()
Definition: FlexibleModelFittingParameterManager.h:72
MeasurementFrameInfo.h
std::lock
T lock(T... args)
Jacobian.h
AsinhChiSquareComparator.h
SourceXtractor::MeasurementFrameImages::getHeight
int getHeight() const
Definition: MeasurementFrameImages.h:54
SourceXtractor::CheckImages::getModelFittingImage
std::shared_ptr< WriteableImage< MeasurementImage::PixelType > > getModelFittingImage(unsigned int frame_number)
Definition: CheckImages.cpp:192
ModelFitting::LeastSquareEngineManager::create
static std::shared_ptr< LeastSquareEngine > create(const std::string &name, unsigned max_iterations=1000)
Definition: LeastSquareEngineManager.cpp:65
SourceXtractor::MeasurementFrameImages::getWidth
int getWidth() const
Definition: MeasurementFrameImages.h:50
SourceXtractor::FlexibleModelFittingTask::m_scale_factor
double m_scale_factor
Definition: FlexibleModelFittingTask.h:88
std::string
STL class.
std::shared_ptr
STL class.
CheckImages.h
SourceXtractor::FlexibleModelFittingTask::~FlexibleModelFittingTask
virtual ~FlexibleModelFittingTask()
Definition: FlexibleModelFittingTask.cpp:438
VectorImageDataVsModelInputTraits.h
std::move
T move(T... args)
SourceXtractor::ImagePsf
Definition: ImagePsf.h:37
__attribute__
#define __attribute__(x)
MeasurementFramePixelCentroid.h
SourceXtractor::MeasurementFrameCoordinates
Definition: MeasurementFrameCoordinates.h:26
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
ResidualEstimator.h
SourceXtractor::SeFloat
SeFloat32 SeFloat
Definition: Types.h:32
std::vector
STL class.
SourceXtractor::DetectionFrameCoordinates
Definition: DetectionFrameCoordinates.h:26
SourceXtractor::MeasurementFrameImages::getLockedImage
std::shared_ptr< Image< SeFloat > > getLockedImage(FrameImageLayer layer) const
Definition: MeasurementFrameImages.h:39
SourceXtractor::FlexibleModelFittingTask::computeProperties
virtual void computeProperties(SourceGroupInterface &group) const override
Computes one or more properties for the SourceGroup and/or the Sources it contains.
Definition: FlexibleModelFittingTask.cpp:209
FlexibleModelFittingTask.h
SourceXtractor::JacobianGroup
Definition: Jacobian.h:56
std::lock_guard< std::recursive_mutex >
SourceXtractor::FlexibleModelFittingTask::setDummyProperty
void setDummyProperty(SourceGroupInterface &group, FlexibleModelFittingParameterManager &parameter_manager, Flags flags) const
Definition: FlexibleModelFittingTask.cpp:347
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition: SourceFlags.h:34
SourceXtractor::FlexibleModelFittingTask::computeChiSquared
SeFloat computeChiSquared(SourceGroupInterface &group, double pixel_scale, FlexibleModelFittingParameterManager &manager, int &total_data_points) const
Definition: FlexibleModelFittingTask.cpp:408
SourceXtractor::LayerVarianceMap
@ LayerVarianceMap
Definition: Frame.h:44
SourceXtractor::MultithreadedMeasurement::g_global_mutex
static std::recursive_mutex g_global_mutex
Definition: MultithreadedMeasurement.h:53
ModelFitting::AsinhChiSquareComparator
Data vs model comparator which computes a modified residual, using asinh.
Definition: AsinhChiSquareComparator.h:40
SourceXtractor::Image< SeFloat >
FrameModel.h
SourceXtractor::MeasurementFrameImages
Definition: MeasurementFrameImages.h:31
std::sqrt
T sqrt(T... args)
SourceXtractor::SourceGroupInterface::getProperty
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Definition: SourceInterface.h:57
std::fill
T fill(T... args)
SourceXtractor::FlexibleModelFittingTask::isFrameValid
bool isFrameValid(SourceGroupInterface &group, int frame_index) const
Definition: FlexibleModelFittingTask.cpp:117
SourceXtractor::FlexibleModelFittingParameterManager
Definition: FlexibleModelFittingParameterManager.h:43
MeasurementFrameGroupRectangle.h
SourceXtractor::MeasurementFrameGroupRectangle::getWidth
int getWidth() const
Definition: MeasurementFrameGroupRectangle.h:55
SourceXtractor::CheckImages::getInstance
static CheckImages & getInstance()
Definition: CheckImages.h:136
SourceXtractor::source_flags
static StaticPlugin< SourceFlagsPlugin > source_flags
Definition: SourceFlagsPlugin.cpp:43
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::FlexibleModelFittingTask::createWeightImage
std::shared_ptr< VectorImage< SeFloat > > createWeightImage(SourceGroupInterface &group, int frame_index) const
Definition: FlexibleModelFittingTask.cpp:132
SourceXtractor::FlexibleModelFittingTask::m_frames
std::vector< std::shared_ptr< FlexibleModelFittingFrame > > m_frames
Definition: FlexibleModelFittingTask.h:85
pixel_scale
const double pixel_scale
Definition: TestImage.cpp:75
SourceXtractor::FlexibleModelFittingParameterManager::getParameter
std::shared_ptr< ModelFitting::BasicParameter > getParameter(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter) const
Definition: FlexibleModelFittingParameterManager.h:51
SourceXtractor::PsfProperty
Definition: PsfProperty.h:32
SourceXtractor::MeasurementFrameGroupRectangle
Definition: MeasurementFrameGroupRectangle.h:33
SourceXtractor::FlexibleModelFittingTask::updateCheckImages
void updateCheckImages(SourceGroupInterface &group, double pixel_scale, FlexibleModelFittingParameterManager &manager) const
Definition: FlexibleModelFittingTask.cpp:363
std::cerr
SourceXtractor::FlexibleModelFittingParameterManager::isParamAccessed
bool isParamAccessed(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter) const
Definition: FlexibleModelFittingParameterManager.h:76
SourceXtractor::MeasurementFrameInfo
Definition: MeasurementFrameInfo.h:28
ManualParameter.h
LeastSquareEngineManager.h
SourceXtractor::FlexibleModelFittingTask::m_parameters
std::vector< std::shared_ptr< FlexibleModelFittingParameter > > m_parameters
Definition: FlexibleModelFittingTask.h:84
std::array
STL class.
MeasurementFrameCoordinates.h
PointModel.h
ModelFitting::EngineParameterManager
Class responsible for managing the parameters the least square engine minimizes.
Definition: EngineParameterManager.h:61
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition: VectorImage.h:89
Elements::Exception
SourceXtractor::FlexibleModelFittingTask::m_priors
std::vector< std::shared_ptr< FlexibleModelFittingPrior > > m_priors
Definition: FlexibleModelFittingTask.h:86
PsfProperty.h
SourceXtractor::SourceGroupInterface::begin
virtual iterator begin()=0
FlexibleModelFitting.h
SourceXtractor::logger
static auto logger
Definition: WCS.cpp:44
e
constexpr double e
Elements::Logging::getLogger
static Logging getLogger(const std::string &name="")
SourceXtractor::Flags::NONE
@ NONE
No flag is set.
SourceXtractor::FlexibleModelFitting
Definition: FlexibleModelFitting.h:40
SourceXtractor::FlexibleModelFittingTask::m_least_squares_engine
std::string m_least_squares_engine
Definition: FlexibleModelFittingTask.h:80
ExtendedModel.h
SourceXtractor::SourceGroupInterface
Defines the interface used to group sources.
Definition: SourceGroupInterface.h:37
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:94
SourceXtractor::FlexibleModelFittingTask::createFrameModel
ModelFitting::FrameModel< ImagePsf, std::shared_ptr< VectorImage< SourceXtractor::SeFloat > > > createFrameModel(SourceGroupInterface &group, double pixel_scale, FlexibleModelFittingParameterManager &manager, std::shared_ptr< FlexibleModelFittingFrame > frame) const
Definition: FlexibleModelFittingTask.cpp:167
MultithreadedMeasurement.h
SourceXtractor::MeasurementFrameInfo::getGain
double getGain() const
Definition: MeasurementFrameInfo.h:39
ModelFitting::FrameModel
Definition: FrameModel.h:125
SourceXtractor::FlexibleModelFittingTask::m_max_iterations
unsigned int m_max_iterations
Definition: FlexibleModelFittingTask.h:81
std::size_t
TransformedModel.h
SourceXtractor::LayerSubtractedImage
@ LayerSubtractedImage
Definition: Frame.h:38
SourceXtractor::FlexibleModelFittingParameterManager::addParameter
void addParameter(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter, std::shared_ptr< ModelFitting::BasicParameter > engine_parameter)
Definition: FlexibleModelFittingParameterManager.h:59
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:94
SourceXtractor::FlexibleModelFittingTask::computeChiSquaredForFrame
SeFloat computeChiSquaredForFrame(std::shared_ptr< const Image< SeFloat >> image, std::shared_ptr< const Image< SeFloat >> model, std::shared_ptr< const Image< SeFloat >> weights, int &data_points) const
Definition: FlexibleModelFittingTask.cpp:392
SourceXtractor::FlexibleModelFittingTask::createImageCopy
std::shared_ptr< VectorImage< SeFloat > > createImageCopy(SourceGroupInterface &group, int frame_index) const
Definition: FlexibleModelFittingTask.cpp:122
ModelFitting::createDataVsModelResiduals
std::unique_ptr< DataVsModelResiduals< typename std::remove_reference< DataType >::type, typename std::remove_reference< ModelType >::type, typename std::remove_reference< WeightType >::type, typename std::remove_reference< Comparator >::type > > createDataVsModelResiduals(DataType &&data, ModelType &&model, WeightType &&weight, Comparator &&comparator)
ModelFitting
Definition: AsinhChiSquareComparator.h:30
std::unordered_map< int, double >
std::numeric_limits
SourceXtractor::FlexibleModelFittingTask::m_modified_chi_squared_scale
double m_modified_chi_squared_scale
Definition: FlexibleModelFittingTask.h:82
DataVsModelResiduals.h
MeasurementFrameImages.h
LogChiSquareComparator.h
ImagePsf.h
SourceXtractor::FlexibleModelFittingTask::FlexibleModelFittingTask
FlexibleModelFittingTask(const std::string &least_squares_engine, unsigned int max_iterations, double modified_chi_squared_scale, std::vector< std::shared_ptr< FlexibleModelFittingParameter >> parameters, std::vector< std::shared_ptr< FlexibleModelFittingFrame >> frames, std::vector< std::shared_ptr< FlexibleModelFittingPrior >> priors, double scale_factor=1.0)
Definition: FlexibleModelFittingTask.cpp:107
FlexibleModelFittingParameterManager.h
SourceXtractor::LayerThresholdedImage
@ LayerThresholdedImage
Definition: Frame.h:40