SourceXtractorPlusPlus  0.16
Please provide a description of the project.
SourcePsfTaskFactory.cpp
Go to the documentation of this file.
1 
20 
21 namespace SourceXtractor {
22 
26 }
27 
29  auto psf_config = manager.getConfiguration<PsfPluginConfig>();
30  auto measurement_config = manager.getConfiguration<MeasurementImageConfig>();
31 
32  const auto& default_psf = psf_config.getPsf();
33  const auto& image_infos = manager.getConfiguration<MeasurementImageConfig>().getImageInfos();
34 
35  for (unsigned int i = 0; i < image_infos.size(); i++) {
36  if (!image_infos[i].m_psf_path.empty()) {
37  m_vpsf[image_infos[i].m_id] = PsfPluginConfig::readPsf(image_infos[i].m_psf_path, image_infos[i].m_psf_hdu);
38  }
39  else if (default_psf) {
40  m_vpsf[image_infos[i].m_id] = default_psf;
41  }
42  }
43 
44  for (auto& vpsf : m_vpsf) {
45  if (!vpsf.second) {
46  throw Elements::Exception() << "Missing PSF. Make sure every frame has a PSF, or that there is a valid default PSF";
47  }
48  }
49 }
50 
52  auto instance = property_id.getIndex();
53 
54  if (m_vpsf.find(instance) == m_vpsf.end() || !m_vpsf.at(instance)) {
55  throw Elements::Exception() << "Missing PSF. Make sure every frame has a PSF";
56  }
57 
58  try {
59  return std::make_shared<SourcePsfTask>(instance, m_vpsf.at(instance));
60  } catch (const std::out_of_range&) {
61  return nullptr;
62  }
63 }
64 
65 } // end SourceXtractor
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
unsigned int getIndex() const
Definition: PropertyId.h:70
static std::shared_ptr< Psf > readPsf(const std::string &filename, int hdu_number=1)
std::shared_ptr< Task > createTask(const PropertyId &property_id) const override
Returns a Task producing a Property corresponding to the given PropertyId.
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
std::map< int, std::shared_ptr< Psf > > m_vpsf
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.