LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
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