# Recipe configuration for ppStack (image combination)

CONVOLVE	BOOL	TRUE		# Convolve images when stacking?
MATCH.ZERO.POINTS BOOL	TRUE		# Convolve images when stacking?

COMBINE.ITER	F32	0.5		# Number of rejection iterations per input
COMBINE.REJ	F32	2.5		# Rejection threshold in combination (sigma)
COMBINE.SYS	F32	0.1		# Relative systematic error in combination
COMBINE.DISCARD	F32	0.2		# Discard fraction for Olympic weighted mean

# XXX which of these is right?
MASK.VAL	STR	MASK.VALUE,CONV.BAD,GHOST	# Mask value of input bad pixels
MASK.IN		STR	MASK.VALUE,CONV.BAD,GHOST	# Mask value of input bad pixels

MASK.SUSPECT	STR	SUSPECT,CONV.POOR	# Mask value of suspect pixels
MASK.BAD	STR	BLANK		# Mask value to give bad pixels
MASK.POOR	STR	CONV.POOR	# Mask value to give poor pixels
POOR.FRACTION	F32	0.25		# Maximum fraction of bad variance for poor pixels
THRESHOLD.MASK	F32	0.5		# Threshold for mask deconvolution (0..1)
DECONV.LIMIT	F32	2.0		# Deconvolution fraction for rejecting entire image
IMAGE.REJ	F32	0.1		# Rejected pixel fraction threshold for rejecting entire image
MATCH.REJ	F32	3.0		# Rejection threshold for chi^2 values from matching
ROWS		S32	64		# Number of rows to read at once
VARIANCE	BOOL	TRUE		# Use variance in rejection?
SAFE		BOOL	TRUE		# Play safe when combining small number of values?
WEIGHTS		BOOL	TRUE		# Use 1/noise^2 weighting?
BIN1		S32	4		# Binning factor for first level
BIN2		S32	4		# Binning factor for second level
PHOTOMETRY      BOOL    TRUE            # Do basic photometry?
SKIP.BG.SUB	BOOL	FALSE		# Bypass background subtraction?

RENORM		BOOL	TRUE		# Renormalise weight maps?
RENORM.NUM	S32	100000		# Number of samples for renormalisation
RENORM.MIN	F32	NAN		# Minimum value for renormlisation
RENORM.MAX	F32	NAN		# Maximum value for renormalisation

### The PHOT mode is intended as a quick and dirty stopgap; it should disappear soon.
PHOT		BOOL	FALSE		# Calculate ZP using own photometry?
PHOT.RADIUS	S32	30		# Photometry radius (pixels)
PHOT.SIGMA	F32	5		# Photometry gaussian sigma for weight (pixels)
PHOT.FRAC	F32	0.9		# Minimum fraction of good pixels

ZP		BOOL	TRUE		# Match zero points?
ZP.RADIUS	F32	4.0		# Radius (pixels) for matching sources
ZP.ITER.1	S32	5		# Iterations for zero point; pass 1
ZP.ITER.2	S32	1000		# Iterations for zero point; pass 2
ZP.TOL		F32	1.0e-6		# Tolerance for zero point iterations
ZP.TRANS.ITER	S32	2		# Iterations for transparency determination
ZP.TRANS.REJ	F32	3.0		# Rejection threshold for transparency determination
ZP.TRANS.THRESH	F32	1.0		# Threshold for transparency determination
ZP.STAR.REJ.1	F32	20.0		# Rejection threshold for stars; pass 1
ZP.STAR.REJ.2	F32	3.0		# Rejection threshold for stars; pass 2
ZP.STAR.LIMIT	F32	1.0e-2		# Limit on star rejection fraction for successful iteration
ZP.STAR.SYS.1	F32	0.10		# Estimated systematic error; pass 1
ZP.STAR.SYS.2	F32	0.05		# Estimated systematic error; pass 2
ZP.MATCH	F32	0.3		# Fraction of images to match for good star
ZP.AIRMASS	METADATA		# Airmass terms by filter
	g	F32	0.0
	r	F32	0.0
	i	F32	0.0
	z	F32	0.0
	y	F32	0.0
END
ZP.TARGET	METADATA		# Target zero point by filter
	g	F32	25.0
	r	F32	25.0
	i	F32	25.0
	z	F32	25.0
	y	F32	25.0
END

PSF.INSTANCES	S32	15		# Number of instances for PSF generation
PSF.RADIUS	F32	20.0		# Radius for PSF generation
PSF.ORDER	S32	1		# Order of spatial variation for PSF generation
PSF.MODEL	STR	PS_MODEL_GAUSS	# Model for PSF generation

TEMP.IMAGE	STR	conv.im.fits	# Suffix for temporary convolved images
TEMP.MASK	STR	conv.mk.fits	# Suffix for temporary convolved masks
TEMP.VARIANCE	STR	conv.var.fits	# Suffix for temporary convolved variance maps
TEMP.DELETE	BOOL	TRUE		# Delete temporary files on completion?

# Recipe overrides for STACK
STACK	METADATA
END


# Debugging
DEBUG	METADATA
	TEMP.DELETE	BOOL	FALSE		# Delete temporary files on completion?
END

# Faster processing for PR images
PR	METADATA
	IMAGE.REJ	    F32	  0.5
	WEIGHTS		    BOOL  FALSE
	CONVOLVE	    BOOL  FALSE
	SKIP.BG.SUB	    BOOL  FALSE
        MATCH.ZERO.POINTS   BOOL  FALSE
        PHOTOMETRY          BOOL  FALSE           # Do basic photometry?
END
