24 #ifndef LSST_MEAS_MODELFIT_GeneralPsfFitter_h_INCLUDED
25 #define LSST_MEAS_MODELFIT_GeneralPsfFitter_h_INCLUDED
29 #include "lsst/pex/config.h"
30 #include "lsst/shapelet/FunctorKeys.h"
34 #include "lsst/afw/table/Source.h"
35 #include "lsst/meas/base/exceptions.h"
36 #include "lsst/meas/base/FlagHandler.h"
39 namespace lsst {
namespace meas {
namespace modelfit {
54 "shapelet order for this component; negative to disable this component completely"
58 "sigma (in pixels) in an isotropic 2-d Gaussian prior on the center of this shapelet component, "
59 "relative to the center of the PSF image"
63 "sigma in an isotropic 2-d Gaussian prior on the conformal-shear ellipticity eta"
67 "Sets the fiducial radius of this component relative to the 'primary radius' of the PSF: either "
68 "the second-moments radius of the PSF image (in an initial fit), or the radius of the primary "
69 "component in a previous fit. Ignored if the previous fit included this component (as then we "
70 "can just use that radius)."
74 "sigma in a Gaussian prior on ln(radius/fiducialRadius)"
94 LSST_NESTED_CONTROL_FIELD(
96 "Innermost shapelet expansion, used to fit PSFs with very sharp cores"
99 LSST_NESTED_CONTROL_FIELD(
101 "Primary shapelet expansion, typically used to fit the bulk of the PSF "
104 LSST_NESTED_CONTROL_FIELD(
106 "Wing shapelet expansion (between primary and outer), typically used to fit the wings of the PSF"
109 LSST_NESTED_CONTROL_FIELD(
111 "Outermost shapelet expansion, used to fit PSFs with very broad wings"
114 LSST_NESTED_CONTROL_FIELD(
116 "Configuration of the optimizer used to do the fitting"
120 defaultNoiseSigma,
double,
"Default value for the noiseSigma parameter in GeneralPsfFitter.apply()"
159 shapelet::MultiShapeletFunctionKey
addFields(
160 afw::table::Schema & schema,
161 std::string
const & prefix
194 shapelet::MultiShapeletFunction
adapt(
195 shapelet::MultiShapeletFunction
const & previousFit,
196 PTR(
Model) previousModel
213 shapelet::MultiShapeletFunction
apply(
214 afw::image::Image<Pixel>
const & image,
215 afw::geom::ellipses::Quadrupole
const & moments,
217 int * pState =
nullptr
219 shapelet::MultiShapeletFunction
apply (
220 afw::image::Image<double>
const & image,
221 afw::geom::ellipses::Quadrupole
const & moments,
223 int * pState =
nullptr
225 return apply(afw::image::Image<float>(image,
true), moments, noiseSigma, pState);
243 shapelet::MultiShapeletFunction
apply(
244 afw::image::Image<Pixel>
const & image,
245 shapelet::MultiShapeletFunction
const & initial,
247 int * pState =
nullptr
249 shapelet::MultiShapeletFunction
apply(
250 afw::image::Image<double>
const & image,
251 shapelet::MultiShapeletFunction
const & initial,
253 int * pState =
nullptr
255 return apply(afw::image::Image<float>(image,
true), initial, noiseSigma);
269 static base::FlagDefinitionList
const & getFlagDefinitions();
279 afw::table::Schema & schema,
280 std::string
const & prefix
283 shapelet::MultiShapeletFunctionKey
getKey() {
288 afw::table::SourceRecord & measRecord,
289 afw::image::Image<double>
const & image,
290 shapelet::MultiShapeletFunction
const & initial
294 afw::table::SourceRecord & measRecord,
295 afw::image::Image<double>
const & image,
296 afw::geom::ellipses::Quadrupole
const & moments
300 afw::table::SourceRecord & measRecord,
301 lsst::meas::base::MeasurementError * error=
nullptr
305 shapelet::MultiShapeletFunctionKey _key;
306 lsst::meas::base::FlagHandler _flagHandler;
317 ndarray::Array<Pixel const,2,1>
const & image,
318 afw::geom::Point2I
const & xy0,
321 ndarray::Array<Scalar const,1,1>
const & fixed
324 void computeModelMatrix(
325 ndarray::Array<Pixel,2,-1>
const & modelMatrix,
326 ndarray::Array<Scalar const,1,1>
const & nonlinear,
327 bool doApplyWeights=
true
334 std::unique_ptr<Impl> _impl;
339 #endif // !LSST_MEAS_MODELFIT_GeneralPsfFitter_h_INCLUDED
Likelihood object used to fit multishapelet models to PSF model images; mostly for internal use by Ge...
shapelet::MultiShapeletFunction apply(afw::image::Image< double > const &image, afw::geom::ellipses::Quadrupole const &moments, Scalar noiseSigma=-1, int *pState=nullptr) const
Perform an initial fit to a PSF image.
boost::shared_ptr< Model > getModel() const
Return the Model object that corresponds to the configuration.
shapelet::MultiShapeletFunction apply(afw::image::Image< double > const &image, shapelet::MultiShapeletFunction const &initial, Scalar noiseSigma=-1, int *pState=nullptr) const
Perform a fit to a PSF image, using a previous fit as a starting point.
GeneralPsfFitterComponentControl(int order_=0, double radiusFactor_=1.0)
double radiusPriorSigma
"sigma in a Gaussian prior on ln(radius/fiducialRadius)" ;
static base::FlagDefinition const MAX_OUTER_ITERATIONS
GeneralPsfFitterControl()
GeneralPsfFitterComponentControl inner
"Innermost shapelet expansion, used to fit PSFs with very sharp cores" ;
GeneralPsfFitterComponentControl outer
"Outermost shapelet expansion, used to fit PSFs with very broad wings" ;
GeneralPsfFitterControl Control
shapelet::MultiShapeletFunction adapt(shapelet::MultiShapeletFunction const &previousFit, boost::shared_ptr< Model > previousModel) const
Adapt a differently-configured previous fit to be used as an starting point for this GeneralPsfFitter...
double Scalar
Typedefs to be used for probability and parameter values.
OptimizerControl optimizer
"Configuration of the optimizer used to do the fitting" ;
shapelet::MultiShapeletFunction apply(afw::image::Image< Pixel > const &image, afw::geom::ellipses::Quadrupole const &moments, Scalar noiseSigma=-1, int *pState=nullptr) const
Perform an initial fit to a PSF image.
Abstract base class and concrete factories that define multi-shapelet galaxy models.
double defaultNoiseSigma
"Default value for the noiseSigma parameter in GeneralPsfFitter.apply()" ;
static base::FlagDefinition const FAILURE
shapelet::MultiShapeletFunctionKey addFields(afw::table::Schema &schema, std::string const &prefix) const
Add fields to a Schema that can be used to store the MultiShapeletFunction returned by apply()...
double positionPriorSigma
"sigma (in pixels) in an isotropic 2-d Gaussian prior on the center of this shapelet component...
Control object used to define one piece of multishapelet fit to a PSF model; see GeneralPsfFitterCont...
shapelet::MultiShapeletFunctionKey getKey()
Configuration object for Optimizer.
static base::FlagDefinition const MAX_INNER_ITERATIONS
GeneralPsfFitterComponentControl primary
"Primary shapelet expansion, typically used to fit the bulk of the PSF " ;
Base class for Bayesian priors.
Base class for optimizer/sampler likelihood functions that compute likelihood at a point...
GeneralPsfFitter(GeneralPsfFitterControl const &ctrl)
Initialize the fitter class with the given control object.
Class for fitting multishapelet models to PSF images.
double radiusFactor
"Sets the fiducial radius of this component relative to the 'primary radius' of the PSF: either " "t...
GeneralPsfFitterComponentControl wings
"Wing shapelet expansion (between primary and outer), typically used to fit the wings of the PSF" ; ...
double ellipticityPriorSigma
"sigma in an isotropic 2-d Gaussian prior on the conformal-shear ellipticity eta" ; ...
Control object used to configure a multishapelet fit to a PSF model; see GeneralPsfFitter.
static base::FlagDefinition const CONTAINS_NAN
int order
"shapelet order for this component; negative to disable this component completely" ; ...
static base::FlagDefinition const EXCEPTION
boost::shared_ptr< Prior > getPrior() const
Return the Prior object that corresponds to the configuration.