LSST Applications g0f08755f38+82efc23009,g12f32b3c4e+e7bdf1200e,g1653933729+a8ce1bb630,g1a0ca8cf93+50eff2b06f,g28da252d5a+52db39f6a5,g2bbee38e9b+37c5a29d61,g2bc492864f+37c5a29d61,g2cdde0e794+c05ff076ad,g3156d2b45e+41e33cbcdc,g347aa1857d+37c5a29d61,g35bb328faa+a8ce1bb630,g3a166c0a6a+37c5a29d61,g3e281a1b8c+fb992f5633,g414038480c+7f03dfc1b0,g41af890bb2+11b950c980,g5fbc88fb19+17cd334064,g6b1c1869cb+12dd639c9a,g781aacb6e4+a8ce1bb630,g80478fca09+72e9651da0,g82479be7b0+04c31367b4,g858d7b2824+82efc23009,g9125e01d80+a8ce1bb630,g9726552aa6+8047e3811d,ga5288a1d22+e532dc0a0b,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+37c5a29d61,gcf0d15dbbd+2acd6d4d48,gd7358e8bfb+778a810b6e,gda3e153d99+82efc23009,gda6a2b7d83+2acd6d4d48,gdaeeff99f8+1711a396fd,ge2409df99d+6b12de1076,ge79ae78c31+37c5a29d61,gf0baf85859+d0a5978c5a,gf3967379c6+4954f8c433,gfb92a5be7c+82efc23009,gfec2e1e490+2aaed99252,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
observation.h
Go to the documentation of this file.
1#ifndef LSST_GAUSS2D_FIT_OBSERVATION_H
2#define LSST_GAUSS2D_FIT_OBSERVATION_H
3
4#include <memory>
5#include <stdexcept>
6
9
10#include "channel.h"
11#include "param_defs.h"
12#include "parametric.h"
13#include "util.h"
14
15namespace lsst::gauss2d::fit {
16
34template <typename T, typename I, typename M>
35class Observation : public Parametric {
36public:
39
49 std::shared_ptr<Mask> mask_inv, const Channel &channel = Channel::NONE())
50 : _image(std::move(image)),
51 _sigma_inv(std::move(sigma_inv)),
52 _mask_inv(std::move(mask_inv)),
53 _channel(channel) {
54 if ((_image == nullptr) || (_sigma_inv == nullptr) || (_mask_inv == nullptr)) {
55 throw std::invalid_argument("Must supply non-null image, variance and mask");
56 }
57 std::string msg;
58 bool passed = images_compatible<T, I, T, I>(*_image, *_sigma_inv, true, &msg);
59 passed &= images_compatible<T, I, bool, M>(*_image, *_mask_inv, true, &msg);
60 if (passed != (msg.empty()))
61 throw std::logic_error("Observation images_compatible=" + std::to_string(passed)
62 + " != msg != '' (=" + msg + ")");
63 if (!passed) throw std::invalid_argument("image/variance/mask incompatible: " + msg);
64 }
65
67 const Channel &get_channel() const { return _channel; }
72
74 size_t get_n_cols() const { return _image->get_n_cols(); }
76 size_t get_n_rows() const { return _image->get_n_rows(); }
77
79 Image &get_image() const { return *_image; }
81 Mask &get_mask_inverse() const { return *_mask_inv; }
83 Image &get_sigma_inverse() const { return *_sigma_inv; }
84
85 ParamRefs &get_parameters(ParamRefs &params, ParamFilter *filter = nullptr) const override {
86 return params;
87 }
88 ParamCRefs &get_parameters_const(ParamCRefs &params, ParamFilter *filter = nullptr) const override {
89 return params;
90 }
91
92 std::string repr(bool name_keywords = false,
93 std::string_view namespace_separator = Object::CC_NAMESPACE_SEPARATOR) const override {
94 return type_name_str<Observation>(false, namespace_separator) + ")" + (name_keywords ? "image=" : "")
95 + repr_ptr(_image.get(), name_keywords, namespace_separator) + ", "
96 + (name_keywords ? "sigma_inv=" : "")
97 + repr_ptr(_sigma_inv.get(), name_keywords, namespace_separator) + ", "
98 + (name_keywords ? "mask_inv=" : "")
99 + repr_ptr(_mask_inv.get(), name_keywords, namespace_separator) + ", "
100 + (name_keywords ? "channel=" : "") + _channel.repr(name_keywords, namespace_separator) + ")";
101 }
102 std::string str() const override {
103 return type_name_str<Observation>(true) + "(image=" + str_ptr(_image.get())
104 + ", sigma_inv=" + str_ptr(_sigma_inv.get()) + ", mask_inv=" + str_ptr(_mask_inv.get())
105 + ", channel=" + _channel.str() + ")";
106 }
107
108 bool operator==(const Observation &other) const {
109 return ((this->get_image() == other.get_image())
110 && (this->get_mask_inverse() == other.get_mask_inverse())
111 && (this->get_sigma_inverse() == other.get_sigma_inverse()));
112 }
113
114private:
116 std::shared_ptr<Image> _sigma_inv;
117 std::shared_ptr<Mask> _mask_inv;
118 const Channel &_channel;
119};
120
121} // namespace lsst::gauss2d::fit
122
123#endif
A 2D image with scalar numeric values, using CRTP.
Definition image.h:107
static constexpr std::string_view CC_NAMESPACE_SEPARATOR
The C++ namespace separator.
Definition object.h:45
An observational channel, usually representing some range of wavelengths of light.
Definition channel.h:29
static const Channel & NONE()
Definition channel.cc:111
std::string repr(bool name_keywords=false, std::string_view namespace_separator=Object::CC_NAMESPACE_SEPARATOR) const override
Return a full, callable string representation of this.
Definition channel.cc:99
std::string str() const override
Return a brief, human-readable string representation of this.
Definition channel.cc:104
An observed single-channel image with an associated variance and mask.
Definition observation.h:35
size_t get_n_rows() const
Get the number of rows in this->_image.
Definition observation.h:76
Observation(std::shared_ptr< Image > image, std::shared_ptr< Image > sigma_inv, std::shared_ptr< Mask > mask_inv, const Channel &channel=Channel::NONE())
Construct an Observation instance.
Definition observation.h:48
bool operator==(const Observation &other) const
const Channel & get_channel() const
Get this->_channel.
Definition observation.h:67
std::shared_ptr< const Image > get_sigma_inverse_ptr_const() const
Get this->_sigma_inv.
Definition observation.h:71
std::string repr(bool name_keywords=false, std::string_view namespace_separator=Object::CC_NAMESPACE_SEPARATOR) const override
Return a full, callable string representation of this.
Definition observation.h:92
size_t get_n_cols() const
Get the number of columns in this->_image.
Definition observation.h:74
Image & get_image() const
Get a ref to this->_image.
Definition observation.h:79
ParamRefs & get_parameters(ParamRefs &params, ParamFilter *filter=nullptr) const override
Add Parameter refs matching the filter to a vector, in order.
Definition observation.h:85
ParamCRefs & get_parameters_const(ParamCRefs &params, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
Definition observation.h:88
std::shared_ptr< const Image > get_image_ptr_const() const
Get this->_image.
Definition observation.h:69
Image & get_sigma_inverse() const
Get a ref to this->sigma_inv.
Definition observation.h:83
std::string str() const override
Return a brief, human-readable string representation of this.
Mask & get_mask_inverse() const
Get a ref to this->_mask.
Definition observation.h:81
A parametric object that can return and filter its Parameter instances.
Definition parametric.h:13
T empty(T... args)
std::string str_ptr(T ptr)
Definition object.h:132
std::string repr_ptr(T ptr, bool name_keywords, std::string_view namespace_separator)
Definition object.h:82
STL namespace.
Options for filtering Parameter instances.
T to_string(T... args)