LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
lsst::afw::image::ApCorrMap Class Reference

A thin wrapper around std::map to allow aperture corrections to be attached to Exposures. More...

#include <ApCorrMap.h>

Inheritance diagram for lsst::afw::image::ApCorrMap:
lsst::afw::table::io::PersistableFacade< ApCorrMap > lsst::afw::table::io::Persistable

Public Types

typedef Internal::const_iterator Iterator
 Iterator type returned by begin() and end(). Dereferences to a pair<string,PTR(BoundedField)>. More...
 

Public Member Functions

Iterator begin () const
 
Iterator end () const
 
std::size_t size () const
 
boost::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. More...
 
boost::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. More...
 
void set (std::string const &name, boost::shared_ptr< math::BoundedField > field)
 Add or replace an aperture correction. More...
 
virtual bool isPersistable () const
 Whether the map is persistable (true IFF all contained BoundedFields are persistable). More...
 
void operator*= (double const scale)
 Scale all fields by a constant. More...
 
void operator/= (double const scale)
 
- Public Member Functions inherited from lsst::afw::table::io::Persistable
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory. More...
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object. More...
 
virtual ~Persistable ()
 

Static Public Attributes

static std::size_t const MAX_NAME_LENGTH = 64
 Maximum number of characters for an aperture correction name (required for persistence). More...
 

Private Types

typedef std::map< std::string,
boost::shared_ptr
< math::BoundedField > > 
Internal
 

Private Member Functions

virtual std::string getPersistenceName () const
 Return the unique name used to persist this object and look up its factory. More...
 
virtual std::string getPythonModule () const
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More...
 
virtual void write (OutputArchiveHandle &handle) const
 Write the object to one or more catalogs. More...
 

Private Attributes

Internal _internal
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::afw::table::io::PersistableFacade< ApCorrMap >
static boost::shared_ptr
< ApCorrMap > 
readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static boost::shared_ptr
< ApCorrMap > 
readFits (std::string const &fileName, int hdu=0)
 Read an object from a regular FITS file. More...
 
static boost::shared_ptr
< ApCorrMap > 
readFits (fits::MemFileManager &manager, int hdu=0)
 Read an object from a FITS file in memory. More...
 
- Protected Types inherited from lsst::afw::table::io::Persistable
typedef io::OutputArchiveHandle OutputArchiveHandle
 
- Protected Member Functions inherited from lsst::afw::table::io::Persistable
 Persistable ()
 
 Persistable (Persistable const &other)
 
void operator= (Persistable const &other)
 

Detailed Description

A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.

ApCorrMap simply adds error handling accessors, persistence, and a bit of encapsulation to std::map (given the simplified interface, for instance, we could switch to unordered_map or some other underyling container in the future).

Definition at line 42 of file ApCorrMap.h.

Member Typedef Documentation

typedef std::map<std::string,boost::shared_ptr< math::BoundedField > > lsst::afw::image::ApCorrMap::Internal
private

Definition at line 43 of file ApCorrMap.h.

typedef Internal::const_iterator lsst::afw::image::ApCorrMap::Iterator

Iterator type returned by begin() and end(). Dereferences to a pair<string,PTR(BoundedField)>.

Definition at line 50 of file ApCorrMap.h.

Member Function Documentation

Iterator lsst::afw::image::ApCorrMap::begin ( ) const
inline

Definition at line 52 of file ApCorrMap.h.

52 { return _internal.begin(); }
Iterator lsst::afw::image::ApCorrMap::end ( ) const
inline

Definition at line 53 of file ApCorrMap.h.

53 { return _internal.end(); }
boost::shared_ptr< math::BoundedField > const lsst::afw::image::ApCorrMap::get ( std::string const &  name) const

Return the field with the given name, returning an empty pointer when the name is not present.

Definition at line 48 of file ApCorrMap.cc.

48  {
49  Iterator i = _internal.find(name);
50  if (i == _internal.end()) {
51  return PTR(math::BoundedField)();
52  }
53  return i->second;
54 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define PTR(...)
Definition: base.h:41
An abstract base class for 2-d functions defined on an integer bounding boxes.
Definition: BoundedField.h:49
Internal::const_iterator Iterator
Iterator type returned by begin() and end(). Dereferences to a pair&lt;string,PTR(BoundedField)&gt;.
Definition: ApCorrMap.h:50
std::string lsst::afw::image::ApCorrMap::getPersistenceName ( ) const
privatevirtual

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 131 of file ApCorrMap.cc.

131  {
132  return getApCorrMapPersistenceName();
133 }
std::string lsst::afw::image::ApCorrMap::getPythonModule ( ) const
privatevirtual

Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.

Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.

Will be ignored if empty.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 135 of file ApCorrMap.cc.

135  {
136  return "lsst.afw.image";
137 }
bool lsst::afw::image::ApCorrMap::isPersistable ( ) const
virtual

Whether the map is persistable (true IFF all contained BoundedFields are persistable).

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 124 of file ApCorrMap.cc.

124  {
125  for (Iterator i = begin(); i != end(); ++i) {
126  if (!i->second->isPersistable()) return false;
127  }
128  return true;
129 }
Iterator begin() const
Definition: ApCorrMap.h:52
Iterator end() const
Definition: ApCorrMap.h:53
Internal::const_iterator Iterator
Iterator type returned by begin() and end(). Dereferences to a pair&lt;string,PTR(BoundedField)&gt;.
Definition: ApCorrMap.h:50
void lsst::afw::image::ApCorrMap::operator*= ( double const  scale)

Scale all fields by a constant.

Definition at line 150 of file ApCorrMap.cc.

150  {
151  Internal replacement;
152  for (Iterator i = begin(); i != end(); ++i) {
153  replacement[i->first] = (*i->second)*scale;
154  }
155  _internal = replacement;
156 }
Iterator begin() const
Definition: ApCorrMap.h:52
Iterator end() const
Definition: ApCorrMap.h:53
Internal::const_iterator Iterator
Iterator type returned by begin() and end(). Dereferences to a pair&lt;string,PTR(BoundedField)&gt;.
Definition: ApCorrMap.h:50
std::map< std::string, boost::shared_ptr< math::BoundedField > > Internal
Definition: ApCorrMap.h:43
void lsst::afw::image::ApCorrMap::operator/= ( double const  scale)
inline

Definition at line 71 of file ApCorrMap.h.

71 { *this *= 1.0/scale; }
boost::shared_ptr< math::BoundedField > const lsst::afw::image::ApCorrMap::operator[] ( std::string const &  name) const

Return the field with the given name, throwing NotFoundError when the name is not present.

Definition at line 37 of file ApCorrMap.cc.

37  {
38  Iterator i = _internal.find(name);
39  if (i == _internal.end()) {
40  throw LSST_EXCEPT(
41  pex::exceptions::NotFoundError,
42  (boost::format("Aperture correction with name '%s' not found") % name).str()
43  );
44  }
45  return i->second;
46 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Internal::const_iterator Iterator
Iterator type returned by begin() and end(). Dereferences to a pair&lt;string,PTR(BoundedField)&gt;.
Definition: ApCorrMap.h:50
void lsst::afw::image::ApCorrMap::set ( std::string const &  name,
boost::shared_ptr< math::BoundedField field 
)

Add or replace an aperture correction.

Definition at line 56 of file ApCorrMap.cc.

56  {
57  if (name.size() > MAX_NAME_LENGTH) {
58  throw LSST_EXCEPT(
59  pex::exceptions::LengthError,
60  (boost::format("Aperture correction name '%s' exceeds size limit of %d characters")
61  % name % MAX_NAME_LENGTH).str()
62  );
63  }
64  _internal.insert(std::make_pair(name, field));
65 }
static std::size_t const MAX_NAME_LENGTH
Maximum number of characters for an aperture correction name (required for persistence).
Definition: ApCorrMap.h:47
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
table::Key< int > field
Definition: ApCorrMap.cc:72
std::size_t lsst::afw::image::ApCorrMap::size ( ) const
inline

Definition at line 55 of file ApCorrMap.h.

55 { return _internal.size(); }
void lsst::afw::image::ApCorrMap::write ( OutputArchiveHandle handle) const
privatevirtual

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 139 of file ApCorrMap.cc.

139  {
140  PersistenceHelper const & keys = PersistenceHelper::get();
141  table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
142  for (Iterator i = begin(); i != end(); ++i) {
143  PTR(table::BaseRecord) record = catalog.addNew();
144  record->set(keys.name, i->first);
145  record->set(keys.field, handle.put(i->second));
146  }
147  handle.saveCatalog(catalog);
148 }
Iterator begin() const
Definition: ApCorrMap.h:52
void set(std::string const &name, boost::shared_ptr< math::BoundedField > field)
Add or replace an aperture correction.
Definition: ApCorrMap.cc:56
table::Key< std::string > name
Definition: ApCorrMap.cc:71
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:61
#define PTR(...)
Definition: base.h:41
Iterator end() const
Definition: ApCorrMap.h:53
Internal::const_iterator Iterator
Iterator type returned by begin() and end(). Dereferences to a pair&lt;string,PTR(BoundedField)&gt;.
Definition: ApCorrMap.h:50
table::Key< int > field
Definition: ApCorrMap.cc:72

Member Data Documentation

Internal lsst::afw::image::ApCorrMap::_internal
private

Definition at line 81 of file ApCorrMap.h.

std::size_t const lsst::afw::image::ApCorrMap::MAX_NAME_LENGTH = 64
static

Maximum number of characters for an aperture correction name (required for persistence).

Definition at line 47 of file ApCorrMap.h.


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