# "mcshort" is a MegaCam camera with only the central six chips --- it's faster than the entire FPA.
# The spliced MecaCam data is stored in single extensions for each chip

# How to recognise this type
RULE	METADATA
	TELESCOP	STR	CFHT 3.6m
	DETECTOR	STR	CFH12K
	INSTRUME	STR	CFH12K Mosaic
	NAXIS		S32	0
END

FILE	METADATA
	# How to read this data
	PHU		STR	CHIP	 # The FITS file represents an entire FPA
	EXTENSIONS	STR	NONE	 # The extensions represent chips
	FPA.OBS		STR	EXPNUM	 # A PHU keyword for unique identifier
	CHIP.NAME	STR	IMAGEID	 # An extension keyword for unique identifie
	EXTWORD         STR     IMAGEID
	CONTENT		STR	IMAGEID	 # Key to the CONTENTS menu
	CONTENT.RULE	STR	{CHIP.N} # How to derive the CONTENT when writing
END

# What's in the FITS file?
CONTENTS	METADATA
	# Content key   ->      chip name:component cell
	ccd00.hdr	STR	ccd00:MIT-LL
	ccd01.hdr	STR	ccd01:MIT-LL
	ccd02.hdr	STR	ccd02:MIT-LL
	ccd03.hdr	STR	ccd03:MIT-LL
	ccd04.hdr	STR	ccd04:MIT-LL
	ccd05.hdr	STR	ccd05:MIT-LL
	ccd06.hdr	STR	ccd06:MIT-LL
	ccd07.hdr	STR	ccd07:MIT-LL
	ccd08.hdr	STR	ccd08:MIT-LL
	ccd09.hdr	STR	ccd09:MIT-LL
	ccd10.hdr	STR	ccd10:MIT-LL
	ccd11.hdr	STR	ccd11:MIT-LL
END

# Specify the chips
CHIPS		METADATA
	MIT-LL	STR	Amp:cell
END


# Specify the cells
CELLS		METADATA
	cell		METADATA
		CELL.BIASSEC.SOURCE	STR	HEADER
		CELL.TRIMSEC.SOURCE	STR	HEADER
		CELL.BIASSEC		STR	BIASSEC
		CELL.TRIMSEC		STR	DATASEC
		CELL.X0			S32	0
		CELL.GAIN.SOURCE	STR	HEADER
		CELL.GAIN		STR	GAIN
	END
END

# How to translate PS concepts into FITS headers
TRANSLATION	METADATA
	FPA.OBSTYPE	STR	OBSTYPE
	FPA.OBJECT	STR	OBSTYPE
        FPA.AIRMASS     STR     AIRMASS
        FPA.FILTERID    STR     FILTER
        FPA.FILTER      STR     FILTER
        FPA.POSANGLE    STR     ROTANGLE
        FPA.RA          STR     RA
        FPA.DEC         STR     DEC
        FPA.RADECSYS    STR     RADECSYS
	FPA.FOCUS	STR	TELFOCUS
	FPA.TIME	STR	MJD-OBS
	FPA.TIMESYS	STR	TIMESYS
	FPA.ALT		STR	TELALT
	FPA.AZ		STR	TELAZ
	FPA.TEMP	STR	DETTEM
	FPA.EXPOSURE	STR	EXPTIME
	CHIP.TEMP	STR	DETTEM
        CELL.EXPOSURE   STR     EXPTIME
        CELL.DARKTIME   STR     DARKTIME
        CELL.SATURATION STR     SATURATE
	CELL.TIME	STR	MJD-OBS
	CELL.TIMESYS	STR	TIMESYS
        CELL.XBIN       STR     CCDBIN1
        CELL.YBIN       STR     CCDBIN2
END

# Default PS concepts that may be specified by value
DEFAULTS        METADATA
	FPA.TELESCOPE		STR	CFHT
	FPA.INSTRUMENT		STR	CFH12K		# this value is used in ipprc.config to find the recipes
	FPA.DETECTOR	        STR	CFH12K
	CHIP.XSIZE		S32	2048
	CHIP.YSIZE		S32	4096
	CELL.XSIZE		S32	2048
	CELL.YSIZE		S32	4096
	CELL.READNOISE          F32     10.0
	CELL.READDIR		S32	1		# Cell is read in x direction
        CELL.BAD                S32     0
	CELL.XPARITY		S32	1
	CELL.YPARITY		S32	1
	CELL.Y0			S32	0
	CHIP.X0.DEPEND		STR	CHIP.NAME
	CHIP.X0		METADATA
		ccd00	S32	0
		ccd01	S32	2048
		ccd02	S32	4096
		ccd03	S32	6144
		ccd04	S32	8192
		ccd05	S32	10240
		ccd06	S32	0    
		ccd07	S32	2048 
		ccd08	S32	4096 
		ccd09	S32	6144 
		ccd10	S32	8192 
		ccd11	S32	10240
	END
	CHIP.Y0.DEPEND		STR	CHIP.NAME
	CHIP.Y0		METADATA
		ccd00	S32	0
		ccd01	S32	0
		ccd02	S32	0
		ccd03	S32	0
		ccd04	S32	0
		ccd05	S32	0
		ccd06	S32	4128
		ccd07	S32	4128
		ccd08	S32	4128
		ccd09	S32	4128
		ccd10	S32	4128
		ccd11	S32	4128
	END
	CHIP.XPARITY		S32	1
	CHIP.YPARITY.DEPEND	STR	CHIP.NAME
	CHIP.YPARITY	METADATA
		ccd00	S32	+1
		ccd01	S32	+1
		ccd02	S32	+1
		ccd03	S32	+1
		ccd04	S32	+1
		ccd05	S32	+1
		ccd06	S32	-1
		ccd07	S32	-1
		ccd08	S32	-1
		ccd09	S32	-1
		ccd10	S32	-1
		ccd11	S32	-1
	END
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
 
