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")) {}
92 class ApCorrMapFactory :
public table::io::PersistableFactory {
95 CatalogVector
const& catalogs)
const override {
96 PersistenceHelper
const&
keys = PersistenceHelper::get();
102 result->set(i->get(keys.name), archive.get<math::BoundedField>(i->get(keys.field)));
107 ApCorrMapFactory(
std::string const&
name) : afw::table::io::PersistableFactory(name) {}
110 std::string getApCorrMapPersistenceName() {
return "ApCorrMap"; }
112 ApCorrMapFactory registration(getApCorrMapPersistenceName());
116 bool ApCorrMap::isPersistable() const noexcept {
118 if (!i->second->isPersistable())
return false;
123 std::string ApCorrMap::getPersistenceName()
const {
return getApCorrMapPersistenceName(); }
125 std::string ApCorrMap::getPythonModule()
const {
return "lsst.afw.image"; }
128 PersistenceHelper
const&
keys = PersistenceHelper::get();
132 record->set(keys.name, i->first);
133 record->set(keys.field, handle.
put(i->second));
141 replacement[i->first] = (*i->second) * scale;
143 _internal = replacement;
148 return std::make_unique<ApCorrMap>(*this);
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...
table::Key< std::string > name
An object passed to Persistable::write to allow it to persist itself.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
def scale(algorithm, min, max=None, frame=None)
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
A base class for image defects.
std::unique_ptr< SchemaItem< U > > result
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,...)
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.
daf::base::PropertySet * set