# Camera configuration file for simulated mosaic

# File formats that we know about
FORMATS         METADATA
	TOGETHER STR	simmosaic/format_together.config
	SPLIT	STR	simmosaic/format_split.config
END
 
# Description of camera --- all the chips and the cells that comprise them
FPA     METADATA
        Chip00		STR	Cell00 Cell01 Cell10 Cell11
        Chip01		STR	Cell00 Cell01 Cell10 Cell11
        Chip10		STR	Cell00 Cell01 Cell10 Cell11
        Chip11		STR	Cell00 Cell01 Cell10 Cell11
END

# move this elsewhere?  we need a lookup table to go from filter ID to abstract name
FILTER.ID       METADATA
	NONE	STR	NONE
	B	STR	B
	V	STR	V
	R	STR	R
	I	STR	I
	g	STR	g
	r	STR	r
	i	STR	i
	z	STR	z
END

# Table of strings to use for the class identifier (see ippdb) according to the file level.
CLASSID		METADATA
	FPA	STR	fpa
	CHIP	STR	{CHIP.NAME}
	CELL	STR	{CHIP.NAME}.{CELL.NAME}
	fpa	STR	fpa
	chip	STR	{CHIP.NAME}
	cell	STR	{CHIP.NAME}.{CELL.NAME}
END

DVO.CAMERADIR	STR	simmosaic		# Camera directory for DVO

# convert supplied FPA.OBSTYPE values to abstract exptype names
OBSTYPE.TABLE METADATA
  bias 	   STR BIAS
  zero 	   STR BIAS
  dark 	   STR DARK
  flat 	   STR SKYFLAT
  skyflat  STR SKYFLAT
  domeflat STR DOMEFLAT
  object   STR OBJECT
  science  STR OBJECT
END

# Recipe options
RECIPES		METADATA
        PPIMAGE         STR     simmosaic/ppImage.config	# Default: all (normal) options on
	PSPHOT		STR	simmosaic/psphot.config		# psphot details
	PSASTRO		STR	simmosaic/psastro.config	# psastro details
	REJECTIONS	STR	simmosaic/rejections.config	# Rejection limits
END

# Reduction classes
REDUCTION	METADATA
	# Detrend processing
	DETREND		METADATA
		BIAS_PROCESS	STR	PPIMAGE_O
		BIAS_RESID	STR	PPIMAGE_B
		BIAS_VERIFY	STR	PPIMAGE_OB
		BIAS_STACK	STR	PPMERGE_BIAS
		DARK_PROCESS	STR	PPIMAGE_OB
		DARK_RESID	STR	PPIMAGE_D
		DARK_VERIFY	STR	PPIMAGE_OBD
		DARK_STACK	STR	PPMERGE_DARK
		SHUTTER_PROCESS	STR	PPIMAGE_OBD
		SHUTTER_RESID	STR	PPIMAGE_S
		SHUTTER_VERIFY	STR	PPIMAGE_OBDS
		SHUTTER_STACK	STR	PPMERGE_SHUTTER
		FLAT_PROCESS	STR	PPIMAGE_OBDS
		FLAT_RESID	STR	PPIMAGE_F
		FLAT_VERIFY	STR	PPIMAGE_OBDSF
		FLAT_STACK	STR	PPMERGE_FLAT
		FRINGE_PROCESS	STR	PPIMAGE_OBDSF
		FRINGE_RESID	STR	PPIMAGE_R
		FRINGE_VERIFY	STR	PPIMAGE_OBDSFR
		FRINGE_STACK	STR	PPMERGE_FRINGE

 		JPEG_BIN1_IMAGE_BIAS     STR  PPIMAGE_J1_IMAGE_B
		JPEG_BIN1_IMAGE_DARK     STR  PPIMAGE_J1_IMAGE_B
		JPEG_BIN1_IMAGE_SHUTTER  STR  PPIMAGE_J1_IMAGE_F
		JPEG_BIN1_IMAGE_FLAT     STR  PPIMAGE_J1_IMAGE_F
		JPEG_BIN1_IMAGE_DOMEFLAT STR  PPIMAGE_J1_IMAGE_F
		JPEG_BIN1_IMAGE_SKYFLAT  STR  PPIMAGE_J1_IMAGE_F
		JPEG_BIN1_IMAGE_FRINGE   STR  PPIMAGE_J1_IMAGE_R
 		JPEG_BIN2_IMAGE_BIAS     STR  PPIMAGE_J2_IMAGE_B
		JPEG_BIN2_IMAGE_DARK     STR  PPIMAGE_J2_IMAGE_B
		JPEG_BIN2_IMAGE_SHUTTER  STR  PPIMAGE_J2_IMAGE_F
		JPEG_BIN2_IMAGE_FLAT     STR  PPIMAGE_J2_IMAGE_F
		JPEG_BIN2_IMAGE_DOMEFLAT STR  PPIMAGE_J2_IMAGE_F
		JPEG_BIN2_IMAGE_SKYFLAT  STR  PPIMAGE_J2_IMAGE_F
		JPEG_BIN2_IMAGE_FRINGE   STR  PPIMAGE_J2_IMAGE_R

 		JPEG_BIN1_RESID_BIAS     STR  PPIMAGE_J1_RESID_B
		JPEG_BIN1_RESID_DARK     STR  PPIMAGE_J1_RESID_B
		JPEG_BIN1_RESID_SHUTTER  STR  PPIMAGE_J1_RESID_F
		JPEG_BIN1_RESID_FLAT     STR  PPIMAGE_J1_RESID_F
		JPEG_BIN1_RESID_DOMEFLAT STR  PPIMAGE_J1_RESID_F
		JPEG_BIN1_RESID_SKYFLAT  STR  PPIMAGE_J1_RESID_F
		JPEG_BIN1_RESID_FRINGE   STR  PPIMAGE_J1_RESID_R
 		JPEG_BIN2_RESID_BIAS     STR  PPIMAGE_J2_RESID_B
		JPEG_BIN2_RESID_DARK     STR  PPIMAGE_J2_RESID_B
		JPEG_BIN2_RESID_SHUTTER  STR  PPIMAGE_J2_RESID_F
		JPEG_BIN2_RESID_FLAT     STR  PPIMAGE_J2_RESID_F
		JPEG_BIN2_RESID_DOMEFLAT STR  PPIMAGE_J2_RESID_F
		JPEG_BIN2_RESID_SKYFLAT  STR  PPIMAGE_J2_RESID_F
		JPEG_BIN2_RESID_FRINGE   STR  PPIMAGE_J2_RESID_R
	END
	# Processing raw data
	DEFAULT		METADATA
		CHIP		STR	PPIMAGE_OBDSFRA
 		JPEG_BIN1       STR     PPIMAGE_J1
 		JPEG_BIN2       STR     PPIMAGE_J2
	END
END

FILERULES METADATA
   ### Redirections
   PSASTRO.INPUT      STR PSASTRO.INPUT.CMF
   PSASTRO.OUTPUT     STR PSASTRO.OUT.CMF.SPL
   PSASTRO.OUTPUT.MEF STR PSASTRO.OUT.CMF.MEF
   PSPHOT.OUTPUT      STR PSPHOT.OUT.CMF.SPL

   ### input file definitions
   ### use @DETDB entries to get the detrend images from the database
   ### replace @DETDB with @FILES if you want to require it from the 
   ### command line, or with an explicit name to require a specific file
   TYPE               INPUT FILENAME.RULE DATA.LEVEL FILE.TYPE 

   ## files used by ppImage
   PPIMAGE.INPUT      INPUT @FILES        CHIP       IMAGE     
   PPIMAGE.MASK       INPUT @DETDB        CELL       IMAGE     
   PPIMAGE.BIAS       INPUT @DETDB        CELL       IMAGE     
   PPIMAGE.DARK       INPUT @DETDB        CELL       IMAGE     
   PPIMAGE.FLAT       INPUT @DETDB        CELL       IMAGE     
   PPIMAGE.FRINGE     INPUT @DETDB        CHIP       FRINGE     
   PPIMAGE.SHUTTER    INPUT @DETDB        CELL       IMAGE     

   ## files used to build and apply the flat-field correction images
   DVOCORR.INPUT      INPUT @FILES        CHIP       IMAGE     
   DVOCORR.REFHEAD    INPUT @FILES        CHIP       HEADER     
   DVOFLAT.INPUT      INPUT @FILES        CHIP       IMAGE 	
   DVOFLAT.CORR       INPUT @DETDB        CHIP       IMAGE 	

   ## files used by psphot 
   PSPHOT.LOAD        INPUT @FILES        CHIP       IMAGE     
   PSPHOT.INPUT       INPUT @FILES        CHIP       IMAGE     
   PSPHOT.MASK        INPUT @FILES        CHIP       MASK     
   PSPHOT.WEIGHT      INPUT @FILES        CHIP       WEIGHT     
   PSPHOT.PSF.LOAD    INPUT @FILES        CHIP	     PSF       
   PSPHOT.INPUT.CMF   INPUT @FILES        CHIP	     CMF       

   ## files used by psastro 
   PSASTRO.INPUT.CMF  INPUT @FILES        CHIP       CMF       

   ## files used by pswarp
   PSWARP.INPUT       INPUT @FILES        CHIP       IMAGE     
   PSWARP.SKYCELL     INPUT @FILES        FPA        IMAGE     
   PSWARP.WEIGHT      INPUT @FILES        CHIP       WEIGHT
   PSWARP.MASK        INPUT @FILES        CHIP       MASK
   PSWARP.ASTROM      INPUT @FILES        CHIP       CMF       

   PPSUB.INPUT        INPUT    none.fits  FPA	     IMAGE
   PPSUB.INPUT.MASK   INPUT    none.fits  FPA	     MASK
   PPSUB.INPUT.WEIGHT INPUT    none.fits  FPA	     WEIGHT
   PPSUB.REF          INPUT    none.fits  FPA	     IMAGE
   PPSUB.REF.MASK     INPUT    none.fits  FPA	     MASK
   PPSUB.REF.WEIGHT   INPUT    none.fits  FPA	     WEIGHT

   PPSTACK.INPUT      INPUT    none.fits  FPA	     IMAGE
   PPSTACK.INPUT.MASK INPUT    none.fits  FPA	     MASK
   PPSTACK.INPUT.WEIGHT INPUT  none.fits  FPA	     WEIGHT

   ### output file definitions
   TYPE                OUTPUT   FILENAME.RULE      	       FILE.TYPE FITS.TYPE DATA.LEVEL FILE.SAVE FILE.FORMAT
   PPIMAGE.OUTPUT      OUTPUT   {OUTPUT}.{CHIP.NAME}.fits      IMAGE     NONE      CHIP       TRUE      SPLIT
   PPIMAGE.OUTPUT.MASK OUTPUT   {OUTPUT}.{CHIP.NAME}.mask.fits MASK      NONE      CHIP       TRUE      SPLIT
   PPIMAGE.OUTPUT.WEIGHT OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits   WEIGHT    NONE      CHIP       TRUE      SPLIT
   PPIMAGE.CHIP        OUTPUT 	{OUTPUT}.{CHIP.NAME}.ch.fits   IMAGE     NONE      CHIP       TRUE      SPLIT
   PPIMAGE.CHIP.MASK   OUTPUT 	{OUTPUT}.{CHIP.NAME}.ch.mask.fits MASK   NONE      CHIP       TRUE      SPLIT
   PPIMAGE.CHIP.WEIGHT OUTPUT 	{OUTPUT}.{CHIP.NAME}.ch.wt.fits WEIGHT   NONE      CHIP       TRUE      SPLIT
   PPIMAGE.OUTPUT.FPA1 OUTPUT 	{OUTPUT}.fpa1.fits             IMAGE     NONE      FPA        TRUE      NONE
   PPIMAGE.OUTPUT.FPA2 OUTPUT 	{OUTPUT}.fpa2.fits             IMAGE     NONE      FPA        TRUE      NONE
   PPIMAGE.STATS       OUTPUT   {OUTPUT}.stats                 STATS     NONE      FPA        TRUE      NONE

   PPIMAGE.JPEG1       OUTPUT   {OUTPUT}.b1.jpg    	       JPEG      NONE      FPA        TRUE      NONE
   PPIMAGE.JPEG2       OUTPUT   {OUTPUT}.b2.jpg    	       JPEG      NONE      FPA        TRUE      NONE
   PPIMAGE.BIN1        OUTPUT   {OUTPUT}.{CHIP.NAME}.b1.fits   IMAGE     NONE      CHIP       TRUE      SPLIT
   PPIMAGE.BIN2        OUTPUT   {OUTPUT}.{CHIP.NAME}.b2.fits   IMAGE     NONE      CHIP       TRUE      SPLIT

   DVOCORR.OUTPUT      OUTPUT 	{OUTPUT}.{CHIP.NAME}.fc.fits   IMAGE     NONE      CHIP       TRUE      NONE
   DVOFLAT.OUTPUT      OUTPUT 	{OUTPUT}.{CHIP.NAME}.co.fits   IMAGE     NONE      CHIP       TRUE      NONE

   PSPHOT.RESID        OUTPUT   {OUTPUT}.{CHIP.NAME}.res.fits  IMAGE     NONE      CHIP       TRUE      NONE
   PSPHOT.BACKGND      OUTPUT   {OUTPUT}.{CHIP.NAME}.bck.fits  IMAGE     NONE      CHIP       TRUE      NONE
   PSPHOT.BACKSUB      OUTPUT   {OUTPUT}.{CHIP.NAME}.sub.fits  IMAGE     NONE      CHIP       TRUE      NONE
   PSPHOT.BACKMDL      OUTPUT   {OUTPUT}.{CHIP.NAME}.mdl.fits  IMAGE     NONE      CHIP       TRUE      NONE
   PSPHOT.BACKMDL.STDEV OUTPUT   {OUTPUT}.{CHIP.NAME}.mdd.fits IMAGE     NONE      CHIP       TRUE      NONE

   PSPHOT.OUTPUT.RAW   OUTPUT   {OUTPUT}.{CHIP.NAME}           RAW       NONE      CHIP       TRUE      NONE
   PSPHOT.OUTPUT.SX    OUTPUT   {OUTPUT}.{CHIP.NAME}.sx        SX        NONE      CHIP       TRUE      NONE
   PSPHOT.OUTPUT.OBJ   OUTPUT   {OUTPUT}.{CHIP.NAME}.obj       OBJ       NONE      CHIP       TRUE      NONE
   PSPHOT.OUT.CMF.SPL  OUTPUT   {OUTPUT}.{CHIP.NAME}.cmf       CMF       NONE      CHIP       TRUE      NONE
   PSPHOT.OUT.CMF.MEF  OUTPUT   {OUTPUT}.cmf                   CMF       NONE      FPA        TRUE      NONE

   PSPHOT.PSF.SAVE     OUTPUT   {OUTPUT}.{CHIP.NAME}.psf       PSF       NONE      CHIP       TRUE      NONE

   SOURCE.PLOT.MOMENTS  OUTPUT  {OUTPUT}.{CHIP.NAME}.mnt.png   KAPA      NONE      CHIP       TRUE      NONE
   SOURCE.PLOT.PSFMODEL OUTPUT  {OUTPUT}.{CHIP.NAME}.psf.png   KAPA      NONE      CHIP       TRUE      NONE
   SOURCE.PLOT.APRESID  OUTPUT  {OUTPUT}.{CHIP.NAME}.dap.png   KAPA      NONE      CHIP       TRUE      NONE

   PSASTRO.OUTPUT.CMP   OUTPUT   {OUTPUT}.{CHIP.NAME}.smp      CMP       NONE      CHIP       TRUE      SPLIT
   PSASTRO.OUT.CMF.SPL  OUTPUT   {OUTPUT}.{CHIP.NAME}.smf      CMF       NONE      CHIP       TRUE      SPLIT
   PSASTRO.OUT.CMF.MEF  OUTPUT   {OUTPUT}.smf		       CMF       NONE      FPA        TRUE      TOGETHER

   PSWARP.OUTPUT       OUTPUT   {OUTPUT}.fits      	       IMAGE     NONE      FPA        TRUE      NONE
   PSWARP.OUTPUT.MASK  OUTPUT   {OUTPUT}.mask.fits             MASK      NONE      FPA        TRUE      NONE
   PSWARP.OUTPUT.WEIGHT OUTPUT  {OUTPUT}.wt.fits               WEIGHT    NONE      FPA        TRUE      NONE
   PSWARP.BIN1         OUTPUT   {OUTPUT}.b1.fits   	       IMAGE     NONE      FPA        TRUE      NONE
   PSWARP.BIN2         OUTPUT   {OUTPUT}.b2.fits   	       IMAGE     NONE      FPA        TRUE      NONE

   PPSUB.OUTPUT        OUTPUT   {OUTPUT}.fits                  IMAGE     NONE      FPA        TRUE      NONE
   PPSUB.OUTPUT.MASK   OUTPUT   {OUTPUT}.mask.fits             MASK      NONE      FPA        TRUE      NONE
   PPSUB.OUTPUT.WEIGHT OUTPUT   {OUTPUT}.wt.fits               WEIGHT    NONE      FPA        TRUE      NONE

   PPSTACK.OUTPUT      OUTPUT   {OUTPUT}.fits                  IMAGE     NONE      FPA        TRUE      NONE
   PPSTACK.OUTPUT.MASK OUTPUT   {OUTPUT}.mask.fits             MASK      NONE      FPA        TRUE      NONE
   PPSTACK.OUTPUT.WEIGHT OUTPUT {OUTPUT}.weight.fits           WEIGHT    NONE      FPA        TRUE      NONE

   PPSIM.OUTPUT        OUTPUT   {OUTPUT}.{CHIP.NAME}.fits      IMAGE     NONE      CHIP       TRUE      SPLIT
   PPSIM.SOURCES       OUTPUT   {OUTPUT}.cmf                   CMF       NONE      FPA        TRUE      NONE

   LOG.IMFILE            OUTPUT {OUTPUT}.{CHIP.NAME}.log       TEXT      NONE      CHIP       TRUE      NONE
   LOG.EXP               OUTPUT {OUTPUT}.log                   TEXT      NONE      FPA        TRUE      NONE
END

# FPA file defines properties of a possible input|output object
# user can set the filename (I|O), filename rules (O), or abstract source (@FILES, @DETDB) (I) 
# user can set the extension name, if used
# user can set the file type (IMAGE, JPEG, RAW, SX, OBJ, CMP, CMF) : but these are not variable in most cases!
# user can set the file depth: only valid for output files
# user can set the data depth: must be >= file depth
# user can set the file format: only valid for newly created FPAs
# user can set the colormap, scaling method, scaling range (JPEG only)
# user can set the extension name for the data and header segments (CMF only)


EXTNAME.RULES	METADATA
	CMF.HEAD	STR	{CHIP.NAME}.hdr
	CMF.DATA	STR	{CHIP.NAME}.psf
	PSF.HEAD	STR	{CHIP.NAME}.hdr
	PSF.TABLE	STR	{CHIP.NAME}.psf_model
	PSF.RESID	STR	{CHIP.NAME}.psf_resid
END

TESSELLATIONS	METADATA
	# Tessellation name with corresponding DVO catdir
	Skycells	STR	path://SIMTEST/skycells
END

BLANK.HEADERS	METADATA
	FPA.TIME	STR	MJD-OBS
	FPA.EXPOSURE	STR	EXPTIME
	FPA.AIRMASS	STR	AIRMASS
END
