LSST Applications g034a557a3c+0df69e75ff,g0afe43252f+b86e4b8053,g11f7dcd041+017865fdd3,g1cd03abf6b+1c8dc8730a,g1ce3e0751c+f991eae79d,g28da252d5a+a136f03385,g2bbee38e9b+b6588ad223,g2bc492864f+b6588ad223,g2cdde0e794+8523d0dbb4,g347aa1857d+b6588ad223,g35bb328faa+b86e4b8053,g3a166c0a6a+b6588ad223,g461a3dce89+b86e4b8053,g52b1c1532d+b86e4b8053,g6233c72cae+da9c58a417,g7f3b0d46df+ad13c1b82d,g80478fca09+f29c5d6c70,g858d7b2824+4fc997592f,g8cd86fa7b1+5f14beadf5,g965a9036f2+4fc997592f,g979bb04a14+87f76c17e6,g9ddcbc5298+f24b38b85a,gae0086650b+b86e4b8053,gbb886bcc26+77117948e7,gc28159a63d+b6588ad223,gc30aee3386+a2f0f6cab9,gcaf7e4fdec+4fc997592f,gcd45df26be+4fc997592f,gcdd4ae20e8+0acf6430b1,gcf0d15dbbd+0acf6430b1,gdaeeff99f8+006e14e809,gdbce86181e+467b805b48,ge3d4d395c2+224150c836,ge5f7162a3a+1d9667e7ad,ge6cb8fbbf7+0992c83eee,ge79ae78c31+b6588ad223,gf048a9a2f4+41d6ddaca1,gf0baf85859+b4cca3d10f,w.2024.30
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)