32 #include "boost/format.hpp" 33 #include "boost/algorithm/string/trim.hpp" 44 FilterProperty::PropertyMap* FilterProperty::_propertyMap = NULL;
47 :
_name(name), _lambdaEff(NAN), _lambdaMin(NAN), _lambdaMax(NAN) {
48 if (prop.
exists(
"lambdaEff")) {
51 if (prop.
exists(
"lambdaMin")) {
54 if (prop.
exists(
"lambdaMax")) {
61 : _name(name), _lambdaEff(-1) {
62 if (pol.
exists(
"lambdaEff")) {
65 if (pol.
exists(
"lambdaMin")) {
68 if (pol.
exists(
"lambdaMax")) {
74 void FilterProperty::_insert(
bool force) {
79 PropertyMap::iterator keyVal = _propertyMap->
find(
getName());
81 if (keyVal != _propertyMap->
end()) {
82 if (keyVal->second == *
this) {
89 _propertyMap->
erase(keyVal);
97 void FilterProperty::_initRegistry() {
110 PropertyMap::iterator keyVal = _propertyMap->
find(name);
112 if (keyVal == _propertyMap->
end()) {
116 return keyVal->second;
128 if (metadata->exists(key)) {
129 std::string filterName = boost::algorithm::trim_right_copy(metadata->getAsString(key));
130 _id = _lookup(filterName, force);
140 if (metadata->exists(key)) {
141 metadata->remove(key);
153 std::string const& canonicalName = getCanonicalName();
154 for (AliasMap::iterator ptr = _aliasMap->begin(),
end = _aliasMap->end(); ptr !=
end; ++ptr) {
155 if (ptr->second == canonicalName) {
170 for (NameMap::const_iterator ptr = _nameMap->begin(),
end = _nameMap->end(); ptr !=
end; ++ptr) {
171 if (ptr->first != unknownFilter) {
182 void Filter::_initRegistry() {
208 NameMap::iterator keyVal = _nameMap->
find(name);
210 if (keyVal != _nameMap->end()) {
211 int oid = keyVal->second;
213 if (
id == oid ||
id == AUTO) {
220 _nameMap->erase(keyVal);
241 NameMap::iterator keyVal = _nameMap->find(oldName);
242 if (keyVal == _nameMap->end()) {
245 int const id = keyVal->second;
248 AliasMap::iterator aliasKeyVal = _aliasMap->find(newName);
249 if (aliasKeyVal != _aliasMap->end()) {
250 if (aliasKeyVal->second == oldName) {
257 _aliasMap->erase(aliasKeyVal);
270 NameMap::iterator keyVal = _nameMap->find(name);
272 if (keyVal == _nameMap->end()) {
273 AliasMap::iterator aliasKeyVal = _aliasMap->find(name);
274 if (aliasKeyVal != _aliasMap->end()) {
275 return _lookup(aliasKeyVal->second);
285 return keyVal->second;
293 IdMap::iterator keyVal = _idMap->find(
id);
295 if (keyVal == _idMap->end()) {
299 return keyVal->second;
305 int const id = _lookup(
_name,
true);
double getAsDouble(std::string const &name) const
bool operator==(FilterProperty const &rhs) const
Return true iff two FilterProperties are identical.
std::string const & _name
bool operator==(Filter const &rhs) const
Are two filters identical?
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
Rotation angle is unknown.
static FilterProperty const & lookup(std::string const &name)
Lookup the properties of a filter "name".
A base class for image defects.
bool exists(const std::string &name) const
static int define(FilterProperty const &filterProperty, int id=AUTO, bool force=false)
Define a filter name to have the specified id.
std::vector< std::string > getAliases() const
Return all aliases by which this filter is known.
bool exists(std::string const &name) const
std::string const & getName() const
Return a filter's name.
static int defineAlias(std::string const &oldName, std::string const &newName, bool force=false)
Define an alias for a filter.
Holds an integer identifier for an LSST filter.
double getDouble(const std::string &name) const
#define LSST_EXCEPT(type,...)
Filter(std::string const &name, bool const force=false)
Creates a Filter with the given name.
FilterProperty const & getFilterProperty() const
Return a Filter's FilterProperty.
Describe the properties of a Filter (e.g.
FilterProperty(std::string const &name, double lambdaEff, double lambdaMin=NAN, double lambdaMax=NAN, bool force=false)
static std::vector< std::string > getNames()
Return a list of known filters.