
# binned output image options
BIN1.XBIN               S32      16
BIN1.YBIN               S32      16
BIN2.XBIN               S32     150
BIN2.YBIN               S32     150

OVERSCAN.SINGLE         BOOL    FALSE            # Reduce overscan to a single value?
OVERSCAN.STAT           STR     MEDIAN
OVERSCAN.BOXCAR         S32     3

PHOTCODE.RULE           STR     {DETECTOR}.{FILTER.ID}.{CHIP.NAME}
OLDDARK                 BOOL    FALSE

## XXX use these local variations until we are building real detrend images

DETREND.CONSTRAINTS  METADATA
  BIAS METADATA
  END
  DARK METADATA
    EXPTIME STR FPA.EXPOSURE
  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
  MASK METADATA
  END	
  ASTROM METADATA
  END	
END

# Overscan, bias
PPIMAGE_OB         METADATA
  BASE.FITS        BOOL    TRUE            # Save base detrended image?
  BASE.MASK.FITS   BOOL    TRUE            # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    TRUE            # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed image? 
  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
  PHOTOM           BOOL    FALSE           # Source identification and photometry
  ASTROM.CHIP      BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
  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
  BASE.FITS        BOOL    TRUE            # Save base detrended image?
  BASE.MASK.FITS   BOOL    TRUE            # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    TRUE            # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed image? 
  OVERSCAN         BOOL    TRUE            # 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
  PHOTOM           BOOL    FALSE           # Source identification and photometry
  ASTROM.CHIP      BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
  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
  BASE.FITS        BOOL    TRUE            # Save base detrended image?
  BASE.MASK.FITS   BOOL    TRUE            # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    TRUE            # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed image? 
  OVERSCAN         BOOL    TRUE            # 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
  PHOTOM           BOOL    FALSE           # Source identification and photometry
  ASTROM.CHIP      BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
  BIN1.FITS        BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS        BOOL    TRUE            # Save 2nd binned chip image?
END

# Overscan, bias, dark, shutter
PPIMAGE_OBDSF      METADATA
  BASE.FITS        BOOL    TRUE            # Save base detrended image?
  BASE.MASK.FITS   BOOL    TRUE            # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    TRUE            # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed image? 
  OVERSCAN         BOOL    TRUE            # Overscan subtraction
  BIAS             BOOL    FALSE           # 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
  PHOTOM           BOOL    FALSE           # Source identification and photometry
  ASTROM.CHIP      BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
  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, astrom
PPIMAGE_DET_ONLY   METADATA
  BASE.FITS        BOOL    FALSE           # Save base detrended image?
  BASE.MASK.FITS   BOOL    FALSE           # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    FALSE           # Save base detrended image?
  CHIP.FITS        BOOL    TRUE            # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    TRUE            # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    TRUE            # Save chip-mosaic-ed image? 
  OVERSCAN         BOOL    TRUE            # Overscan subtraction
  BIAS             BOOL    FALSE           # Bias subtraction
  DARK             BOOL    TRUE            # Dark subtraction
  SHUTTER          BOOL    FALSE           # Shutter correction
  FLAT             BOOL    TRUE            # Flat-field normalisation
  MASK             BOOL    TRUE            # Mask bad pixels
  REPLACE.MASKED   BOOL    TRUE            # Fill in masked pixels
  FRINGE           BOOL    FALSE           # Fringe subtraction
  BIN1.FITS        BOOL    TRUE            # Save 1st binned chip image?
  BIN2.FITS        BOOL    TRUE            # Save 2nd binned chip image?
  FPA1.FITS        BOOL    TRUE            # Save 1st binned fpa image? 
  FPA2.FITS        BOOL    TRUE            # Save 2nd binned fpa 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
PPIMAGE_OBDSFR     METADATA
  BASE.FITS        BOOL    TRUE            # Save base detrended image?
  BASE.MASK.FITS   BOOL    TRUE            # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    TRUE            # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed image? 
  OVERSCAN         BOOL    TRUE            # Overscan subtraction
  BIAS             BOOL    FALSE           # Bias subtraction
  DARK             BOOL    TRUE            # Dark subtraction
  SHUTTER          BOOL    FALSE           # Shutter correction
  FLAT             BOOL    TRUE            # Flat-field normalisation
  MASK             BOOL    TRUE            # Mask bad pixels
  REPLACE.MASKED   BOOL    TRUE            # Fill in masked pixels
  REPLACE.MODE     STR     MODEL           # VALUE, MODEL
  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_OBDSFRP    METADATA
  BASE.FITS        BOOL    FALSE           # Save base detrended image?
  BASE.MASK.FITS   BOOL    FALSE           # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    FALSE           # Save base detrended image?
  CHIP.FITS        BOOL    TRUE            # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    TRUE            # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    TRUE            # Save chip-mosaic-ed image? 
  OVERSCAN         BOOL    TRUE            # Overscan subtraction
  BIAS             BOOL    FALSE           # Bias subtraction
  DARK             BOOL    TRUE            # Dark subtraction
  SHUTTER          BOOL    FALSE           # Shutter correction
  FLAT             BOOL    TRUE            # Flat-field normalisation
  MASK             BOOL    TRUE            # Mask bad pixels
  REPLACE.MASKED   BOOL    TRUE            # Fill in masked pixels
  REPLACE.MODE     STR     MODEL           # VALUE, MODEL
  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    TRUE            # 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
  BASE.FITS        BOOL    FALSE           # Save base detrended image?
  BASE.MASK.FITS   BOOL    FALSE           # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    FALSE           # Save base detrended image?
  CHIP.FITS        BOOL    TRUE            # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    TRUE            # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    TRUE            # Save chip-mosaic-ed image? 
  OVERSCAN         BOOL    TRUE            # Overscan subtraction
  BIAS             BOOL    FALSE           # Bias subtraction
  DARK             BOOL    TRUE            # Dark subtraction
  SHUTTER          BOOL    FALSE           # Shutter correction
  FLAT             BOOL    TRUE            # Flat-field normalisation
  MASK             BOOL    TRUE            # Mask bad pixels
  REPLACE.MASKED   BOOL    TRUE            # Fill in masked 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    TRUE            # Source identification and photometry
  ASTROM.CHIP      BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
END

# Photometry and astrometry only (for pre-reduced data)
PPIMAGE_PA         METADATA
  BASE.FITS        BOOL    FALSE           # Save base detrended image?
  BASE.MASK.FITS   BOOL    FALSE           # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    FALSE           # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed image? 
  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?
  BIN1.JPEG        BOOL    TRUE            # Save 1st binned jpeg?
  BIN2.JPEG        BOOL    TRUE            # Save 2nd binned jpeg?
  PHOTOM           BOOL    TRUE            # Source identification and photometry
  ASTROM.CHIP      BOOL    FALSE           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
END

# JPEG images for different types of residual images
# Save JPEG from BIN1 for bias
PPIMAGE_J1_RESID_B      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           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
  BASE.FITS        BOOL    FALSE           # Save base image?
  BASE.MASK.FITS   BOOL    FALSE           # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    FALSE           # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed 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

  # GPC1 has significant dark structures: use a wide greyscale range
  PPIMAGE.JPEG1    METADATA
    COLORMAP       STR     -greyscale
    SCALE.MODE     STR     VALUE
    SCALE.MIN      F32     -50.0
    SCALE.MAX      F32     +50.0
  END
END

# Save JPEG from BIN2 for bias
PPIMAGE_J2_RESID_B        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           # Astrometry per chip?
  ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
  BASE.FITS        BOOL    FALSE           # Save base image?
  BASE.MASK.FITS   BOOL    FALSE           # Save base detrended image?
  BASE.WEIGHT.FITS BOOL    FALSE           # Save base detrended image?
  CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image? 
  CHIP.WEIGHT.FITS BOOL    FALSE           # Save chip-mosaic-ed 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

  # GPC1 has significant dark structures: use a wide greyscale range
  PPIMAGE.JPEG2    METADATA
    COLORMAP       STR     -greyscale
    SCALE.MODE     STR     VALUE
    SCALE.MIN      F32     -50.0
    SCALE.MAX      F32     +50.0
  END
END

