lsst.afw  14.0-25-g0e8fc950e+7
Filter.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 //
26 //##====---------------- ----------------====##/
27 //
28 // Class encapsulating an identifier for an LSST filter.
29 //
30 //##====---------------- ----------------====##/
31 
32 #ifndef LSST_AFW_IMAGE_FILTER_H
33 #define LSST_AFW_IMAGE_FILTER_H
34 
35 #include <string>
36 #include <unordered_map>
37 #include <vector>
38 #include <memory>
39 #include "lsst/base.h"
40 #include "lsst/pex/policy/Policy.h"
41 
42 namespace lsst {
43 namespace daf {
44 namespace base {
45 class PropertySet;
46 }
47 }
48 
49 namespace afw {
50 namespace image {
51 
56 public:
57  explicit FilterProperty(std::string const& name, double lambdaEff, bool force = false)
58  : _name(name), _lambdaEff(lambdaEff) {
59  _insert(force);
60  }
66  explicit FilterProperty(std::string const& name,
68  bool force = false);
76  explicit FilterProperty(std::string const& name, lsst::pex::policy::Policy const& pol,
77  bool force = false);
81  std::string const& getName() const { return _name; }
85  double getLambdaEff() const { return _lambdaEff; }
91  bool operator==(FilterProperty const& rhs) const;
95  bool operator!=(FilterProperty const& rhs
96  ) const {
97  return !(*this == rhs);
98  }
102  static void reset() { _initRegistry(); }
103 
109  static FilterProperty const& lookup(std::string const& name);
110 
111 private:
113 
117  static void _initRegistry();
123  void _insert(bool force = false);
124 
125  std::string _name; // name of filter
126  double _lambdaEff; // effective wavelength (nm)
127 
128  static PropertyMap* _propertyMap; // mapping from name -> FilterProperty
129 };
130 
134 class Filter {
135 public:
136  static int const AUTO;
137  static int const UNKNOWN;
138 
142  explicit Filter(std::string const& name,
143  bool const force = false
144  )
145  : _id(_lookup(name, force)), _name(name) {}
149  explicit Filter(int id = UNKNOWN
150  )
151  : _id(id), _name(_lookup(id)) {}
158  explicit Filter(std::shared_ptr<lsst::daf::base::PropertySet const>, bool const force = false);
159 
163  bool operator==(Filter const& rhs) const;
164  bool operator!=(Filter const& rhs) const { return !(*this == rhs); }
165 
169  int getId() const { return _id; }
173  std::string const& getName() const { return _name; }
179  std::string const& getCanonicalName() const { return _lookup(_id); }
185  std::vector<std::string> getAliases() const;
186 
190  FilterProperty const& getFilterProperty() const;
194  static void reset() { _initRegistry(); }
202  static int define(FilterProperty const& filterProperty, int id = AUTO, bool force = false);
210  static int defineAlias(std::string const& oldName, std::string const& newName, bool force = false);
211 
215  static std::vector<std::string> getNames();
216 
217 private:
221 
225  static void _initRegistry();
232  static int _lookup(std::string const& name, bool const force = false);
236  static std::string const& _lookup(int id);
237 
238  int _id;
240 
241  static int _id0; // next Id to use
242  static AliasMap* _aliasMap; // mapping from alias -> name
243  static IdMap* _idMap; // mapping from id -> name
244  static NameMap* _nameMap; // mapping from name -> id
245 };
246 
247 namespace detail {
255 }
256 }
257 }
258 } // lsst::afw::image
259 
260 #endif // LSST_AFW_IMAGE_FILTER_H
std::string const & getCanonicalName() const
Return a filter&#39;s canonical name.
Definition: Filter.h:179
static void reset()
Clear all definitions.
Definition: Filter.h:102
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool operator!=(Filter const &rhs) const
Definition: Filter.h:164
std::string const & _name
Definition: Mask.cc:566
int getId() const
Return a Filter&#39;s integral id.
Definition: Filter.h:169
static int const UNKNOWN
Definition: Filter.h:137
bool operator==(CoordKey const &lhs, CoordKey const &rhs)
Compare CoordKeys for equality using the constituent Keys.
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
Definition: Filter.cc:123
STL class.
double getLambdaEff() const
Return the filter&#39;s effective wavelength (nm)
Definition: Filter.h:85
A base class for image defects.
int _id
Definition: Mask.cc:567
static int const AUTO
Definition: Filter.h:136
std::string const & getName() const
Return a filter&#39;s name.
Definition: Filter.h:81
Holds an integer identifier for an LSST filter.
Definition: Filter.h:134
FilterProperty(std::string const &name, double lambdaEff, bool force=false)
Definition: Filter.h:57
std::string const & getName() const
Return a Filter&#39;s name.
Definition: Filter.h:173
bool operator!=(FilterProperty const &rhs) const
Return true iff rhs != this.
Definition: Filter.h:95
Filter(int id=UNKNOWN)
Creates a Filter with the given identifier.
Definition: Filter.h:149
Filter(std::string const &name, bool const force=false)
Creates a Filter with the given name.
Definition: Filter.h:142
Describe the properties of a Filter (e.g.
Definition: Filter.h:55
static void reset()
Clear all definitions.
Definition: Filter.h:194