# The spliced MecaCam data is stored in single extensions for each chip

# How to recognise this type
RULE	METADATA
	DETECTOR	STR	MegaCam
	NAXIS           S32     0
	EXTEND		BOOL	T
        HISTORY         STR     imsplice: Splicing results in all detectors as if read from A amplifier
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	EXPNUM	# 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
	ccd00		STR	ccd00:CCD42-90
	ccd01		STR	ccd01:CCD42-90
	ccd02		STR	ccd02:CCD42-90
	ccd03		STR	ccd03:CCD42-90
	ccd04		STR	ccd04:CCD42-90
	ccd05		STR	ccd05:CCD42-90
	ccd06		STR	ccd06:CCD42-90
	ccd07		STR	ccd07:CCD42-90
	ccd08		STR	ccd08:CCD42-90
	ccd09		STR	ccd09:CCD42-90
	ccd10		STR	ccd10:CCD42-90
	ccd11		STR	ccd11:CCD42-90
	ccd12		STR	ccd12:CCD42-90
	ccd13		STR	ccd13:CCD42-90
	ccd14		STR	ccd14:CCD42-90
	ccd15		STR	ccd15:CCD42-90
	ccd16		STR	ccd16:CCD42-90
	ccd17		STR	ccd17:CCD42-90
	ccd18		STR	ccd18:CCD42-90
	ccd19		STR	ccd19:CCD42-90
	ccd20		STR	ccd20:CCD42-90
	ccd21		STR	ccd21:CCD42-90
	ccd22		STR	ccd22:CCD42-90
	ccd23		STR	ccd23:CCD42-90
	ccd24		STR	ccd24:CCD42-90
	ccd25		STR	ccd25:CCD42-90
	ccd26		STR	ccd26:CCD42-90
	ccd27		STR	ccd27:CCD42-90
	ccd28		STR	ccd28:CCD42-90
	ccd29		STR	ccd29:CCD42-90
	ccd30		STR	ccd30:CCD42-90
	ccd31		STR	ccd31:CCD42-90
	ccd32		STR	ccd32:CCD42-90
	ccd33		STR	ccd33:CCD42-90
	ccd34		STR	ccd34:CCD42-90
	ccd35		STR	ccd35:CCD42-90
END

# Specify the chips
CHIPS		METADATA
	# Chip type, cellName:cellType
	CCD42-90	STR	LeftAmp:left RightAmp:right
END


# Specify the cells
CELLS		METADATA
	# Cell type, concepts to use
	left		METADATA
		CELL.BIASSEC.SOURCE	STR	HEADER
		CELL.TRIMSEC.SOURCE	STR	HEADER
		CELL.BIASSEC		STR	BSECA
		CELL.TRIMSEC		STR	TSECA
		CELL.X0			S32	0
		CELL.GAIN.SOURCE	STR	HEADER
		CELL.GAIN		STR	GAINA
	END

	right		METADATA
		CELL.BIASSEC.SOURCE	STR	HEADER
		CELL.TRIMSEC.SOURCE	STR	HEADER
		CELL.BIASSEC		STR	BSECB
		CELL.TRIMSEC		STR	TSECB
		CELL.X0			S32	1024
		CELL.GAIN.SOURCE	STR	HEADER
		CELL.GAIN		STR	GAINB
	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.OBSTYPE	STR	OBSTYPE
	FPA.OBJECT	STR	OBJECT
	FPA.TIME	STR	MJD-OBS
	FPA.TIMESYS	STR	TIMESYS
        FPA.RA          STR     RA
        FPA.DEC         STR     DEC
        FPA.RADECSYS    STR     RADECSYS
	FPA.TEMP	STR	DETTEM
	FPA.EXPOSURE	STR	EXPTIME
	CHIP.TEMP	STR	DETTEM
        CELL.EXPOSURE   STR     EXPTIME
        CELL.DARKTIME   STR     DARKTIME
        CELL.READNOISE  STR     RDNOISE
	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	MEGACAM		# this value is used in ipprc.config to find the recipes
	FPA.DETECTOR	        STR	MEGACAM
	FPA.POSANGLE		F32	0.0     # not reported until 03Am04
	FPA.FOCUS		F32	0.0     # not reported until 03Am04
	FPA.ALT			F32	0.0     # not reported until 03Am04
	FPA.AZ			F32	0.0     # not reported until 03Am04
	CHIP.XSIZE		S32	2048
	CHIP.YSIZE		S32	4612
	CELL.XSIZE		S32	1024
	CELL.YSIZE		S32	4612
	CELL.XWINDOW		S32	0
	CELL.YWINDOW		S32	0
	CELL.READDIR		S32	1		# Cell is read in x direction
        CELL.SATURATION		F32	50000.0
        CELL.BAD                F32     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	12288
		ccd07	S32	14336
		ccd08	S32	16384
		ccd09	S32	0
		ccd10	S32	2048
		ccd11	S32	4096
		ccd12	S32	6144
		ccd13	S32	8192
		ccd14	S32	10240
		ccd15	S32	12288
		ccd16	S32	14336
		ccd17	S32	16384
		ccd18	S32    -2048
		ccd19	S32	0
		ccd20	S32	2048 
		ccd21	S32	4096 
		ccd22	S32	6144 
		ccd23	S32	8192 
		ccd24	S32	10240
		ccd25	S32	12288
		ccd26	S32	14336
		ccd27	S32    -2048
		ccd28	S32	0
		ccd29	S32	2048 
		ccd30	S32	4096 
		ccd31	S32	6144 
		ccd32	S32	8192 
		ccd33	S32	10240
		ccd34	S32	12288
		ccd35	S32	14336
	END
	CHIP.Y0.DEPEND		STR	CHIP.NAME
	CHIP.Y0		METADATA
		ccd00	S32	18447
		ccd01	S32	18447
		ccd02	S32	18447
		ccd03	S32	18447
		ccd04	S32	18447
		ccd05	S32	18447
		ccd06	S32	18447
		ccd07	S32	18447
		ccd08	S32	18447
		ccd09	S32	13835
		ccd10	S32	13835
		ccd11	S32	13835
		ccd12	S32	13835
		ccd13	S32	13835
		ccd14	S32	13835
		ccd15	S32	13835
		ccd16	S32	13835
		ccd17	S32	13835
		ccd18	S32	4612
		ccd19	S32	4612
		ccd20	S32	4612
		ccd21	S32	4612
		ccd22	S32	4612
		ccd23	S32	4612
		ccd24	S32	4612
		ccd25	S32	4612
		ccd26	S32	4612
		ccd27	S32	0
		ccd28	S32	0
		ccd29	S32	0
		ccd30	S32	0
		ccd31	S32	0
		ccd32	S32	0
		ccd33	S32	0
		ccd34	S32	0
		ccd35	S32	0
	END
	CHIP.XPARITY.DEPEND	STR	CHIP.NAME
	CHIP.XPARITY	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
		ccd12	S32	-1
		ccd13	S32	-1
		ccd14	S32	-1
		ccd15	S32	-1
		ccd16	S32	-1
		ccd17	S32	-1
		ccd18	S32	1
		ccd19	S32	1
		ccd20	S32	1
		ccd21	S32	1
		ccd22	S32	1
		ccd23	S32	1
		ccd24	S32	1
		ccd25	S32	1
		ccd26	S32	1
		ccd27	S32	1
		ccd28	S32	1
		ccd29	S32	1
		ccd30	S32	1
		ccd31	S32	1
		ccd32	S32	1
		ccd33	S32	1
		ccd34	S32	1
		ccd35	S32	1
	END
	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
		ccd12	S32	-1
		ccd13	S32	-1
		ccd14	S32	-1
		ccd15	S32	-1
		ccd16	S32	-1
		ccd17	S32	-1
		ccd18	S32	1
		ccd19	S32	1
		ccd20	S32	1
		ccd21	S32	1
		ccd22	S32	1
		ccd23	S32	1
		ccd24	S32	1
		ccd25	S32	1
		ccd26	S32	1
		ccd27	S32	1
		ccd28	S32	1
		ccd29	S32	1
		ccd30	S32	1
		ccd31	S32	1
		ccd32	S32	1
		ccd33	S32	1
		ccd34	S32	1
		ccd35	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
 
