LSST Applications g1653933729+34a971ddd9,g1a997c3884+34a971ddd9,g2160c40384+da0d0eec6b,g28da252d5a+cb6ff358b6,g2bbee38e9b+e5a1bc5b38,g2bc492864f+e5a1bc5b38,g2ca4be77d2+2af33ed832,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+e5a1bc5b38,g35bb328faa+34a971ddd9,g3a166c0a6a+e5a1bc5b38,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9f5be647b3,g41af890bb2+f34483f65b,g5065538af8+53fd6e9482,g5a0bb5165c+1b31a0decc,g717e5f8c0f+19a1ad098c,g80478fca09+1acdc24a0d,g8204df1d8d+19a1ad098c,g82479be7b0+44a04e1d61,g858d7b2824+19a1ad098c,g9125e01d80+34a971ddd9,ga5288a1d22+ad6d5da1a4,gae0086650b+34a971ddd9,gb58c049af0+ace264a4f2,gbd397ab92a+d5fd0218dc,gc28159a63d+e5a1bc5b38,gcf0d15dbbd+618cb38075,gd6b7c0dfd1+3388d854ad,gda6a2b7d83+618cb38075,gdaeeff99f8+7774323b41,ge2409df99d+8082276ac0,ge33fd446bb+19a1ad098c,ge79ae78c31+e5a1bc5b38,gf0baf85859+890af219f9,gf5289d68f6+701f7b396a,w.2024.37
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)