LSST Applications g1653933729+34a971ddd9,g1a997c3884+34a971ddd9,g28da252d5a+32b12a4112,g2bbee38e9b+ffc559ee46,g2bc492864f+ffc559ee46,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+ffc559ee46,g35bb328faa+34a971ddd9,g3a166c0a6a+ffc559ee46,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9f5be647b3,g41af890bb2+686ab7cd58,g4e1a3235cc+1fd785b14f,g7b55021d1b+da0d0eec6b,g80478fca09+6e21f9dc20,g82479be7b0+6fa35d7547,g858d7b2824+356eaf3287,g9125e01d80+34a971ddd9,ga5288a1d22+ba1f9bb3ef,gae0086650b+34a971ddd9,gb4748cc0e8+fd26a265a0,gb4ec7eb0ab+356eaf3287,gb58c049af0+ace264a4f2,gc081298178+30f12d1e69,gc28159a63d+ffc559ee46,gcf0d15dbbd+4adb3139bd,gd6b7c0dfd1+aae9efebf5,gda3e153d99+356eaf3287,gda6a2b7d83+4adb3139bd,gdaeeff99f8+7774323b41,gdd5a9049c5+ea78b51778,ge2409df99d+fa478de0b0,ge33fd446bb+356eaf3287,ge79ae78c31+ffc559ee46,gf0baf85859+890af219f9,gf5289d68f6+e11c78aeea,w.2024.41
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)