# LBCred format.config, copied from MegaCam format_mef.config
# Like Megacam, LBC has an FPA in a multi-extension fits file, with one chip per extension


# How to recognise this type
RULE	METADATA
	TELESCOP	STR	LBT-DX
	INSTRUME	STR	LBC-RED
	NAXIS           S32     0
	EXTEND		BOOL	T
END

FILE	METADATA
	# How to read this data
	PHU		STR	FPA	# The FITS file represents an entire FPA
	EXTENSIONS	STR	CHIP	# The extensions represent chips
	FPA.OBS	STR	OBS_ID	# A PHU keyword for unique identifier
	CHIP.NAME	STR	EXTNAME	# An extension keyword for unique identifie
END

# What's in the FITS file?
CONTENTS	METADATA
	# Extension name, chipName:chipType
	LBCCHIP1	STR	CHIP1:Chip
	LBCCHIP2	STR	CHIP2:Chip
	LBCCHIP3	STR	CHIP3:Chip
	LBCCHIP4	STR	CHIP4:Chip
END

# Specify the chips
CHIPS		METADATA
	# Chip type, cellName:cellType
	Chip	STR	Cell:Cell
END


# Specify the cells
CELLS		METADATA
	# Cell type, concepts to use
	Cell	METADATA
		CELL.BIASSEC.SOURCE	STR	HEADER
		CELL.TRIMSEC.SOURCE	STR	HEADER
		CELL.BIASSEC		STR	BIASSEC
		CELL.TRIMSEC		STR	TRIMSEC
	# Not sure about these...
		CELL.X0			S32	0
		CELL.Y0			S32	0
		CELL.GAIN.SOURCE	STR	HEADER
		CELL.GAIN		STR	GAIN
	END
END

# How to translate PS concepts into FITS headers
TRANSLATION	METADATA
        FPA.AIRMASS     STR     AIRMASS
        FPA.FILTERID    STR     FILTER
        FPA.FILTER      STR     FILTER
        FPA.POSANGLE    STR     ROTANGLE
        FPA.RA          STR     OBSRA
        FPA.DEC         STR     OBSDEC
        FPA.RADECSYS    STR     RADECSYS
	FPA.OBSTYPE	STR	IMAGETYPE
	FPA.OBJECT	STR	OBJECT
	FPA.FOCUS	STR	Z4 # ???
	FPA.TIME	STR	MJD_OBS
#	FPA.TIMESYS	STR	TIMESYS
	FPA.ALT		STR	TELALT
	FPA.AZ		STR	TELAZ
	FPA.TEMP	STR	CCDTEM
	FPA.EXPOSURE	STR	EXPTIME
	CHIP.TEMP	STR	DETTEM
        CELL.EXPOSURE   STR     EXPTIME
        CELL.DARKTIME   STR     EXPTIME
        CELL.READNOISE  STR     RDNOISE
	CELL.TIME	STR	MJD_OBS
#	CELL.TIMESYS	STR	TIMESYS
        CELL.XBIN       STR     LBCBIN
        CELL.YBIN       STR     LBCBIN
	CELL.SATURATION	STR	SATURATE
END

# Default PS concepts that may be specified by value
DEFAULTS        METADATA
	FPA.TELESCOPE		STR	LBT-DX
	FPA.INSTRUMENT		STR	LBC-RED		# this value is used in ipprc.config to find the recipes
	FPA.DETECTOR	        STR	LBC-RED
	CELL.TIMESYS		STR	UTC
	FPA.TIMESYS		STR	UTC
	CHIP.XSIZE		S32	2048
	CHIP.YSIZE		S32	4608
	CELL.XSIZE		S32	2048
	CELL.YSIZE		S32	4608
	CELL.XWINDOW		S32	0
	CELL.YWINDOW		S32	0
	CELL.READDIR		S32	1		# Cell is read in x direction
        CELL.SATURATION		F32	65536.0
        CELL.BAD                F32     0
	CELL.XPARITY		S32	1
	CELL.YPARITY		S32	1
	CHIP.X0.DEPEND		STR	CHIP.NAME
	# Do the x0, y0 positions need to account for the gaps??? 
	# How do I specify rotation?
	# 
	# LBC layout is
	#
	#   444444444
	#   444444444
	#   444444444
	#
	#  333 222 111
	#  333 222 111
	#  333 222 111
	#  333 222 111
	#  333 222 111
	#  333 222 111
	# 
	CHIP.X0		METADATA
		CHIP1	S32	4096
		CHIP2	S32	2048
		CHIP3	S32	0
	# This is probably wrong!
		CHIP4	S32	1024
	END
	CHIP.Y0.DEPEND		STR	CHIP.NAME
	CHIP.Y0		METADATA
		CHIP1	S32	0
		CHIP2	S32	0
		CHIP3	S32	0
		CHIP4	S32	4608
	END
	CHIP.XPARITY	S32	1
	CHIP.YPARITY	S32	1
END


# How to translation PS concepts into database lookups
DATABASE	METADATA
	TYPE		dbEntry		TABLE		COLUMN		GIVENDBCOL	GIVENPS
#	CELL.GAIN	dbEntry		Camera		gain		chipId,cellId	CHIP.NAME,CELL.NAME
#	CELL.READNOISE	dbEntry		Camera		readNoise	chipId,cellId	CHIP.NAME,CELL.NAME

# A database entry refers to a particular column (COLUMN) in a
# particular table (TABLE), given certain PS concepts (GIVENPS) that
# match certain database columns (GIVENDBCOL).
END		

# Where there might be some ambiguity, specify the format
FORMATS		METADATA
	FPA.RA		STR	HOURS
	FPA.DEC		STR	DEGREES
	FPA.TIME	STR	MJD
	CELL.TIME	STR	MJD
END
 
