Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+cc8870d3f5,g07dc498a13+5aa0b8792f,g0fba68d861+80045be308,g1409bbee79+5aa0b8792f,g1a7e361dbc+5aa0b8792f,g1fd858c14a+f64bc332a9,g208c678f98+1ae86710ed,g35bb328faa+fcb1d3bbc8,g4d2262a081+47ad8a29a8,g4d39ba7253+9633a327c1,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+9633a327c1,g668ecb457e+25d63fd678,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+8b64ca622a,g89139ef638+5aa0b8792f,g89e1512fd8+04325574d3,g8d6b6b353c+9633a327c1,g9125e01d80+fcb1d3bbc8,g989de1cb63+5aa0b8792f,g9f33ca652e+b196626af7,ga9baa6287d+9633a327c1,gaaedd4e678+5aa0b8792f,gabe3b4be73+1e0a283bba,gb1101e3267+71e32094df,gb58c049af0+f03b321e39,gb90eeb9370+2807b1ad02,gcf25f946ba+8b64ca622a,gd315a588df+a39986a76f,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+4e42d81ab7,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,gfe73954cf8+a1301e4c20,w.2025.11
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)