LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+a41d3748ce,g1470d8bcf6+6be6c9203b,g2079a07aa2+14824f138e,g212a7c68fe+a4f2ea4efa,g2305ad1205+72971fe858,g295015adf3+ab2c85acae,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+31b3a28dff,g487adcacf7+082e807817,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+b2918d57ae,g5a732f18d5+66d966b544,g64a986408d+a41d3748ce,g858d7b2824+a41d3748ce,g8a8a8dda67+a6fc98d2e7,g99cad8db69+7fe4acdf18,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+84af8b3ff8,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gba4ed39666+9664299f35,gbb8dafda3b+d8d527deb2,gc07e1c2157+b2dbe6b631,gc120e1dc64+61440b2abb,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+31b3a28dff,gdaeeff99f8+a38ce5ea23,ge6526c86ff+39927bb362,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+a41d3748ce,v24.1.5.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxMixin Class Reference
Inheritance diagram for lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxMixin:
lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxForcedPlugin lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxSingleFramePlugin

Public Member Functions

 __init__ (self, config, name, schema)
 
 measure (self, measRecord, exposure)
 
 fail (self, measRecord, error=None)
 

Public Attributes

 sequence
 

Detailed Description

Mixin base class for fitting shapelet approximations to the PSF model

This class does almost all of the work for its two derived classes,
GeneralShapeletPsfApproxSingleFramePlugin and
GeneralShapeletPsfApproxForcedPlugin, which simply adapt it to the
slightly different interfaces for single-frame and forced measurement.  It
in turn delegates its work to the C++ GeneralPsfFitter class; it holds
sequence of these corresponding to different models (generally with
increasing complexity). Each GeneralPsfFitter starts with the result of
the previous one as an input, using GeneralPsfFitter::adapt to hopefully
allow these previous fits to reduce the time spent on the next one.

At present, this plugin does not define any failure flags, which will
almost certainly have to be changed in the future.  So far, however, I
haven't actually seen it fail on any PSFs I've given it, so I'll wait
until we can run on large enough data volumes to see what the actual
failure modes are, instead of trying to guess them in advance.

Definition at line 107 of file psfContinued.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxMixin.__init__ ( self,
config,
name,
schema )
Initialize the plugin, creating a sequence of GeneralPsfFitter
instances to do the fitting and MultiShapeletFunctionKey instances to
save the results to a record.

Reimplemented in lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxSingleFramePlugin, and lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxForcedPlugin.

Definition at line 127 of file psfContinued.py.

127 def __init__(self, config, name, schema):
128 """Initialize the plugin, creating a sequence of GeneralPsfFitter
129 instances to do the fitting and MultiShapeletFunctionKey instances to
130 save the results to a record.
131 """
132 self.sequence = []
133 for m in config.sequence:
134 fitter = GeneralPsfFitterAlgorithm(
135 config.models[m].makeControl(),
136 schema,
137 schema[name][m].getPrefix()
138 )
139 self.sequence.append((fitter, schema[name][m].getPrefix()))
140

Member Function Documentation

◆ fail()

lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxMixin.fail ( self,
measRecord,
error = None )

Reimplemented in lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxSingleFramePlugin, and lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxForcedPlugin.

Definition at line 183 of file psfContinued.py.

183 def fail(self, measRecord, error=None):
184 pass
185
186

◆ measure()

lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxMixin.measure ( self,
measRecord,
exposure )
Fit the configured sequence of models the given Exposure's Psf, as
evaluated at measRecord.getCentroid(), then save the results to
measRecord.

Reimplemented in lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxSingleFramePlugin, and lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxForcedPlugin.

Definition at line 141 of file psfContinued.py.

141 def measure(self, measRecord, exposure):
142 """Fit the configured sequence of models the given Exposure's Psf, as
143 evaluated at measRecord.getCentroid(), then save the results to
144 measRecord.
145 """
146 if not exposure.hasPsf():
148 "GeneralShapeletPsfApprox requires Exposure to have a Psf")
149 psf = exposure.getPsf()
150 psfImage = psf.computeKernelImage(measRecord.getCentroid())
151 psfShape = psf.computeShape(measRecord.getCentroid())
152 lastError = None
153 lastModel = None
154 # Fit the first element in the sequence, using the PSFs moments to
155 # initialize the parameters For every other element in the fitting
156 # sequence, use the previous fit to initialize the parameters
157 lastResult = None
158 for fitter, name in self.sequence:
159 try:
160 if lastModel is None:
161 fitter.measure(measRecord, psfImage, psfShape)
162 else:
163 fitter.measure(measRecord, psfImage,
164 fitter.adapt(lastResult, lastModel))
165 lastResult = measRecord.get(fitter.getKey())
166 lastModel = fitter.getModel()
167 except lsst.meas.base.baseMeasurement.FATAL_EXCEPTIONS:
168 raise
169 except lsst.meas.base.MeasurementError as error:
170 fitter.fail(measRecord, error.cpp)
171 lastError = error
172 except Exception as error:
173 fitter.fail(measRecord)
174 lastError = error
175 # When we are done with all the fitters, raise the last error if there
176 # was one. This gives the calling task a chance to do whatever it
177 # wants
178 if lastError is not None:
179 raise lastError
180
Exception to be thrown when a measurement algorithm experiences a fatal error.
Definition exceptions.h:76
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition exceptions.h:48

Member Data Documentation

◆ sequence

lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxMixin.sequence

Definition at line 132 of file psfContinued.py.


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