LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Color.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * Capture the colour of an object
4  */
5 
6 #ifndef LSST_AFW_IMAGE_COLOR_H
7 #define LSST_AFW_IMAGE_COLOR_H
8 
9 #include <cmath>
10 #include <limits>
11 #include "lsst/afw/image/Filter.h"
12 
13 namespace lsst {
14 namespace afw {
15 namespace image {
16 
26 class Color final {
27 public:
28  explicit Color(double g_r = std::numeric_limits<double>::quiet_NaN()) : _g_r(g_r) {}
29 
30  Color(Color const &) = default;
31  Color(Color &&) = default;
32  Color &operator=(Color const &) = default;
33  Color &operator=(Color &&) = default;
34  ~Color() noexcept = default;
35 
37  bool isIndeterminate() const noexcept { return std::isnan(_g_r); }
38 
40 
50  bool operator==(Color const &other) const noexcept {
51  return (isIndeterminate() && other.isIndeterminate()) || other._g_r == _g_r;
52  }
53  bool operator!=(Color const &other) const noexcept { return !operator==(other); }
55 
57  std::size_t hash_value() const noexcept { return isIndeterminate() ? 42 : std::hash<double>()(_g_r); }
58 
61  [
62  [deprecated("Removed with no replacement (but see lsst::afw::image::TransmissionCurve). Will be "
63  "removed after v22.")]] double
65  ) const {
66  return 1000 * _g_r;
67  }
68 
69 private:
70  double _g_r;
71 };
72 } // namespace image
73 } // namespace afw
74 } // namespace lsst
75 
76 namespace std {
77 template <>
78 struct hash<lsst::afw::image::Color> {
81  size_t operator()(argument_type const &obj) const noexcept { return obj.hash_value(); }
82 };
83 } // namespace std
84 
85 #endif
Describe the colour of a source.
Definition: Color.h:26
Color & operator=(Color const &)=default
bool operator==(Color const &other) const noexcept
Equality comparison for colors.
Definition: Color.h:50
Color(Color &&)=default
~Color() noexcept=default
Color(double g_r=std::numeric_limits< double >::quiet_NaN())
Definition: Color.h:28
Color(Color const &)=default
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Color.h:57
Color & operator=(Color &&)=default
bool isIndeterminate() const noexcept
Whether the color is the special value that indicates that it is unspecified.
Definition: Color.h:37
double getLambdaEff(Filter const &) const
Return the effective wavelength for this object in the given filter.
Definition: Color.h:64
bool operator!=(Color const &other) const noexcept
Definition: Color.h:53
T isnan(T... args)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
class[[deprecated("Removed with no replacement (but see lsst::afw::image::TransmissionCurve). Will be " "removed after v22.")]] FilterProperty final
Describe the properties of a Filter (e.g.
Definition: Filter.h:53
A base class for image defects.
STL namespace.
size_t operator()(argument_type const &obj) const noexcept
Definition: Color.h:81