LSST Applications g0265f82a02+c6dfa2ddaf,g1162b98a3f+b2075782a9,g2079a07aa2+1b2e822518,g2bbee38e9b+c6dfa2ddaf,g337abbeb29+c6dfa2ddaf,g3ddfee87b4+a60788ef87,g50ff169b8f+2eb0e556e8,g52b1c1532d+90ebb246c7,g555ede804d+a60788ef87,g591dd9f2cf+ba8caea58f,g5ec818987f+864ee9cddb,g858d7b2824+9ee1ab4172,g876c692160+a40945ebb7,g8a8a8dda67+90ebb246c7,g8cdfe0ae6a+4fd9e222a8,g99cad8db69+5e309b7bc6,g9ddcbc5298+a1346535a5,ga1e77700b3+df8f93165b,ga8c6da7877+aa12a14d27,gae46bcf261+c6dfa2ddaf,gb0e22166c9+8634eb87fb,gb3f2274832+d0da15e3be,gba4ed39666+1ac82b564f,gbb8dafda3b+5dfd9c994b,gbeb006f7da+97157f9740,gc28159a63d+c6dfa2ddaf,gc86a011abf+9ee1ab4172,gcf0d15dbbd+a60788ef87,gdaeeff99f8+1cafcb7cd4,gdc0c513512+9ee1ab4172,ge79ae78c31+c6dfa2ddaf,geb67518f79+ba1859f325,geb961e4c1e+f9439d1e6f,gee10cc3b42+90ebb246c7,gf1cff7945b+9ee1ab4172,w.2024.12
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Types | List of all members
lsst::afw::math::LinearCombinationKernel::Factory Class Reference
Inheritance diagram for lsst::afw::math::LinearCombinationKernel::Factory:
lsst::afw::table::io::PersistableFactory

Public Member Functions

std::shared_ptr< afw::table::io::Persistableread (InputArchive const &archive, CatalogVector const &catalogs) const override
 Construct a new object from the given InputArchive and vector of catalogs.
 
 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 325 of file LinearCombinationKernel.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::afw::math::LinearCombinationKernel::Factory::Factory ( std::string const & name)
inlineexplicit

Definition at line 354 of file LinearCombinationKernel.cc.

354: 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}
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.

◆ read()

std::shared_ptr< afw::table::io::Persistable > lsst::afw::math::LinearCombinationKernel::Factory::read ( InputArchive const & archive,
CatalogVector const & catalogs ) const
inlineoverridevirtual

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

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

Definition at line 327 of file LinearCombinationKernel.cc.

328 {
329 LSST_ARCHIVE_ASSERT(catalogs.size() == 1u);
330 LSST_ARCHIVE_ASSERT(catalogs.front().size() == 1u);
331 LinearCombinationKernelPersistenceHelper const keys(catalogs.front().getSchema());
332 afw::table::BaseRecord const &record = catalogs.front().front();
333 lsst::geom::Extent2I dimensions(record.get(keys.dimensions));
334 std::vector<std::shared_ptr<Kernel>> componentList(keys.components.getSize());
335 for (std::size_t i = 0; i < componentList.size(); ++i) {
336 componentList[i] = archive.get<Kernel>(record[keys.components[i]]);
337 }
339 if (keys.spatialFunctions.isValid()) {
340 std::vector<SpatialFunctionPtr> spatialFunctionList = keys.readSpatialFunctions(archive, record);
341 result.reset(new LinearCombinationKernel(componentList, spatialFunctionList));
342 } else {
343 std::vector<double> kernelParameters(keys.amplitudes.getSize());
344 for (std::size_t i = 0; i < kernelParameters.size(); ++i) {
345 kernelParameters[i] = record[keys.amplitudes[i]];
346 }
347 result.reset(new LinearCombinationKernel(componentList, kernelParameters));
348 }
349 LSST_ARCHIVE_ASSERT(result->getDimensions() == dimensions);
350 result->setCtr(record.get(keys.center));
351 return result;
352 }
py::object result
Definition _schema.cc:429
afw::table::PointKey< int > dimensions
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition Persistable.h:48
Kernel()
Construct a null Kernel of size 0,0.
Definition Kernel.cc:49
LinearCombinationKernel()
Construct an empty LinearCombinationKernel of size 0x0.

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