# Recipe configuration for ppMerge

ROWS            S32     128		# Number of rows to read at once
ELECTRONS       F32     100.0           # Minimum number of electrons for useful signal
SAMPLE          S32     100000          # Sampling factor for measuring the background
REJ		F32	3.0		# Rejection threshold (sigma)
ITER		S32	2		# Number of rejection iterations
FRACHIGH	F32	0.0		# Fraction of high pixels to reject immediately
FRACLOW		F32	0.0		# Fraction of low pixels to reject immediately
NKEEP		S32	5		# Minimum number of pixels in stack to keep
WEIGHTS		BOOL	FALSE		# Use image weights in combination?
FRINGE.NUM	S32	10000		# Number of fringe regions
FRINGE.SIZE	S32	5		# Half-size of fringe regions
FRINGE.XSMOOTH	S32	5		# Number of smoothing regions in x
FRINGE.YSMOOTH	S32	11		# Number of smoothing regions in y
SHUTTER.SIZE	S32	128		# Size for shutter measurement regions
MASK.SUSPECT	F32	5.0		# Threshold for suspect pixels (sigma)
MASK.BAD	F32	0.2		# Threshold for bad pixels
MASK.MODE	STR	FRACTION	# Mode for identifying bad pixels in the suspect map
MASK.CHIPSTATS	BOOL	TRUE		# Measure stats for masking by chip (otherwise by readout)?
MASK.GROW	S32	0		# Grow bad pixels by this radius
MASK.SET.VALUE	STR	FLAT		# set this bit in the output mask

COMBINE		STR	CLIPPED		# Statistic to use for combination
MEAN		STR	ROBUST_MEDIAN	# Statistic to use to measure the mean
STDEV		STR	ROBUST_STDEV	# Statistic to use to measure the stdev

MASK.SMOOTH.SUSPECT BOOL TRUE           # smooth the suspect-pixel image before making mask
MASK.SMOOTH.SCALE   F32  3.0            # sigma (pixels) of smoothing kernel

STATS.BY.CHIP   BOOL    TRUE            # measure stats for masking by chip (or by readout)
MASK.GROW.NPIX  S32     3               # measure stats for masking by chip (or by readout)

# Ordinates for fitting dark current
DARK.ORDINATES	METADATA
	CELL.DARKTIME	S32	1	# Traditional dark current term
END
DARK.NORM	STR	NONE		# Dark normalisation concept

# Bias combination --- don't want min/max rejection
PPMERGE_BIAS	METADATA
	REJ		F32	3.0		# Rejection threshold (sigma)
	ITER		S32	2		# Number of rejection iterations
	FRACHIGH	F32	0.0		# Fraction of high pixels to reject immediately
	FRACLOW		F32	0.0		# Fraction of low pixels to reject immediately
	WEIGHTS		BOOL	FALSE		# Use image weights?
	COMBINE		STR	CLIPPED		# Statistic to use for combination: 
END


# Dark combination --- don't want min/max rejection
# More aggressive clipping than bias, so as to remove CRs
PPMERGE_DARK	METADATA
	REJ		F32	3.0		# Rejection threshold (sigma)
	ITER		S32	2		# Number of rejection iterations
	FRACHIGH	F32	0.0		# Fraction of high pixels to reject immediately
	FRACLOW		F32	0.0		# Fraction of low pixels to reject immediately
	WEIGHTS		BOOL	TRUE		# Use image weights?
	COMBINE		STR	CLIPPED		# Statistic to use for combination: 
END

# Flat combination --- use min/max rejection
PPMERGE_FLAT	METADATA
	REJ		F32	3.0		# Rejection threshold (sigma)
	ITER		S32	1		# Number of rejection iterations
	FRACHIGH	F32	0.3		# Fraction of high pixels to reject immediately
	FRACLOW		F32	0.1		# Fraction of low pixels to reject immediately
	NKEEP		S32	5		# Minimum number of pixels in stack to keep
	WEIGHTS		BOOL	TRUE		# Use image weights?
	COMBINE		STR	MEAN		# Statistic to use for combination: 
END


# Fringe combination --- already included in default, above
PPMERGE_FRINGE	METADATA
	FRACHIGH	F32	0.1		# Fraction of high pixels to reject immediately
	WEIGHTS		BOOL	TRUE		# Use image weights?
END

# Mask generation --- already included in default, above
PPMERGE_DARKMASK METADATA
	ITER		S32	2		# Number of iterations
	MASK.BAD	F32	0.2		# Threshold for bad pixels (sigma)
	MASK.MODE	STR	FRACTION	# Mode for identifying bad pixels in the suspect map
        MASK.SET.VALUE	STR	DARK		# set this bit in the output mask
END

# Mask generation --- already included in default, above
PPMERGE_FLATMASK METADATA
	ITER		S32	2		# Number of iterations
	MASK.BAD	F32	0.2		# Threshold for bad pixels (sigma)
	MASK.MODE	STR	FRACTION	# Mode for identifying bad pixels in the suspect map
        MASK.SET.VALUE	STR	FLAT		# set this bit in the output mask
END

# Shutter generation --- already included in default, above
PPMERGE_SHUTTER	METADATA
	REJ		F32	2.0		# Rejection threshold (sigma)
	ITER		S32	1		# Number of rejection iterations
END
