LSST Applications g0fba68d861+05a5e06e50,g1fd858c14a+904f1f4196,g2c84ff76c0+247cd845a2,g2c9e612ef2+f5117f1d55,g35bb328faa+fcb1d3bbc8,g4af146b050+123c2f4d45,g4d2262a081+a9e7a6e053,g4e0f332c67+c58e4b632d,g53246c7159+fcb1d3bbc8,g5a012ec0e7+ac98094cfc,g60b5630c4e+f5117f1d55,g67b6fd64d1+dd0349c22b,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g87b7deb4dc+2a1aa4536a,g8852436030+d21aad2af4,g89139ef638+dd0349c22b,g8d6b6b353c+f5117f1d55,g9125e01d80+fcb1d3bbc8,g989de1cb63+dd0349c22b,g9f33ca652e+0a580a37dd,g9f7030ddb1+ae84e0d5a5,ga2b97cdc51+f5117f1d55,gabe3b4be73+1e0a283bba,gb1101e3267+1d994e7598,gb58c049af0+f03b321e39,gb89ab40317+dd0349c22b,gcca6a94b71+4ed007ada1,gcf25f946ba+d21aad2af4,gd315a588df+9d9c5ccff1,gd6cbbdb0b4+75aa4b1db4,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+6fce216140,ge278dab8ac+c61fbefdff,ge410e46f29+dd0349c22b,ge82c20c137+e12a08b75a,gf67bdafdda+dd0349c22b,v28.0.2.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst::meas::algorithms::CoaddPsf::Factory Class Reference
Inheritance diagram for lsst::meas::algorithms::CoaddPsf::Factory:
lsst::afw::table::io::PersistableFactory

Public Member Functions

virtual std::shared_ptr< afw::table::io::Persistableread (InputArchive const &archive, CatalogVector const &catalogs) const
 Construct a new object from the given InputArchive and vector of catalogs.
 
std::shared_ptr< afw::table::io::PersistablereadV0 (InputArchive const &archive, CatalogVector const &catalogs) const
 
 Factory (std::string const &name)
 

Static Public Member Functions

static PersistableFactory const & lookup (std::string const &name, std::string const &module="")
 Return the factory that has been registered with the given name.
 

Protected Types

using InputArchive = io::InputArchive
 
using CatalogVector = io::CatalogVector
 

Detailed Description

Definition at line 375 of file CoaddPsf.cc.

Member Typedef Documentation

◆ CatalogVector

using lsst::afw::table::io::PersistableFactory::CatalogVector = io::CatalogVector
protectedinherited

Definition at line 231 of file Persistable.h.

◆ InputArchive

using lsst::afw::table::io::PersistableFactory::InputArchive = io::InputArchive
protectedinherited

Definition at line 230 of file Persistable.h.

Constructor & Destructor Documentation

◆ Factory()

lsst::meas::algorithms::CoaddPsf::Factory::Factory ( std::string const & name)
inline

Definition at line 419 of file CoaddPsf.cc.

419: afw::table::io::PersistableFactory(name) {}

Member Function Documentation

◆ lookup()

PersistableFactory const & lsst::afw::table::io::PersistableFactory::lookup ( std::string const & name,
std::string const & module = "" )
staticinherited

Return the factory that has been registered with the given name.

If the lookup fails and module is not an empty string, we will attempt to import a Python module with that name (this will only work when the C++ is being called from Python) and try again.

Definition at line 76 of file Persistable.cc.

76 {
77 RegistryMap::const_iterator i = getRegistry().find(name);
78 if (i == getRegistry().end()) {
79 if (!module.empty()) {
80 bool success = base::ModuleImporter::import(module);
81 if (!success) {
82 throw LSST_EXCEPT(
83 pex::exceptions::NotFoundError,
84 (boost::format(
85 "PersistableFactory with name '%s' not found, and import of module "
86 "'%s' failed (possibly because Python calls were not available from C++).") %
87 name % module)
88 .str());
89 }
90 i = getRegistry().find(name);
91 if (i == getRegistry().end()) {
92 throw LSST_EXCEPT(
93 pex::exceptions::LogicError,
94 (boost::format(
95 "PersistableFactory with name '%s' not found even after successful import "
96 "of module '%s'. Please report this as a bug in the persistence "
97 "implementation for this object.") %
98 name % module)
99 .str());
100 }
101 } else {
102 throw LSST_EXCEPT(
103 pex::exceptions::LogicError,
104 (boost::format(
105 "PersistableFactory with name '%s' not found, and no Python module to import "
106 "was provided. Please report this as a bug in the persistence implementation "
107 "for this object.") %
108 name)
109 .str());
110 }
111 }
112 return *i->second;
113}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
static bool import(std::string const &name)
Import the given Python module, and return true if successful.
T end(T... args)

◆ read()

virtual std::shared_ptr< afw::table::io::Persistable > lsst::meas::algorithms::CoaddPsf::Factory::read ( InputArchive const & archive,
CatalogVector const & catalogs ) const
inlinevirtual

Construct a new object from the given InputArchive and vector of catalogs.

Implements lsst::afw::table::io::PersistableFactory.

Definition at line 378 of file CoaddPsf.cc.

378 {
379 if (catalogs.size() == 1u) {
380 // Old CoaddPsfs were saved in only one catalog, because we didn't
381 // save the warping parameters and average position, and we could
382 // save the coadd Wcs in a special final record.
383 return readV0(archive, catalogs);
384 }
385 LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
386 CoaddPsfPersistenceHelper const &keys1 = CoaddPsfPersistenceHelper::get();
387 LSST_ARCHIVE_ASSERT(catalogs.front().getSchema() == keys1.schema);
388 afw::table::BaseRecord const &record1 = catalogs.front().front();
389 return std::shared_ptr<CoaddPsf>(
391 *archive.get<afw::geom::SkyWcs>(record1.get(keys1.coaddWcs)),
392 record1.get(keys1.averagePosition), record1.get(keys1.warpingKernelName),
393 record1.get(keys1.cacheSize)));
394 }
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition Persistable.h:48
std::shared_ptr< RecordT > const get(size_type i) const
Return a pointer to the record at index i.
Definition Catalog.h:463
static ExposureCatalogT readFromArchive(io::InputArchive const &archive, BaseCatalog const &catalog)
std::shared_ptr< afw::table::io::Persistable > readV0(InputArchive const &archive, CatalogVector const &catalogs) const
Definition CoaddPsf.cc:401
CoaddPsf(afw::table::ExposureCatalog const &catalog, afw::geom::SkyWcs const &coaddWcs, std::string const &weightFieldName="weight", std::string const &warpingKernelName="lanczos3", int cacheSize=10000)
Main constructors for CoaddPsf.
Definition CoaddPsf.cc:142
T get(T... args)

◆ readV0()

std::shared_ptr< afw::table::io::Persistable > lsst::meas::algorithms::CoaddPsf::Factory::readV0 ( InputArchive const & archive,
CatalogVector const & catalogs ) const
inline

Definition at line 401 of file CoaddPsf.cc.

402 {
403 auto internalCat = afw::table::ExposureCatalog::readFromArchive(archive, catalogs.front());
404 // Coadd WCS is stored in a special last record.
405 auto coaddWcs = internalCat.back().getWcs();
406 internalCat.pop_back();
407 // Attempt to reconstruct the average position. We can't do this
408 // exactly, since the catalog we saved isn't the same one that was
409 // used to compute the original average position.
410 afw::table::Key<double> weightKey;
411 try {
412 weightKey = internalCat.getSchema()["weight"];
413 } catch (pex::exceptions::NotFoundError &) {
414 }
415 auto averagePos = computeAveragePosition(internalCat, *coaddWcs, weightKey);
416 return std::shared_ptr<CoaddPsf>(new CoaddPsf(internalCat, *coaddWcs, averagePos));
417 }

The documentation for this class was generated from the following file: