# The raw GPC data comes off the telescope with each of the chips stored in separate files

# How to identify this type
RULE	METADATA
#	TELESCOP	STR	PS1
#	DETECTOR	STR	GPC1
	CONTROLR	STR	STARGRASP
	PSFORMAT        STR     MEF
END

# How to read this data
FILE	METADATA
	PHU		STR	FPA	   # The FITS file represents a complete camera fpa
	EXTENSIONS	STR	CHIP	   # The extensions represent chips
	FPA.OBS		STR	CONTROLR   # A PHU keyword for unique identifier within the hierarchy level
END

# What's in the FITS file?
CONTENTS	METADATA
	# CONTENT      =    chip name : type
        CCID58-2-15a1  STR  XY01:GPCChip
        CCID58-2-18a1  STR  XY02:GPCChip
        CCID58-1-13a1  STR  XY03:GPCChip
        CCID58-1-09a1  STR  XY04:GPCChip
        CCID58-2-16b1  STR  XY05:GPCChip
        CCID58-2-09b1  STR  XY06:GPCChip
        CCID58-2-22a1  STR  XY10:GPCChip
        CCID58-2-13a2  STR  XY11:GPCChip
        CCID58-1-17a2  STR  XY12:GPCChip
        CCID58-1-14a2  STR  XY13:GPCChip
        CCID58-1-09a2  STR  XY14:GPCChip
        CCID58-2-13b1  STR  XY15:GPCChip
        CCID58-1-09b1  STR  XY16:GPCChip
        CCID58-2-10b2  STR  XY17:GPCChip
        CCID58-1-19a1  STR  XY20:GPCChip
        CCID58-1-04a1  STR  XY21:GPCChip
        CCID58-2-09a2  STR  XY22:GPCChip
        CCID58-1-02a1  STR  XY23:GPCChip
        CCID58-1-04a2  STR  XY24:GPCChip
        CCID58-1-01b1  STR  XY25:GPCChip
        CCID58-2-07b2  STR  XY26:GPCChip
        CCID58-1-18b1  STR  XY27:GPCChip
        CCID58-1-12a1  STR  XY30:GPCChip
        CCID58-2-01a1  STR  XY31:GPCChip
        CCID58-2-01a2  STR  XY32:GPCChip
        CCID58-1-02a2  STR  XY33:GPCChip
        CCID58-2-04a1  STR  XY34:GPCChip
        CCID58-1-01b2  STR  XY35:GPCChip
        CCID58-1-02b1  STR  XY36:GPCChip
        CCID58-2-16b2  STR  XY37:GPCChip
        CCID58-2-18b2  STR  XY40:GPCChip
        CCID58-1-03b2  STR  XY41:GPCChip
        CCID58-1-07b1  STR  XY42:GPCChip
        CCID58-2-11b2  STR  XY43:GPCChip
        CCID58-1-05a2  STR  XY44:GPCChip
        CCID58-1-21a2  STR  XY45:GPCChip
        CCID58-2-07a2  STR  XY46:GPCChip
        CCID58-1-21a1  STR  XY47:GPCChip
        CCID58-1-17b1  STR  XY50:GPCChip
        CCID58-2-09b2  STR  XY51:GPCChip
        CCID58-1-04b1  STR  XY52:GPCChip
        CCID58-1-05b2  STR  XY53:GPCChip
        CCID58-2-09a1  STR  XY54:GPCChip
        CCID58-2-12a2  STR  XY55:GPCChip
        CCID58-1-10a2  STR  XY56:GPCChip
        CCID58-2-12a1  STR  XY57:GPCChip
        CCID58-2-22b2  STR  XY60:GPCChip
        CCID58-1-03b1  STR  XY61:GPCChip
        CCID58-2-23b2  STR  XY62:GPCChip
        CCID58-1-02b2  STR  XY63:GPCChip
        CCID58-1-07a1  STR  XY64:GPCChip
        CCID58-2-17a2  STR  XY65:GPCChip
        CCID58-2-14a1  STR  XY66:GPCChip
        CCID58-2-16a2  STR  XY67:GPCChip
        CCID58-2-04b2  STR  XY71:GPCChip
        CCID58-1-14b1  STR  XY72:GPCChip
        CCID58-1-25b1  STR  XY73:GPCChip
        CCID58-1-18a1  STR  XY74:GPCChip
        CCID58-2-16a1  STR  XY75:GPCChip
        CCID58-2-05a1  STR  XY76:GPCChip
END

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

# Specify the cell data
CELLS	METADATA
	GPCCell		METADATA
		CELL.TRIMSEC.SOURCE	STR	HEADER
		CELL.TRIMSEC		STR	DATASEC
		CELL.BIASSEC.SOURCE	STR	HEADER
		CELL.BIASSEC		STR	BIASSEC
	END
END


# How to translate PS concepts into FITS headers
TRANSLATION	METADATA
        FPA.FILTERID    STR     FILTERID
        FPA.FILTER      STR     FILTERID
        FPA.RA          STR     RA
        FPA.DEC         STR     DEC
        FPA.RADECSYS    STR     RADECSYS
	FPA.OBSTYPE     STR     OBSTYPE
	FPA.OBJECT	STR	OBJECT
	FPA.AIRMASS	STR	AIRMASS
	FPA.POSANGLE	STR	POSANGLE
	FPA.FOCUS	STR	M2Z
	FPA.TIME	STR	MJD-OBS
	FPA.ALT		STR	ALT
	FPA.AZ		STR	AZ
	FPA.TEMP	STR	DETTEM
	CHIP.ID         STR	DETECTOR
	CELL.XBIN	STR	CCDSUM
	CELL.YBIN	STR	CCDSUM
	CELL.X0		STR	IMNPIX1
	CELL.Y0		STR	IMNPIX2
 	CELL.XPARITY	STR	ATM1_1
	CELL.YPARITY	STR	ATM2_2
#	CELL.SATURATION	STR	SATURATE
	FPA.EXPOSURE	STR	EXPREQ		# Requested exposure time, presumably camera exposure time
	CELL.EXPOSURE	STR	EXPTIME		# Exposure time measured by shutter
	CELL.DARKTIME	STR	DARKTIME	# Exposure time for camera
END

# Default PS concepts that may be specified by value
DEFAULTS	METADATA
	FPA.TELESCOPE	STR	PS1
	FPA.INSTRUMENT	STR	GPC1
	FPA.DETECTOR	STR	GPC1
	FPA.OBS	S32	12345
	FPA.TIMESYS	STR	UTC
	CHIP.XPARITY	S32	1
	CHIP.YPARITY	S32	1
	CHIP.X0.DEPEND		STR	CHIP.NAME
	CHIP.X0		METADATA
          XY01  S32     4971
          XY02  S32     4971
          XY03  S32     4971
          XY04  S32     4971
          XY05  S32     4971
          XY06  S32     4971
          XY10  S32     9942
          XY11  S32     9942
          XY12  S32     9942
          XY13  S32     9942
          XY14  S32     9942
          XY15  S32     9942
          XY16  S32     9942
          XY17  S32     9942
          XY20  S32     14913
          XY21  S32     14913
          XY22  S32     14913
          XY23  S32     14913
          XY24  S32     14913
          XY25  S32     14913
          XY26  S32     14913
          XY27  S32     14913
          XY30  S32     19884
          XY31  S32     19884
          XY32  S32     19884
          XY33  S32     19884
          XY34  S32     19884
          XY35  S32     19884
          XY36  S32     19884
          XY37  S32     19884
          XY40  S32     20041
          XY41  S32     20041
          XY42  S32     20041
          XY43  S32     20041
          XY44  S32     20041
          XY45  S32     20041
          XY46  S32     20041
          XY47  S32     20041
          XY50  S32     25012
          XY51  S32     25012
          XY52  S32     25012
          XY53  S32     25012
          XY54  S32     25012
          XY55  S32     25012
          XY56  S32     25012
          XY57  S32     25012
          XY60  S32     29983
          XY61  S32     29983
          XY62  S32     29983
          XY63  S32     29983
          XY64  S32     29983
          XY65  S32     29983
          XY66  S32     29983
          XY67  S32     29983
          XY71  S32     34954
          XY72  S32     34954
          XY73  S32     34954
          XY74  S32     34954
          XY75  S32     34954
          XY76  S32     34954
	END
	CHIP.Y0.DEPEND		STR	CHIP.NAME
	CHIP.Y0		METADATA
          XY01  S32     10286
          XY02  S32     15429
          XY03  S32     20572
          XY04  S32     25715
          XY05  S32     30858
          XY06  S32     36001
          XY10  S32     5143
          XY11  S32     10286
          XY12  S32     15429
          XY13  S32     20572
          XY14  S32     25715
          XY15  S32     30858
          XY16  S32     36001
          XY17  S32     41144
          XY20  S32     5143
          XY21  S32     10286
          XY22  S32     15429
          XY23  S32     20572
          XY24  S32     25715
          XY25  S32     30858
          XY26  S32     36001
          XY27  S32     41144
          XY30  S32     5143
          XY31  S32     10286
          XY32  S32     15429
          XY33  S32     20572
          XY34  S32     25715
          XY35  S32     30858
          XY36  S32     36001
          XY37  S32     41144
          XY40  S32     306
          XY41  S32     5449
          XY42  S32     10592
          XY43  S32     15735
          XY44  S32     20878
          XY45  S32     26021
          XY46  S32     31164
          XY47  S32     36307
          XY50  S32     306
          XY51  S32     5449
          XY52  S32     10592
          XY53  S32     15735
          XY54  S32     20878
          XY55  S32     26021
          XY56  S32     31164
          XY57  S32     36307
          XY60  S32     306
          XY61  S32     5449
          XY62  S32     10592
          XY63  S32     15735
          XY64  S32     20878
          XY65  S32     26021
          XY66  S32     31164
          XY67  S32     36307
          XY71  S32     5449
          XY72  S32     10592
          XY73  S32     15735
          XY74  S32     20878
          XY75  S32     26021
          XY76  S32     31164
        END
	CHIP.XPARITY.DEPEND	STR	CHIP.NAME
	CHIP.XPARITY	METADATA
          XY01  S32     -1
          XY02  S32     -1
          XY03  S32     -1
          XY04  S32     -1
          XY05  S32     -1
          XY06  S32     -1
          XY10  S32     -1
          XY11  S32     -1
          XY12  S32     -1
          XY13  S32     -1
          XY14  S32     -1
          XY15  S32     -1
          XY16  S32     -1
          XY17  S32     -1
          XY20  S32     -1
          XY21  S32     -1
          XY22  S32     -1
          XY23  S32     -1
          XY24  S32     -1
          XY25  S32     -1
          XY26  S32     -1
          XY27  S32     -1
          XY30  S32     -1
          XY31  S32     -1
          XY32  S32     -1
          XY33  S32     -1
          XY34  S32     -1
          XY35  S32     -1
          XY36  S32     -1
          XY37  S32     -1
          XY40  S32     1
          XY41  S32     1
          XY42  S32     1
          XY43  S32     1
          XY44  S32     1
          XY45  S32     1
          XY46  S32     1
          XY47  S32     1
          XY50  S32     1
          XY51  S32     1
          XY52  S32     1
          XY53  S32     1
          XY54  S32     1
          XY55  S32     1
          XY56  S32     1
          XY57  S32     1
          XY60  S32     1
          XY61  S32     1
          XY62  S32     1
          XY63  S32     1
          XY64  S32     1
          XY65  S32     1
          XY66  S32     1
          XY67  S32     1
          XY71  S32     1
          XY72  S32     1
          XY73  S32     1
          XY74  S32     1
          XY75  S32     1
          XY76  S32     1
	END
	CHIP.YPARITY.DEPEND	STR	CHIP.NAME
	CHIP.YPARITY	METADATA
          XY01  S32     -1
          XY02  S32     -1
          XY03  S32     -1
          XY04  S32     -1
          XY05  S32     -1
          XY06  S32     -1
          XY10  S32     -1
          XY11  S32     -1
          XY12  S32     -1
          XY13  S32     -1
          XY14  S32     -1
          XY15  S32     -1
          XY16  S32     -1
          XY17  S32     -1
          XY20  S32     -1
          XY21  S32     -1
          XY22  S32     -1
          XY23  S32     -1
          XY24  S32     -1
          XY25  S32     -1
          XY26  S32     -1
          XY27  S32     -1
          XY30  S32     -1
          XY31  S32     -1
          XY32  S32     -1
          XY33  S32     -1
          XY34  S32     -1
          XY35  S32     -1
          XY36  S32     -1
          XY37  S32     -1
          XY40  S32     1
          XY41  S32     1
          XY42  S32     1
          XY43  S32     1
          XY44  S32     1
          XY45  S32     1
          XY46  S32     1
          XY47  S32     1
          XY50  S32     1
          XY51  S32     1
          XY52  S32     1
          XY53  S32     1
          XY54  S32     1
          XY55  S32     1
          XY56  S32     1
          XY57  S32     1
          XY60  S32     1
          XY61  S32     1
          XY62  S32     1
          XY63  S32     1
          XY64  S32     1
          XY65  S32     1
          XY66  S32     1
          XY67  S32     1
          XY71  S32     1
          XY72  S32     1
          XY73  S32     1
          XY74  S32     1
          XY75  S32     1
          XY76  S32     1
	END
	CELL.GAIN	F32	1.0
	CELL.READNOISE	F32	0.0
	CELL.READDIR	S32	1
	CELL.BAD	S32	0
#	CELL.TIME	STR	MJD-OBS
#	CELL.TIMESYS	STR	TIMESYS
#	CELL.SATURATION	STR	60000
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,CELL
#	CELL.READNOISE	dbEntry		Camera		readNoise	chipId,cellId	CHIP,CELL

# 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	DEGREES
	FPA.DEC		STR	DEGREES
	FPA.TIME	STR	MJD
	CELL.TIME	STR	MJD
	CELL.BINNING	STR	TOGETHER
	CELL.X0		STR	FORTRAN
	CELL.Y0		STR	FORTRAN
END
 
# Recipe options
RECIPES		METADATA
END
 
# How to get the supplementary stuff: mask and weight
SUPPLEMENTARY	METADATA
	MASK.SOURCE	STR	FILE		# Source type for mask: EXT | FILE
	MASK.NAME	STR	%a_mask.fits	# Name for mask extension or filename
	WEIGHT.SOURCE	STR	FILE		# Source type for weight: EXT | FILE
	WEIGHT.NAME	STR	%a_weight.fits	# Name for weight extension or filename
END
