How to properly configure measureCoaddSources?

Up to now I was running with the folloing configuration file:

import lsst.meas.extensions.shapeHSM 
config.measurement.plugins.names |= ["ext_shapeHSM_HsmShapeRegauss", "ext_shapeHSM_HsmSourceMoments",
config.measurement.slots.shape = "ext_shapeHSM_HsmSourceMoments"

import lsst.meas.modelfit
import lsst.shapelet
config.measurement.plugins.names |= ["modelfit_GeneralShapeletPsfApprox", "modelfit_DoubleShapeletPsfApprox",   "modelfit_CModel"]


But I am getting warnings like the following:

Cannot aperture correct modelfit_CModel_dev because could not find modelfit_CModel_dev_flux or modelfit_CModel_dev_fluxSigma in apCorrMap

And while running mergeCoaddMeasurements I get:

 Can't find flag ext_photometryKron_KronFlux_flag in schema: "Field 'ext_photometryKron_KronFlux_flag' not found in Schema."

What should I add in the configuration file to avoid this ?

I’m not sure what the second warning is, but I imagine you can fix it by setting up meas_extensions_photometryKron and adding ext_photometryKron_KronFlux to the list of algorithms. I don’t understand why it’s necessary in, though.

The first warning can only be fixed by re-running single-frame processing and coaddition with the modelfit algorithms enabled there: we derive our coadd aperture corrections by “coadding” the aperture corrections from individual exposures, so if we don’t generate an aperture correction for CModel at that point, there’s nothing we can do about it later.

As a side note, it should be unnecessary to run modelfit_GeneralShapeletPsfApprox; it’s an alternative to modelfit_DoubleShapeletPsfApprox that’s slower and more prone to failure, and I the the CModel default is to use DoubleShapeletPsfApprox so it’s probably being ignored right now anyway.

In order to enable CModel in processCcd, is it enough to add:

import lsst.meas.modelfit
import lsst.shapelet
config.charImage.measurement.plugins.names |= ["modelfit_DoubleShapeletPsfApprox", "modelfit_CModel"]
config.calibrate.measurement.plugins.names |= ["modelfit_DoubleShapeletPsfApprox", "modelfit_CModel"]

in the configuration file ?

It should actually only be necessary to do this for charImage; adding these to the plugins for calibrate is harmless but unnecessary, since aperture corrections are measured in charImage. And I don’t think you need to import lsst.shapelet. But the lines themselves look correct.

1 Like

It will dramatically increase the runtime.

1 Like

Have a look at the configuration for HSC in obs_subaru. We have a configuration file, that gets loaded whenever we want to activate CModel. This allows reuse in processCcd, measureCoaddSources, forcedPhotCoadd, etc. The import is in a try block, which makes it very easy to disable CModel by simply doing unsetup -j meas_modelfit.

from __future__ import print_function
# Enable CModel mags (unsetup meas_modelfit or use $MEAS_MODELFIT_DIR/config/ to disable)
# 'config' is a SourceMeasurementConfig.
import os
    import lsst.meas.modelfit
    config.measurement.plugins.names |= ["modelfit_DoubleShapeletPsfApprox", "modelfit_CModel"]
    config.measurement.slots.modelFlux = 'modelfit_CModel'
    config.catalogCalculation.plugins['base_ClassificationExtendedness'].fluxRatio = 0.985
except (KeyError, ImportError):
    print("Cannot import lsst.meas.modelfit: disabling CModel measurements")

Then, in

from lsst.utils import getPackageDir
configDir = os.path.join(getPackageDir("obs_subaru"), "config")
config.charImage.load(os.path.join(configDir, ""))
1 Like