LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
lsst::gauss2d::fit::FractionalIntegralModel Class Reference

An IntegralModel that returns a Parameter-dependent fraction of the flux of another IntegralModel. More...

#include <fractionalintegralmodel.h>

Inheritance diagram for lsst::gauss2d::fit::FractionalIntegralModel:
lsst::gauss2d::fit::IntegralModel lsst::gauss2d::fit::Chromatic lsst::gauss2d::fit::Parametric lsst::gauss2d::Object lsst::gauss2d::fit::FractionalIntegralModel::Shared_enabler

Classes

struct  Shared_enabler
 

Public Types

typedef std::pair< std::reference_wrapper< const Channel >, std::shared_ptr< ProperFractionParameterD > > ChannelIntegralParameterD
 
typedef std::vector< ChannelIntegralParameterDData
 

Public Member Functions

 FractionalIntegralModel (const FractionalIntegralModel &)=delete
 
FractionalIntegralModeloperator= (const FractionalIntegralModel &)=delete
 
 ~FractionalIntegralModel ()
 
std::shared_ptr< ProperFractionParameterDat (const Channel &channel)
 
std::shared_ptr< const ProperFractionParameterDat (const Channel &channel) const
 
Data::iterator begin () noexcept
 
Data::const_iterator cbegin () const noexcept
 
Data::iterator end () noexcept
 
Data::const_iterator cend () const noexcept
 
std::vector< std::reference_wrapper< const Channel > > get_channels () const override
 Get the set of channels this instance is applicable for.
 
const IntegralModelget_parent_model () const
 
double get_integral (const Channel &channel) const override
 Get the value of the integral in a single Channel.
 
std::vector< std::pair< ParamBaseCRef, ExtraParamFactorValues > > get_integral_derivative_factors (const Channel &channel) const override
 Return the partial derivative of the model w.r.t.
 
double get_integral_remainder (const Channel &channel) const
 
ProperFractionParameterDget_parameter_frac (const Channel &channel) const
 
ParamRefsget_parameters (ParamRefs &params, ParamFilter *filter=nullptr) const override
 Add Parameter refs matching the filter to a vector, in order.
 
ParamCRefsget_parameters_const (ParamCRefs &params, ParamFilter *filter=nullptr) const override
 Same as get_parameters(), but for const refs.
 
bool is_final () const
 
size_t size () const
 
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.
 
ParamRefs get_parameters_new (ParamFilter *filter=nullptr) const
 Same as get_parameters(), but returning a new vector.
 
ParamCRefs get_parameters_const_new (ParamFilter *filter=nullptr) const
 Same as get_parameters_const(), but returning a new vector.
 

Static Public Member Functions

static std::shared_ptr< FractionalIntegralModelfind_model (const IntegralModel &model)
 Find the FractionalIntegralModel that depends on a given IntegralModel, if any.
 
static std::shared_ptr< FractionalIntegralModelmake (std::optional< const Data > data, std::shared_ptr< const IntegralModel > model, bool is_final=false)
 Construct a FractionalIntegralModel and add to registry.
 
static const std::shared_ptr< const FractionalIntegralModelmake_const (std::optional< const Data > data, std::shared_ptr< const IntegralModel > model, bool is_final=false)
 
static std::string_view null_str (const std::string_view &namespace_separator)
 

Static Public Attributes

static constexpr std::string_view CC_NAMESPACE_SEPARATOR = "::"
 The C++ namespace separator.
 
static constexpr std::string_view NULL_STR_GENERAL = "None"
 
static constexpr std::string_view PY_NAMESPACE_SEPARATOR = "."
 

Detailed Description

An IntegralModel that returns a Parameter-dependent fraction of the flux of another IntegralModel.

FractionalIntegralModel instances can be chained but are registered to enforce having at most one dependent FractionalIntegralModel. Chains should end in a single fixed ProperFractionParameter of value 1; this is not yet fully enforced.

Note
For longer chains, a single ProperFractionParameter of value 1 will render all downstream models zero-valued, regardless of their own ProperFractionParameter values. Consider setting Limits to prevent such situations if they become problematic.

Definition at line 30 of file fractionalintegralmodel.h.

Member Typedef Documentation

◆ ChannelIntegralParameterD

Definition at line 33 of file fractionalintegralmodel.h.

◆ Data

Definition at line 34 of file fractionalintegralmodel.h.

Constructor & Destructor Documentation

◆ FractionalIntegralModel()

lsst::gauss2d::fit::FractionalIntegralModel::FractionalIntegralModel ( const FractionalIntegralModel & )
explicitdelete

◆ ~FractionalIntegralModel()

lsst::gauss2d::fit::FractionalIntegralModel::~FractionalIntegralModel ( )

Definition at line 71 of file fractionalintegralmodel.cc.

71{};

Member Function Documentation

◆ at() [1/2]

std::shared_ptr< ProperFractionParameterD > lsst::gauss2d::fit::FractionalIntegralModel::at ( const Channel & channel)

Definition at line 73 of file fractionalintegralmodel.cc.

73 {
74 return _map.at(channel);
75}

◆ at() [2/2]

std::shared_ptr< const ProperFractionParameterD > lsst::gauss2d::fit::FractionalIntegralModel::at ( const Channel & channel) const

Definition at line 76 of file fractionalintegralmodel.cc.

76 {
77 return _map.at(channel);
78}

◆ begin()

FractionalIntegralModel::Data::iterator lsst::gauss2d::fit::FractionalIntegralModel::begin ( )
noexcept

Definition at line 88 of file fractionalintegralmodel.cc.

88 {
89 return _data.begin();
90}
T begin(T... args)

◆ cbegin()

FractionalIntegralModel::Data::const_iterator lsst::gauss2d::fit::FractionalIntegralModel::cbegin ( ) const
noexcept

Definition at line 91 of file fractionalintegralmodel.cc.

91 {
92 return _data.begin();
93}

◆ cend()

FractionalIntegralModel::Data::const_iterator lsst::gauss2d::fit::FractionalIntegralModel::cend ( ) const
noexcept

Definition at line 98 of file fractionalintegralmodel.cc.

98 {
99 return _data.cend();
100}
T cend(T... args)

◆ end()

FractionalIntegralModel::Data::iterator lsst::gauss2d::fit::FractionalIntegralModel::end ( )
noexcept

Definition at line 95 of file fractionalintegralmodel.cc.

95 {
96 return _data.end();
97}

◆ find_model()

static std::shared_ptr< FractionalIntegralModel > lsst::gauss2d::fit::FractionalIntegralModel::find_model ( const IntegralModel & model)
inlinestatic

Find the FractionalIntegralModel that depends on a given IntegralModel, if any.

Parameters
modelThe IntegralModel to search for
Returns
The FractionalIntegralModel that depends on model, or nullptr if none

Definition at line 56 of file fractionalintegralmodel.h.

56 {
57 const auto found = _registry_rev.find(model);
58 return (found == _registry_rev.end()) ? nullptr : (*found).second.lock();
59 }

◆ get_channels()

std::vector< std::reference_wrapper< const Channel > > lsst::gauss2d::fit::FractionalIntegralModel::get_channels ( ) const
overridevirtual

Get the set of channels this instance is applicable for.

Note
Implementers must return a set (all unique items). This cannot be enforced (yet).

Implements lsst::gauss2d::fit::Chromatic.

Definition at line 102 of file fractionalintegralmodel.cc.

102 {
104 for (auto &datum : _data) rval.emplace_back(datum.first);
105 return rval;
106}

◆ get_integral()

double lsst::gauss2d::fit::FractionalIntegralModel::get_integral ( const Channel & channel) const
overridevirtual

Get the value of the integral in a single Channel.

Implements lsst::gauss2d::fit::IntegralModel.

Definition at line 115 of file fractionalintegralmodel.cc.

115 {
116 return _map.at(channel)->get_value() * (_get_integral_remainder(_parent.get(), *_model, channel));
117}
double _get_integral_remainder(const FractionalIntegralModel *frac, const IntegralModel &model, const Channel &channel)

◆ get_integral_derivative_factors()

std::vector< std::pair< ParamBaseCRef, ExtraParamFactorValues > > lsst::gauss2d::fit::FractionalIntegralModel::get_integral_derivative_factors ( const Channel & channel) const
overridevirtual

Return the partial derivative of the model w.r.t.

each metaparameter.

This is generally needed only for nonlinear Parameter instances.

Parameters
channelThe Channel to return derivatives for.
Returns
A vector of Parameter/derivative pairs, with values ordered as specified in GaussianEvaluator (L, sigma_x, sigma_y).

Implements lsst::gauss2d::fit::IntegralModel.

Definition at line 120 of file fractionalintegralmodel.cc.

120 {
121 const auto &frac = *(this->_map.at(channel));
122 /*
123 For a model with no parent:
124 gauss2d will evaluate dmodel/dweight_comp
125 Fitters will want dmodel/dfrac
126
127 frac = weight_comp/weight_total
128 dfrac/dweight_comp = 1/weight_total
129 dweight_comp = dfrac*weight_total
130
131 dmodel/d_frac = weight_total*dmodel/dweight_comp
132
133 With a parent:
134
135 parent: weight_comp_parent = weight_total*frac_parent
136 child1: weight_comp_child1 = weight_total*(1 - frac_parent)
137 ...
138 childN: weight_comp_childN = weight_total*(1 - frac_parent)...*(1-frac_childNminus1)
139
140 dmodel/dfrac_parent = weight_total*(1 - frac_parent)*dmodel/dweight_comp
141 = -weight_total*dmodel/dweight_comp
142
143 i.e. there are N fraction parameters dependent on dmodel/dweight_comp for children.
144 (excluding the fixed fraction for an is_final child)
145 */
146 if (_parent == nullptr) {
147 return {{frac, {_model->get_integral(channel), 0., 0.}}};
148 }
149 auto factors = _parent->get_integral_derivative_factors(channel);
150 if (is_final()) {
151 /*
152 The last component's fraction is fixed, but it has an integral of
153 (1 - frac_previous)*integral_remaining, the derivative of which
154 w.r.t. frac_revious is -1*integral_remaining.
155 */
156 factors.back().second[0] *= -1.;
157 } else {
158 // TODO: Check this if/when it's ever enabled
159 factors.push_back({frac, {factors.back().second[0], 0., 0.}});
160 }
161 return factors;
162}

◆ get_integral_remainder()

double lsst::gauss2d::fit::FractionalIntegralModel::get_integral_remainder ( const Channel & channel) const

Definition at line 164 of file fractionalintegralmodel.cc.

164 {
165 return (1. - this->at(channel)->get_value()) * _get_integral_remainder(_parent.get(), *_model, channel);
166}
std::shared_ptr< ProperFractionParameterD > at(const Channel &channel)

◆ get_parameter_frac()

ProperFractionParameterD & lsst::gauss2d::fit::FractionalIntegralModel::get_parameter_frac ( const Channel & channel) const

Definition at line 168 of file fractionalintegralmodel.cc.

168 {
169 return *(_map.at(channel));
170}

◆ get_parameters()

ParamRefs & lsst::gauss2d::fit::FractionalIntegralModel::get_parameters ( ParamRefs & params,
ParamFilter * filter = nullptr ) const
overridevirtual

Add Parameter refs matching the filter to a vector, in order.

Parameters
paramsThe vector to add to.
filterThe filter to apply to this Object's parameters.
Returns
A ref to params (for method chaining)

Implements lsst::gauss2d::fit::Parametric.

Definition at line 172 of file fractionalintegralmodel.cc.

172 {
173 _model->get_parameters(params, filter);
174 // Don't return the n_channels fixed frac=1 parameters at the end
175 const size_t n_p_max = _data.size() - (this->is_final() ? this->get_channels().size() : 0);
176 size_t i = 0;
177 for (auto &p : _data) {
178 if (i++ == n_p_max) break;
179 insert_param_channel(p.first, *p.second, params, filter);
180 }
181 return params;
182}
std::vector< std::reference_wrapper< const Channel > > get_channels() const override
Get the set of channels this instance is applicable for.
void insert_param_channel(const lsst::gauss2d::fit::Channel &channel, g2f::ParamBase &param, t &params, ParamFilter *filter)
Same as insert_param, but only inserting if filter has a null or matching Channel.
T size(T... args)

◆ get_parameters_const()

ParamCRefs & lsst::gauss2d::fit::FractionalIntegralModel::get_parameters_const ( ParamCRefs & params,
ParamFilter * filter = nullptr ) const
overridevirtual

Same as get_parameters(), but for const refs.

Implements lsst::gauss2d::fit::Parametric.

Definition at line 184 of file fractionalintegralmodel.cc.

184 {
185 _model->get_parameters_const(params, filter);
186 const size_t n_p_max = _data.size() - (this->is_final() ? this->get_channels().size() : 0);
187 size_t i = 0;
188 for (const auto &p : _data) {
189 if (i++ == n_p_max) break;
190 insert_param_channel(p.first, *p.second, params, filter);
191 }
192 return params;
193}

◆ get_parameters_const_new()

ParamCRefs lsst::gauss2d::fit::Parametric::get_parameters_const_new ( ParamFilter * filter = nullptr) const
inlineinherited

Same as get_parameters_const(), but returning a new vector.

Definition at line 33 of file parametric.h.

33 {
34 ParamCRefs params{};
35 get_parameters_const(params, filter);
36 return params;
37 }
virtual ParamCRefs & get_parameters_const(ParamCRefs &params, ParamFilter *filter=nullptr) const =0
Same as get_parameters(), but for const refs.
std::vector< ParamBaseCRef > ParamCRefs
Definition param_defs.h:11

◆ get_parameters_new()

ParamRefs lsst::gauss2d::fit::Parametric::get_parameters_new ( ParamFilter * filter = nullptr) const
inlineinherited

Same as get_parameters(), but returning a new vector.

Definition at line 27 of file parametric.h.

27 {
28 ParamRefs params{};
29 get_parameters(params, filter);
30 return params;
31 }
virtual ParamRefs & get_parameters(ParamRefs &params, ParamFilter *filter=nullptr) const =0
Add Parameter refs matching the filter to a vector, in order.
std::vector< ParamBaseRef > ParamRefs
Definition param_defs.h:13

◆ get_parent_model()

const IntegralModel & lsst::gauss2d::fit::FractionalIntegralModel::get_parent_model ( ) const

Definition at line 108 of file fractionalintegralmodel.cc.

108{ return *_model; }

◆ is_final()

bool lsst::gauss2d::fit::FractionalIntegralModel::is_final ( ) const

Definition at line 195 of file fractionalintegralmodel.cc.

195{ return _is_final; }

◆ make()

std::shared_ptr< FractionalIntegralModel > lsst::gauss2d::fit::FractionalIntegralModel::make ( std::optional< const Data > data,
std::shared_ptr< const IntegralModel > model,
bool is_final = false )
static

Construct a FractionalIntegralModel and add to registry.

Parameters
dataThe map of ProperFractionParameter instances for each channel.
modelThe IntegralModel that ProperFractionParameter instances multiply by.
is_finalWhether these fractions are the last in the chain.
Note
Input parameters are validated and will throw exceptions if invalid, e.g. if data and model do not cover the same channels.
Returns
A new FractionalIntegralModel instance

Definition at line 230 of file fractionalintegralmodel.cc.

231 {
232 std::shared_ptr<FractionalIntegralModel> ptr = std::make_shared<Shared_enabler>(data, model, is_final);
233 _registry.insert({*ptr, *model});
234 FractionalIntegralModel::_registry_rev.insert({*model, ptr});
235 return ptr;
236}
char * data
Definition BaseRecord.cc:61
std::uint64_t * ptr
Definition RangeSet.cc:95
model(data, psfmodels, sources)

◆ make_const()

const std::shared_ptr< const FractionalIntegralModel > lsst::gauss2d::fit::FractionalIntegralModel::make_const ( std::optional< const Data > data,
std::shared_ptr< const IntegralModel > model,
bool is_final = false )
static

Definition at line 238 of file fractionalintegralmodel.cc.

239 {
240 return make(data, model, is_final);
241}
static std::shared_ptr< FractionalIntegralModel > make(std::optional< const Data > data, std::shared_ptr< const IntegralModel > model, bool is_final=false)
Construct a FractionalIntegralModel and add to registry.

◆ null_str()

static std::string_view lsst::gauss2d::Object::null_str ( const std::string_view & namespace_separator)
inlinestaticinherited

Definition at line 49 of file object.h.

49 {
50 return namespace_separator == CC_NAMESPACE_SEPARATOR ? "nullptr" : NULL_STR_GENERAL;
51 }
static constexpr std::string_view CC_NAMESPACE_SEPARATOR
The C++ namespace separator.
Definition object.h:45
static constexpr std::string_view NULL_STR_GENERAL
Definition object.h:46

◆ operator=()

FractionalIntegralModel & lsst::gauss2d::fit::FractionalIntegralModel::operator= ( const FractionalIntegralModel & )
delete

◆ repr()

std::string lsst::gauss2d::fit::FractionalIntegralModel::repr ( bool name_keywords = false,
std::string_view namespace_separator = Object::CC_NAMESPACE_SEPARATOR ) const
overridevirtual

Return a full, callable string representation of this.

Parameters
name_keywordsWhether to prefix arguments with "{name}=", where name is the arg name in the header (as with keyword arguments in Python).
namespace_separatorThe string to use to delimit namespaces, i.e. :: in C++ and . in Python.
Returns
A callable string representation of this, which should return an an identical object to this.
Note
The representation with name_keywords=false must be callable in C++. The representation with name_keywords=true should be callable in Python, if there are any bindings.

Implements lsst::gauss2d::Object.

Definition at line 199 of file fractionalintegralmodel.cc.

199 {
200 std::string s = type_name_str<FractionalIntegralModel>(false, namespace_separator) + "("
201 + (name_keywords ? "data={" : "{");
202 for (const auto &datum : _data) {
203 s += datum.first.get().repr(name_keywords, namespace_separator) + ": "
204 + datum.second->repr(name_keywords, namespace_separator) + ",";
205 }
206 return s + "})";
207}

◆ size()

size_t lsst::gauss2d::fit::FractionalIntegralModel::size ( ) const

Definition at line 197 of file fractionalintegralmodel.cc.

197{ return _data.size(); }

◆ str()

std::string lsst::gauss2d::fit::FractionalIntegralModel::str ( ) const
overridevirtual

Return a brief, human-readable string representation of this.

Implements lsst::gauss2d::Object.

Definition at line 209 of file fractionalintegralmodel.cc.

209 {
210 std::string s = type_name_str<FractionalIntegralModel>(true) + "(data={";
211 for (const auto &datum : _data) {
212 s += datum.first.get().str() + ": " + datum.second->str() + ",";
213 }
214 s += "}, model=" + _model->str() + ", is_final=" + std::to_string(_is_final) + ")";
215 return s;
216}
T to_string(T... args)

Member Data Documentation

◆ CC_NAMESPACE_SEPARATOR

constexpr std::string_view lsst::gauss2d::Object::CC_NAMESPACE_SEPARATOR = "::"
staticconstexprinherited

The C++ namespace separator.

Definition at line 45 of file object.h.

◆ NULL_STR_GENERAL

constexpr std::string_view lsst::gauss2d::Object::NULL_STR_GENERAL = "None"
staticconstexprinherited

Definition at line 46 of file object.h.

◆ PY_NAMESPACE_SEPARATOR

constexpr std::string_view lsst::gauss2d::Object::PY_NAMESPACE_SEPARATOR = "."
staticconstexprinherited

Definition at line 47 of file object.h.


The documentation for this class was generated from the following files: