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);
96 return (_lambdaEff == rhs._lambdaEff);
99 void FilterProperty::_initRegistry() {
112 PropertyMap::iterator keyVal = _propertyMap->
find(name);
114 if (keyVal == _propertyMap->
end()) {
118 return keyVal->second;
130 if (metadata->exists(key)) {
131 std::string filterName = boost::algorithm::trim_right_copy(metadata->getAsString(key));
132 _id = _lookup(filterName, force);
142 if (metadata->exists(key)) {
143 metadata->remove(key);
155 std::string const& canonicalName = getCanonicalName();
156 for (AliasMap::iterator ptr = _aliasMap->begin(),
end = _aliasMap->end(); ptr !=
end; ++ptr) {
157 if (ptr->second == canonicalName) {
172 for (NameMap::const_iterator ptr = _nameMap->begin(),
end = _nameMap->end(); ptr !=
end; ++ptr) {
173 if (ptr->first != unknownFilter) {
184 void Filter::_initRegistry() {
210 NameMap::iterator keyVal = _nameMap->
find(name);
212 if (keyVal != _nameMap->end()) {
213 int oid = keyVal->second;
215 if (
id == oid ||
id == AUTO) {
222 _nameMap->erase(keyVal);
243 NameMap::iterator keyVal = _nameMap->find(oldName);
244 if (keyVal == _nameMap->end()) {
247 int const id = keyVal->second;
250 AliasMap::iterator aliasKeyVal = _aliasMap->find(newName);
251 if (aliasKeyVal != _aliasMap->end()) {
252 if (aliasKeyVal->second == oldName) {
259 _aliasMap->erase(aliasKeyVal);
272 NameMap::iterator keyVal = _nameMap->find(name);
274 if (keyVal == _nameMap->end()) {
275 AliasMap::iterator aliasKeyVal = _aliasMap->find(name);
276 if (aliasKeyVal != _aliasMap->end()) {
277 return _lookup(aliasKeyVal->second);
287 return keyVal->second;
295 IdMap::iterator keyVal = _idMap->find(
id);
297 if (keyVal == _idMap->end()) {
301 return keyVal->second;
307 int const id = _lookup(_name,
true);
double getAsDouble(std::string const &name) const
bool operator==(Filter const &rhs) const noexcept
Are two filters identical?
std::string const & getName() const noexcept
Return a filter's name.
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
bool operator==(FilterProperty const &rhs) const noexcept
Return true iff two FilterProperties are identical.
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
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.