import hsc.pipe.tasks.stack
assert type(root)==hsc.pipe.tasks.stack.StackConfig, 'config is of type %s.%s instead of hsc.pipe.tasks.stack.StackConfig' % (type(root).__module__, type(root).__name__)
'''dataId keys that identify an exposure '''
root.backgroundReference.visitKeys=['visit']

import hsc.pipe.tasks.stack
import lsst.pex.config.config
root.backgroundReference.select.retarget(target=hsc.pipe.tasks.stack.NullSelectImagesTask, ConfigClass=lsst.pex.config.config.Config)
'''Weight for scoring number of exposures '''
root.backgroundReference.assign.scoreNumExposures=2.0

'''Weight for scoring average overlap '''
root.backgroundReference.assign.scoreAverageOverlap=1.0

'''Weight for scoring number of patches '''
root.backgroundReference.assign.scoreNumPatches=2.0

'''Weight for scoring average PSF width '''
root.backgroundReference.assign.scoreAveragePsfWidth=0.1

'''Weight for scoring average background stdev '''
root.backgroundReference.assign.scoreAverageBgStdev=0.01

'''Merged background model bin size (tract pixels) '''
root.backgroundReference.construct.bgSize=256

'''Radius for taper to start '''
root.backgroundReference.construct.taper.start=None

'''Radius for taper to stop '''
root.backgroundReference.construct.taper.stop=None

'''Mask planes to mask '''
root.backgroundReference.construct.mask=['BAD', 'SAT', 'NO_DATA']

'''Clobber existing outputs? '''
root.backgroundReference.construct.clobber=False

'''desired photometric zero point '''
root.backgroundReference.construct.scaling.zeroPoint=27.0

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.backgroundReference.construct.matching.undersampleStyle='REDUCE_INTERP_ORDER'

'''Names of mask planes to ignore while estimating the background '''
root.backgroundReference.construct.matching.background.ignoredPixelMask=['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.backgroundReference.construct.matching.background.undersampleStyle='REDUCE_INTERP_ORDER'

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.backgroundReference.construct.matching.background.algorithm='NATURAL_SPLINE'

'''how large a region of the sky should be used for each background point
	Valid Range = [10,inf) '''
root.backgroundReference.construct.matching.background.binSize=128

'''Ignore NaNs when estimating the background '''
root.backgroundReference.construct.matching.background.isNanSafe=False

'''type of statistic to use for grid points
Allowed values:
	MEDIAN	median
	MEANCLIP	clipped mean
	None	Field is optional
	MEAN	unclipped mean
 '''
root.backgroundReference.construct.matching.background.statisticsProperty='MEANCLIP'

'''Apprimation order for background Chebyshev (valid only with useApprox=True) '''
root.backgroundReference.construct.matching.background.approxOrder=6

'''Use Approximate (Chebyshev) to model background. '''
root.backgroundReference.construct.matching.background.useApprox=True

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.backgroundReference.construct.matching.interpolation='AKIMA_SPLINE'

'''Name of coadd of interest '''
root.backgroundReference.coaddName='deep'

'''Estimate the background again after final source detection? '''
root.detectCoaddSources.detection.reEstimateBackground=True

'''detected sources with fewer than the specified number of pixels will be ignored
	Valid Range = [0,inf) '''
root.detectCoaddSources.detection.minPixels=1

'''Grow detections by nSigmaToGrow * sigma; if 0 then do not grow '''
root.detectCoaddSources.detection.nSigmaToGrow=2.4

'''Names of mask planes to ignore while estimating the background '''
root.detectCoaddSources.detection.footprintBackground.ignoredPixelMask=['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.detectCoaddSources.detection.footprintBackground.undersampleStyle='REDUCE_INTERP_ORDER'

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.detectCoaddSources.detection.footprintBackground.algorithm='AKIMA_SPLINE'

'''how large a region of the sky should be used for each background point
	Valid Range = [10,inf) '''
root.detectCoaddSources.detection.footprintBackground.binSize=64

'''Ignore NaNs when estimating the background '''
root.detectCoaddSources.detection.footprintBackground.isNanSafe=False

'''type of statistic to use for grid points
Allowed values:
	MEDIAN	median
	MEANCLIP	clipped mean
	None	Field is optional
	MEAN	unclipped mean
 '''
root.detectCoaddSources.detection.footprintBackground.statisticsProperty='MEANCLIP'

'''Apprimation order for background Chebyshev (valid only with useApprox=True) '''
root.detectCoaddSources.detection.footprintBackground.approxOrder=6

'''Use Approximate (Chebyshev) to model background. '''
root.detectCoaddSources.detection.footprintBackground.useApprox=False

'''Do background subtraction before footprint detection? '''
root.detectCoaddSources.detection.doFootprintBackground=False

'''Include threshold relative to thresholdValue
	Valid Range = [0.0,inf) '''
root.detectCoaddSources.detection.includeThresholdMultiplier=1.0

'''Pixels should be grown as isotropically as possible (slower) '''
root.detectCoaddSources.detection.isotropicGrow=True

'''Fiddle factor to add to the background; debugging only '''
root.detectCoaddSources.detection.adjustBackground=0.0

'''specifies the desired flavor of Threshold
Allowed values:
	pixel_stdev	threshold applied to per-pixel std deviation
	variance	threshold applied to image variance
	value	threshold applied to image value
	stdev	threshold applied to image std deviation
 '''
root.detectCoaddSources.detection.thresholdType='pixel_stdev'

'''Names of mask planes to ignore while estimating the background '''
root.detectCoaddSources.detection.background.ignoredPixelMask=['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.detectCoaddSources.detection.background.undersampleStyle='REDUCE_INTERP_ORDER'

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.detectCoaddSources.detection.background.algorithm='NATURAL_SPLINE'

'''how large a region of the sky should be used for each background point
	Valid Range = [10,inf) '''
root.detectCoaddSources.detection.background.binSize=4096

'''Ignore NaNs when estimating the background '''
root.detectCoaddSources.detection.background.isNanSafe=False

'''type of statistic to use for grid points
Allowed values:
	MEDIAN	median
	MEANCLIP	clipped mean
	None	Field is optional
	MEAN	unclipped mean
 '''
root.detectCoaddSources.detection.background.statisticsProperty='MEANCLIP'

'''Apprimation order for background Chebyshev (valid only with useApprox=True) '''
root.detectCoaddSources.detection.background.approxOrder=6

'''Use Approximate (Chebyshev) to model background. '''
root.detectCoaddSources.detection.background.useApprox=False

'''Grow detections to set the image mask bits, but return the original (not-grown) footprints '''
root.detectCoaddSources.detection.returnOriginalFootprints=False

'''specifies whether to detect positive, or negative sources, or both
Allowed values:
	positive	detect only positive sources
	negative	detect only negative sources
	both	detect both positive and negative sources
 '''
root.detectCoaddSources.detection.thresholdPolarity='positive'

'''Threshold for footprints
	Valid Range = [0.0,inf) '''
root.detectCoaddSources.detection.thresholdValue=5.0

'''Mask planes for pixels to reject '''
root.detectCoaddSources.mask=['DETECTED', 'BAD', 'SAT', 'NO_DATA', 'INTRP']

'''Scale variance plane using empirical noise? '''
root.detectCoaddSources.doScaleVariance=True

'''Name of coadd '''
root.detectCoaddSources.coaddName='deep'

'''Sigma for outlier rejection; ignored if doSigmaClip false. '''
root.assembleCoadd.sigmaClip=1.5

'''Maximum ratio of the mean squared error of the background matching model to the variance of the difference in backgrounds '''
root.assembleCoadd.maxMatchResidualRatio=1.1

'''Automatically select the coadd temp exposure to use as a reference for background matching? Ignored if doMatchBackgrounds false. If False you must specify the reference temp exposure as the data Id '''
root.assembleCoadd.autoReference=True

'''Match backgrounds of coadd temp exposures before coadding them? If False, the coadd temp expsosures must already have been background subtracted or matched '''
root.assembleCoadd.doMatchBackgrounds=False

'''Minimum fractional overlap of clipped footprint with visit DETECTED to be clipped '''
root.assembleCoadd.minClipFootOverlap=0.6

import hsc.pipe.tasks.stack
import lsst.pex.config.config
root.assembleCoadd.select.retarget(target=hsc.pipe.tasks.stack.NullSelectImagesTask, ConfigClass=lsst.pex.config.config.Config)
'''Minimum fractional overlap of clipped footprints with visit DETECTED to be clipped when two visits overlap '''
root.assembleCoadd.minClipFootOverlapDouble=0.45

'''Estimate the background again after final source detection? '''
root.assembleCoadd.clipDetection.reEstimateBackground=False

'''detected sources with fewer than the specified number of pixels will be ignored
	Valid Range = [0,inf) '''
root.assembleCoadd.clipDetection.minPixels=4

'''Grow detections by nSigmaToGrow * sigma; if 0 then do not grow '''
root.assembleCoadd.clipDetection.nSigmaToGrow=2.0

'''Names of mask planes to ignore while estimating the background '''
root.assembleCoadd.clipDetection.footprintBackground.ignoredPixelMask=['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.assembleCoadd.clipDetection.footprintBackground.undersampleStyle='REDUCE_INTERP_ORDER'

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.assembleCoadd.clipDetection.footprintBackground.algorithm='AKIMA_SPLINE'

'''how large a region of the sky should be used for each background point
	Valid Range = [10,inf) '''
root.assembleCoadd.clipDetection.footprintBackground.binSize=64

'''Ignore NaNs when estimating the background '''
root.assembleCoadd.clipDetection.footprintBackground.isNanSafe=False

'''type of statistic to use for grid points
Allowed values:
	MEDIAN	median
	MEANCLIP	clipped mean
	None	Field is optional
	MEAN	unclipped mean
 '''
root.assembleCoadd.clipDetection.footprintBackground.statisticsProperty='MEANCLIP'

'''Apprimation order for background Chebyshev (valid only with useApprox=True) '''
root.assembleCoadd.clipDetection.footprintBackground.approxOrder=6

'''Use Approximate (Chebyshev) to model background. '''
root.assembleCoadd.clipDetection.footprintBackground.useApprox=False

'''Do background subtraction before footprint detection? '''
root.assembleCoadd.clipDetection.doFootprintBackground=False

'''Include threshold relative to thresholdValue
	Valid Range = [0.0,inf) '''
root.assembleCoadd.clipDetection.includeThresholdMultiplier=1.0

'''Pixels should be grown as isotropically as possible (slower) '''
root.assembleCoadd.clipDetection.isotropicGrow=True

'''Fiddle factor to add to the background; debugging only '''
root.assembleCoadd.clipDetection.adjustBackground=0.0

'''specifies the desired flavor of Threshold
Allowed values:
	pixel_stdev	threshold applied to per-pixel std deviation
	variance	threshold applied to image variance
	value	threshold applied to image value
	stdev	threshold applied to image std deviation
 '''
root.assembleCoadd.clipDetection.thresholdType='pixel_stdev'

'''Names of mask planes to ignore while estimating the background '''
root.assembleCoadd.clipDetection.background.ignoredPixelMask=['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.assembleCoadd.clipDetection.background.undersampleStyle='REDUCE_INTERP_ORDER'

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.assembleCoadd.clipDetection.background.algorithm='NATURAL_SPLINE'

'''how large a region of the sky should be used for each background point
	Valid Range = [10,inf) '''
root.assembleCoadd.clipDetection.background.binSize=128

'''Ignore NaNs when estimating the background '''
root.assembleCoadd.clipDetection.background.isNanSafe=False

'''type of statistic to use for grid points
Allowed values:
	MEDIAN	median
	MEANCLIP	clipped mean
	None	Field is optional
	MEAN	unclipped mean
 '''
root.assembleCoadd.clipDetection.background.statisticsProperty='MEANCLIP'

'''Apprimation order for background Chebyshev (valid only with useApprox=True) '''
root.assembleCoadd.clipDetection.background.approxOrder=6

'''Use Approximate (Chebyshev) to model background. '''
root.assembleCoadd.clipDetection.background.useApprox=True

'''Grow detections to set the image mask bits, but return the original (not-grown) footprints '''
root.assembleCoadd.clipDetection.returnOriginalFootprints=False

'''specifies whether to detect positive, or negative sources, or both
Allowed values:
	positive	detect only positive sources
	negative	detect only negative sources
	both	detect both positive and negative sources
 '''
root.assembleCoadd.clipDetection.thresholdPolarity='both'

'''Threshold for footprints
	Valid Range = [0.0,inf) '''
root.assembleCoadd.clipDetection.thresholdValue=2.0

'''Smoothly taper (on the PSF scale) to the fallback value at the edge of the image? '''
root.assembleCoadd.interpImage.useFallbackValueAtEdge=True

'''Interpolation kernel size = interpFwhm converted to pixels * interpKernelSizeFactor. '''
root.assembleCoadd.interpImage.interpKernelSizeFactor=3.0

'''Mask planes that, if set, the associated pixel should not be included in the coaddTempExp. '''
root.assembleCoadd.badMaskPlanes=['BAD', 'EDGE', 'SAT', 'INTRP', 'NO_DATA']

'''Relative amplitude of wing '''
root.assembleCoadd.modelPsf.wingAmplitude=0.1

'''Multiplier of fwhm for kernel size '''
root.assembleCoadd.modelPsf.sizeFactor=3.0

'''FWHM of core (arcseconds) '''
root.assembleCoadd.modelPsf.fwhm=1.0

'''Multiplier of fwhm for wing fwhm '''
root.assembleCoadd.modelPsf.wingFwhmFactor=2.5

'''Maximum RMS of residuals of the background offset fit in matchBackgrounds. '''
root.assembleCoadd.maxMatchResidualRMS=1.0

'''Minimum number of pixels in footprint to use DETECTED mask from the single visits when labeling clipped footprints '''
root.assembleCoadd.minBigOverlap=100

'''Minimum fractional overlap of clipped footprint with visit DETECTED to be clipped when only one visit overlaps '''
root.assembleCoadd.minClipFootOverlapSingle=0.5

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.assembleCoadd.matchBackgrounds.undersampleStyle='REDUCE_INTERP_ORDER'

'''Names of mask planes to ignore while estimating the background '''
root.assembleCoadd.matchBackgrounds.background.ignoredPixelMask=['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.assembleCoadd.matchBackgrounds.background.undersampleStyle='REDUCE_INTERP_ORDER'

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.assembleCoadd.matchBackgrounds.background.algorithm='NATURAL_SPLINE'

'''how large a region of the sky should be used for each background point
	Valid Range = [10,inf) '''
root.assembleCoadd.matchBackgrounds.background.binSize=128

'''Ignore NaNs when estimating the background '''
root.assembleCoadd.matchBackgrounds.background.isNanSafe=False

'''type of statistic to use for grid points
Allowed values:
	MEDIAN	median
	MEANCLIP	clipped mean
	None	Field is optional
	MEAN	unclipped mean
 '''
root.assembleCoadd.matchBackgrounds.background.statisticsProperty='MEANCLIP'

'''Apprimation order for background Chebyshev (valid only with useApprox=True) '''
root.assembleCoadd.matchBackgrounds.background.approxOrder=6

'''Use Approximate (Chebyshev) to model background. '''
root.assembleCoadd.matchBackgrounds.background.useApprox=True

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.assembleCoadd.matchBackgrounds.interpolation='AKIMA_SPLINE'

'''Coadd name: typically one of deep or goodSeeing. '''
root.assembleCoadd.coaddName='deep'

'''Match to modelPsf? '''
root.assembleCoadd.doPsfMatch=False

'''FWHM of PSF used for interpolation (arcsec) '''
root.assembleCoadd.interpFwhm=1.5

'''Set mask and flag bits for bright objects? '''
root.assembleCoadd.doMaskBrightObjects=True

'''Number of iterations of outlier rejection; ignored if doSigmaClip false. '''
root.assembleCoadd.clipIter=3

'''Threshold (in fractional weight) of rejection at which we propagate a mask plane to the coadd; that is, we set the mask bit on the coadd if the fraction the rejected frames would have contributed exceeds this value. '''
root.assembleCoadd.maskPropagationThresholds={'SAT': 0.1}

'''Apply meas_mosaic ubercal results to input calexps? '''
root.assembleCoadd.doApplyUberCal=True

'''Width, height of stack subregion size; make small enough that a full stack of images will fit into memory at once. '''
root.assembleCoadd.subregionSize=[10000, 200]

'''desired photometric zero point '''
root.assembleCoadd.scaleZeroPoint.zeroPoint=27.0

'''Name of mask bit used for bright objects '''
root.assembleCoadd.brightObjectMaskName='BRIGHT_OBJECT'

'''Save weights in the CCDs table as well as the visits table? (This is necessary for easy construction of CoaddPsf, but otherwise duplicate information.) '''
root.assembleCoadd.inputRecorder.saveCcdWeights=True

'''Save the total number of good pixels in each coaddTempExp (redundant with a sum of good pixels in associated CCDs) '''
root.assembleCoadd.inputRecorder.saveVisitGoodPix=True

'''Add records for CCDs we iterated over but did not add a coaddTempExp due to a lack of unmasked pixels in the coadd footprint. '''
root.assembleCoadd.inputRecorder.saveEmptyCcds=False

'''Add records for CCDs we iterated over but did not add a coaddTempExp due to an exception (often due to the calexp not being found on disk). '''
root.assembleCoadd.inputRecorder.saveErrorCcds=False

'''Interpolate over NaN pixels? Also extrapolate, if necessary, but the results are ugly. '''
root.assembleCoadd.doInterp=True

'''Persist coadd? '''
root.assembleCoadd.doWrite=False

'''Perform sigma clipped outlier rejection? If False then compute a simple mean. '''
root.assembleCoadd.doSigmaClip=False

'''Mask planes to remove before coadding '''
root.assembleCoadd.removeMaskPlanes=['CROSSTALK', 'NOT_DEBLENDED']

'''Maximum fractional overlap of clipped footprints with visit DETECTED when considering two visits '''
root.assembleCoadd.maxClipFootOverlapDouble=0.15

'''Name for coadd '''
root.coaddName='deep'

'''Build background reference? '''
root.doBackgroundReference=False

'''Overwrite coadd? '''
root.doOverwriteCoadd=False

'''overwrite <coaddName>Coadd_tempExp; If False, continue if the file exists on disk '''
root.makeCoaddTempExp.doOverwrite=False

'''Scale kernelSize, alardGaussians by input Fwhm '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].scaleByFwhm=True

'''Type of spatial functions for kernel and background
Allowed values:
	chebyshev1	Chebyshev polynomial of the first kind
	polynomial	Standard x,y polynomial
	None	Field is optional
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].spatialModelType='chebyshev1'

'''Calculate kernel and background uncertainties for each kernel candidate?
                 This comes from the inverse of the covariance matrix.
                 Warning: regularization can cause problems for this step. '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].calculateKernelUncertainty=False

'''Include terms (including kernel cross terms) for background in ip_diffim '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].fitForBackground=False

'''Maximum Kernel Size '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSizeMax=35

'''Number of Gaussians in alard-lupton basis '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].alardNGauss=3

'''Do sigma clipping on each raw kernel candidate '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].singleKernelClipping=False

'''Maximum condition number for a well conditioned spatial matrix '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].maxSpatialConditionNumber=10000000000.0

'''Minimum Kernel Size '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSizeMin=21

'''Radius for calculation of stats in 'core' of KernelCandidate diffim.
                 Total number of pixels used will be (2*radius)**2.
                 This is used both for 'core' diffim quality as well as ranking of
                 KernelCandidates by their total flux in this core '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].candidateCoreRadius=3

'''Size (rows) in pixels of each SpatialCell for spatial modeling '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].sizeCellX=128

'''Size (columns) in pixels of each SpatialCell for spatial modeling '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].sizeCellY=128

'''Test for maximum condition number when inverting a kernel matrix.
                 Anything above maxConditionNumber is not used and the candidate is set as BAD.
                 Also used to truncate inverse matrix in estimateBiasedRisk.  However,
                 if you are doing any deconvolution you will want to turn this off, or use
                 a large maxConditionNumber '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].checkConditionNumber=False

'''Mask planes to ignore when calculating diffim statistics
                 Options: NO_DATA EDGE SAT BAD CR INTRP '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].badMaskPlanes=['NO_DATA', 'SAT']

'''Degree of spatial modification of ALL gaussians in AL basis during deconvolution '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].alardDegGaussDeconv=3

'''Use Pca to reduce the dimensionality of the kernel basis sets.
                 This is particularly useful for delta-function kernels.
                 Functionally, after all Cells have their raw kernels determined, we run
                 a Pca on these Kernels, re-fit the Cells using the eigenKernels and then
                 fit those for spatial variation using the same technique as for Alard-Lupton kernels.
                 If this option is used, the first term will have no spatial variation and the
                 kernel sum will be conserved. '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].usePcaForSpatialKernel=False

'''Subtract off the mean feature before doing the Pca '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].subtractMeanForPca=True

'''Number of KernelCandidates in each SpatialCell to use in the spatial fitting '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].nStarPerCell=3

'''Rejects KernelCandidates yielding bad difference image quality.
                 Used by BuildSingleKernelVisitor, AssessSpatialKernelVisitor.
                 Represents average over pixels of (image/sqrt(variance)). '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].candidateResidualMeanMax=0.25

'''Use the core of the footprint for the quality statistics, instead of the entire footprint.
                 WARNING: if there is deconvolution we probably will need to turn this off '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].useCoreStats=False

'''Use constant variance weighting in single kernel fitting?
                 In some cases this is better for bright star residuals. '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].constantVarianceWeighting=True

'''Type of basis set for PSF matching kernel.
Allowed values:
	alard-lupton	Alard-Lupton sum-of-gaussians basis set,
                           * The first term has no spatial variation
                           * The kernel sum is conserved
                           * You may want to turn off 'usePcaForSpatialKernel'
	None	Field is optional
	delta-function	Delta-function kernel basis set,
                           * You may enable the option useRegularization
                           * You should seriously consider usePcaForSpatialKernel, which will also
                             enable kernel sum conservation for the delta function kernels
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].kernelBasisSet='alard-lupton'

'''Sigma in pixels of Gaussians (FWHM = 2.35 sigma).  Must in number equal alardNGauss '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].alardSigGauss=[0.7, 1.5, 3.0]

'''Default scale factor between Gaussian sigmas  '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].alardGaussBeta=2.0

'''Use Bayesian Information Criterion to select the number of bases going into the kernel '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].useBicForKernelBasis=False

'''Number of rows/columns in the convolution kernel; should be odd-valued.
                 Modified by kernelSizeFwhmScaling if scaleByFwhm = true '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSize=11

'''Names of mask planes to ignore while estimating the background '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.ignoredPixelMask=['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']

'''behaviour if there are too few points in grid for requested interpolation style
Allowed values:
	INCREASE_NXNYSAMPLE	Increase the number of samples used to make the interpolation grid.
	THROW_EXCEPTION	throw an exception if there are too few points
	None	Field is optional
	REDUCE_INTERP_ORDER	use an interpolation style with a lower order.
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.undersampleStyle='REDUCE_INTERP_ORDER'

'''how to interpolate the background values. This maps to an enum; see afw::math::Background
Allowed values:
	NONE	No background estimation is to be attempted
	CONSTANT	Use a single constant value
	LINEAR	Use linear interpolation
	AKIMA_SPLINE	higher-level nonlinear spline that is more robust to outliers
	None	Field is optional
	NATURAL_SPLINE	cubic spline with zero second derivative at endpoints
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.algorithm='NATURAL_SPLINE'

'''how large a region of the sky should be used for each background point
	Valid Range = [10,inf) '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.binSize=128

'''Ignore NaNs when estimating the background '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.isNanSafe=False

'''type of statistic to use for grid points
Allowed values:
	MEDIAN	median
	MEANCLIP	clipped mean
	None	Field is optional
	MEAN	unclipped mean
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.statisticsProperty='MEANCLIP'

'''Apprimation order for background Chebyshev (valid only with useApprox=True) '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.approxOrder=6

'''Use Approximate (Chebyshev) to model background. '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].afwBackgroundConfig.useApprox=True

'''Do sigma clipping after building the spatial model '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].spatialKernelClipping=False

'''Maximum allowed sigma for outliers from kernel sum distribution.
                 Used to reject variable objects from the kernel model '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].maxKsumSigma=3.0

'''Spatial order of convolution kernel variation '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].spatialKernelOrder=2

'''Minimum number of pixels in an acceptable Footprint '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.fpNpixMin=5

'''Type of detection threshold
Allowed values:
	pixel_stdev	Use stdev derived from variance plane
	variance	Use variance of image plane
	None	Field is optional
	value	Use counts as the detection threshold type
	stdev	Use standard deviation of image plane
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.detThresholdType='pixel_stdev'

'''If true run detection on the template (image to convolve);
                 if false run detection on the science image '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.detOnTemplate=True

'''Value of footprint detection threshold '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.detThreshold=10.0

'''Mask planes that lead to an invalid detection.
                 Options: NO_DATA EDGE SAT BAD CR INTRP '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.badMaskPlanes=['NO_DATA', 'SAT']

'''Maximum number of pixels in an acceptable Footprint;
                 too big and the subsequent convolutions become unwieldy '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.fpNpixMax=500

'''Growing radius (in pixels) for each raw detection
                 footprint.  The smaller the faster; however the
                 kernel sum does not converge if the stamp is too
                 small; and the kernel is not constrained at all if
                 the stamp is the size of the kernel.  The grown stamp
                 is 2 * fpGrowPix pixels larger in each dimension.
                 This is overridden by fpGrowKernelScaling if scaleByFwhm '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.fpGrowPix=30

'''If config.scaleByFwhm, grow the footprint based on
                 the final kernelSize.  Each footprint will be
                 2*fpGrowKernelScaling*kernelSize x
                 2*fpGrowKernelScaling*kernelSize.  With the value
                 of 1.0, the remaining pixels in each KernelCandiate
                 after convolution by the basis functions will be
                 eqaul to the kernel size iteslf. '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.fpGrowKernelScaling=1.0

'''Scale fpGrowPix by input Fwhm? '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].detectionConfig.scaleByFwhm=True

'''Maximum number of iterations for rejecting bad KernelCandidates in spatial fitting '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].maxSpatialIterations=3

'''How much to scale the kernel size based on the largest AL Sigma '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSizeFwhmScaling=6.0

'''Polynomial order of spatial modification of Gaussians.  Must in number equal alardNGauss '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].alardDegGauss=[4, 2, 2]

'''Spatial order of differential background variation '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].spatialBgOrder=1

'''Rejects KernelCandidates yielding bad difference image quality.
                 Used by BuildSingleKernelVisitor, AssessSpatialKernelVisitor.
                 Represents stddev over pixels of (image/sqrt(variance)). '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].candidateResidualStdMax=1.5

'''Do sigma clipping on the ensemble of kernel sums '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSumClipping=False

'''Number of principal components to use for Pca basis, including the
                 mean kernel if requested. '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].numPrincipalComponents=5

'''Warping kernel
Allowed values:
	bilinear	bilinear interpolation
	lanczos3	Lanczos kernel of order 3
	lanczos4	Lanczos kernel of order 4
	lanczos5	Lanczos kernel of order 5
	None	Field is optional
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].warpingConfig.warpingKernelName='lanczos4'

'''interpLength argument to lsst.afw.math.warpExposure '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].warpingConfig.interpLength=10

'''cacheSize argument to lsst.afw.math.SeparableKernel.computeCache '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].warpingConfig.cacheSize=0

'''use GPU acceleration? '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].warpingConfig.devicePreference=0

'''Warping kernel for mask (use warpingKernelName if '')
Allowed values:
		use the regular warping kernel for the mask plane, as well as the image and variance planes
	bilinear	bilinear interpolation
	lanczos3	Lanczos kernel of order 3
	lanczos4	Lanczos kernel of order 4
	lanczos5	Lanczos kernel of order 5
	None	Field is optional
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].warpingConfig.maskWarpingKernelName='bilinear'

'''mask bits to grow to full width of image/variance kernel, '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].warpingConfig.growFullMask=16

'''Remake KernelCandidate using better variance estimate after first pass?
                 Primarily useful when convolving a single-depth image, otherwise not necessary. '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].iterateSingleKernel=False

'''Use singular values (SVD) or eigen values (EIGENVALUE) to determine condition number
Allowed values:
	EIGENVALUE	Use eigen values (faster)
	SVD	Use singular values
	None	Field is optional
 '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].conditionNumberType='EIGENVALUE'

'''Maximum condition number for a well conditioned matrix '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].maxConditionNumber=50000000.0

'''Minimum Sigma (pixels) for Gaussians '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].alardMinSig=0.7

'''Use afw background subtraction instead of ip_diffim '''
root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel['AL'].useAfwBackground=False

root.makeCoaddTempExp.warpAndPsfMatch.psfMatch.kernel.name='AL'
'''Warping kernel
Allowed values:
	bilinear	bilinear interpolation
	lanczos3	Lanczos kernel of order 3
	lanczos4	Lanczos kernel of order 4
	lanczos5	Lanczos kernel of order 5
	None	Field is optional
 '''
root.makeCoaddTempExp.warpAndPsfMatch.warp.warpingKernelName='lanczos3'

'''interpLength argument to lsst.afw.math.warpExposure '''
root.makeCoaddTempExp.warpAndPsfMatch.warp.interpLength=10

'''cacheSize argument to lsst.afw.math.SeparableKernel.computeCache '''
root.makeCoaddTempExp.warpAndPsfMatch.warp.cacheSize=1000000

'''use GPU acceleration? '''
root.makeCoaddTempExp.warpAndPsfMatch.warp.devicePreference=0

'''Warping kernel for mask (use warpingKernelName if '')
Allowed values:
		use the regular warping kernel for the mask plane, as well as the image and variance planes
	bilinear	bilinear interpolation
	lanczos3	Lanczos kernel of order 3
	lanczos4	Lanczos kernel of order 4
	lanczos5	Lanczos kernel of order 5
	None	Field is optional
 '''
root.makeCoaddTempExp.warpAndPsfMatch.warp.maskWarpingKernelName='bilinear'

'''mask bits to grow to full width of image/variance kernel, '''
root.makeCoaddTempExp.warpAndPsfMatch.warp.growFullMask=16

'''Save weights in the CCDs table as well as the visits table? (This is necessary for easy construction of CoaddPsf, but otherwise duplicate information.) '''
root.makeCoaddTempExp.inputRecorder.saveCcdWeights=True

'''Save the total number of good pixels in each coaddTempExp (redundant with a sum of good pixels in associated CCDs) '''
root.makeCoaddTempExp.inputRecorder.saveVisitGoodPix=True

'''Add records for CCDs we iterated over but did not add a coaddTempExp due to a lack of unmasked pixels in the coadd footprint. '''
root.makeCoaddTempExp.inputRecorder.saveEmptyCcds=False

'''Add records for CCDs we iterated over but did not add a coaddTempExp due to an exception (often due to the calexp not being found on disk). '''
root.makeCoaddTempExp.inputRecorder.saveErrorCcds=False

'''Coadd name: typically one of deep or goodSeeing. '''
root.makeCoaddTempExp.coaddName='deep'

'''Apply meas_mosaic ubercal results to input calexps? '''
root.makeCoaddTempExp.doApplyUberCal=True

'''Relative amplitude of wing '''
root.makeCoaddTempExp.modelPsf.wingAmplitude=0.1

'''Multiplier of fwhm for kernel size '''
root.makeCoaddTempExp.modelPsf.sizeFactor=3.0

'''FWHM of core (arcseconds) '''
root.makeCoaddTempExp.modelPsf.fwhm=1.0

'''Multiplier of fwhm for wing fwhm '''
root.makeCoaddTempExp.modelPsf.wingFwhmFactor=2.5

'''Match to modelPsf? '''
root.makeCoaddTempExp.doPsfMatch=False

import hsc.pipe.tasks.stack
import lsst.pex.config.config
root.makeCoaddTempExp.select.retarget(target=hsc.pipe.tasks.stack.NullSelectImagesTask, ConfigClass=lsst.pex.config.config.Config)
'''persist <coaddName>Coadd_tempExp '''
root.makeCoaddTempExp.doWrite=True

'''Mask planes that, if set, the associated pixel should not be included in the coaddTempExp. '''
root.makeCoaddTempExp.badMaskPlanes=['NO_DATA']

'''Work with a background subtracted calexp? '''
root.makeCoaddTempExp.bgSubtracted=True

import lsst.pipe.tasks.selectImages
import lsst.pex.config.config
root.select.retarget(target=lsst.pipe.tasks.selectImages.WcsSelectImagesTask, ConfigClass=lsst.pex.config.config.Config)
