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
data.h
Go to the documentation of this file.
1#ifndef LSST_GAUSS2D_FIT_DATA_H
2#define LSST_GAUSS2D_FIT_DATA_H
3
4#include <memory>
5#include <stdexcept>
6#include <vector>
7
8#include "channel.h"
9#include "chromatic.h"
10#include "observation.h"
11#include "param_defs.h"
12#include "parametric.h"
13
14namespace lsst::gauss2d::fit {
15
16/*
17 A Data is a collection of Observations that a consistent Model can be
18 generated for.
19*/
31template <typename T, typename I, typename M>
32class Data : public Chromatic, public Parametric {
33public:
36
43 _observations.reserve(observations.size());
44 _observation_ptrs.reserve(observations.size());
45
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);
52 }
53 _observations.push_back(ObservationCRef(*observation));
54 _observation_ptrs.push_back(observation);
55 }
56 }
57
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(); }
61
62 inline auto cbegin() const { return _observations.begin(); }
63 inline auto cend() const { return _observations.end(); }
64
66 return _channels_ordered;
67 }
68
69 ParamRefs& get_parameters(ParamRefs& params, ParamFilter* filter = nullptr) const override {
70 for (const Observation& exp : *this) exp.get_parameters(params, filter);
71 return params;
72 }
73 ParamCRefs& get_parameters_const(ParamCRefs& params, ParamFilter* filter = nullptr) const override {
74 for (auto exp_it = this->cbegin(); exp_it != this->cend(); ++exp_it) {
75 (*exp_it).get().get_parameters_const(params, filter);
76 }
77 return params;
78 }
79
81 size_t size() const { return _observations.size(); }
82
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) + ",";
88 }
89 str += "]);";
90 return str;
91 }
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() + ",";
96 }
97 str += "])";
98 return str;
99 }
100
101private:
102 // This could be unordered, but std::hash<std::string> won't take const strings
106 std::vector<ObservationCRef> _observations = {};
107};
108
109} // namespace lsst::gauss2d::fit
110
111#endif
static constexpr std::string_view CC_NAMESPACE_SEPARATOR
The C++ namespace separator.
Definition object.h:45
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 data.h:83
Data(std::vector< std::shared_ptr< const Observation > > observations)
Construct a Data instance.
Definition data.h:42
ParamRefs & get_parameters(ParamRefs &params, ParamFilter *filter=nullptr) const override
Add Parameter refs matching the filter to a vector, in order.
Definition data.h:69
ParamCRefs & get_parameters_const(ParamCRefs &params, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
Definition data.h:73
std::string str() const override
Definition data.h:92
std::reference_wrapper< const Observation > ObservationCRef
Definition data.h:35
lsst::gauss2d::fit::Observation< T, I, M > Observation
Definition data.h:34
auto at(size_t i) const
Definition data.h:58
auto begin() const
Definition data.h:59
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
auto end() const
Definition data.h:60
auto cend() const
Definition data.h:63
auto cbegin() const
Definition data.h:62
An observed single-channel image with an associated variance and mask.
Definition observation.h:35
A parametric object that can return and filter its Parameter instances.
Definition parametric.h:13
std::vector< ParamBaseRef > ParamRefs
Definition param_defs.h:13
std::vector< ParamBaseCRef > ParamCRefs
Definition param_defs.h:11
Options for filtering Parameter instances.