lsst.gauss2d.fit g199a45376c+3b7b3fd841
 
Loading...
Searching...
No Matches
sersicmixcomponent.h
1#ifndef LSST_GAUSS2D_FIT_SERSICMIXCOMPONENT_H
2#define LSST_GAUSS2D_FIT_SERSICMIXCOMPONENT_H
3
4#include "lsst/modelfit/parameters.h"
5
6#include "channel.h"
7#include "ellipticalcomponent.h"
8#include "integralmodel.h"
9#include "param_defs.h"
10#include "param_filter.h"
11#include "sersicmix.h"
12#include "sersicparametricellipse.h"
13
14namespace lsst::gauss2d::fit {
19public:
22 double value = _get_default(), std::shared_ptr<const parameters::Limits<double>> limits = nullptr,
23 std::shared_ptr<const parameters::Transform<double>> transform = nullptr,
24 std::shared_ptr<const parameters::Unit> unit = nullptr, bool fixed = false,
25 std::string label = "", std::shared_ptr<const SersicMixInterpolator> interpolator = nullptr);
26
28 double get_integralratio(unsigned short index) const;
30 double get_integralratio_deriv(unsigned short index) const;
31 static std::shared_ptr<const SersicMixInterpolator> get_interpolator_default(unsigned short order
32 = SERSICMIX_ORDER_DEFAULT);
33 const parameters::Limits<double>& get_limits_maximal() const override;
34 double get_min() const override { return 0.5; }
35 double get_max() const override { return 8.0; }
37 double get_sizeratio(unsigned short index) const;
39 double get_sizeratio_deriv(unsigned short index) const;
40
41 InterpType get_interptype() const;
42 unsigned short get_order() const;
43
44 void set_value(double value) override;
45 void set_value_transformed(double value_transformed) override;
46
47private:
48 std::vector<IntegralSize> _integralsizes;
49 std::vector<IntegralSize> _integralsizes_derivs;
50 const std::shared_ptr<const SersicMixInterpolator> _interpolator;
51
53 void _set_ratios(double sersicindex);
54};
55
56// TODO: Revisit the necessity of this class
61public:
63 explicit SersicParametricEllipseHolder(std::shared_ptr<SersicParametricEllipse> ellipse = nullptr)
64 : _ellipsedata(std::move(ellipse)) {
65 if (_ellipsedata == nullptr) _ellipsedata = std::make_shared<SersicParametricEllipse>();
66 }
67 std::shared_ptr<SersicParametricEllipse> _ellipsedata;
68};
69
70// TODO: Add ref to derivation of weights, when published
85class SersicMixComponent : private SersicParametricEllipseHolder, public EllipticalComponent {
86public:
87 explicit SersicMixComponent(std::shared_ptr<SersicParametricEllipse> ellipse = nullptr,
88 std::shared_ptr<CentroidParameters> centroid = nullptr,
89 std::shared_ptr<IntegralModel> integralmodel = nullptr,
90 std::shared_ptr<SersicMixComponentIndexParameterD> sersicindex = nullptr);
91 ~SersicMixComponent();
92
93 void add_extra_param_map(const Channel& channel, ExtraParamMap& map_extra, const GradParamMap& map_grad,
94 ParameterMap& offsets) const override;
95 void add_extra_param_factors(const Channel& channel, ExtraParamFactors& factors) const override;
96 void add_grad_param_map(const Channel& channel, GradParamMap& map, ParameterMap& offsets) const override;
97 void add_grad_param_factors(const Channel& channel, GradParamFactors& factor) const override;
98
99 std::unique_ptr<const lsst::gauss2d::Gaussians> get_gaussians(const Channel& channel) const override;
100 size_t get_n_gaussians(const Channel& channel) const override;
101
102 ParamRefs& get_parameters(ParamRefs& params, ParamFilter* filter = nullptr) const override;
103 ParamCRefs& get_parameters_const(ParamCRefs& params, ParamFilter* filter = nullptr) const override;
104
105 double get_sersicindex() const;
106
107 SersicMixComponentIndexParameterD& get_sersicindex_param() const;
108 std::shared_ptr<SersicMixComponentIndexParameterD> get_sersicindex_param_ptr();
109
110 static const size_t N_PARAMS = N_PARAMS_GAUSS2D + 1;
111
112 void set_extra_param_factors(const Channel& channel, ExtraParamFactors& factors,
113 size_t index) const override;
114 void set_grad_param_factors(const Channel& channel, GradParamFactors& factors,
115 size_t index) const override;
116 void set_sersicindex(double value);
117
118 std::string repr(bool name_keywords = false,
119 std::string_view namespace_separator = Object::CC_NAMESPACE_SEPARATOR) const override;
120 std::string str() const override;
121
122private:
124 std::shared_ptr<SersicMixComponentIndexParameterD> _sersicindex;
125 std::map<std::reference_wrapper<const Channel>, std::vector<std::unique_ptr<SersicMixGaussianComponent>>>
126 _gaussians;
127};
128} // namespace lsst::gauss2d::fit
129
130#endif
An observational channel, usually representing some range of wavelengths of light.
Definition channel.h:29
EllipticalComponent(std::shared_ptr< ParametricEllipse > ellipse, std::shared_ptr< CentroidParameters > centroid=nullptr, std::shared_ptr< IntegralModel > integralmodel=nullptr)
Definition ellipticalcomponent.cc:13
double get_sizeratio(unsigned short index) const
Return the size ratio for a given Gaussian sub-component index.
Definition sersicmixcomponent.cc:212
double get_integralratio_deriv(unsigned short index) const
Return the integral ratio derivative for a given Gaussian sub-component index.
Definition sersicmixcomponent.cc:199
SersicMixComponentIndexParameterD(double value=_get_default(), std::shared_ptr< const parameters::Limits< double > > limits=nullptr, std::shared_ptr< const parameters::Transform< double > > transform=nullptr, std::shared_ptr< const parameters::Unit > unit=nullptr, bool fixed=false, std::string label="", std::shared_ptr< const SersicMixInterpolator > interpolator=nullptr)
See docs for Parameter.
Definition sersicmixcomponent.cc:239
double get_integralratio(unsigned short index) const
Return the integral ratio for a given Gaussian sub-component index.
Definition sersicmixcomponent.cc:191
double get_sizeratio_deriv(unsigned short index) const
Return the size ratio derivative for a given Gaussian sub-component index.
Definition sersicmixcomponent.cc:220
void set_extra_param_factors(const Channel &channel, ExtraParamFactors &factors, size_t index) const override
Definition sersicmixcomponent.cc:419
std::unique_ptr< const lsst::gauss2d::Gaussians > get_gaussians(const Channel &channel) const override
Definition sersicmixcomponent.cc:381
void set_grad_param_factors(const Channel &channel, GradParamFactors &factors, size_t index) const override
Definition sersicmixcomponent.cc:444
void add_extra_param_map(const Channel &channel, ExtraParamMap &map_extra, const GradParamMap &map_grad, ParameterMap &offsets) const override
Definition sersicmixcomponent.cc:295
ParamRefs & get_parameters(ParamRefs &params, ParamFilter *filter=nullptr) const override
Definition sersicmixcomponent.cc:397
void add_extra_param_factors(const Channel &channel, ExtraParamFactors &factors) const override
Definition sersicmixcomponent.cc:320
ParamCRefs & get_parameters_const(ParamCRefs &params, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
Definition sersicmixcomponent.cc:403
void add_grad_param_map(const Channel &channel, GradParamMap &map, ParameterMap &offsets) const override
Definition sersicmixcomponent.cc:326
void add_grad_param_factors(const Channel &channel, GradParamFactors &factor) const override
Definition sersicmixcomponent.cc:364
size_t get_n_gaussians(const Channel &channel) const override
Return the number of Gaussian sub-components controlled by this model.
Definition sersicmixcomponent.cc:393
SersicParametricEllipseHolder(std::shared_ptr< SersicParametricEllipse > ellipse=nullptr)
This constructor does not need to be called by users.
Definition sersicmixcomponent.h:63
Definition param_filter.h:17