LSST Applications g0f08755f38+82efc23009,g12f32b3c4e+e7bdf1200e,g1653933729+a8ce1bb630,g1a0ca8cf93+50eff2b06f,g28da252d5a+52db39f6a5,g2bbee38e9b+37c5a29d61,g2bc492864f+37c5a29d61,g2cdde0e794+c05ff076ad,g3156d2b45e+41e33cbcdc,g347aa1857d+37c5a29d61,g35bb328faa+a8ce1bb630,g3a166c0a6a+37c5a29d61,g3e281a1b8c+fb992f5633,g414038480c+7f03dfc1b0,g41af890bb2+11b950c980,g5fbc88fb19+17cd334064,g6b1c1869cb+12dd639c9a,g781aacb6e4+a8ce1bb630,g80478fca09+72e9651da0,g82479be7b0+04c31367b4,g858d7b2824+82efc23009,g9125e01d80+a8ce1bb630,g9726552aa6+8047e3811d,ga5288a1d22+e532dc0a0b,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+37c5a29d61,gcf0d15dbbd+2acd6d4d48,gd7358e8bfb+778a810b6e,gda3e153d99+82efc23009,gda6a2b7d83+2acd6d4d48,gdaeeff99f8+1711a396fd,ge2409df99d+6b12de1076,ge79ae78c31+37c5a29d61,gf0baf85859+d0a5978c5a,gf3967379c6+4954f8c433,gfb92a5be7c+82efc23009,gfec2e1e490+2aaed99252,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
source.cc
Go to the documentation of this file.
1#include <optional>
2#include <stdexcept>
3
5
7
8namespace lsst::gauss2d::fit {
10 _components.reserve(components.size());
11 size_t i = 0;
12 for (auto& component : components) {
13 if (component == nullptr)
14 throw std::invalid_argument("Source components[" + std::to_string(i) + "] can't be null");
15 _components.push_back(std::move(component));
16 i++;
17 }
18}
19
20void Source::add_extra_param_map(const Channel& channel, ExtraParamMap& map_extra,
21 const GradParamMap& map_grad, ParameterMap& offsets) const {
22 for (auto& component : _components) component->add_extra_param_map(channel, map_extra, map_grad, offsets);
23}
24
25void Source::add_extra_param_factors(const Channel& channel, ExtraParamFactors& factors) const {
26 for (auto& component : _components) component->add_extra_param_factors(channel, factors);
27}
28
29void Source::add_grad_param_map(const Channel& channel, GradParamMap& map, ParameterMap& offsets) const {
30 for (auto& component : _components) component->add_grad_param_map(channel, map, offsets);
31}
32
33void Source::add_grad_param_factors(const Channel& channel, GradParamFactors& factors) const {
34 for (auto& component : _components) component->add_grad_param_factors(channel, factors);
35}
36
37Components Source::get_components() const { return _components; }
38
41 // TODO: This isn't sufficient; need to implement get_n_components
42 in.reserve(_components.size());
43 for (auto& component : _components) {
44 in.push_back(component->get_gaussians(channel)->get_data());
45 }
46 return std::make_unique<lsst::gauss2d::Gaussians>(in);
47}
48
49size_t Source::get_n_gaussians(const Channel& channel) const {
50 size_t n_g = 0;
51 for (auto& component : _components) n_g += component->get_n_gaussians(channel);
52 return n_g;
53}
54
56 for (auto& component : _components) component->get_parameters(params, filter);
57 return params;
58}
59
61 for (auto& component : _components) component->get_parameters_const(params, filter);
62 return params;
63}
64
65void Source::set_extra_param_factors(const Channel& channel, ExtraParamFactors& factors, size_t index) const {
66 for (auto& component : _components) {
67 component->set_extra_param_factors(channel, factors, index);
68 index += component->get_n_gaussians(channel);
69 }
70}
71
72void Source::set_grad_param_factors(const Channel& channel, GradParamFactors& factors, size_t index) const {
73 for (auto& component : _components) {
74 component->set_grad_param_factors(channel, factors, index);
75 index += component->get_n_gaussians(channel);
76 }
77}
78
79std::string Source::repr(bool name_keywords, std::string_view namespace_separator) const {
80 std::string s = type_name_str<Source>(false, namespace_separator) + "("
81 + (name_keywords ? "components=[" : "[");
82 for (const auto& c : _components) s += c->repr(name_keywords, namespace_separator) + ",";
83 return s + "])";
84}
85
87 std::string s = type_name_str<Source>(true) + "(components=[";
88 for (const auto& c : _components) s += c->str() + ",";
89 return s + "])";
90}
91} // namespace lsst::gauss2d::fit
table::Key< table::Array< int > > components
An observational channel, usually representing some range of wavelengths of light.
Definition channel.h:29
void add_grad_param_factors(const Channel &channel, GradParamFactors &factors) const override
Add Parameter gradient factors to an existing map.
Definition source.cc:33
std::unique_ptr< const lsst::gauss2d::Gaussians > get_gaussians(const Channel &channel) const override
Return the vector of Gaussian sub-components controlled by this model.
Definition source.cc:39
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 source.cc:79
std::string str() const override
Return a brief, human-readable string representation of this.
Definition source.cc:86
void add_grad_param_map(const Channel &channel, GradParamMap &map, ParameterMap &offsets) const override
Add Parameter gradient indices to an existing map.
Definition source.cc:29
ParamRefs & get_parameters(ParamRefs &params, ParamFilter *filter=nullptr) const override
Add Parameter refs matching the filter to a vector, in order.
Definition source.cc:55
void set_grad_param_factors(const Channel &channel, GradParamFactors &factors, size_t index) const override
Set Parameter gradient factors in an existing map.
Definition source.cc:72
ParamCRefs & get_parameters_const(ParamCRefs &params, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
Definition source.cc:60
void add_extra_param_map(const Channel &channel, ExtraParamMap &map_extra, const GradParamMap &map_grad, ParameterMap &offsets) const override
Add extra Parameter indices to a map.
Definition source.cc:20
Source(Components &components)
Definition source.cc:9
void set_extra_param_factors(const Channel &channel, ExtraParamFactors &factors, size_t index) const override
Set extra Parameter gradient factors in an existing map.
Definition source.cc:65
void add_extra_param_factors(const Channel &channel, ExtraParamFactors &factors) const override
Add extra Parameter gradient factors to an existing vector.
Definition source.cc:25
size_t get_n_gaussians(const Channel &channel) const override
Return the number of Gaussian sub-components controlled by this model.
Definition source.cc:49
Components get_components() const override
Definition source.cc:37
T move(T... args)
T push_back(T... args)
T reserve(T... args)
T size(T... args)
Options for filtering Parameter instances.
T to_string(T... args)