# Camera configuration file for Cfh12k: describes the camera

# File formats that we know about
FORMATS		METADATA
	EARLY	STR	cfh12k/format_mef_early.config
	ESPLIT	STR	cfh12k/format_split_early.config
	MEF	STR	cfh12k/format_mef.config
	SPLIT	STR	cfh12k/format_split.config
END

# Description of camera --- all the chips and the cells that comprise them
FPA	METADATA
	ccd00	STR	Amp
	ccd01	STR	Amp
	ccd02	STR	Amp
	ccd03	STR	Amp
	ccd04	STR	Amp
	ccd05	STR	Amp
	ccd06	STR	Amp
	ccd07	STR	Amp
	ccd08	STR	Amp
	ccd09	STR	Amp
	ccd10	STR	Amp
	ccd11	STR	Amp
END

# move this elsewhere?  we need a lookup table to go from filter ID to abstract name
FILTER.ID       METADATA
   B       STR    B           	
   V       STR    V           	
   R       STR    R           	
   I       STR    I           	
   	              		
   Z       MULTI
   Z       STR    Z           	
   Z       STR    Zp           
   Z       STR    Zprime       
   	              		
   Ha      MULTI
   Ha      STR    Ha           
   Ha      STR    Ha.MP7605    
   Ha      STR    Halpha       
   Ha      STR    Haalpha.on   
   	              		
   HaOff   MULTI
   HaOff   STR    HaOFF        
   HaOff   STR    HaOFF.MP7604 
   HaOff   STR    Halpha.off   
   	              		
   Hb      STR    Hb           
   HbOff   STR    HbOff        
   	              		
   CN      MULTI
   CN      STR    CN           
   CN      STR    CN.MP780     
   CN      STR    cn.MP7803    
   CN      STR    CN.MP7803    
   	              		
   TiO     MULTI
   TiO     STR    TiO          
   TiO     STR    TiO.MP77     
   TiO     STR    tio.MP7701   
   TiO     STR    TiO.MP7701   
   	              		
   NB920   STR    NB920        
   	              		
   B2F     MULTI
   B2F     STR    B2F          
   B2F     STR    UKN:B2F
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}
END

DARK.NORM 	STR cfh12k/dark.config
DARK.NORM.KEY 	STR fpa_{CHIP.NAME}_Amp
# DARK.NORM.KEY STR BASIC ## rough version from global stats

# 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
	# Other recipes
        PSPHOT          STR     cfh12k/psphot.config           # psphot details
        PSASTRO         STR     cfh12k/psastro.config          # psastro details
	PPIMAGE         STR     cfh12k/ppImage.config		# ppImage recipe
	REJECTIONS      STR     cfh12k/rejections.config	# rejection recipe
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
	END
	# Processing raw data
	DEFAULT		METADATA
		CHIP		STR	PPIMAGE_OBDSFRA
	END
END

FILERULES METADATA
   ### Redirections
   PSASTRO.INPUT      STR PSASTRO.INPUT.CMF
   PSASTRO.OUTPUT     STR PSASTRO.OUT.CMF.MEF
   PSASTRO.OUTPUT.MEF STR PSASTRO.OUT.CMF.MEF
   PSPHOT.OUTPUT      STR PSPHOT.OUT.CMF.MEF
   PPIMAGE.OUTPUT     STR PPIMAGE.OUTPUT.MEF
   PPIMAGE.BIN1       STR PPIMAGE.BIN1.MEF
   PPIMAGE.BIN2       STR PPIMAGE.BIN2.MEF
   DVOCORR.OUTPUT     STR DVOCORR.MEF.OUTPUT
   DVOFLAT.OUTPUT     STR DVOFLAT.MEF.OUTPUT
   PPIMAGE.OUTPUT.MASK STR PPIMAGE.OUT.MK.MEF
   PPIMAGE.OUTPUT.WEIGHT STR PPIMAGE.OUT.WT.MEF

   ### 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        CHIP       IMAGE
   PPIMAGE.BIAS       INPUT @DETDB        CHIP       IMAGE
   PPIMAGE.DARK       INPUT @DETDB        CHIP       IMAGE
   PPIMAGE.FLAT       INPUT @DETDB        CHIP       IMAGE
   PPIMAGE.FRINGE     INPUT @DETDB        CHIP       FRINGE     
   PPIMAGE.SHUTTER    INPUT @DETDB        CHIP       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.CMP  INPUT @FILES        CHIP       CMP       
   PSASTRO.INPUT.CMF  INPUT @FILES        CHIP       CMF       

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

   ### output file definitions
   TYPE                  OUTPUT FILENAME.RULE                 FILE.TYPE FITS.TYPE DATA.LEVEL FILE.SAVE FILE.FORMAT
   PPIMAGE.OUTPUT.SPL  	 OUTPUT {OUTPUT}.{CHIP.NAME}.b0.fits  IMAGE     NONE      CHIP       TRUE      SPLIT
   PPIMAGE.OUTPUT.MEF  	 OUTPUT {OUTPUT}.b0.fits              IMAGE     NONE      CHIP       TRUE      MEF
   PPIMAGE.OUT.MK.SPL  	 OUTPUT {OUTPUT}.{CHIP.NAME}.mk.fits  MASK      NONE      CHIP       TRUE      SPLIT
   PPIMAGE.OUT.WT.SPL  	 OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits  WEIGHT    NONE      CHIP       TRUE      SPLIT
   PPIMAGE.OUT.MK.MEF  	 OUTPUT {OUTPUT}.mk.fits              MASK      NONE      CHIP       TRUE      MEF
   PPIMAGE.OUT.WT.MEF  	 OUTPUT {OUTPUT}.wt.fits              WEIGHT    NONE      CHIP       TRUE      MEF
   PPIMAGE.CHIP          OUTPUT {OUTPUT}.fits                 IMAGE     NONE      CHIP       TRUE      MEF
   PPIMAGE.CHIP.MASK     OUTPUT {OUTPUT}.mk.fits              MASK      NONE      CHIP       TRUE      MEF
   PPIMAGE.CHIP.WEIGHT   OUTPUT {OUTPUT}.wt.fits              WEIGHT    NONE      CHIP       TRUE      MEF
   PPIMAGE.OUTPUT.FPA1 	 OUTPUT {OUTPUT}.b1.fits              IMAGE     NONE      FPA        TRUE      MEF
   PPIMAGE.OUTPUT.FPA2 	 OUTPUT {OUTPUT}.b2.fits              IMAGE     NONE      FPA        TRUE      MEF

   PPIMAGE.BIN1.SPL    	 OUTPUT {OUTPUT}.{CHIP.NAME}.b1.fits  IMAGE     NONE      CHIP       TRUE      SPLIT
   PPIMAGE.BIN2.SPL    	 OUTPUT {OUTPUT}.{CHIP.NAME}.b2.fits  IMAGE     NONE      CHIP       TRUE      SPLIT
   PPIMAGE.BIN1.MEF    	 OUTPUT {OUTPUT}.b1c.fits             IMAGE     NONE      CHIP       TRUE      MEF
   PPIMAGE.BIN2.MEF    	 OUTPUT {OUTPUT}.b2c.fits             IMAGE     NONE      CHIP       TRUE      MEF

   PPIMAGE.JPEG1       	 OUTPUT {OUTPUT}.b1.jpg               JPEG      NONE      FPA        TRUE      NONE
   PPIMAGE.JPEG2       	 OUTPUT {OUTPUT}.b2.jpg               JPEG      NONE      FPA        TRUE      NONE

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

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

   PSPHOT.OUTPUT.RAW   	 OUTPUT {OUTPUT}.{CHIP.NAME}          RAW       NONE      CHIP       TRUE      NONE
   PSPHOT.OUTPUT.SX    	 OUTPUT {OUTPUT}.sx                   SX        NONE      CHIP       TRUE      NONE
   PSPHOT.OUTPUT.OBJ   	 OUTPUT {OUTPUT}.obj                  OBJ       NONE      CHIP       TRUE      NONE
   PSPHOT.OUTPUT.CMP   	 OUTPUT {OUTPUT}.{CHIP.NAME}.cmp      CMP       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}.psf                  PSF       NONE      CHIP       TRUE      MEF

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

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

   PSWARP.OUTPUT       	 OUTPUT {OUTPUT}.fits      	      IMAGE     NONE      FPA        TRUE      NONE
   PSWARP.OUTPUT.MASK    OUTPUT {OUTPUT}.mk.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

   PPSIM.OUTPUT          OUTPUT {OUTPUT}.{CHIP.NAME}.fits     IMAGE     NONE      CHIP       TRUE      SPLIT

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

EXTNAME.RULES METADATA
  CMF.HEAD STR {CHIP.NAME}.hdr
  CMF.DATA STR {CHIP.NAME}.psf # use .PSF and .EXT?

  PSF.HEAD  STR {CHIP.NAME}.hdr
  PSF.TABLE STR {CHIP.NAME}.psf_model
  PSF.RESID STR {CHIP.NAME}.psf_resid
END

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