1 __all__ = (
"displayReconstructedCmodel", 
"displayReconstrucedCmodelMpl",
     2            "buildCModelImages", 
"reconstructCModel")
     5 import matplotlib.pyplot 
as plt
    13     """ Display an image, the Cmodel, and residuals    17     exposure : `lsst.afw.image.Exposure`    18         Exposure object that contains the source which was modeled    19     record : `lsst.afw.table.SourceRecord`    20         Record object which contains the measurements made on the source    21     config : `lsst.meas.modelfit.CModel(SingleFrame/Forced)Config`    22         Configuration object of the CModel plugin used in the measurement    24     display : `str`, optional    25         Display in which to render the data, may be mpl for matplotlib or afw    26         for afwDisplay, defaults to mpl    31         If the display backend specified is not implemented    36     elif display == 
"afw":
    37         raise NotImplementedError(
"The afw display backend is not yet "    40         raise NotImplementedError(
"The display backend '{}' is not a supported"    45     """ Display an image, the Cmodel, and residuals using matplotlib    49     exposure : `lsst.afw.image.Exposure`    50         Exposure object that contains the source which was  modeled    51     record : `lsst.afw.table.SourceRecord`    52         Record object which contains the measurements made on the source    53     config : `lsst.meas.modelfit.CModel(SingleFrame/Forced)Config`    54         Configuration object of the CModel plugin used in the measurement    61     subImMin = subImage.array.min()
    62     subImMax = subImage.array.max()
    65     devResidual = subImage.array-devIm.array
    66     expResidual = subImage.array-expIm.array
    67     jointResidual = subImage.array-jointIm.array
    68     residualList = (devResidual, expResidual, jointResidual)
    70     differences = [(x.max()-x.max()) 
for x 
in residualList]
    71     maxDifferenceIndex = np.argmax(differences)
    72     resImMin = residualList[maxDifferenceIndex].
min()
    73     resImMax = residualList[maxDifferenceIndex].
max()
    76     fig, axes = plt.subplots(3, 3, sharex=
'col', sharey=
'row', figsize=(8, 5))
    77     fig.subplots_adjust(left=0.25, right=0.8)
    78     lCBar = fig.add_axes([0.1, 0.15, 0.05, 0.7])
    79     rCBar = fig.add_axes([0.85, 0.15, 0.05, 0.7])
    83         axes[i, 0].imshow(subImage.array, vmin=subImMin, vmax=subImMax)
    86     axes[0, 1].imshow(devIm.array, vmin=subImMin, vmax=subImMax)
    87     axes[0, 2].imshow(devResidual, vmin=resImMin, vmax=resImMax, cmap=
"BrBG")
    90     axes[1, 1].imshow(expIm.array, vmin=subImMin, vmax=subImMax)
    91     axes[1, 2].imshow(expResidual, vmin=resImMin, vmax=resImMax, cmap=
"BrBG")
    94     axes[2, 1].imshow(jointIm.array, vmin=subImMin, vmax=subImMax)
    95     axes[2, 2].imshow(jointResidual, vmin=resImMin, vmax=resImMax, cmap=
"BrBG")
    97     axes[0, 0].set_title(
"Image")
    98     axes[0, 1].set_title(
"Model")
    99     axes[0, 2].set_title(
'Residuals')
   101     axes[0, 0].set_ylabel(
"Dev")
   102     axes[1, 0].set_ylabel(
"Exp")
   103     axes[2, 0].set_ylabel(
"Joint")
   105     fig.colorbar(axes[0, 0].get_images()[0], lCBar)
   106     lCBar.yaxis.set_ticks_position(
'left')
   107     fig.colorbar(axes[maxDifferenceIndex, 2].get_images()[0], rCBar)
   113     """ Create Images out of the CModel for the given record   117     exposure : `lsst.afw.image.Exposure`   118         Exposure object that contains the source which was  modeled   119     record : `lsst.afw.table.SourceRecord`   120         Record object which contains the measurements made on the source   121     config : `lsst.meas.modelfit.CModel(SingleFrame/Forced)Config`   122         Configuration object of the CModel plugin used in the measurement   127     subImage : `lsst.afw.image.ImageF`   128         Sub image of the original data taken from a region defined by the   129         bounding box of the footprint for the object defined in the given   131     devIm : `lsst.afw.image.ImageF`   132         Image created from the dev component of the CModel for the supplied   133         record at the same pixel locations as subImage   134     expIm: `lsst.afw.image.ImageF`   135         Image created from the exp component of the CModel for the supplied   136         record at the same pixel locations as subImage   138         Image created from the joint fit of the dev and exp components of the   139         CModel for the supplied record at the same pixel locations as subImage   144     footBBox = record.getFootprint().getBBox()
   145     subImage = afwImage.ImageF(exposure.getImage(), footBBox)
   149         record.schema[config.psfName])
   150     psfApprox = record.get(shapeletPsfKey)
   153     devIm = afwImage.ImageF(footBBox)
   154     dev = dev.convolve(psfApprox)
   158     expIm = afwImage.ImageF(footBBox)
   159     exp = exp.convolve(psfApprox)
   163     jointIm = afwImage.ImageF(footBBox)
   164     jointDev = jointDev.convolve(psfApprox)
   165     jointExp = jointExp.convolve(psfApprox)
   169     return subImage, devIm, expIm, jointIm
   173     """ Reconstruct the CModel for the given record   177     exposure : `lsst.afw.image.Exposure`   178         Exposure object that contains the source which was  modeled   179     record : `lsst.afw.table.SourceRecord`   180         Record object which contains the measurements made on the source   181     config : `lsst.meas.modelfit.CModel(SingleFrame/Forced)Config`   182         Configuration object of the CModel plugin used in the measurement   187     devShapelet : `lsst.shapelet.MultiShapeletFunction`   188         Multi-component shapelet model of the dev component of CModel   189     expShapelet : `lsst.shapelet.MultiShapeletFunction`   190         Multi-component shapelet model fo the exp component of CModel   191     devJointShapelet : `lsst.shapelet.MultiShapeletFunction`   192         Multi-component shapelet model of the dev component of CModel jointly   193         fit with the exp component   194     expJointShapelet : `lsst.shapelet.MultiShapeletFunction`   195         Multi-component shapelet model of the exp component of Cmodel jointly   196         fit with the dev component   200     center = record.getCentroid()
   201     position = exposure.getWcs().pixelToSky(center)
   202     measSys = measMod.UnitSystem(exposure)
   203     approxFlux = record.get(
"base_PsfFlux_instFlux")
   204     fitSys = measMod.UnitSystem(position, exposure.getCalib(), approxFlux)
   205     fitSysToMeasSys = measMod.LocalUnitTransform(center, fitSys, measSys)
   208     ctrl = config.makeControl()
   209     baseName = 
"modelfit_CModel"   210     nonlinearKeys = [
"{}_{{model}}_nonlinear_{p}".
format(baseName, p=p)
   212     fixedKeys = [
"{}_{{model}}_fixed_{p}".
format(baseName, p=p)
   214     fluxKey = 
"{}_{{model}}_instFlux".
format(baseName)
   218         apCorr = record.get(
"{}_apCorr".
format(baseName))
   220         print(
"Warning, problem retrieving aperture correction, using a value"   225     devNonLinearParams = np.array([record.get(key.format(model=
"dev"))
   226                                   for key 
in nonlinearKeys])
   227     devFixedParams = np.array([record.get(key.format(model=
"dev"))
   228                               for key 
in fixedKeys])
   229     devAmp = np.array([record.get(fluxKey.format(model=
"dev"))])
   231     devShapelet = ctrl.dev.getModel().makeShapeletFunction(devNonLinearParams,
   234     devShapelet.transformInPlace(fitSysToMeasSys.geometric)
   237     expNonLinearParams = np.array([record.get(key.format(model=
"exp"))
   238                                   for key 
in nonlinearKeys])
   239     expFixedParams = np.array([record.get(key.format(model=
"exp"))
   240                               for key 
in fixedKeys])
   241     expAmp = np.array([record.get(fluxKey.format(model=
"exp"))])
   243     expShapelet = ctrl.exp.getModel().makeShapeletFunction(expNonLinearParams,
   246     expShapelet.transformInPlace(fitSysToMeasSys.geometric)
   249     fracDev = record.get(
"{}_fracDev".
format(baseName))
   250     jointFlux = np.array([record.get(
"{}_instFlux".
format(baseName))])
   252     devJointShapelet = ctrl.dev.getModel()\
   253         .makeShapeletFunction(devNonLinearParams, jointFlux*fracDev,
   255     devJointShapelet.transformInPlace(fitSysToMeasSys.geometric)
   257     expJointShapelet = ctrl.exp.getModel()\
   258         .makeShapeletFunction(expNonLinearParams, jointFlux*(1-fracDev),
   260     expJointShapelet.transformInPlace(fitSysToMeasSys.geometric)
   262     return devShapelet, expShapelet, devJointShapelet, expJointShapelet
 def displayReconstructedCmodel(exposure, record, config, display="mpl")
def reconstructCModel(exposure, record, config)
Class that maps MultiShapeletFunction objects to fields in afw::table objects. 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
def displayReconstrucedCmodelMpl(exposure, record, config)
void addToImage(boost::shared_ptr< afw::image::Image< double > > image, std::vector< boost::shared_ptr< afw::image::Image< double > >> const &imgVector, std::vector< double > const &weightVector)
def buildCModelImages(exposure, record, config)