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
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
lsst::gauss2d::fit::PsfModel Class Reference

A Gaussian mixture model of a point spread function. More...

#include <psfmodel.h>

Inheritance diagram for lsst::gauss2d::fit::PsfModel:
lsst::gauss2d::fit::ComponentMixture lsst::gauss2d::fit::ParametricModel lsst::gauss2d::fit::Parametric lsst::gauss2d::Object

Public Member Functions

 PsfModel (Components &components)
 
 ~PsfModel ()
 
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.
 
void add_extra_param_factors (const Channel &channel, ExtraParamFactors &factors) const override
 Add extra Parameter gradient factors to an existing vector.
 
void add_grad_param_map (const Channel &channel, GradParamMap &map, ParameterMap &offsets) const override
 Add Parameter gradient indices to an existing map.
 
void add_grad_param_factors (const Channel &channel, GradParamFactors &factor) const override
 Add Parameter gradient factors to an existing map.
 
Components get_components () const override
 
std::unique_ptr< const lsst::gauss2d::Gaussiansget_gaussians (const Channel &channel=Channel::NONE()) const override
 Return the vector of Gaussian sub-components controlled by this model.
 
size_t get_n_gaussians (const Channel &channel=Channel::NONE()) const override
 Return the number of Gaussian sub-components controlled by this model.
 
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.
 
void set_extra_param_factors (const Channel &channel, ExtraParamFactors &factors, size_t index) const override
 Set extra Parameter gradient factors in an existing map.
 
void set_grad_param_factors (const Channel &channel, GradParamFactors &factor, size_t index) const override
 Set Parameter gradient factors in an existing map.
 
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::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

A Gaussian mixture model of a point spread function.

A PsfModel is, like a Source, a ComponentMixture. It represents the PSF, i.e. the smoothing kernel for a single Observation (whether from the optical system, environmental conditions, or any other source of blurring). As such, it should have an IntegralModel instance that sum to unity. This is most easily enforced with the use of FractionalIntegralModel.

PsfModels are also generally required to not have a specific Channel. Logically, it should have the same Channel as the Observation it applies to, but generally, it cannot be defined to apply to multiple Observations, so non-NONE Channels are disallowed to reflect this fact.

Definition at line 26 of file psfmodel.h.

Constructor & Destructor Documentation

◆ PsfModel()

lsst::gauss2d::fit::PsfModel::PsfModel ( Components & components)
explicit

Definition at line 12 of file psfmodel.cc.

12 {
13 size_t i = 0;
14 _components.reserve(components.size());
15 for (auto& component : components) {
16 if (component == nullptr)
17 throw std::invalid_argument("PsfModel components[" + std::to_string(i) + "] can't be null");
18 auto channels = component->get_integralmodel().get_channels();
19 if ((channels.size() != 1) || ((*channels.begin()).get() != Channel::NONE())) {
20 throw std::invalid_argument("PsfModel components[" + std::to_string(i)
21 + "].get_integralmodel().get_channels()="
22 + str_iter_ref<true>(channels) + " must only contain None");
23 }
24 _components.push_back(std::move(component));
25 i++;
26 }
27}
table::Key< table::Array< int > > components
static const Channel & NONE()
Definition channel.cc:111
T move(T... args)
T push_back(T... args)
T reserve(T... args)
T to_string(T... args)

◆ ~PsfModel()

lsst::gauss2d::fit::PsfModel::~PsfModel ( )

Definition at line 29 of file psfmodel.cc.

29{}

Member Function Documentation

◆ add_extra_param_factors()

void lsst::gauss2d::fit::PsfModel::add_extra_param_factors ( const Channel & channel,
ExtraParamFactors & factors ) const
overridevirtual

Add extra Parameter gradient factors to an existing vector.

Parameters
channelThe Channel to add factors for.
factorsThe ExtraParamFactors to add to.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 36 of file psfmodel.cc.

36 {
37 for (auto& component : _components) component->add_extra_param_factors(channel, factors);
38}
void add_extra_param_factors(const Channel &channel, ExtraParamFactors &factors) const override
Add extra Parameter gradient factors to an existing vector.
Definition psfmodel.cc:36

◆ add_extra_param_map()

void lsst::gauss2d::fit::PsfModel::add_extra_param_map ( const Channel & channel,
ExtraParamMap & map_extra,
const GradParamMap & map_grad,
ParameterMap & offsets ) const
overridevirtual

Add extra Parameter indices to a map.

Parameters
channelThe Channel to add indices for.
map_extraThe ExtraParamMap to add to.
map_gradThe completed GradParamMap.
offsetsA map of index offsets for Parameters that have already been added.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 31 of file psfmodel.cc.

32 {
33 for (auto& component : _components) component->add_extra_param_map(channel, map_extra, map_grad, offsets);
34}
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 psfmodel.cc:31

◆ add_grad_param_factors()

void lsst::gauss2d::fit::PsfModel::add_grad_param_factors ( const Channel & channel,
GradParamFactors & factors ) const
overridevirtual

Add Parameter gradient factors to an existing map.

Parameters
channelThe Channel to add factors for.
factorsThe GradParamFactors to add to.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 44 of file psfmodel.cc.

44 {
45 for (auto& component : _components) component->add_grad_param_factors(channel, factors);
46}
void add_grad_param_factors(const Channel &channel, GradParamFactors &factor) const override
Add Parameter gradient factors to an existing map.
Definition psfmodel.cc:44

◆ add_grad_param_map()

void lsst::gauss2d::fit::PsfModel::add_grad_param_map ( const Channel & channel,
GradParamMap & map,
ParameterMap & offsets ) const
overridevirtual

Add Parameter gradient indices to an existing map.

Parameters
channelThe Channel to add indices for.
mapThe map to add to.
offsetsA map of index offsets for Parameters that have already been added.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 40 of file psfmodel.cc.

40 {
41 for (auto& component : _components) component->add_grad_param_map(channel, map, offsets);
42}
void add_grad_param_map(const Channel &channel, GradParamMap &map, ParameterMap &offsets) const override
Add Parameter gradient indices to an existing map.
Definition psfmodel.cc:40

◆ get_components()

Components lsst::gauss2d::fit::PsfModel::get_components ( ) const
overridevirtual

Implements lsst::gauss2d::fit::ComponentMixture.

Definition at line 48 of file psfmodel.cc.

48{ return _components; }

◆ get_gaussians()

std::unique_ptr< const lsst::gauss2d::Gaussians > lsst::gauss2d::fit::PsfModel::get_gaussians ( const Channel & channel = Channel::NONE()) const
overridevirtual

Return the vector of Gaussian sub-components controlled by this model.

Parameters
channelThe Channel to return Gaussians for.
Returns
The Gaussians controlled by this model.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 50 of file psfmodel.cc.

50 {
52 in.reserve(_components.size());
53 for (auto& component : _components) {
54 in.push_back(component->get_gaussians(channel)->get_data());
55 }
56 return std::make_unique<lsst::gauss2d::Gaussians>(in);
57}
T size(T... args)

◆ get_n_gaussians()

size_t lsst::gauss2d::fit::PsfModel::get_n_gaussians ( const Channel & channel = Channel::NONE()) const
overridevirtual

Return the number of Gaussian sub-components controlled by this model.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 59 of file psfmodel.cc.

59 {
60 size_t n_g = 0;
61 for (auto& component : _components) n_g += component->get_n_gaussians(channel);
62 return n_g;
63}
size_t get_n_gaussians(const Channel &channel=Channel::NONE()) const override
Return the number of Gaussian sub-components controlled by this model.
Definition psfmodel.cc:59

◆ get_parameters()

ParamRefs & lsst::gauss2d::fit::PsfModel::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 65 of file psfmodel.cc.

65 {
66 for (auto& component : _components) component->get_parameters(params, filter);
67 return params;
68}
ParamRefs & get_parameters(ParamRefs &params, ParamFilter *filter=nullptr) const override
Add Parameter refs matching the filter to a vector, in order.
Definition psfmodel.cc:65

◆ get_parameters_const()

ParamCRefs & lsst::gauss2d::fit::PsfModel::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 69 of file psfmodel.cc.

69 {
70 for (auto& component : _components) component->get_parameters_const(params, filter);
71 return params;
72}
ParamCRefs & get_parameters_const(ParamCRefs &params, ParamFilter *filter=nullptr) const override
Same as get_parameters(), but for const refs.
Definition psfmodel.cc:69

◆ 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

◆ 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

◆ repr()

std::string lsst::gauss2d::fit::PsfModel::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 83 of file psfmodel.cc.

83 {
84 std::string str = type_name_str<PsfModel>(false, namespace_separator) + "("
85 + (name_keywords ? "components=[" : "[");
86 for (const auto& s : _components) str += s->repr(name_keywords, namespace_separator) + ",";
87 return str + "])";
88}
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 psfmodel.cc:83

◆ set_extra_param_factors()

void lsst::gauss2d::fit::PsfModel::set_extra_param_factors ( const Channel & channel,
ExtraParamFactors & factors,
size_t index ) const
overridevirtual

Set extra Parameter gradient factors in an existing map.

Parameters
channelThe Channel to set factors for.
factorsThe ExtraParamFactors to set factors for.
indexThe index to begin setting factors at.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 74 of file psfmodel.cc.

75 {
76 for (auto& component : _components) component->set_extra_param_factors(channel, factors, index);
77}
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 psfmodel.cc:74

◆ set_grad_param_factors()

void lsst::gauss2d::fit::PsfModel::set_grad_param_factors ( const Channel & channel,
GradParamFactors & factors,
size_t index ) const
overridevirtual

Set Parameter gradient factors in an existing map.

Parameters
channelThe Channel to set factors for.
factorsThe GradParamFactors to set factors for.
indexThe index to begin setting factors at.

Implements lsst::gauss2d::fit::ParametricModel.

Definition at line 79 of file psfmodel.cc.

79 {
80 for (auto& component : _components) component->set_grad_param_factors(channel, factors, index);
81}
void set_grad_param_factors(const Channel &channel, GradParamFactors &factor, size_t index) const override
Set Parameter gradient factors in an existing map.
Definition psfmodel.cc:79

◆ str()

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

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

Implements lsst::gauss2d::Object.

Definition at line 90 of file psfmodel.cc.

90 {
91 std::string str = type_name_str<PsfModel>(true) + "(components=[";
92 for (const auto& s : _components) str += s->str() + ",";
93 return str + "])";
94}

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: