17static const size_t N_PARAMS_INTEGRAL_MAX = 2;
18static const size_t N_PARAMS_EXTRA_INTEGRAL_MAX = N_PARAMS_INTEGRAL_MAX - 1;
30 _centroid->get_parameters_const(params, &filter);
31 _ellipse->get_parameters_const(params, &filter);
33 const size_t n_params_nonint = params.
size();
36 if (n_params_nonint != n_params_expect) {
45 size_t n_params_int = params_int.size();
46 if (!(n_params_int <= N_PARAMS_INTEGRAL_MAX)) {
51 for (
auto param : params_int) params.push_back(param);
57 auto factors_int =
_integralmodel->get_integral_derivative_factors(channel);
58 const size_t n_factors = factors_int.
size();
59 if (!(n_factors <= N_PARAMS_EXTRA_INTEGRAL_MAX)) {
67 for (
const auto& factor : factors_int) {
68 const auto& param = factor.first.get();
69 if (!param.get_fixed()) {
70 auto found = offsets.find(param);
71 if (found == offsets.end()) {
73 " was add_grad_param_map called first?");
75 offset = (*found).second;
76 idx = map_grad.
size() - 1;
90 auto& values = map.
back();
92 size_t size_map = offsets.size();
93 size_t index_param_map;
95 const size_t& order_param = IDX_ORDER[idx_param];
97 const auto& param = params.
at(idx_param).get();
98 if (!param.get_fixed()) {
99 if (offsets.find(param) == offsets.end()) {
100 index_param_map = ++size_map;
101 offsets[param] = index_param_map;
103 index_param_map = offsets[param];
105 values[order_param] = index_param_map;
108 const size_t n_params = params.
size();
110 for (
size_t idx_param =
N_PARAMS_GAUSS2D; idx_param < n_params; ++idx_param) {
111 const auto& param = params.
at(idx_param).get();
112 if (!param.get_fixed() && (offsets.find(param) == offsets.end())) {
113 offsets[param] = ++size_map;
123 const Channel& channel)
const {
126 std::make_shared<GaussianModelIntegral>(channel, this->
_integralmodel))};
127 return std::make_unique<const lsst::gauss2d::Gaussians>(gaussians);
143 size_t index)
const {
144 auto factors_int =
_integralmodel->get_integral_derivative_factors(channel);
145 const size_t n_factors = factors_int.
size();
146 if (!(n_factors <= 1)) {
149 +
" parameter factors" +
"; only a maximum of one is supported.");
151 auto&
row = factors[index];
154 row[0] = factors_int[0].second[0] / factors_int[0].first.get().get_transform_derivative();
163 size_t index)
const {
164 auto params = this->_get_parameters_grad(channel);
165 auto& values = factors.
at(index);
168 const size_t& order_param = IDX_ORDER[idx_param];
170 const auto& param = params[idx_param].get();
171 if (param.get_fixed()) {
172 values[order_param] = 0;
174 auto deriv = param.get_transform_derivative();
177 +
" get_transform_derivative=0 (will result in divide by 0)");
179 values[order_param] = 1.0 / deriv;
185 return type_name_str<GaussianComponent>(
false, namespace_separator) +
"("
An observational channel, usually representing some range of wavelengths of light.
std::string str() const override
Return a brief, human-readable string representation of this.
A Component with an elliptically-symmetric intensity profile.
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.
std::string str() const override
Return a brief, human-readable string representation of this.
std::shared_ptr< CentroidParameters > _centroid
ParamCRefs & get_parameters_const(ParamCRefs ¶ms, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
std::shared_ptr< IntegralModel > _integralmodel
ParamRefs & get_parameters(ParamRefs ¶ms, ParamFilter *filter=nullptr) const override
Add Parameter refs matching the filter to a vector, in order.
std::shared_ptr< ParametricEllipse > _ellipse
size_t get_n_gaussians(const Channel &channel) const override
Return the number of Gaussian sub-components controlled by this model.
ParamCRefs & get_parameters_const(ParamCRefs ¶ms, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
void add_extra_param_factors(const Channel &channel, ExtraParamFactors &factors) const override
Add extra Parameter gradient factors to an existing vector.
void set_extra_param_factors(const Channel &channel, ExtraParamFactors &factors, size_t index) const override
Set extra Parameter gradient factors in an existing map.
GaussianComponent(std::shared_ptr< GaussianParametricEllipse > ellipse=nullptr, std::shared_ptr< CentroidParameters > centroid=nullptr, std::shared_ptr< IntegralModel > integralmodel=nullptr)
Construct a GaussianComponent from ellipse, centroid and integral parameters.
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.
ParamRefs & get_parameters(ParamRefs ¶ms, ParamFilter *filter=nullptr) const override
Add Parameter refs matching the filter to a vector, in order.
void add_grad_param_factors(const Channel &channel, GradParamFactors &factor) const override
Add Parameter gradient factors to an existing map.
void add_grad_param_map(const Channel &channel, GradParamMap &map, ParameterMap &offsets) const override
Add Parameter gradient indices to an existing map.
void set_grad_param_factors(const Channel &channel, GradParamFactors &factors, size_t index) const override
Set Parameter gradient factors in an existing map.
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.
std::string str() const override
Return a brief, human-readable string representation of this.
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.
std::shared_ptr< GaussianParametricEllipse > _ellipsedata
std::vector< T > nonconsecutive_unique(const std::vector< T > &vec)
std::vector< ParamBaseCRef > ParamCRefs
const size_t N_PARAMS_GAUSS2D
Options for filtering Parameter instances.
std::optional< std::reference_wrapper< const Channel > > channel