LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
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)