# Camera format configuration for Pan-STARRS Test Camera 3

# How to recognise this type
RULE	METADATA
#        IMAGESWV        STR     GPC DaqCom v2.05 (Mar 08 2007)
	ORIGIN		STR	PS1
	CONTROLR	STR	STARGRASP
	EXTEND		BOOL	T
END

FILE	METADATA
	# How to read this data
	PHU		STR	CHIP	# The FITS file represents a chip
	EXTENSIONS	STR	CELL	# The extensions represent cells
	FPA.NAME	STR	OBSTYPE	# A PHU keyword for unique identifier
	CONTENT	        STR     DETECTOR # How to determine content of FITS file
	CONTENT.RULE	STR	{CHIP.NAME}	# How to derive the CONTENT when writing
END

# What's in the FITS file?
CONTENTS	METADATA
	# File identifier with corresponding file layout name
	CCID58-1-06b2	STR	CCID58-1-06b2:CCD_10u
	CCID45-1-14A	STR	CCID45-1-14A:CCD_12u
	CCID45-1-11A	STR	CCID45-1-11A:CCD_12u
	CCID45-1-22A	STR	CCID45-1-22A:CCD_12u
	CCID45-1-04C	STR	CCID45-1-04C:CCD_10u
	CCID45-1-13A	STR	CCID45-1-13A:CCD_12u
	CCID45-1-05A	STR	CCID45-1-05A:CCD_12u
	CCID45-1-19A	STR	CCID45-1-19A:CCD_12u
END

# Specify the layout
CHIPS	METADATA
	CCD_10u		METADATA
		# Extension name, cellName:cellType
		xy00	STR	xy00:pitch10u
		xy01	STR	xy01:pitch10u
		xy02	STR	xy02:pitch10u
		xy03	STR	xy03:pitch10u
		xy04	STR	xy04:pitch10u
		xy05	STR	xy05:pitch10u
		xy06	STR	xy06:pitch10u
		xy07	STR	xy07:pitch10u
		xy10	STR	xy10:pitch10u
		xy11	STR	xy11:pitch10u
		xy12	STR	xy12:pitch10u
		xy13	STR	xy13:pitch10u
		xy14	STR	xy14:pitch10u
		xy15	STR	xy15:pitch10u
		xy16	STR	xy16:pitch10u
		xy17	STR	xy17:pitch10u
		xy20	STR	xy20:pitch10u
		xy21	STR	xy21:pitch10u
		xy22	STR	xy22:pitch10u
		xy23	STR	xy23:pitch10u
		xy24	STR	xy24:pitch10u
		xy25	STR	xy25:pitch10u
		xy26	STR	xy26:pitch10u
		xy27	STR	xy27:pitch10u
		xy30	STR	xy30:pitch10u
		xy31	STR	xy31:pitch10u
		xy32	STR	xy32:pitch10u
		xy33	STR	xy33:pitch10u
		xy34	STR	xy34:pitch10u
		xy35	STR	xy35:pitch10u
		xy36	STR	xy36:pitch10u
		xy37	STR	xy37:pitch10u
		xy40	STR	xy40:pitch10u
		xy41	STR	xy41:pitch10u
		xy42	STR	xy42:pitch10u
		xy43	STR	xy43:pitch10u
		xy44	STR	xy44:pitch10u
		xy45	STR	xy45:pitch10u
		xy46	STR	xy46:pitch10u
		xy47	STR	xy47:pitch10u
		xy50	STR	xy50:pitch10u
		xy51	STR	xy51:pitch10u
		xy52	STR	xy52:pitch10u
		xy53	STR	xy53:pitch10u
		xy54	STR	xy54:pitch10u
		xy55	STR	xy55:pitch10u
		xy56	STR	xy56:pitch10u
		xy57	STR	xy57:pitch10u
		xy60	STR	xy60:pitch10u
		xy61	STR	xy61:pitch10u
		xy62	STR	xy62:pitch10u
		xy63	STR	xy63:pitch10u
		xy64	STR	xy64:pitch10u
		xy65	STR	xy65:pitch10u
		xy66	STR	xy66:pitch10u
		xy67	STR	xy67:pitch10u
		xy70	STR	xy70:pitch10u
		xy71	STR	xy71:pitch10u
		xy72	STR	xy72:pitch10u
		xy73	STR	xy73:pitch10u
		xy74	STR	xy74:pitch10u
		xy75	STR	xy75:pitch10u
		xy76	STR	xy76:pitch10u
		xy77	STR	xy77:pitch10u
	END
	CCD_12u		METADATA
		# Extension name, cellName:cellType
		xy00	STR	xy00:pitch12u
		xy01	STR	xy01:pitch12u
		xy02	STR	xy02:pitch12u
		xy03	STR	xy03:pitch12u
		xy04	STR	xy04:pitch12u
		xy05	STR	xy05:pitch12u
		xy06	STR	xy06:pitch12u
		xy07	STR	xy07:pitch12u
		xy10	STR	xy10:pitch12u
		xy11	STR	xy11:pitch12u
		xy12	STR	xy12:pitch12u
		xy13	STR	xy13:pitch12u
		xy14	STR	xy14:pitch12u
		xy15	STR	xy15:pitch12u
		xy16	STR	xy16:pitch12u
		xy17	STR	xy17:pitch12u
		xy20	STR	xy20:pitch12u
		xy21	STR	xy21:pitch12u
		xy22	STR	xy22:pitch12u
		xy23	STR	xy23:pitch12u
		xy24	STR	xy24:pitch12u
		xy25	STR	xy25:pitch12u
		xy26	STR	xy26:pitch12u
		xy27	STR	xy27:pitch12u
		xy30	STR	xy30:pitch12u
		xy31	STR	xy31:pitch12u
		xy32	STR	xy32:pitch12u
		xy33	STR	xy33:pitch12u
		xy34	STR	xy34:pitch12u
		xy35	STR	xy35:pitch12u
		xy36	STR	xy36:pitch12u
		xy37	STR	xy37:pitch12u
		xy40	STR	xy40:pitch12u
		xy41	STR	xy41:pitch12u
		xy42	STR	xy42:pitch12u
		xy43	STR	xy43:pitch12u
		xy44	STR	xy44:pitch12u
		xy45	STR	xy45:pitch12u
		xy46	STR	xy46:pitch12u
		xy47	STR	xy47:pitch12u
		xy50	STR	xy50:pitch12u
		xy51	STR	xy51:pitch12u
		xy52	STR	xy52:pitch12u
		xy53	STR	xy53:pitch12u
		xy54	STR	xy54:pitch12u
		xy55	STR	xy55:pitch12u
		xy56	STR	xy56:pitch12u
		xy57	STR	xy57:pitch12u
		xy60	STR	xy60:pitch12u
		xy61	STR	xy61:pitch12u
		xy62	STR	xy62:pitch12u
		xy63	STR	xy63:pitch12u
		xy64	STR	xy64:pitch12u
		xy65	STR	xy65:pitch12u
		xy66	STR	xy66:pitch12u
		xy67	STR	xy67:pitch12u
		xy70	STR	xy70:pitch12u
		xy71	STR	xy71:pitch12u
		xy72	STR	xy72:pitch12u
		xy73	STR	xy73:pitch12u
		xy74	STR	xy74:pitch12u
		xy75	STR	xy75:pitch12u
		xy76	STR	xy76:pitch12u
		xy77	STR	xy77:pitch12u
	END
END		

# Specify the cell data
CELLS	METADATA
	pitch10u	METADATA
		CELL.BIASSEC.SOURCE	STR	HEADER
		CELL.TRIMSEC.SOURCE	STR	HEADER
		CELL.BIASSEC		STR	BIASSEC
		CELL.TRIMSEC		STR	DATASEC
		CELL.XSIZE		S32	590
		CELL.YSIZE		S32	598
	END

	pitch12u	METADATA
		CELL.BIASSEC.SOURCE	STR	HEADER
		CELL.TRIMSEC.SOURCE	STR	HEADER
		CELL.BIASSEC		STR	BIASSEC
		CELL.TRIMSEC		STR	DATASEC
		CELL.XSIZE		S32	477
		CELL.YSIZE		S32	496
	END
	pitch10u	METADATA
		CELL.BIASSEC.SOURCE	STR	VALUE
		CELL.TRIMSEC.SOURCE	STR	VALUE
		CELL.BIASSEC		STR	[575:606,1:594]
		CELL.TRIMSEC		STR	[1:574,1:594]
	#	CELL.BIASSEC		STR	BIASSEC
	#	CELL.TRIMSEC		STR	DATASEC
	END

	# This is just in here for fun
	pitch12u	METADATA
		CELL.BIASSEC.SOURCE	STR	VALUE
		CELL.TRIMSEC.SOURCE	STR	VALUE
		CELL.BIASSEC		STR	[1:10,1:512];[523:574,1:512]
		CELL.TRIMSEC		STR	[11:522,1:512]
	#	CELL.BIASSEC		STR	BIASSEC
	#	CELL.TRIMSEC		STR	TRIMSEC
	END
END

# How to translate PS concepts into FITS headers
TRANSLATION	METADATA
	FPA.TELESCOPE	STR	TELESCOP
	FPA.INSTRUMENT	STR	INSTRUME
	FPA.DETECTOR	STR	DETECTOR
        FPA.AIRMASS     STR     AIRMASS
	FPA.OBSTYPE	STR	OBSTYPE
	FPA.OBJECT	STR	OBSTYPE
#	FPA.OBJECT	STR	OBJECT		# Not always available
#        FPA.FILTERID    STR     FILTER		# Not available from OTIS
#        FPA.FILTER      STR     FILTER		# Not available from OTIS
        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.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.TIME	STR	MJD-OBS
        CELL.SATURATION STR     SATURATE
        CELL.XBIN       STR     CCDBIN1
        CELL.YBIN       STR     CCDBIN2
#	CELL.BAD	STR	BADLEVEL

#### How to get the cell coordiantes from readout coordinates
#	READOUT.X0		STR	CNPIX1
#	READOUT.Y0		STR	CNPIX2

### How to get the chip coordinates from cell coordinates
	CELL.X0		STR	IMNPIX1
	CELL.Y0		STR	IMNPIX2
	CELL.XPARITY	STR	IMTM1_1
	CELL.YPARITY	STR	IMTM2_2
END

# Default PS concepts that may be specified by value
DEFAULTS        METADATA
	FPA.TIMESYS		STR	UTC
	CELL.TIMESYS		STR	UTC
	FPA.FILTERID		STR	NONE
	FPA.FILTER		STR	NONE
	CELL.GAIN		F32	1.0
	CELL.READNOISE          F32     10.0
	CELL.READDIR		S32	1		# Cell is read in x direction
        CELL.BAD                S32     0

	CHIP.XSIZE.DEPEND	STR	CHIP.NAME
	CHIP.XSIZE	METADATA
		CCID58-1-06b2	S32	4837		# 10 micron pitch
		CCID45-1-14A	S32	4033
		CCID45-1-11A	S32	4033
		CCID45-1-22A	S32	4033
		CCID45-1-04C	S32	4837		# 10 micron pitch
		CCID45-1-13A	S32	4033
		CCID45-1-05A	S32	4033    
		CCID45-1-19A	S32	4033 
	END

	CHIP.YSIZE.DEPEND	STR	CHIP.NAME
	CHIP.YSIZE	METADATA
		CCID58-1-06b2	S32	4829		# 10 micron pitch
		CCID45-1-14A	S32	4031
		CCID45-1-11A	S32	4031
		CCID45-1-22A	S32	4031
		CCID45-1-04C	S32	4829		# 10 micron pitch
		CCID45-1-13A	S32	4031
		CCID45-1-05A	S32	4031    
		CCID45-1-19A	S32	4031 
	END

#		CCID58-1-06b2	0,0
#		CCID45-1-14A	0,1
#		CCID45-1-11A	1,0
#		CCID45-1-22A	1,1
#		CCID45-1-04C	2,0
#		CCID45-1-13A	2,1
#		CCID45-1-05A	3,0
#		CCID45-1-19A	3,1

	### How to get FPA coordinates from chip coordinates
	CHIP.X0.DEPEND		STR	CHIP.NAME
	CHIP.X0		METADATA
		CCID58-1-06b2	S32	0
		CCID45-1-14A	S32	0
		CCID45-1-11A	S32	4900
		CCID45-1-22A	S32	4900
		CCID45-1-04C	S32	9800
		CCID45-1-13A	S32	9800
		CCID45-1-05A	S32	14700
		CCID45-1-19A	S32	14700 
	END
	CHIP.Y0.DEPEND		STR	CHIP.NAME
	CHIP.Y0		METADATA
		CCID58-1-06b2	S32	0
		CCID45-1-14A	S32	4900
		CCID45-1-11A	S32	0
		CCID45-1-22A	S32	4900
		CCID45-1-04C	S32	0
		CCID45-1-13A	S32	4900
		CCID45-1-05A	S32	0
		CCID45-1-19A	S32	4900
	END
	CHIP.XPARITY.DEPEND	STR	CHIP.NAME
	CHIP.XPARITY	METADATA
		CCID58-1-06b2	S32	+1
		CCID45-1-14A	S32	+1
		CCID45-1-11A	S32	+1
		CCID45-1-22A	S32	+1
		CCID45-1-04C	S32	+1
		CCID45-1-13A	S32	+1
		CCID45-1-05A	S32	+1
		CCID45-1-19A	S32	+1
	END
	CHIP.YPARITY.DEPEND	STR	CHIP.NAME
	CHIP.YPARITY	METADATA
		CCID58-1-06b2	S32	+1
		CCID45-1-14A	S32	+1
		CCID45-1-11A	S32	+1
		CCID45-1-22A	S32	+1
		CCID45-1-04C	S32	+1
		CCID45-1-13A	S32	+1
		CCID45-1-05A	S32	+1
		CCID45-1-19A	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
 
