30 #include "lsst/afw/table/io/Persistable.cc" 46 if (i == _internal.end()) {
48 (
boost::format(
"Aperture correction with name '%s' not found") % name).
str());
55 if (i == _internal.end()) {
62 if (name.
size() > MAX_NAME_LENGTH) {
65 (
boost::format(
"Aperture correction name '%s' exceeds size limit of %d characters") % name %
74 struct PersistenceHelper {
76 table::Key<std::string>
name;
79 static PersistenceHelper
const&
get() {
80 static PersistenceHelper
const instance;
87 name(schema.addField<
std::string>(
"name",
"name of the aperture correction",
88 ApCorrMap::MAX_NAME_LENGTH)),
89 field(schema.addField<
int>(
"field",
"archive ID of the BoundedField object")) {
90 schema.getCitizen().markPersistent();
94 class ApCorrMapFactory :
public table::io::PersistableFactory {
97 CatalogVector
const& catalogs)
const override {
98 PersistenceHelper
const&
keys = PersistenceHelper::get();
104 result->set(i->get(keys.name), archive.get<math::BoundedField>(i->get(keys.field)));
109 ApCorrMapFactory(
std::string const&
name) : afw::table::io::PersistableFactory(name) {}
112 std::string getApCorrMapPersistenceName() {
return "ApCorrMap"; }
114 ApCorrMapFactory registration(getApCorrMapPersistenceName());
118 bool ApCorrMap::isPersistable() const noexcept {
120 if (!i->second->isPersistable())
return false;
125 std::string ApCorrMap::getPersistenceName()
const {
return getApCorrMapPersistenceName(); }
127 std::string ApCorrMap::getPythonModule()
const {
return "lsst.afw.image"; }
130 PersistenceHelper
const&
keys = PersistenceHelper::get();
134 record->set(keys.name, i->first);
135 record->set(keys.field, handle.
put(i->second));
143 replacement[i->first] = (*i->second) * scale;
145 _internal = replacement;
150 return std::make_unique<ApCorrMap>(*this);
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
An object passed to Persistable::write to allow it to persist itself.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Reports attempts to exceed implementation-defined length limits for some classes. ...
def scale(algorithm, min, max=None, frame=None)
daf::base::PropertySet * set
Reports attempts to access elements using an invalid key.
A base class for image defects.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
table::Key< std::string > name
CatalogIterator< typename Internal::const_iterator > const_iterator
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Image< LhsPixelT > & operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) where types are different.
Internal::const_iterator Iterator
Iterator type returned by begin() and end().
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.