33 #include "boost/format.hpp"
34 #include "boost/algorithm/string/trim.hpp"
39 namespace pexEx = lsst::pex::exceptions;
41 namespace lsst {
namespace afw {
namespace image {
46 std::string
const&
name,
49 ) :
_name(name), _lambdaEff(-1)
51 if (prop.
exists(
"lambdaEff")) {
64 ) :
_name(name), _lambdaEff(-1)
66 if (pol.
exists(
"lambdaEff")) {
86 if (keyVal->second == *
this) {
131 PropertyMap::iterator keyVal =
_propertyMap->find(name);
134 throw LSST_EXCEPT(pexEx::NotFoundError,
"Unable to find filter " + name);
137 return keyVal->second;
143 std::string
const unknownFilter =
"_unknown_";
153 std::string
const key =
"FILTER";
154 if( metadata->
exists(key) ) {
155 std::string filterName = boost::algorithm::trim_right_copy(metadata->
getAsString(key));
172 std::string key =
"FILTER";
173 if (metadata->
exists(key)) {
190 std::vector<std::string> names;
192 for (NameMap::const_iterator ptr =
_nameMap->begin(), end =
_nameMap->end(); ptr != end; ++ptr) {
193 if (ptr->first != unknownFilter) {
194 names.push_back(ptr->first);
197 std::sort(names.begin(), names.end());
252 NameMap::iterator keyVal =
_nameMap->find(name);
255 int oid = keyVal->second;
257 if (
id == oid ||
id ==
AUTO) {
262 throw LSST_EXCEPT(pexEx::RuntimeError,
"Filter " + name +
" is already defined");
273 _nameMap->insert(std::make_pair(name,
id));
274 _idMap->insert(std::make_pair(
id, name));
283 std::string
const& newName,
292 NameMap::iterator keyVal =
_nameMap->find(oldName);
294 throw LSST_EXCEPT(pexEx::NotFoundError,
"Unable to find filter " + oldName);
296 int const id = keyVal->second;
299 AliasMap::iterator aliasKeyVal =
_aliasMap->find(newName);
301 if (aliasKeyVal->second == oldName) {
306 throw LSST_EXCEPT(pexEx::NotFoundError,
"Filter " + newName +
" is already defined");
311 _aliasMap->insert(std::make_pair(newName, oldName));
327 NameMap::iterator keyVal =
_nameMap->find(name);
330 AliasMap::iterator aliasKeyVal =
_aliasMap->find(name);
332 return _lookup(aliasKeyVal->second);
338 throw LSST_EXCEPT(pexEx::NotFoundError,
"Unable to find filter " + name);
342 return keyVal->second;
354 IdMap::iterator keyVal =
_idMap->find(
id);
356 if (keyVal ==
_idMap->end()) {
360 return keyVal->second;
std::tr1::unordered_map< std::string const, std::string const > AliasMap
bool exists(const std::string &name) const
table::Key< std::string > name
bool operator==(Filter const &rhs) const
virtual void remove(std::string const &name)
std::string const & _name
std::tr1::unordered_map< std::string const, FilterProperty > PropertyMap
static NameMap * _nameMap
Include files required for standard LSST Exception handling.
void _insert(bool force=false)
static void _initRegistry()
a container for holding hierarchical configuration data in memory.
static int _lookup(std::string const &name, bool const force=false)
static PropertyMap * _propertyMap
FilterProperty const & getFilterProperty() const
table::Key< table::Array< Kernel::Pixel > > image
std::tr1::unordered_map< unsigned int const, std::string const > IdMap
static int define(FilterProperty const &filterProperty, int id=AUTO, bool force=false)
static FilterProperty const & lookup(std::string const &name)
static int defineAlias(std::string const &oldName, std::string const &newName, bool force=false)
Holds an integer identifier for an LSST filter.
#define LSST_EXCEPT(type,...)
FilterProperty(std::string const &name, double lambdaEff, bool force=false)
double getDouble(const std::string &name) const
double getAsDouble(std::string const &name) const
Class for storing generic metadata.
std::string getAsString(std::string const &name) const
static void _initRegistry()
static AliasMap * _aliasMap
int stripFilterKeywords(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
Filter(std::string const &name, bool const force=false)
bool operator==(FilterProperty const &rhs) const
std::tr1::unordered_map< std::string const, unsigned int const > NameMap
std::string const & getName() const
bool exists(std::string const &name) const
static std::vector< std::string > getNames()
Class encapsulating an identifier for an LSST filter.