LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
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: