### ppImage recipe configuration file for Megacam

# Overscan subtraction
OVERSCAN.SINGLE		BOOL	FALSE		# Reduce overscan to a single value?
OVERSCAN.FIT		STR	NONE		# NONE | POLYNOMIAL | SPLINE
OVERSCAN.ORDER		S32	0		# Order of polynomial fit
OVERSCAN.STAT		STR	MEAN		# MEAN | MEDIAN

OVERSCAN	BOOL	TRUE		# Overscan subtraction
BIAS		BOOL	TRUE		# Bias subtraction
DARK		BOOL	TRUE		# Dark subtraction
FLAT		BOOL	TRUE		# Flat-field normalisation
SHUTTER		BOOL	FALSE		# Shutter correction
FRINGE		BOOL	FALSE		# Fringe subtraction

# this table lists extra constraints which should be applied when
# selecting the detrend images.
# note: camera and time are always applied

DETREND.CONSTRAINTS  METADATA
  BIAS METADATA
  END
  DARK METADATA
  END
  FLAT METADATA
    FILTER  STR FPA.FILTERID
  END
  FLAT_CORRECTION METADATA
    FILTER   STR FPA.FILTER
  END
  FRINGE METADATA
    FILTER   STR FPA.FILTER
  END
  SHUTTER METADATA
  END	
END

# only apply the fringe for these filters
FRINGE.FILTERS  MULTI
FRINGE.FILTERS	STR r
FRINGE.FILTERS	STR i
FRINGE.FILTERS	STR z

PHOTCODE.RULE		STR	{DETECTOR}.{FILTER.ID}.{CHIP.N}



################################################################################
# Diffferent processing options, which may be loaded symbolically
################################################################################

# No operation except potential normalisation
PPIMAGE_N         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Overscan subtraction only
PPIMAGE_O         METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Bias subtraction only
PPIMAGE_B         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Dark subtraction only
PPIMAGE_D         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    TRUE            # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Shutter correction only
PPIMAGE_S         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Flat-fielding only
PPIMAGE_F         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    TRUE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Fringe correction only
PPIMAGE_R         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE            # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Photometry only
PPIMAGE_P         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  PHOTOM          BOOL    FALSE           # Source identification and photometry
END

# Photometry & Astrometry
PPIMAGE_A         METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  PHOTOM          BOOL    FALSE           # Source identification and photometry
  ASTROM.CHIP     BOOL    FALSE           # Source identification and photometry
END

# Overscan, bias
PPIMAGE_OB        METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Overscan, bias, dark
PPIMAGE_OBD      METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    TRUE            # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Overscan, bias, dark, shutter
PPIMAGE_OBDS      METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    TRUE            # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Overscan, bias, dark, shutter, flat-field
PPIMAGE_OBDSF     METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    TRUE            # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    TRUE            # Flat-field normalisation
  MASK            BOOL    FALSE            # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Overscan, bias, dark, shutter, flat-field, fringe
PPIMAGE_OBDSFR    METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    TRUE            # Dark subtraction
  SHUTTER         BOOL    FALSE            # Shutter correction
  FLAT            BOOL    TRUE            # Flat-field normalisation
  MASK            BOOL    FALSE            # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
END

# Overscan, bias, dark, shutter, flat-field, fringe, photom
PPIMAGE_OBDSFRP   METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    TRUE            # Dark subtraction
  SHUTTER         BOOL    FALSE            # Shutter correction
  FLAT            BOOL    TRUE            # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
  PHOTOM          BOOL    FALSE		  # Source identification and photometry
  ASTROM.CHIP     BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC   BOOL    FALSE		  # Astrometry for mosaic?
END

# Overscan, bias, dark, shutter, flat-field, fringe, photom, astrom
PPIMAGE_OBDSFRA   METADATA
  OVERSCAN        BOOL    TRUE            # Overscan subtraction
  BIAS            BOOL    TRUE            # Bias subtraction
  DARK            BOOL    TRUE            # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    TRUE            # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE            # Fringe subtraction
  BIN1.FITS       BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS       BOOL    TRUE            # Save 2nd binned chip image?
  PHOTOM          BOOL    FALSE		  # Source identification and photometry
  ASTROM.CHIP     BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC   BOOL    FALSE		  # Astrometry for mosaic?
END

# Save JPEG from BIN1
PPIMAGE_J1        METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BASE.FITS       BOOL    FALSE           # Save base image?
  BIN1.FITS       BOOL    FALSE           # Save 1st binned chip image?
  BIN2.FITS       BOOL    FALSE           # Save 2nd binned chip image?
  BIN1.JPEG       BOOL    TRUE		  # Save 1st binned jpeg?
  BIN2.JPEG       BOOL    FALSE		  # Save 2nd binned jpeg?
  BIN1.XBIN       S32     1               # Image is already binned
  BIN1.YBIN       S32     1               # Image is already binned
  BIN2.XBIN       S32     1               # Image is already binned
  BIN2.YBIN       S32     1               # Image is already binned
END

# Save JPEG from BIN2
PPIMAGE_J2        METADATA
  OVERSCAN        BOOL    FALSE           # Overscan subtraction
  BIAS            BOOL    FALSE           # Bias subtraction
  DARK            BOOL    FALSE           # Dark subtraction
  SHUTTER         BOOL    FALSE           # Shutter correction
  FLAT            BOOL    FALSE           # Flat-field normalisation
  MASK            BOOL    FALSE           # Mask bad pixels
  FRINGE          BOOL    FALSE           # Fringe subtraction
  BASE.FITS       BOOL    FALSE           # Save base image?
  BIN1.FITS       BOOL    FALSE           # Save 1st binned chip image?
  BIN2.FITS       BOOL    FALSE           # Save 2nd binned chip image?
  BIN1.JPEG       BOOL    FALSE		  # Save 1st binned jpeg?
  BIN2.JPEG       BOOL    TRUE		  # Save 2nd binned jpeg?
  BIN1.XBIN       S32     1               # Image is already binned
  BIN1.YBIN       S32     1               # Image is already binned
  BIN2.XBIN       S32     1               # Image is already binned
  BIN2.YBIN       S32     1               # Image is already binned
END
