41 if (i == _internal.
end()) {
43 (boost::format(
"Aperture correction with name '%s' not found") % name).str());
50 if (i == _internal.
end()) {
60 (boost::format(
"Aperture correction name '%s' exceeds size limit of %d characters") % name %
69 struct PersistenceHelper {
71 table::Key<std::string>
name;
74 static PersistenceHelper
const&
get() {
75 static PersistenceHelper
const instance;
82 name(schema.addField<
std::string>(
"name",
"name of the aperture correction",
83 ApCorrMap::MAX_NAME_LENGTH)),
84 field(schema.addField<
int>(
"field",
"archive ID of the BoundedField object")) {
85 schema.getCitizen().markPersistent();
89 class ApCorrMapFactory :
public table::io::PersistableFactory {
92 CatalogVector
const& catalogs)
const {
93 PersistenceHelper
const& keys = PersistenceHelper::get();
99 result->set(i->get(keys.name), archive.get<math::BoundedField>(i->get(keys.field)));
104 ApCorrMapFactory(
std::string const&
name) : afw::table::io::PersistableFactory(name) {}
107 std::string getApCorrMapPersistenceName() {
return "ApCorrMap"; }
109 ApCorrMapFactory registration(getApCorrMapPersistenceName());
115 if (!i->second->isPersistable())
return false;
120 std::string ApCorrMap::getPersistenceName()
const {
return getApCorrMapPersistenceName(); }
122 std::string ApCorrMap::getPythonModule()
const {
return "lsst.afw.image"; }
125 PersistenceHelper
const& keys = PersistenceHelper::get();
129 record->set(keys.name, i->first);
130 record->set(keys.field, handle.
put(i->second));
138 replacement[i->first] = (*i->second) * scale;
140 _internal = replacement;
static std::size_t const MAX_NAME_LENGTH
Maximum number of characters for an aperture correction name (required for persistence).
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
std::shared_ptr< math::BoundedField > const get(std::string const &name) const
Return the field with the given name, returning an empty pointer when the name is not present...
virtual bool isPersistable() const
Whether the map is persistable (true IFF all contained BoundedFields are persistable).
An object passed to Persistable::write to allow it to persist itself.
A custom container class for records, based on std::vector.
#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)
ApCorrMap & operator*=(double const scale)
Scale all fields by a constant.
A base class for image defects.
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,...)
void set(std::string const &name, std::shared_ptr< math::BoundedField > field)
Add or replace an aperture correction.
Internal::const_iterator Iterator
Iterator type returned by begin() and end().
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
std::shared_ptr< math::BoundedField > const operator[](std::string const &name) const
Return the field with the given name, throwing NotFoundError when the name is not present...
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.