LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Public Member Functions | Static Public Member Functions | Protected Types | List of all members
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. More...
 
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. More...
 

Protected Types

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

Detailed Description

Definition at line 370 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 414 of file CoaddPsf.cc.

414 : afw::table::io::PersistableFactory(name) {}
table::Key< std::string > name
Definition: Amplifier.cc:116

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,
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,
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 }
int end
#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.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ 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 373 of file CoaddPsf.cc.

373  {
374  if (catalogs.size() == 1u) {
375  // Old CoaddPsfs were saved in only one catalog, because we didn't
376  // save the warping parameters and average position, and we could
377  // save the coadd Wcs in a special final record.
378  return readV0(archive, catalogs);
379  }
380  LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
381  CoaddPsfPersistenceHelper const &keys1 = CoaddPsfPersistenceHelper::get();
382  LSST_ARCHIVE_ASSERT(catalogs.front().getSchema() == keys1.schema);
383  afw::table::BaseRecord const &record1 = catalogs.front().front();
385  new CoaddPsf(afw::table::ExposureCatalog::readFromArchive(archive, catalogs.back()),
386  *archive.get<afw::geom::SkyWcs>(record1.get(keys1.coaddWcs)),
387  record1.get(keys1.averagePosition), record1.get(keys1.warpingKernelName),
388  record1.get(keys1.cacheSize)));
389  }
#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:464
static ExposureCatalogT readFromArchive(io::InputArchive const &archive, BaseCatalog const &catalog)
Convenience input function for Persistables that contain an ExposureCatalog.
Definition: Exposure.cc:456
std::shared_ptr< afw::table::io::Persistable > readV0(InputArchive const &archive, CatalogVector const &catalogs) const
Definition: CoaddPsf.cc:396
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:141
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 396 of file CoaddPsf.cc.

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

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