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