1#ifndef LSST_GAUSS2D_FIT_OBSERVATION_H
2#define LSST_GAUSS2D_FIT_OBSERVATION_H
7#include "lsst/gauss2d/image.h"
8#include "lsst/gauss2d/type_name.h"
11#include "param_defs.h"
12#include "parametric.h"
15namespace lsst::gauss2d::fit {
34template <
typename T,
typename I,
typename M>
37 using Image = lsst::gauss2d::Image<T, I>;
38 using Mask = lsst::gauss2d::Image<bool, M>;
48 explicit Observation(std::shared_ptr<Image> image, std::shared_ptr<Image> sigma_inv,
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)),
54 if ((_image ==
nullptr) || (_sigma_inv ==
nullptr) || (_mask_inv ==
nullptr)) {
55 throw std::invalid_argument(
"Must supply non-null image, variance and mask");
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);
74 size_t get_n_cols()
const {
return _image->get_n_cols(); }
76 size_t get_n_rows()
const {
return _image->get_n_rows(); }
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) +
")";
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() +
")";
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()));
115 std::shared_ptr<Image> _image;
116 std::shared_ptr<Image> _sigma_inv;
117 std::shared_ptr<Mask> _mask_inv;
118 const Channel &_channel;
An observational channel, usually representing some range of wavelengths of light.
Definition channel.h:29
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())
Definition observation.h:48
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
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 ¶ms, ParamFilter *filter=nullptr) const override
Definition observation.h:85
ParamCRefs & get_parameters_const(ParamCRefs ¶ms, 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
Mask & get_mask_inverse() const
Get a ref to this->_mask.
Definition observation.h:81
Definition parametric.h:13
Definition param_filter.h:17