1#ifndef LSST_GAUSS2D_FIT_DATA_H
2#define LSST_GAUSS2D_FIT_DATA_H
10#include "observation.h"
11#include "param_defs.h"
12#include "parametric.h"
14namespace lsst::gauss2d::fit {
31template <
typename T,
typename I,
typename M>
35 using ObservationCRef = std::reference_wrapper<const Observation>;
42 explicit Data(std::vector<std::shared_ptr<const Observation>> observations) {
43 _observations.reserve(observations.size());
44 _observation_ptrs.reserve(observations.size());
46 for (
const auto& observation : observations) {
47 if (observation ==
nullptr)
throw std::invalid_argument(
"Can't store null Observation");
48 const auto& channel = observation->get_channel();
49 if (_channels.find(channel) == _channels.end()) {
50 _channels_ordered.push_back(channel);
51 _channels.insert(channel);
53 _observations.push_back(ObservationCRef(*observation));
54 _observation_ptrs.push_back(observation);
58 inline auto at(
size_t i)
const {
return _observations.at(i); }
59 inline auto begin()
const {
return _observations.begin(); }
60 inline auto end()
const {
return _observations.end(); }
62 inline auto cbegin()
const {
return _observations.begin(); }
63 inline auto cend()
const {
return _observations.end(); }
65 std::vector<std::reference_wrapper<const Channel>>
get_channels()
const override {
66 return _channels_ordered;
70 for (
const Observation& exp : *
this) exp.
get_parameters(params, filter);
74 for (
auto exp_it = this->cbegin(); exp_it != this->cend(); ++exp_it) {
75 (*exp_it).get().get_parameters_const(params, filter);
81 size_t size()
const {
return _observations.size(); }
83 std::string repr(
bool name_keywords =
false,
84 std::string_view namespace_separator = Object::CC_NAMESPACE_SEPARATOR)
const override {
85 std::string str = std::string(
"Data(") + (name_keywords ?
"observations=[" :
"[");
86 for (
auto exp_it = this->cbegin(); exp_it != this->cend(); ++exp_it) {
87 str += (*exp_it).get().repr(name_keywords, namespace_separator) +
",";
92 std::string str()
const override {
93 std::string str =
"Data(observations=[";
94 for (
auto exp_it = this->cbegin(); exp_it != this->cend(); ++exp_it) {
95 str += (*exp_it).get().str() +
",";
103 std::set<std::reference_wrapper<const Channel>> _channels = {};
104 std::vector<std::reference_wrapper<const Channel>> _channels_ordered = {};
105 std::vector<std::shared_ptr<const Observation>> _observation_ptrs = {};
106 std::vector<ObservationCRef> _observations = {};
Data(std::vector< std::shared_ptr< const Observation > > observations)
Definition data.h:42
ParamRefs & get_parameters(ParamRefs ¶ms, ParamFilter *filter=nullptr) const override
Definition data.h:69
ParamCRefs & get_parameters_const(ParamCRefs ¶ms, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
Definition data.h:73
std::vector< std::reference_wrapper< const Channel > > get_channels() const override
Get the set of channels this instance is applicable for.
Definition data.h:65
size_t size() const
Get the number of member Observation.
Definition data.h:81
An observed single-channel image with an associated variance and mask.
Definition observation.h:35
ParamRefs & get_parameters(ParamRefs ¶ms, ParamFilter *filter=nullptr) const override
Definition observation.h:85
Definition parametric.h:13
Definition param_filter.h:17