LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
|
A collection of Sources comprising a ParametricModel of Data. More...
#include <model.h>
Public Types | |
typedef GaussianEvaluator< T, Image, Indices > | Evaluator |
typedef std::map< std::reference_wrapper< const Channel >, std::vector< std::unique_ptr< const Gaussians > > > | GaussiansMap |
typedef Data< T, Image, Mask > | ModelData |
typedef ModelData::Observation | Observation |
Public Member Functions | |
Model (std::shared_ptr< const ModelData > data, PsfModels &psfmodels, Sources &sources, Priors &priors) | |
Construct a Model instance from Data, PsfModels, Sources and Priors. | |
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 &factors) const override |
Add Parameter gradient factors to an existing map. | |
std::vector< double > | compute_loglike_grad (bool include_prior=true, bool print=false, bool verify=false, double findiff_frac=1e-5, double findiff_add=1e-5, double rtol=1e-3, double atol=1e-8) |
Compute the gradient (partial first derivative) of the log-likelihood for each free parameter. | |
std::unique_ptr< Image > | compute_hessian (bool transformed=false, bool include_prior=true, std::optional< HessianOptions > options=std::nullopt, bool print=false) |
Compute the Hessian matrix (second order partial derivatives) of the log likehood. | |
std::vector< double > | evaluate (bool print=false, bool normalize_loglike=false) |
Evaluate the model for every Observation in _data. | |
double | evaluate_observation (size_t idx) |
Evaluate a single observation with the given index in _data. | |
std::shared_ptr< const ModelData > | get_data () const |
Return _data. | |
EvaluatorMode | get_mode () const |
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::vector< double > | get_loglike_const_terms () |
Get the constant (variance-dependent) terms of the log likelihood for each observation. | |
size_t | get_n_gaussians (const Channel &channel) const override |
Return the number of Gaussian sub-components controlled by this model. | |
std::vector< std::shared_ptr< Image > > | get_outputs () const |
Return _outputs (output Image instances for each Observation in _data) | |
std::vector< std::pair< ParamBaseCRef, size_t > > | get_offsets_parameters () const |
ParamRefs & | get_parameters (ParamRefs ¶ms, ParamFilter *filter=nullptr) const override |
Add Parameter refs matching the filter to a vector, in order. | |
ParamCRefs & | get_parameters_const (ParamCRefs ¶ms, ParamFilter *filter=nullptr) const override |
Same as get_parameters(), but for const refs. | |
ParamRefs & | get_parameters_observation (ParamRefs ¶ms, size_t idx, ParamFilter *filter=nullptr) const |
Same as get_parameters(), but for a single Observation with index idx in _data. | |
ParamCRefs & | get_parameters_observation_const (ParamCRefs ¶ms, size_t idx, ParamFilter *filter=nullptr) const |
Same as get_parameters_const(), but for a single Observation with index idx in _data. | |
Priors | get_priors () const |
Return _priors, the list of Prior instances. | |
PsfModels | get_psfmodels () const |
Return _psfmodels, the list of PsfModel instances for each Observation in _data. | |
Sources | get_sources () const |
Return _sources, the list of Source instances for each Observation in _data. | |
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 &factors, size_t index) const override |
Set Parameter gradient factors in an existing map. | |
void | setup_evaluators (EvaluatorMode mode=EvaluatorMode::image, std::vector< std::vector< std::shared_ptr< Image > > > outputs={}, std::vector< std::shared_ptr< Image > > residuals={}, std::vector< std::shared_ptr< Image > > outputs_prior={}, std::shared_ptr< Image > residuals_prior=nullptr, bool force=false, bool print=false) |
Setup Evaluator instances for every Observation in _data using the given EvaluatorMode. | |
size_t | size () const |
Get the size of this->_data. | |
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::vector< std::string > | verify_jacobian (double findiff_frac=1e-5, double findiff_add=1e-5, double rtol=1e-3, double atol=1e-3, double max_ll_diff=0) |
Verify that the Jacobian is correct by comparing to finite differences. | |
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 = "." |
A collection of Sources comprising a ParametricModel of Data.
typedef GaussianEvaluator<T, Image, Indices> lsst::gauss2d::fit::Model< T, Image, Indices, Mask >::Evaluator |
typedef std::map<std::reference_wrapper<const Channel>, std::vector<std::unique_ptr<const Gaussians> > > lsst::gauss2d::fit::Model< T, Image, Indices, Mask >::GaussiansMap |
typedef ModelData::Observation lsst::gauss2d::fit::Model< T, Image, Indices, Mask >::Observation |
|
inlineexplicit |
Construct a Model instance from Data, PsfModels, Sources and Priors.
data | The data to model. |
psfmodels | A vector of PSF models, ordered to match each Observation in data. |
sources | A vector of Source models. |
priors | A vector of Prior likelihoods. |
Definition at line 94 of file model.h.
|
inlineoverridevirtual |
Add extra Parameter gradient factors to an existing vector.
channel | The Channel to add factors for. |
factors | The ExtraParamFactors to add to. |
Implements lsst::gauss2d::fit::ParametricModel.
Definition at line 681 of file model.h.
|
inlineoverridevirtual |
Add extra Parameter indices to a map.
channel | The Channel to add indices for. |
map_extra | The ExtraParamMap to add to. |
map_grad | The completed GradParamMap. |
offsets | A map of index offsets for Parameters that have already been added. |
Implements lsst::gauss2d::fit::ParametricModel.
Definition at line 677 of file model.h.
|
inlineoverridevirtual |
Add Parameter gradient factors to an existing map.
channel | The Channel to add factors for. |
factors | The GradParamFactors to add to. |
Implements lsst::gauss2d::fit::ParametricModel.
Definition at line 687 of file model.h.
|
inlineoverridevirtual |
Add Parameter gradient indices to an existing map.
channel | The Channel to add indices for. |
map | The map to add to. |
offsets | A map of index offsets for Parameters that have already been added. |
Implements lsst::gauss2d::fit::ParametricModel.
Definition at line 684 of file model.h.
|
inline |
Compute the Hessian matrix (second order partial derivatives) of the log likehood.
transformed | Whether the matrix should be computed for transformed parameters or not If not, parameter transforms are temporarily removed. |
include_prior | Whether to include the prior likelihood(s) in the Hessian. |
options | Options for computing the Hessian via finite differencing of loglikelihood gradients. If null, the Hessian is estimated as J^T J (where J is the Jacobian). |
Definition at line 825 of file model.h.
|
inline |
Compute the gradient (partial first derivative) of the log-likelihood for each free parameter.
include_prior | Whether to include the prior likelihood(s) in the gradients. |
Whether to print diagnostic/debugging information. | |
verify | Whether to verify the values by comparing to finite differences. |
findiff_frac | The value of the finite difference increment, as a fraction of the parameter value. |
findiff_add | The minimum value of the finite difference increment. |
rtol | The allowed relative tolerance in the Jacobian as compared to the finite difference. |
atol | The allowed absolute tolerance in the Jacobian as compared to the finite difference. |
Definition at line 704 of file model.h.
|
inline |
Evaluate the model for every Observation in _data.
Whether to print diagnostic statements to stdout. | |
normalize_loglike | Whether to include the normalizing (variance-dependent) term in the log likelihood. If false, the log likelihood for a model with no residuals is 0. |
Definition at line 1019 of file model.h.
|
inline |
Evaluate a single observation with the given index in _data.
idx | The numeric index of the observation. |
Definition at line 1051 of file model.h.
|
inline |
|
inlineoverridevirtual |
Return the vector of Gaussian sub-components controlled by this model.
Implements lsst::gauss2d::fit::ParametricModel.
Definition at line 1061 of file model.h.
|
inline |
Get the constant (variance-dependent) terms of the log likelihood for each observation.
Definition at line 1079 of file model.h.
|
inline |
|
inlineoverridevirtual |
Return the number of Gaussian sub-components controlled by this model.
Implements lsst::gauss2d::fit::ParametricModel.
Definition at line 1106 of file model.h.
|
inline |
|
inline |
Return _outputs (output Image instances for each Observation in _data)
Definition at line 1113 of file model.h.
|
inlineoverridevirtual |
Add Parameter refs matching the filter to a vector, in order.
params | The vector to add to. |
filter | The filter to apply to this Object's parameters. |
Implements lsst::gauss2d::fit::Parametric.
Definition at line 1123 of file model.h.
|
inlineoverridevirtual |
Same as get_parameters(), but for const refs.
Implements lsst::gauss2d::fit::Parametric.
Definition at line 1130 of file model.h.
|
inlineinherited |
Same as get_parameters_const(), but returning a new vector.
Definition at line 33 of file parametric.h.
|
inlineinherited |
Same as get_parameters(), but returning a new vector.
Definition at line 27 of file parametric.h.
|
inline |
Same as get_parameters(), but for a single Observation with index idx in _data.
Definition at line 1138 of file model.h.
|
inline |
Same as get_parameters_const(), but for a single Observation with index idx in _data.
Definition at line 1148 of file model.h.
|
inline |
|
inline |
Return _psfmodels, the list of PsfModel instances for each Observation in _data.
Definition at line 1161 of file model.h.
|
inline |
Return _sources, the list of Source instances for each Observation in _data.
Definition at line 1164 of file model.h.
|
inlinestaticinherited |
Definition at line 49 of file object.h.
|
inlineoverridevirtual |
Return a full, callable string representation of this.
name_keywords | Whether to prefix arguments with "{name}=", where name is the arg name in the header (as with keyword arguments in Python). |
namespace_separator | The string to use to delimit namespaces, i.e. :: in C++ and . in Python. |
Implements lsst::gauss2d::Object.
Definition at line 1377 of file model.h.
|
inlineoverridevirtual |
Set extra Parameter gradient factors in an existing map.
channel | The Channel to set factors for. |
factors | The ExtraParamFactors to set factors for. |
index | The index to begin setting factors at. |
Implements lsst::gauss2d::fit::ParametricModel.
|
inlineoverridevirtual |
Set Parameter gradient factors in an existing map.
channel | The Channel to set factors for. |
factors | The GradParamFactors to set factors for. |
index | The index to begin setting factors at. |
Implements lsst::gauss2d::fit::ParametricModel.
|
inline |
Setup Evaluator instances for every Observation in _data using the given EvaluatorMode.
mode | The EvaluatorMode to use for all Evaluator instances. |
outputs | A vector of vectors of Image outputs for each Evaluator (created if empty and needed). |
residuals | A vector of residual Images for each Evaluator (created if empty and needed). |
outputs_prior | A vector of prior output (Jacobian) Images for each Evaluator (created if empty and needed). |
residuals_prior | A vector of prior residual Images for each Evaluator (created if empty and needed). |
force | Whether to force setting up even if already set up in the same mode |
Whether to print diagnostic statements to stdout. |
Definition at line 1199 of file model.h.
|
inline |
|
inlineoverridevirtual |
Return a brief, human-readable string representation of this.
Implements lsst::gauss2d::Object.
Definition at line 1389 of file model.h.
|
inline |
Verify that the Jacobian is correct by comparing to finite differences.
findiff_frac | The value of the finite difference increment, as a fraction of the parameter value. |
findiff_add | The minimum value of the finite difference increment. |
rtol | The allowed relative tolerance in the Jacobian as compared to the finite difference. |
atol | The allowed absolute tolerance in the Jacobian as compared to the finite difference. |
max_ll_diff | The maximum allowed difference between equivalent log-likelihood evaluations. Must be >= 0 and should only be a few orders of magnitude larger than machine epsilon. |
Definition at line 1412 of file model.h.
|
staticconstexprinherited |
|
staticconstexprinherited |
|
staticconstexprinherited |