Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0fba68d861+aa97b6e50c,g1ec0fe41b4+f536777771,g1fd858c14a+a9301854fb,g35bb328faa+fcb1d3bbc8,g4af146b050+a5c07d5b1d,g4d2262a081+78f4f01b60,g53246c7159+fcb1d3bbc8,g56a49b3a55+9c12191793,g5a012ec0e7+3632fc3ff3,g60b5630c4e+ded28b650d,g67b6fd64d1+ed4b5058f4,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g8352419a5c+fcb1d3bbc8,g87b7deb4dc+7b42cf88bf,g8852436030+e5453db6e6,g89139ef638+ed4b5058f4,g8e3bb8577d+d38d73bdbd,g9125e01d80+fcb1d3bbc8,g94187f82dc+ded28b650d,g989de1cb63+ed4b5058f4,g9d31334357+ded28b650d,g9f33ca652e+50a8019d8c,gabe3b4be73+1e0a283bba,gabf8522325+fa80ff7197,gb1101e3267+d9fb1f8026,gb58c049af0+f03b321e39,gb89ab40317+ed4b5058f4,gcf25f946ba+e5453db6e6,gcf6002c91b+2a0c9e9e84,gd6cbbdb0b4+bb83cc51f8,gdd1046aedd+ded28b650d,gde0f65d7ad+66b3a48cb7,ge278dab8ac+d65b3c2b70,ge410e46f29+ed4b5058f4,gf23fb2af72+b7cae620c0,gf5e32f922b+fcb1d3bbc8,gf67bdafdda+ed4b5058f4,w.2025.16
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
size_t get_n_rows() const
Get the number of rows in this->_image.
Definition observation.h:76
lsst::gauss2d::Image< bool, M > Mask
Definition observation.h:38
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.
lsst::gauss2d::Image< T, I > Image
Definition observation.h:37
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::vector< ParamBaseRef > ParamRefs
Definition param_defs.h:13
std::vector< ParamBaseCRef > ParamCRefs
Definition param_defs.h:11
std::string str_ptr(T ptr)
Definition object.h:132
std::string type_name_str(bool strip_namespace=false, std::string_view namespace_str=detail::NAMESPACE_SEPARATOR)
Get a string representation of an arbitrary C++ type, potentially modifying its namespace prefix.
Definition type_name.h:104
std::string repr_ptr(T ptr, bool name_keywords, std::string_view namespace_separator)
Definition object.h:82
bool images_compatible(const Image< T1, C1 > &img1, const Image< T2, C2 > &img2, bool compare_coordsys=true, std::string *msg=nullptr)
Return if two images are compatible.
Definition image.h:70
STL namespace.
Options for filtering Parameter instances.
T to_string(T... args)