Index: /trunk/icd-demo/Makefile
===================================================================
--- /trunk/icd-demo/Makefile	(revision 9126)
+++ /trunk/icd-demo/Makefile	(revision 9127)
@@ -21,8 +21,15 @@
 icd-demo: $(ICDDEMO)
 
+ICDTEST = $(BIN)/icd-test.$(ARCH)
+
+icd-test: $(ICDTEST)
+
 sample:
+	@if [ ! -d fits ]; then mkdir -p fits; fi
 	cd def; ../bin/icd-demo.$(ARCH) P2.file.txt ../fits/P2.file.fits
 	cd def; ../bin/icd-demo.$(ARCH) P4S.file.txt ../fits/P4S.file.fits
 	cd def; ../bin/icd-demo.$(ARCH) P4D.file.txt ../fits/P4D.file.fits
+	cd def; ../bin/icd-demo.$(ARCH) P4Dlo.file.txt ../fits/P4Dlo.file.fits
+	cd def; ../bin/icd-demo.$(ARCH) CS.file.txt ../fits/CS.file.fits
 
 # dependancy rules for binary code #########################
Index: /trunk/icd-demo/def/CS.cell0.ext.txt
===================================================================
--- /trunk/icd-demo/def/CS.cell0.ext.txt	(revision 9127)
+++ /trunk/icd-demo/def/CS.cell0.ext.txt	(revision 9127)
@@ -0,0 +1,132 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR EXTENDED_SRC_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE              NONE   NONE  "IPP detection identifer index"
+    PET_R             TTYPE  E     ARCSECONDS           0      1  "Petrosian radius"
+    PET_MAG           TTYPE  E     MAG                -10    +30  "Petrosian magnitude"
+    PET_R50           TTYPE  E     ARCSECONDS           0      1  "Petrosian radius for 50% light"
+    PET_R90           TTYPE  E     ARCSECONDS           0      1  "Petrosian radius for 90% light"
+    RA_PET            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from Petrosian fit"
+    DEC_PET           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from Petrosian fit"
+    RA_PET_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of Petrosian fit RA"
+    DEC_PET_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of Petrosian fit DEC"
+    PET_QF            TTYPE  E     NONE              NONE   NONE  "Petrosian coverage/quality factor"
+    DEV_R             TTYPE  E     ARCSECONDS           0      1  "deVaucouleurs radius"
+    MAG_DEV           TTYPE  E     MAG                -10    +30  "deVaucouleurs magnitude"
+    MAG_DEV_SIG       TTYPE  E     MAG                -10    +30  "Sigma of deVaucouleurs magnitude"
+    DEV_AB            TTYPE  E     NONE              NONE   NONE  "deVaucouleurs axis ratio"
+    DEV_PHI           TTYPE  E     DEGREES              0    180  "deVaucouleurs orientation angle"
+    RA_DEV            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from deVaucouleurs fit"
+    DEC_DEV           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from deVaucouleurs fit"
+    RA_DEV_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of deVaucouleurs fit RA"
+    DEC_DEV_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of deVaucouleurs fit DEC"
+    DEV_QF            TTYPE  E     NONE              NONE   NONE  "deVaucouleurs coverage/quality factor"
+    EXP_R             TTYPE  E     ARCSECONDS           0      1  "Exponential fit model radius"
+    MAG_EXP           TTYPE  E     MAG                -10    +30  "Exponential fit model magnitude"
+    MAG__EXP_SIG      TTYPE  E     MAG                -10    +30  "Sigma of Exponential fit model magnitude"
+    EXP_AB            TTYPE  E     NONE              NONE   NONE  "Exponential fit model axis ratio"
+    EXP_PHI           TTYPE  E     DEGREES              0    180  "Exponetial fit orientation angle"
+    RA_EXP            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from Expondential model fit"
+    DEC_EXP           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from Expondential model fit"
+    RA_EXP_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of Expondential model fit RA"
+    DEC_EXP_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of Expondential model fit DEC"
+    EXP_QF            TTYPE  E     NONE              NONE   NONE  "Exponential fit coverage/quality factor"
+    SER_R             TTYPE  E     ARCSECONDS           0      1  "Sersic fit model radius"
+    MAG_SER           TTYPE  E     MAG                -10    +30  "Sersic fit model magnitude"
+    MAG_SER_SIG       TTYPE  E     MAG                -10    +30  "Sigma of Sersic fit model magnitude"
+    SER_AB            TTYPE  E     NONE              NONE   NONE  "Sersic fit model axis ratio"
+    SER_PHI           TTYPE  E     DEGREES              0    180  "Exponetial fit orientation angle"
+    SER_NU            TTYPE  E     NONE                 0     10  "Sersic fit index nu"
+    RA_SER            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from Sersic fit"
+    DEC_SER           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from Sersic fit"
+    RA_SER_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of Sersic fit RA"
+    DEC_SER_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of Sersic fit DEC"
+    SER_QF            TTYPE  E     NONE              NONE   NONE  "Sersic fit coverage/quality factor"
+    PCS_R             TTYPE  E     ARCSECONDS           0      1  "PSF Convolved Sersic fit model radius"
+    MAG_PSC           TTYPE  E     MAG                -10    +30  "PSF Convolved Sersic fit model magnitude"
+    MAG_PSC_SIG       TTYPE  E     MAG                -10    +30  "Sigma of PSF Convolved Sersic fit model magnitude"
+    PCS_AB            TTYPE  E     NONE              NONE   NONE  "PSF Convolved Sersic fit model axis ratio"
+    PCS_PHI           TTYPE  E     DEGREES              0    180  "Exponetial fit orientation angle"
+    PCS_NU            TTYPE  E     NONE                 0     10  "PSF Convolved Sersic fit index nu"
+    RA_PSC            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from PSF Convolved Sersic fit"
+    DEC_PSC           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from PSF Convolved Sersic fit"
+    RA_PSC_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of PSF Convolved Sersic fit RA"
+    DEC_PSC_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of PSF Convolved Sersic fit DEC"
+    PCS_QF            TTYPE  E     NONE              NONE   NONE  "PSF Convolved Sersic coverage/quality factor"
+    WL_SIGMA          TTYPE  E     NONE              NONE   NONE  "Weak lensing sigma"
+    EPS_1             TTYPE  E     NONE              NONE   NONE  "Weak lensing eps(1)"
+    EPS_2             TTYPE  E     NONE              NONE   NONE  "Weak lensing eps(2)"
+    P_SM_1_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(1,1)"
+    P_SM_1_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(1,2)"
+    P_SM_2_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(2,1)"
+    P_SM_2_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(2,2)"
+    P_SH_1_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(1,1)"
+    P_SH_1_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(1,2)"
+    P_SH_2_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(2,1)"
+    P_SH_2_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(2,2)"
+    SB_R_1            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #1"
+    SB_R_1_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #1"
+    SB_R_1_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #1"
+    SB_R_2            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #2"
+    SB_R_2_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #2"
+    SB_R_2_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #2"
+    SB_R_3            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #3"
+    SB_R_3_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #3"
+    SB_R_3_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #3"
+    SB_R_4            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #4"
+    SB_R_4_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #4"
+    SB_R_4_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #4"
+    SB_R_5            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #5"
+    SB_R_5_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #5"
+    SB_R_5_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #5"
+    SB_R_6            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #6"
+    SB_R_6_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #6"
+    SB_R_5_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #6"
+    SB_R_7            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #7"
+    SB_R_7_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #7"
+    SB_R_7_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #7"
+    SB_R_8            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #8"
+    SB_R_8_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #8"
+    SB_R_8_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #8"
+    SB_R_9            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #9"
+    SB_R_9_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #9"
+    SB_R_9_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #9"
+    SB_R_10           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #10"
+    SB_R_10_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #10"
+    SB_R_10_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #10"
+    SB_R_11           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #11"
+    SB_R_11_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #11"
+    SB_R_11_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #11"
+    SB_R_12           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #12"
+    SB_R_12_RR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #12"
+    SB_R_12_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #12"
+    SB_R_13           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #13"
+    SB_R_13_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #13"
+    SB_R_13_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #13"
+    SB_R_14           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #14"
+    SB_R_14_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #14"
+    SB_R_14_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #14"
+    SB_R_15           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #15"
+    SB_R_15_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #15"
+    SB_R_15_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #15"
+    LOG_A             TTYPE  E     NONE              NONE   NONE  "Log of asymmetry parameter"
+    LOG_C             TTYPE  E     NONE              NONE   NONE  "Log of concentration parameter"
+    INCL              TTYPE  E     NONE                 0    180  "Inclination"
+  END
+END
Index: /trunk/icd-demo/def/CS.cell0.hdu.txt
===================================================================
--- /trunk/icd-demo/def/CS.cell0.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/CS.cell0.hdu.txt	(revision 9127)
@@ -0,0 +1,93 @@
+
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR
+  COMMENT  STR  Basic Info about this frame
+  COMMENT  STR
+  SKYCELL  S32                       # Sky Cell ID number
+  REFID    S32                       # Reference Sky Cell ID number
+  SUBTRID  S32                       # ID of Sky Cell Image subtracted 
+  FILTER   S32                       # Filter 
+  STACKID  S32                       # ID for this image stack
+  NP2IMGS  S32                       # Number of P2 images contributing
+  ANALVER  S32                       # Software Analysis Version
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  P2 images used to generate this image stack
+  COMMENT  STR 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/CS.cell0.psf.txt
===================================================================
--- /trunk/icd-demo/def/CS.cell0.psf.txt	(revision 9127)
+++ /trunk/icd-demo/def/CS.cell0.psf.txt	(revision 9127)
@@ -0,0 +1,43 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR PSF_FIT_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+    Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+    X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+    Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+    RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+    DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+    RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+    DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+    PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+    PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+    PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+    SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+    SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+    STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+    PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+    PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+    PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+    PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+    CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+    CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+    N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+  END
+END
Index: /trunk/icd-demo/def/CS.cell1.ext.txt
===================================================================
--- /trunk/icd-demo/def/CS.cell1.ext.txt	(revision 9127)
+++ /trunk/icd-demo/def/CS.cell1.ext.txt	(revision 9127)
@@ -0,0 +1,132 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR EXTENDED_SRC_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE              NONE   NONE  "IPP detection identifer index"
+    PET_R             TTYPE  E     ARCSECONDS           0      1  "Petrosian radius"
+    PET_MAG           TTYPE  E     MAG                -10    +30  "Petrosian magnitude"
+    PET_R50           TTYPE  E     ARCSECONDS           0      1  "Petrosian radius for 50% light"
+    PET_R90           TTYPE  E     ARCSECONDS           0      1  "Petrosian radius for 90% light"
+    RA_PET            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from Petrosian fit"
+    DEC_PET           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from Petrosian fit"
+    RA_PET_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of Petrosian fit RA"
+    DEC_PET_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of Petrosian fit DEC"
+    PET_QF            TTYPE  E     NONE              NONE   NONE  "Petrosian coverage/quality factor"
+    DEV_R             TTYPE  E     ARCSECONDS           0      1  "deVaucouleurs radius"
+    MAG_DEV           TTYPE  E     MAG                -10    +30  "deVaucouleurs magnitude"
+    MAG_DEV_SIG       TTYPE  E     MAG                -10    +30  "Sigma of deVaucouleurs magnitude"
+    DEV_AB            TTYPE  E     NONE              NONE   NONE  "deVaucouleurs axis ratio"
+    DEV_PHI           TTYPE  E     DEGREES              0    180  "deVaucouleurs orientation angle"
+    RA_DEV            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from deVaucouleurs fit"
+    DEC_DEV           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from deVaucouleurs fit"
+    RA_DEV_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of deVaucouleurs fit RA"
+    DEC_DEV_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of deVaucouleurs fit DEC"
+    DEV_QF            TTYPE  E     NONE              NONE   NONE  "deVaucouleurs coverage/quality factor"
+    EXP_R             TTYPE  E     ARCSECONDS           0      1  "Exponential fit model radius"
+    MAG_EXP           TTYPE  E     MAG                -10    +30  "Exponential fit model magnitude"
+    MAG__EXP_SIG      TTYPE  E     MAG                -10    +30  "Sigma of Exponential fit model magnitude"
+    EXP_AB            TTYPE  E     NONE              NONE   NONE  "Exponential fit model axis ratio"
+    EXP_PHI           TTYPE  E     DEGREES              0    180  "Exponetial fit orientation angle"
+    RA_EXP            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from Expondential model fit"
+    DEC_EXP           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from Expondential model fit"
+    RA_EXP_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of Expondential model fit RA"
+    DEC_EXP_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of Expondential model fit DEC"
+    EXP_QF            TTYPE  E     NONE              NONE   NONE  "Exponential fit coverage/quality factor"
+    SER_R             TTYPE  E     ARCSECONDS           0      1  "Sersic fit model radius"
+    MAG_SER           TTYPE  E     MAG                -10    +30  "Sersic fit model magnitude"
+    MAG_SER_SIG       TTYPE  E     MAG                -10    +30  "Sigma of Sersic fit model magnitude"
+    SER_AB            TTYPE  E     NONE              NONE   NONE  "Sersic fit model axis ratio"
+    SER_PHI           TTYPE  E     DEGREES              0    180  "Exponetial fit orientation angle"
+    SER_NU            TTYPE  E     NONE                 0     10  "Sersic fit index nu"
+    RA_SER            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from Sersic fit"
+    DEC_SER           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from Sersic fit"
+    RA_SER_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of Sersic fit RA"
+    DEC_SER_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of Sersic fit DEC"
+    SER_QF            TTYPE  E     NONE              NONE   NONE  "Sersic fit coverage/quality factor"
+    PCS_R             TTYPE  E     ARCSECONDS           0      1  "PSF Convolved Sersic fit model radius"
+    MAG_PSC           TTYPE  E     MAG                -10    +30  "PSF Convolved Sersic fit model magnitude"
+    MAG_PSC_SIG       TTYPE  E     MAG                -10    +30  "Sigma of PSF Convolved Sersic fit model magnitude"
+    PCS_AB            TTYPE  E     NONE              NONE   NONE  "PSF Convolved Sersic fit model axis ratio"
+    PCS_PHI           TTYPE  E     DEGREES              0    180  "Exponetial fit orientation angle"
+    PCS_NU            TTYPE  E     NONE                 0     10  "PSF Convolved Sersic fit index nu"
+    RA_PSC            TTYPE  D    "DECIMAL DEGREES"     0    360  "RA from PSF Convolved Sersic fit"
+    DEC_PSC           TTYPE  D    "DECIMAL DEGREES"   -90    +90  "DEC from PSF Convolved Sersic fit"
+    RA_PSC_SIG        TTYPE  E     ARCSECONDS           0      1  "Sigma of PSF Convolved Sersic fit RA"
+    DEC_PSC_SIG       TTYPE  E     ARCSECONDS           0      1  "Sigma of PSF Convolved Sersic fit DEC"
+    PCS_QF            TTYPE  E     NONE              NONE   NONE  "PSF Convolved Sersic coverage/quality factor"
+    WL_SIGMA          TTYPE  E     NONE              NONE   NONE  "Weak lensing sigma"
+    EPS_1             TTYPE  E     NONE              NONE   NONE  "Weak lensing eps(1)"
+    EPS_2             TTYPE  E     NONE              NONE   NONE  "Weak lensing eps(2)"
+    P_SM_1_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(1,1)"
+    P_SM_1_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(1,2)"
+    P_SM_2_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(2,1)"
+    P_SM_2_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SM(2,2)"
+    P_SH_1_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(1,1)"
+    P_SH_1_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(1,2)"
+    P_SH_2_1          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(2,1)"
+    P_SH_2_2          TTYPE  E     NONE              NONE   NONE  "Weak lensing P_SH(2,2)"
+    SB_R_1            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #1"
+    SB_R_1_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #1"
+    SB_R_1_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #1"
+    SB_R_2            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #2"
+    SB_R_2_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #2"
+    SB_R_2_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #2"
+    SB_R_3            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #3"
+    SB_R_3_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #3"
+    SB_R_3_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #3"
+    SB_R_4            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #4"
+    SB_R_4_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #4"
+    SB_R_4_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #4"
+    SB_R_5            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #5"
+    SB_R_5_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #5"
+    SB_R_5_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #5"
+    SB_R_6            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #6"
+    SB_R_6_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #6"
+    SB_R_5_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #6"
+    SB_R_7            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #7"
+    SB_R_7_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #7"
+    SB_R_7_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #7"
+    SB_R_8            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #8"
+    SB_R_8_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #8"
+    SB_R_8_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #8"
+    SB_R_9            TTYPE  E     MAG                -10    +30  "Surface brightness inside R #9"
+    SB_R_9_ERR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #9"
+    SB_R_9_VAR        TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #9"
+    SB_R_10           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #10"
+    SB_R_10_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #10"
+    SB_R_10_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #10"
+    SB_R_11           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #11"
+    SB_R_11_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #11"
+    SB_R_11_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #11"
+    SB_R_12           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #12"
+    SB_R_12_RR        TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #12"
+    SB_R_12_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #12"
+    SB_R_13           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #13"
+    SB_R_13_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #13"
+    SB_R_13_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #13"
+    SB_R_14           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #14"
+    SB_R_14_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #14"
+    SB_R_14_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #14"
+    SB_R_15           TTYPE  E     MAG                -10    +30  "Surface brightness inside R #15"
+    SB_R_15_ERR       TTYPE  E     MAG                -10    +30  "Estimated error of SB inside R #15"
+    SB_R_15_VAR       TTYPE  E     MAG                -10    +30  "Estimated variance of SB inside R #15"
+    LOG_A             TTYPE  E     NONE              NONE   NONE  "Log of asymmetry parameter"
+    LOG_C             TTYPE  E     NONE              NONE   NONE  "Log of concentration parameter"
+    INCL              TTYPE  E     NONE                 0    180  "Inclination"
+  END
+END
Index: /trunk/icd-demo/def/CS.cell1.hdu.txt
===================================================================
--- /trunk/icd-demo/def/CS.cell1.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/CS.cell1.hdu.txt	(revision 9127)
@@ -0,0 +1,93 @@
+
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR
+  COMMENT  STR  Basic Info about this frame
+  COMMENT  STR
+  SKYCELL  S32                       # Sky Cell ID number
+  REFID    S32                       # Reference Sky Cell ID number
+  SUBTRID  S32                       # ID of Sky Cell Image subtracted 
+  FILTER   S32                       # Filter 
+  STACKID  S32                       # ID for this image stack
+  NP2IMGS  S32                       # Number of P2 images contributing
+  ANALVER  S32                       # Software Analysis Version
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  P2 images used to generate this image stack
+  COMMENT  STR 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/CS.cell1.psf.txt
===================================================================
--- /trunk/icd-demo/def/CS.cell1.psf.txt	(revision 9127)
+++ /trunk/icd-demo/def/CS.cell1.psf.txt	(revision 9127)
@@ -0,0 +1,43 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR PSF_FIT_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+    Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+    X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+    Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+    RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+    DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+    RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+    DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+    PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+    PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+    PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+    SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+    SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+    STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+    PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+    PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+    PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+    PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+    CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+    CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+    N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+  END
+END
Index: /trunk/icd-demo/def/CS.file.txt
===================================================================
--- /trunk/icd-demo/def/CS.file.txt	(revision 9127)
+++ /trunk/icd-demo/def/CS.file.txt	(revision 9127)
@@ -0,0 +1,14 @@
+
+# Keywords for CSS Frame Descriptor HDU
+HEADER METADATA
+  NCELLS  S32                2 # Number of sky cell extensions
+END
+
+# the file contains table data for each chip:
+TABLE MULTI
+TABLE STR CS.cell0.hdu.txt
+TABLE STR CS.cell0.psf.txt
+TABLE STR CS.cell0.ext.txt
+TABLE STR CS.cell1.hdu.txt
+TABLE STR CS.cell1.psf.txt
+TABLE STR CS.cell1.ext.txt
Index: /trunk/icd-demo/def/P2.chip0.alt.txt
===================================================================
--- /trunk/icd-demo/def/P2.chip0.alt.txt	(revision 9126)
+++ /trunk/icd-demo/def/P2.chip0.alt.txt	(revision 9127)
@@ -1,32 +1,34 @@
  
 # extra data which belongs to table header
-HEADER METADATA
-  EXTNAME STR ALT_FIT_PARAMS
-  COMMENT STR
-  COMMENT STR  This HDU applies to all detections that have been analyzed
-  COMMENT STR  with the IPP alternative PSF fitting procedure. 
-  COMMENT STR  Note that the IPP_IDET must be unique within a file so as
-  COMMENT STR  to allow matching up sources between the PSF matching and
-  COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
-  COMMENT STR  detections or the extended source fits to the
-  COMMENT STR  Image Stack/Cumulative Sky detections.
-  COMMENT STR   
+FITSTABLE METADATA
+  HEADER METADATA
+    EXTNAME STR ALT_FIT_PARAMS
+    COMMENT STR
+    COMMENT STR  This HDU applies to all detections that have been analyzed
+    COMMENT STR  with the IPP alternative PSF fitting procedure. 
+    COMMENT STR  Note that the IPP_IDET must be unique within a file so as
+    COMMENT STR  to allow matching up sources between the PSF matching and
+    COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
+    COMMENT STR  detections or the extended source fits to the
+    COMMENT STR  Image Stack/Cumulative Sky detections.
+    COMMENT STR   
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    RA_ALT            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"                                
+    DEC_ALT           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"                               
+    RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
+    DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
+    ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
+    CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
+    CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
+    ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
+    ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
+    ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
+    ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
+    ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
+  END
 END
-
-# description of the FITS table columns
-COLUMNS METADATA
-  TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
-  IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
-  RA_ALT            TTYPE  D     DECIMAL DEGREES     0    360   "RA from PSF fit"                                
-  DEC_ALT           TTYPE  D     DECIMAL DEGREES   -90    +90   "DEC from PSF fit"                               
-  RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
-  DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
-  ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
-  CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
-  CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
-  ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
-  ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
-  ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
-  ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
-  ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
-END
Index: /trunk/icd-demo/def/P2.chip0.hdu.txt
===================================================================
--- /trunk/icd-demo/def/P2.chip0.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/P2.chip0.hdu.txt	(revision 9127)
@@ -0,0 +1,100 @@
+ 
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR
+  COMMENT  STR  Combination (P4S, P4D, Image Stack/ Cumulative Sky) Image
+  COMMENT  STR  Metadata HDU
+  COMMENT  STR  
+  OBS_ID   STR  UnknownFormat       # Observation Identifier
+  CLASSID  S32                    0 # Class ID = focal plane location
+  DETECTID S32                    0 # Numerical ID of detector
+  NX       S32                 4800 # Number of columns on the detector
+  NY       S32                 4800 # Number of rows on the detector   DATE    STR 2006/02/05
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR 
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR 
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  Images used to process this exposure
+  COMMENT  STR 
+  DETREND1 STR  bias.00.fits        # 
+  DETREND2 STR  dark.00.fits        # 
+  DETREND3 STR  flat.00.fits        # 
+  DETREND4 STR  fringe.01.fits      # 
+  DETREND5 STR  none                # 
+  DETREND6 STR  none                # 
+  DETREND7 STR  none                # 
+  DETREND8 STR  none                # 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/P2.chip0.psf.txt
===================================================================
--- /trunk/icd-demo/def/P2.chip0.psf.txt	(revision 9126)
+++ /trunk/icd-demo/def/P2.chip0.psf.txt	(revision 9127)
@@ -1,141 +1,43 @@
- 
-# description of the chip metadata
-BLANK METADATA
-  COMMENT  STR  MULTI
-  COMMENT  STR
-  COMMENT  STR  Combination (P4S, P4D, Image Stack/ Cumulative Sky) Image
-  COMMENT  STR  Metadata HDU
-  COMMENT  STR  
-  OBS_ID   STR  UnknownFormat       # Observation Identifier
-  CLASSID  S32                    0 # Class ID = focal plane location
-  DETECTID S32                    0 # Numerical ID of detector
-  NX       S32                 4800 # Number of columns on the detector
-  NY       S32                 4800 # Number of rows on the detector   DATE    STR 2006/02/05
-  COMMENT  STR
-  COMMENT  STR  Astrometric Solution (up to linear terms)
-  COMMENT  STR
-  NASTRO   S32                  100 # Number of astrometry stars
-  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
-  CTYPE1   STR  RA---TAN            # WCS Coordinate type
-  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
-  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
-  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
-  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
-  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
-  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
-  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
-  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
-  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
-  COMMENT  STR
-  COMMENT  STR  Higher order terms in astrometric solution
-  COMMENT  STR
-  POLYORD  S32                    3 # Polynomial Order
-  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
-  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
-  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
-  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
-  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
-  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
-  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
-  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
-  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
-  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
-  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
-  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
-  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
-  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
-  COMMENT  STR
-  COMMENT  STR  PSF Description Parameters
-  COMMENT  STR
-  PSFMOD   S32                    1 # PSF Model number
-  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
-  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
-  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
-  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
-  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
-  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
-  COMMENT  STR
-  COMMENT  STR  Photometry Calibration information
-  COMMENT  STR
-  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
-  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
-  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
-  COMMENT  STR
-  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
-  PHOTOCID S32                      # Numerical code for reduction code
-  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
-  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
-  PHOT_NS  S32                   19 # Elixir zero point - N stars
-  PHOT_NM  S32                    5 # Elixir zero point - N images
-  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
-  PHOT_X   F32               0.0830 # Elixir zero point - color term
-  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
-  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
-  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
-  COMMENT  STR
-  COMMENT  STR  Some statistics on this image
-  COMMENT  STR
-  NDETECT  S32                 1000 # Number of detections
-  MAGSAT   F32                15.0  # Magnitude at which sources saturate
-  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
-  SKYVAL   F32              1000.0  # Median sky value on detector
-  SKYVAR   F32                 1.0  # Variance of sky values
-  BIASVAL  F32               200.0  # Mean bias level of frame
-  BIASVAR  F32                 1.0  # Variance of bias values
-  COMMENT  STR
-  COMMENT  STR  Images used to process this exposure
-  COMMENT  STR 
-  DETREND1 STR  bias.00.fits        # 
-  DETREND2 STR  dark.00.fits        # 
-  DETREND3 STR  flat.00.fits        # 
-  DETREND4 STR  fringe.01.fits      # 
-  DETREND5 STR  none                # 
-  DETREND6 STR  none                # 
-  DETREND7 STR  none                # 
-  DETREND8 STR  none                # 
-  COMMENT  STR
-  COMMENT  STR  Quality Assurance Flags from IPP
-  COMMENT  STR
-  QAFLAGS  STR  UnknownValue        # IP QA flags
-END
 
 # extra data which belongs to table header
-HEADER METADATA
-  COMMENT  STR  MULTI
-  COMMENT  STR   
-  COMMENT  STR   This HDU applies to all detections that have been analyzed
-  COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
-  COMMENT  STR   must be unique within a file so as to allow matching up
-  COMMENT  STR   sources between the PSF matching and either the alternative
-  COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
-  COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
-  COMMENT  STR
-  EXTNAME  STR PSF_FIT_PARAMS
+FITSTABLE METADATA 
+ HEADER METADATA
+   COMMENT  STR  MULTI
+   COMMENT  STR   
+   COMMENT  STR   This HDU applies to all detections that have been analyzed
+   COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+   COMMENT  STR   must be unique within a file so as to allow matching up
+   COMMENT  STR   sources between the PSF matching and either the alternative
+   COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+   COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+   COMMENT  STR
+   EXTNAME  STR PSF_FIT_PARAMS
+ END
+
+ # description of the FITS table columns
+ COLUMNS METADATA
+   TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+   IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+   X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+   Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+   X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+   Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+   RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+   DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+   RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+   DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+   PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+   PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+   PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+   SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+   SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+   STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+   PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+   PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+   PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+   PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+   CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+   CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+   N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+ END
 END
-
-# description of the FITS table columns
-COLUMNS METADATA
-  TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
-  IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
-  X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
-  Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
-  X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
-  Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
-  RA_PSF            TTYPE  D     DECIMAL DEGREES     0    360   "RA from PSF fit"
-  DEC_PSF           TTYPE  D     DECIMAL DEGREES   -90    +90   "DEC from PSF fit"
-  RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
-  DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
-  PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
-  PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
-  PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
-  SKY               TTYPE  E     ADU                 0  60000   "Sky level"
-  SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
-  STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
-  PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
-  PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
-  PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
-  PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
-  CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
-  CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
-  N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
-END
Index: /trunk/icd-demo/def/P2.chip1.alt.txt
===================================================================
--- /trunk/icd-demo/def/P2.chip1.alt.txt	(revision 9126)
+++ /trunk/icd-demo/def/P2.chip1.alt.txt	(revision 9127)
@@ -1,32 +1,34 @@
  
 # extra data which belongs to table header
-HEADER METADATA
-  EXTNAME STR ALT_FIT_PARAMS
-  COMMENT STR
-  COMMENT STR  This HDU applies to all detections that have been analyzed
-  COMMENT STR  with the IPP alternative PSF fitting procedure. 
-  COMMENT STR  Note that the IPP_IDET must be unique within a file so as
-  COMMENT STR  to allow matching up sources between the PSF matching and
-  COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
-  COMMENT STR  detections or the extended source fits to the
-  COMMENT STR  Image Stack/Cumulative Sky detections.
-  COMMENT STR   
+FITSTABLE METADATA
+  HEADER METADATA
+    EXTNAME STR ALT_FIT_PARAMS
+    COMMENT STR
+    COMMENT STR  This HDU applies to all detections that have been analyzed
+    COMMENT STR  with the IPP alternative PSF fitting procedure. 
+    COMMENT STR  Note that the IPP_IDET must be unique within a file so as
+    COMMENT STR  to allow matching up sources between the PSF matching and
+    COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
+    COMMENT STR  detections or the extended source fits to the
+    COMMENT STR  Image Stack/Cumulative Sky detections.
+    COMMENT STR   
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    RA_ALT            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"                                
+    DEC_ALT           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"                               
+    RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
+    DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
+    ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
+    CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
+    CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
+    ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
+    ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
+    ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
+    ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
+    ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
+  END
 END
-
-# description of the FITS table columns
-COLUMNS METADATA
-  TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
-  IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
-  RA_ALT            TTYPE  D     DECIMAL DEGREES     0    360   "RA from PSF fit"                                
-  DEC_ALT           TTYPE  D     DECIMAL DEGREES   -90    +90   "DEC from PSF fit"                               
-  RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
-  DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
-  ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
-  CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
-  CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
-  ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
-  ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
-  ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
-  ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
-  ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
-END
Index: /trunk/icd-demo/def/P2.chip1.hdu.txt
===================================================================
--- /trunk/icd-demo/def/P2.chip1.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/P2.chip1.hdu.txt	(revision 9127)
@@ -0,0 +1,99 @@
+ 
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR
+  COMMENT  STR  Combination (P4S, P4D, Image Stack/ Cumulative Sky) Image
+  COMMENT  STR  Metadata HDU
+  COMMENT  STR  
+  OBS_ID   STR  UnknownFormat       # Observation Identifier
+  CLASSID  S32                    0 # Class ID = focal plane location
+  DETECTID S32                    0 # Numerical ID of detector
+  NX       S32                 4800 # Number of columns on the detector
+  NY       S32                 4800 # Number of rows on the detector   DATE    STR 2006/02/05
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  Images used to process this exposure
+  COMMENT  STR 
+  DETREND1 STR  bias.00.fits        # 
+  DETREND2 STR  dark.00.fits        # 
+  DETREND3 STR  flat.00.fits        # 
+  DETREND4 STR  fringe.01.fits      # 
+  DETREND5 STR  none                # 
+  DETREND6 STR  none                # 
+  DETREND7 STR  none                # 
+  DETREND8 STR  none                # 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/P2.chip1.psf.txt
===================================================================
--- /trunk/icd-demo/def/P2.chip1.psf.txt	(revision 9126)
+++ /trunk/icd-demo/def/P2.chip1.psf.txt	(revision 9127)
@@ -1,139 +1,42 @@
- 
-# description of the chip metadata
-BLANK METADATA
-  COMMENT  STR
-  COMMENT  STR  Combination (P4S, P4D, Image Stack/ Cumulative Sky) Image
-  COMMENT  STR  Metadata HDU
-  COMMENT  STR  
-  OBS_ID   STR  UnknownFormat       # Observation Identifier
-  CLASSID  S32                    0 # Class ID = focal plane location
-  DETECTID S32                    0 # Numerical ID of detector
-  NX       S32                 4800 # Number of columns on the detector
-  NY       S32                 4800 # Number of rows on the detector   DATE    STR 2006/02/05
-  COMMENT  STR
-  COMMENT  STR  Astrometric Solution (up to linear terms)
-  COMMENT  STR
-  NASTRO   S32                  100 # Number of astrometry stars
-  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
-  CTYPE1   STR  RA---TAN            # WCS Coordinate type
-  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
-  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
-  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
-  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
-  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
-  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
-  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
-  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
-  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
-  COMMENT  STR
-  COMMENT  STR  Higher order terms in astrometric solution
-  COMMENT  STR
-  POLYORD  S32                    3 # Polynomial Order
-  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
-  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
-  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
-  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
-  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
-  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
-  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
-  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
-  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
-  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
-  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
-  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
-  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
-  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
-  COMMENT  STR
-  COMMENT  STR  PSF Description Parameters
-  COMMENT  STR
-  PSFMOD   S32                    1 # PSF Model number
-  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
-  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
-  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
-  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
-  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
-  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
-  COMMENT  STR
-  COMMENT  STR  Photometry Calibration information
-  COMMENT  STR
-  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
-  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
-  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
-  COMMENT  STR
-  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
-  PHOTOCID S32                      # Numerical code for reduction code
-  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
-  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
-  PHOT_NS  S32                   19 # Elixir zero point - N stars
-  PHOT_NM  S32                    5 # Elixir zero point - N images
-  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
-  PHOT_X   F32               0.0830 # Elixir zero point - color term
-  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
-  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
-  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
-  COMMENT  STR
-  COMMENT  STR  Some statistics on this image
-  COMMENT  STR
-  NDETECT  S32                 1000 # Number of detections
-  MAGSAT   F32                15.0  # Magnitude at which sources saturate
-  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
-  SKYVAL   F32              1000.0  # Median sky value on detector
-  SKYVAR   F32                 1.0  # Variance of sky values
-  BIASVAL  F32               200.0  # Mean bias level of frame
-  BIASVAR  F32                 1.0  # Variance of bias values
-  COMMENT  STR
-  COMMENT  STR  Images used to process this exposure
-  COMMENT  STR 
-  DETREND1 STR  bias.00.fits        # 
-  DETREND2 STR  dark.00.fits        # 
-  DETREND3 STR  flat.00.fits        # 
-  DETREND4 STR  fringe.01.fits      # 
-  DETREND5 STR  none                # 
-  DETREND6 STR  none                # 
-  DETREND7 STR  none                # 
-  DETREND8 STR  none                # 
-  COMMENT  STR
-  COMMENT  STR  Quality Assurance Flags from IPP
-  COMMENT  STR
-  QAFLAGS  STR  UnknownValue        # IP QA flags
-END
 
 # extra data which belongs to table header
-HEADER METADATA
-  COMMENT  STR   
-  COMMENT  STR   This HDU applies to all detections that have been analyzed
-  COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
-  COMMENT  STR   must be unique within a file so as to allow matching up
-  COMMENT  STR   sources between the PSF matching and either the alternative
-  COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
-  COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
-  COMMENT  STR
-  EXTNAME  STR PSF_FIT_PARAMS
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR PSF_FIT_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+    Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+    X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+    Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+    RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+    DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+    RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+    DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+    PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+    PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+    PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+    SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+    SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+    STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+    PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+    PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+    PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+    PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+    CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+    CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+    N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+  END
 END
-
-# description of the FITS table columns
-COLUMNS METADATA
-  TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
-  IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
-  X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
-  Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
-  X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
-  Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
-  RA_PSF            TTYPE  D     DECIMAL DEGREES     0    360   "RA from PSF fit"
-  DEC_PSF           TTYPE  D     DECIMAL DEGREES   -90    +90   "DEC from PSF fit"
-  RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
-  DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
-  PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
-  PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
-  PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
-  SKY               TTYPE  E     ADU                 0  60000   "Sky level"
-  SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
-  STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
-  PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
-  PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
-  PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
-  PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
-  CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
-  CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
-  N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
-END
Index: /trunk/icd-demo/def/P2.file.txt
===================================================================
--- /trunk/icd-demo/def/P2.file.txt	(revision 9126)
+++ /trunk/icd-demo/def/P2.file.txt	(revision 9127)
@@ -25,6 +25,8 @@
 # the file contains table data for each chip:
 TABLE MULTI
+TABLE STR P2.chip0.hdu.txt
 TABLE STR P2.chip0.psf.txt
 TABLE STR P2.chip0.alt.txt
+TABLE STR P2.chip1.hdu.txt
 TABLE STR P2.chip1.psf.txt
 TABLE STR P2.chip1.alt.txt
Index: /trunk/icd-demo/def/P4D.cell0.alt.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell0.alt.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell0.alt.txt	(revision 9127)
@@ -0,0 +1,34 @@
+ 
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    EXTNAME STR ALT_FIT_PARAMS
+    COMMENT STR
+    COMMENT STR  This HDU applies to all detections that have been analyzed
+    COMMENT STR  with the IPP alternative PSF fitting procedure. 
+    COMMENT STR  Note that the IPP_IDET must be unique within a file so as
+    COMMENT STR  to allow matching up sources between the PSF matching and
+    COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
+    COMMENT STR  detections or the extended source fits to the
+    COMMENT STR  Image Stack/Cumulative Sky detections.
+    COMMENT STR   
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    RA_ALT            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"                                
+    DEC_ALT           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"                               
+    RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
+    DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
+    ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
+    CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
+    CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
+    ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
+    ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
+    ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
+    ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
+    ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
+  END
+END
Index: /trunk/icd-demo/def/P4D.cell0.hdu.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell0.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell0.hdu.txt	(revision 9127)
@@ -0,0 +1,93 @@
+
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR
+  COMMENT  STR  Basic Info about this frame
+  COMMENT  STR
+  SKYCELL  S32                       # Sky Cell ID number
+  REFID    S32                       # Reference Sky Cell ID number
+  SUBTRID  S32                       # ID of Sky Cell Image subtracted 
+  FILTER   S32                       # Filter 
+  STACKID  S32                       # ID for this image stack
+  NP2IMGS  S32                       # Number of P2 images contributing
+  ANALVER  S32                       # Software Analysis Version
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  P2 images used to generate this image stack
+  COMMENT  STR 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/P4D.cell0.low.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell0.low.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell0.low.txt	(revision 9127)
@@ -0,0 +1,41 @@
+
+# extra data which belongs to table header
+HEADER METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR   
+  COMMENT  STR   This HDU applies to all detections that have been analyzed
+  COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+  COMMENT  STR   must be unique within a file so as to allow matching up
+  COMMENT  STR   sources between the PSF matching and either the alternative
+  COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+  COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+  COMMENT  STR
+  EXTNAME  STR PSF_FIT_PARAMS
+END
+
+# description of the FITS table columns
+COLUMNS METADATA
+  TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+  IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+  X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+  Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+  X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+  Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+  RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+  DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+  RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+  DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+  PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+  PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+  PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+  SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+  SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+  STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+  PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+  PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+  PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+  PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+  CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+  CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+  N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+END
Index: /trunk/icd-demo/def/P4D.cell0.psf.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell0.psf.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell0.psf.txt	(revision 9127)
@@ -0,0 +1,43 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR PSF_FIT_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+    Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+    X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+    Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+    RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+    DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+    RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+    DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+    PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+    PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+    PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+    SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+    SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+    STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+    PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+    PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+    PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+    PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+    CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+    CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+    N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+  END
+END
Index: /trunk/icd-demo/def/P4D.cell1.alt.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell1.alt.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell1.alt.txt	(revision 9127)
@@ -0,0 +1,34 @@
+ 
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    EXTNAME STR ALT_FIT_PARAMS
+    COMMENT STR
+    COMMENT STR  This HDU applies to all detections that have been analyzed
+    COMMENT STR  with the IPP alternative PSF fitting procedure. 
+    COMMENT STR  Note that the IPP_IDET must be unique within a file so as
+    COMMENT STR  to allow matching up sources between the PSF matching and
+    COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
+    COMMENT STR  detections or the extended source fits to the
+    COMMENT STR  Image Stack/Cumulative Sky detections.
+    COMMENT STR   
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    RA_ALT            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"                                
+    DEC_ALT           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"                               
+    RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
+    DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
+    ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
+    CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
+    CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
+    ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
+    ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
+    ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
+    ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
+    ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
+  END
+END
Index: /trunk/icd-demo/def/P4D.cell1.hdu.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell1.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell1.hdu.txt	(revision 9127)
@@ -0,0 +1,93 @@
+
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR
+  COMMENT  STR  Basic Info about this frame
+  COMMENT  STR
+  SKYCELL  S32                       # Sky Cell ID number
+  REFID    S32                       # Reference Sky Cell ID number
+  SUBTRID  S32                       # ID of Sky Cell Image subtracted 
+  FILTER   S32                       # Filter 
+  STACKID  S32                       # ID for this image stack
+  NP2IMGS  S32                       # Number of P2 images contributing
+  ANALVER  S32                       # Software Analysis Version
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  P2 images used to generate this image stack
+  COMMENT  STR 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/P4D.cell1.low.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell1.low.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell1.low.txt	(revision 9127)
@@ -0,0 +1,41 @@
+
+# extra data which belongs to table header
+HEADER METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR   
+  COMMENT  STR   This HDU applies to all detections that have been analyzed
+  COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+  COMMENT  STR   must be unique within a file so as to allow matching up
+  COMMENT  STR   sources between the PSF matching and either the alternative
+  COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+  COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+  COMMENT  STR
+  EXTNAME  STR PSF_FIT_PARAMS
+END
+
+# description of the FITS table columns
+COLUMNS METADATA
+  TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+  IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+  X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+  Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+  X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+  Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+  RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+  DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+  RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+  DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+  PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+  PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+  PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+  SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+  SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+  STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+  PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+  PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+  PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+  PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+  CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+  CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+  N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+END
Index: /trunk/icd-demo/def/P4D.cell1.psf.txt
===================================================================
--- /trunk/icd-demo/def/P4D.cell1.psf.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4D.cell1.psf.txt	(revision 9127)
@@ -0,0 +1,43 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR PSF_FIT_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+    Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+    X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+    Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+    RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+    DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+    RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+    DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+    PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+    PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+    PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+    SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+    SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+    STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+    PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+    PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+    PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+    PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+    CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+    CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+    N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+  END
+END
Index: /trunk/icd-demo/def/P4D.file.txt
===================================================================
--- /trunk/icd-demo/def/P4D.file.txt	(revision 9126)
+++ /trunk/icd-demo/def/P4D.file.txt	(revision 9127)
@@ -2,31 +2,13 @@
 # Keywords for P4D Frame Descriptor HDU
 HEADER METADATA
-  TELESCOP STR  PS1                 # Telescope name
-  TELNUM   S32                    1 # Telescope number
-  CAMERA   STR  GPC1                # Camera name
-  CAMERAID S32                    1 # Camera number
-  OBS_ID   STR  UnknownFormat       # Observation identifier
-  ANALVER  S32                    0 # Analysis version number
-  P1RECIP  STR              Basic.0 # Phase 1 recipe
-  P2RECIP  STR               GPC.01 # Phase 2 recipe
-  P3RECIP  STR               GPC.00 # Phase 3 recipe
-  NFILES   F32                    1 # Number of associated files ???
-  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
-  PHOT_CS  F32                0.007 # Scater in photometric solution (mag)
-  MJDATE   F64        10000.0011223 # MJD at start of exposure
-  EXPTIME  F32                30.01 # Exposure time (seconds)
-  FILTER   STR  r.12345             # Filter identification string
-  FILTERID F32                    2 # Filter holder position
-  AIRMASS  F32                1.012 # Airmass at start of exposure
-  RA       F32            10.000000 # Telescope boresight in RA (degrees)
-  DEC      F32            -10.00000 # Telescope boresight in DEC (degrees)
+  NCELLS  S32                2 # Number of sky cell extensions
 END
 
-# the file contains table data for each chip:
+# the file contains table data for each cell:
 TABLE MULTI
-TABLE STR P4D.chip0.psf.txt
-TABLE STR P4D.chip0.alt.txt
-TABLE STR P4D.chip0.low.txt
-TABLE STR P4D.chip1.psf.txt
-TABLE STR P4D.chip1.alt.txt
-TABLE STR P4D.chip1.low.txt
+TABLE STR P4D.cell0.hdu.txt
+TABLE STR P4D.cell0.psf.txt
+TABLE STR P4D.cell0.alt.txt
+TABLE STR P4D.cell1.hdu.txt
+TABLE STR P4D.cell1.psf.txt
+TABLE STR P4D.cell1.alt.txt
Index: /trunk/icd-demo/def/P4Dlo.file.txt
===================================================================
--- /trunk/icd-demo/def/P4Dlo.file.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4Dlo.file.txt	(revision 9127)
@@ -0,0 +1,12 @@
+
+# Keywords for P4D Frame Descriptor HDU
+HEADER METADATA
+  NCELLS  S32                2 # Number of sky cell extensions
+END
+
+# the file contains table data for each cell:
+TABLE MULTI
+TABLE STR P4D.cell0.hdu.txt
+TABLE STR P4D.cell0.low.txt
+TABLE STR P4D.cell1.hdu.txt
+TABLE STR P4D.cell1.low.txt
Index: /trunk/icd-demo/def/P4S.cell0.alt.txt
===================================================================
--- /trunk/icd-demo/def/P4S.cell0.alt.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4S.cell0.alt.txt	(revision 9127)
@@ -0,0 +1,34 @@
+ 
+# extra data which belongs to table header
+FITSTABLE METADATA
+HEADER METADATA
+    EXTNAME STR ALT_FIT_PARAMS
+    COMMENT STR
+    COMMENT STR  This HDU applies to all detections that have been analyzed
+    COMMENT STR  with the IPP alternative PSF fitting procedure. 
+    COMMENT STR  Note that the IPP_IDET must be unique within a file so as
+    COMMENT STR  to allow matching up sources between the PSF matching and
+    COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
+    COMMENT STR  detections or the extended source fits to the
+    COMMENT STR  Image Stack/Cumulative Sky detections.
+    COMMENT STR   
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    RA_ALT            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"                                
+    DEC_ALT           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"                               
+    RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
+    DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
+    ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
+    CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
+    CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
+    ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
+    ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
+    ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
+    ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
+    ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
+  END
+END
Index: /trunk/icd-demo/def/P4S.cell0.hdu.txt
===================================================================
--- /trunk/icd-demo/def/P4S.cell0.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4S.cell0.hdu.txt	(revision 9127)
@@ -0,0 +1,93 @@
+
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR
+  COMMENT  STR  Basic Info about this frame
+  COMMENT  STR
+  SKYCELL  S32                       # Sky Cell ID number
+  REFID    S32                       # Reference Sky Cell ID number
+  SUBTRID  S32                       # ID of Sky Cell Image subtracted 
+  FILTER   S32                       # Filter 
+  STACKID  S32                       # ID for this image stack
+  NP2IMGS  S32                       # Number of P2 images contributing
+  ANALVER  S32                       # Software Analysis Version
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  P2 images used to generate this image stack
+  COMMENT  STR 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/P4S.cell0.psf.txt
===================================================================
--- /trunk/icd-demo/def/P4S.cell0.psf.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4S.cell0.psf.txt	(revision 9127)
@@ -0,0 +1,43 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR PSF_FIT_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+    Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+    X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+    Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+    RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+    DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+    RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+    DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+    PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+    PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+    PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+    SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+    SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+    STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+    PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+    PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+    PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+    PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+    CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+    CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+    N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+  END
+END
Index: /trunk/icd-demo/def/P4S.cell1.alt.txt
===================================================================
--- /trunk/icd-demo/def/P4S.cell1.alt.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4S.cell1.alt.txt	(revision 9127)
@@ -0,0 +1,34 @@
+ 
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    EXTNAME STR ALT_FIT_PARAMS
+    COMMENT STR
+    COMMENT STR  This HDU applies to all detections that have been analyzed
+    COMMENT STR  with the IPP alternative PSF fitting procedure. 
+    COMMENT STR  Note that the IPP_IDET must be unique within a file so as
+    COMMENT STR  to allow matching up sources between the PSF matching and
+    COMMENT STR  either the alternative PSF fits for P2, P4S, and P4D
+    COMMENT STR  detections or the extended source fits to the
+    COMMENT STR  Image Stack/Cumulative Sky detections.
+    COMMENT STR   
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    RA_ALT            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"                                
+    DEC_ALT           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"                               
+    RA_ALT_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"                            
+    DEC_ALT_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"                           
+    ALT_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"                    
+    CAL_ALT_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"                           
+    CAL_ALT_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"                  
+    ALT_PARM_1        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 1"                  
+    ALT_PARM_2        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 2"                  
+    ALT_PARM_3        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 3"                  
+    ALT_PARM_4        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 4"                  
+    ALT_PARM_5        TTYPE  E     NONE             NONE   NONE   "ALT model parameter 5"                  
+  END
+END
Index: /trunk/icd-demo/def/P4S.cell1.hdu.txt
===================================================================
--- /trunk/icd-demo/def/P4S.cell1.hdu.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4S.cell1.hdu.txt	(revision 9127)
@@ -0,0 +1,93 @@
+
+# description of the chip metadata
+BLANK METADATA
+  COMMENT  STR  MULTI
+  COMMENT  STR
+  COMMENT  STR  Basic Info about this frame
+  COMMENT  STR
+  SKYCELL  S32                       # Sky Cell ID number
+  REFID    S32                       # Reference Sky Cell ID number
+  SUBTRID  S32                       # ID of Sky Cell Image subtracted 
+  FILTER   S32                       # Filter 
+  STACKID  S32                       # ID for this image stack
+  NP2IMGS  S32                       # Number of P2 images contributing
+  ANALVER  S32                       # Software Analysis Version
+  COMMENT  STR
+  COMMENT  STR  Astrometric Solution (up to linear terms)
+  COMMENT  STR
+  NASTRO   S32                  100 # Number of astrometry stars
+  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
+  CTYPE1   STR  RA---TAN            # WCS Coordinate type
+  CTYPE2   STR  DEC--TAN            # WCS Coordinate type
+  CRVAL1   F32      321.30941666667 # WCS Ref value (RA in decimal degrees)
+  CRVAL2   F32     -5.1685277777778 # WCS Ref value (DEC in decimal degrees)
+  CRPIX1   F32    -1051.17692913657 # WCS Coordinate reference pixel
+  CRPIX2   F32     2033.40939404705 # WCS Coordinate reference pixel
+  CD1_1    F32  1.13378419402790E-4 # WCS Coordinate scale matrix
+  CD1_2    F32  8.93919113249280E-8 # WCS Coordinate scale matrix
+  CD2_1    F32  -5.4105516940550E-7 # WCS Coordinate scale matrix
+  CD2_2    F32  -1.1365323690945E-4 # WCS Coordinate scale matrix
+  COMMENT  STR
+  COMMENT  STR  Higher order terms in astrometric solution
+  COMMENT  STR
+  POLYORD  S32                    3 # Polynomial Order
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 1, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 1, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 1, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 1, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 1, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 1, coefficient of Y^2
+  PCA1X3Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^3
+  PCA1X2Y1 F32                  0.0 # WCS, Axis 2, coefficient of X^2 * Y
+  PCA1X1Y2 F32                  0.0 # WCS, Axis 2, coefficient of X * Y^2
+  PCA1X0Y3 F32                  0.0 # WCS, Axis 2, coefficient of Y^3
+  PCA1X2Y0 F32                  0.0 # WCS, Axis 2, coefficient of X^2
+  PCA1X1Y1 F32                  0.0 # WCS, Axis 2, coefficient of X * Y
+  PCA1X0Y2 F32                  0.0 # WCS, Axis 2, coefficient of Y^2
+  COMMENT  STR
+  COMMENT  STR  PSF Description Parameters
+  COMMENT  STR
+  PSFMOD   S32                    1 # PSF Model number
+  PSFFWHM  F32                  1.0 # PSF Full width at Half Maximum (pixels)
+  PSFWIDX  F32                  1.0 # PSF Width in X coordinate (pixels)
+  PSFWIDY  F32                  1.0 # PSF Width in Y coordinate (pixels)
+  PSFTHETA F32                  0.0 # PSF Orientation angle (degrees)
+  PSF_EX1  F32                  0.0 # PSF Extra parameter #1
+  PSF_EX2  F32                  0.0 # PSF Extra parameter #2
+  COMMENT  STR
+  COMMENT  STR  Photometry Calibration information
+  COMMENT  STR
+  COMMENT  STR   Formula for Photometry, based on keywords given in this header:
+  COMMENT  STR   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+  COMMENT  STR   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+  COMMENT  STR
+  PHOTCODE STR  GPC.00.r            # Photometry reduction code identifier
+  PHOTOCID S32                      # Numerical code for reduction code
+  PHOT_C   F32              25.7150 # Elixir zero point - measured for camera run
+  PHOT_CS  F32               0.0048 # Elixir zero point - scatter
+  PHOT_NS  S32                   19 # Elixir zero point - N stars
+  PHOT_NM  S32                    5 # Elixir zero point - N images
+  PHOT_C0  F32              25.7430 # Elixir zero point - nominal
+  PHOT_X   F32               0.0830 # Elixir zero point - color term
+  PHOT_K   F32              -0.0400 # Elixir zero point - airmass term
+  PHOT_C1  STR  i_SDSS              # Elixir zero point - color 1
+  PHOT_C2  STR  r_SDSS              # Elixir zero point - color 2
+  COMMENT  STR
+  COMMENT  STR  Some statistics on this image
+  COMMENT  STR
+  NDETECT  S32                 1000 # Number of detections
+  MAGSAT   F32                15.0  # Magnitude at which sources saturate
+  MAGCOMP  F32                22.0  # Magnitude for which frame is 95% complete
+  SKYVAL   F32              1000.0  # Median sky value on detector
+  SKYVAR   F32                 1.0  # Variance of sky values
+  BIASVAL  F32               200.0  # Mean bias level of frame
+  BIASVAR  F32                 1.0  # Variance of bias values
+  COMMENT  STR
+  COMMENT  STR  P2 images used to generate this image stack
+  COMMENT  STR 
+  COMMENT  STR
+  COMMENT  STR  Quality Assurance Flags from IPP
+  COMMENT  STR
+  QAFLAGS  STR  UnknownValue        # IP QA flags
+END
Index: /trunk/icd-demo/def/P4S.cell1.psf.txt
===================================================================
--- /trunk/icd-demo/def/P4S.cell1.psf.txt	(revision 9127)
+++ /trunk/icd-demo/def/P4S.cell1.psf.txt	(revision 9127)
@@ -0,0 +1,43 @@
+
+# extra data which belongs to table header
+FITSTABLE METADATA
+  HEADER METADATA
+    COMMENT  STR  MULTI
+    COMMENT  STR   
+    COMMENT  STR   This HDU applies to all detections that have been analyzed
+    COMMENT  STR   with the IPP PSF fitting procedure. Note that the IPP_IDET
+    COMMENT  STR   must be unique within a file so as to allow matching up
+    COMMENT  STR   sources between the PSF matching and either the alternative
+    COMMENT  STR   PSF fits for P2, P4S, and P4D detections or the extended
+    COMMENT  STR   source fits to the Image Stack/Cumulative Sky detections.
+    COMMENT  STR
+    EXTNAME  STR PSF_FIT_PARAMS
+  END
+
+  # description of the FITS table columns
+  COLUMNS METADATA
+    TYPE              TTYPE  TFORM TUNIT            TMIN   TMAX   COMMENT
+    IPP_IDET          TTYPE  J     NONE             NONE   NONE   "IPP detection identifer index"                 
+    X_PSF             TTYPE  E     PIXELS              0   5000   "PSF x coordinate"                              
+    Y_PSF             TTYPE  E     PIXELS              0   5000   "PSF y coordinate"                              
+    X_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF x coordinate"                     
+    Y_PSF_SIG         TTYPE  E     PIXELS              0     10   "Sigma in PSF y coordinate"                     
+    RA_PSF            TTYPE  D    "DECIMAL DEGREES"    0    360   "RA from PSF fit"
+    DEC_PSF           TTYPE  D    "DECIMAL DEGREES"  -90    +90   "DEC from PSF fit"
+    RA_PSF_SIG        TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit RA"
+    DEC_PSF_SIG       TTYPE  E     ARCSECONDS          0      1   "Sigma of PSF fit DEC"
+    PSF_INST_MAG      TTYPE  E     MAG               -20      0   "PSF fit instrumental magnitude"
+    PSF_INST_MAG_SIG  TTYPE  E     MAG                 0    0.5   "Sigma of PSF instrumental magnitude"
+    PEAK_FLUX_AS_MAG  TTYPE  E     MAG               -20      0   "Peak flux expressed as magnitude"
+    SKY               TTYPE  E     ADU                 0  60000   "Sky level"
+    SKY_SIGMA         TTYPE  E     ADU                 0  60000   "Sigma of sky level"
+    STAR_GALAXY_SEP   TTYPE  E     NONE                0      1   "Star-Galaxy separator"
+    PSF_WIDTH_X       TTYPE  E     ARCSECONDS          0     20   "PSF width in x coordinate"
+    PSF_WIDTH_Y       TTYPE  E     ARCSECONDS          0     20   "PSF width in y coordinate"
+    PSF_THETA         TTYPE  E     DEGREES          -180   +180   "PSF orientation angle"
+    PSF_QF            TTYPE  E     NONE                0      1   "PSF coverage/quality factor"
+    CAL_PSF_MAG       TTYPE  E     MAG               -10    +30   "Calibrated magnitude"
+    CAL_PSF_MAG_SIG   TTYPE  E     MAG                 0    0.5   "Sigma of calibrated magnitude"
+    N_FRAMES          TTYPE  I     NONE                0  10000   "Number of frames overlapping source center"
+  END
+END
Index: /trunk/icd-demo/def/P4S.file.txt
===================================================================
--- /trunk/icd-demo/def/P4S.file.txt	(revision 9126)
+++ /trunk/icd-demo/def/P4S.file.txt	(revision 9127)
@@ -2,29 +2,13 @@
 # Keywords for P4S Frame Descriptor HDU
 HEADER METADATA
-  TELESCOP STR  PS1                 # Telescope name
-  TELNUM   S32                    1 # Telescope number
-  CAMERA   STR  GPC1                # Camera name
-  CAMERAID S32                    1 # Camera number
-  OBS_ID   STR  UnknownFormat       # Observation identifier
-  ANALVER  S32                    0 # Analysis version number
-  P1RECIP  STR              Basic.0 # Phase 1 recipe
-  P2RECIP  STR               GPC.01 # Phase 2 recipe
-  P3RECIP  STR               GPC.00 # Phase 3 recipe
-  NFILES   F32                    1 # Number of associated files ???
-  CERROR   F32               10.000 # Scatter in astrometry solution (MAS)
-  PHOT_CS  F32                0.007 # Scater in photometric solution (mag)
-  MJDATE   F64        10000.0011223 # MJD at start of exposure
-  EXPTIME  F32                30.01 # Exposure time (seconds)
-  FILTER   STR  r.12345             # Filter identification string
-  FILTERID F32                    2 # Filter holder position
-  AIRMASS  F32                1.012 # Airmass at start of exposure
-  RA       F32            10.000000 # Telescope boresight in RA (degrees)
-  DEC      F32            -10.00000 # Telescope boresight in DEC (degrees)
+  NCELLS  S32                2 # Number of sky cell extensions
 END
 
 # the file contains table data for each chip:
 TABLE MULTI
-TABLE STR P4S.chip0.psf.txt
-TABLE STR P4S.chip0.alt.txt
-TABLE STR P4S.chip1.psf.txt
-TABLE STR P4S.chip1.alt.txt
+TABLE STR P4S.cell0.hdu.txt
+TABLE STR P4S.cell0.psf.txt
+TABLE STR P4S.cell0.alt.txt
+TABLE STR P4S.cell1.hdu.txt
+TABLE STR P4S.cell1.psf.txt
+TABLE STR P4S.cell1.alt.txt
Index: /trunk/icd-demo/raw/ext-fits-detections.txt
===================================================================
--- /trunk/icd-demo/raw/ext-fits-detections.txt	(revision 9126)
+++ /trunk/icd-demo/raw/ext-fits-detections.txt	(revision 9127)
@@ -325,5 +325,5 @@
 TTYPE103= 'SB_R_14           ' / Surface brightness inside R #14
 TUNIT103= 'MAG               ' /
-TFORM103 = 'E                 ' /
+TFORM103= 'E                 ' /
 TTYPE104= 'SB_R_14_ERR       ' / Estimated error of SB inside R #14
 TUNIT104= 'MAG               ' /
Index: /trunk/icd-demo/raw/p2frame.txt
===================================================================
--- /trunk/icd-demo/raw/p2frame.txt	(revision 9127)
+++ /trunk/icd-demo/raw/p2frame.txt	(revision 9127)
@@ -0,0 +1,29 @@
+SIMPLE  =                    T / FITS STANDARD
+BITPIX  =                    0 / FITS BITS/PIXEL
+NAXIS   =                    0 / NUMBER OF AXES
+EXTEND  =                    T /
+DATE    = 'DD/MM/YY'           / Date file created
+CHECKSUM=                      / Checksum for this header
+COMMENT
+COMMENT   P2 Frame Metadata HDU
+COMMENT
+TELESCOP= 'PS1               ' / Telescope name
+TELNUM  =                    1 / Telescope number
+CAMERA  = 'GPC1              ' / Camera name
+CAMERAID=                    1 / Camera number
+OBS_ID  = '                  ' / Observation identifier
+ANALVER =                  XXX / Analysis version number
+P1RECIP =                  YYY / Phase 1 recipe
+P2RECIP =                  ZZZ / Phase 2 recipe
+P3RECIP =                  AAA / Phase 3 recipe
+NFILES  =                    1 / Number of associated files
+CERROR  =              xxx.yyy / Scatter in astrometry solution (MAS)
+PHOT_CS =              aa.bbbb / Scater in photometric solution (mag)
+MJDATE  =        XXXXX.YYYYYYY / MJD at start of exposure
+EXPTIME =               TTT.SS / Exposure time (seconds)
+FILTER  = 'r.12345           ' / Filter identification string
+FILTERID=                    2 / Filter holder position
+AIRMASS =               xx.yyy / Airmass at start of exposure
+RA      =            aaa.bbbbb / Telescope boresight in RA (degrees)
+DEC     =            ccc.ddddd / Telescope boresight in DEC (degrees)
+END
Index: /trunk/icd-demo/raw/p2image.txt
===================================================================
--- /trunk/icd-demo/raw/p2image.txt	(revision 9127)
+++ /trunk/icd-demo/raw/p2image.txt	(revision 9127)
@@ -0,0 +1,101 @@
+BITPIX  =                    8 / FITS BITS/PIXEL
+NAXIS   =                    0 / NUMBER OF AXES
+EXTEND  =                    T /
+DATE    = 'DD/MM/YY'           / Date file created
+CHECKSUM=                      / Checksum for this header
+COMMENT
+COMMENT  Combination (P4S, P4D, Image Stack/ Cumulative Sky) Image
+COMMENT  Metadata HDU
+COMMENT  
+OBS_ID  = '                  ' / Observation Identifier
+CLASSID =                      / Class ID = focal plane location
+DETECTID=                      / Numerical ID of detector
+NX      =                 CCCC / Number of columns on the detector
+NY      =                 RRRR / Number of rows on the detector 
+COMMENT
+COMMENT  Astrometric Solution (up to linear terms)
+COMMENT
+NASTRO  =                 NNNN / Number of astrometry stars
+CERROR  =              XXX.YYY / Scatter in astrometry solution (MAS)
+CTYPE1  = 'RA---TAN'           / WCS Coordinate type
+CTYPE2  = 'DEC--TAN'           / WCS Coordinate type
+CRVAL1  =      321.30941666667 / WCS Ref value (RA in decimal degrees)
+CRVAL2  =     -5.1685277777778 / WCS Ref value (DEC in decimal degrees)
+CRPIX1  =    -1051.17692913657 / WCS Coordinate reference pixel
+CRPIX2  =     2033.40939404705 / WCS Coordinate reference pixel
+CD1_1   =  1.13378419402790E-4 / WCS Coordinate scale matrix
+CD1_2   =  8.93919113249280E-8 / WCS Coordinate scale matrix
+CD2_1   =  -5.4105516940550E-7 / WCS Coordinate scale matrix
+CD2_2   =  -1.1365323690945E-4 / WCS Coordinate scale matrix
+COMMENT
+COMMENT  Higher order terms in astrometric solution
+COMMENT
+POLYORD =                    3 / Polynomial Order
+PCA1X3Y0=                      / WCS, Axis 1, coefficient of X^3
+PCA1X2Y1=                      / WCS, Axis 1, coefficient of X^2 * Y
+PCA1X1Y2=                      / WCS, Axis 1, coefficient of X * Y^2
+PCA1X0Y3=                      / WCS, Axis 1, coefficient of Y^3
+PCA1X2Y0=                      / WCS, Axis 1, coefficient of X^2
+PCA1X1Y1=                      / WCS, Axis 1, coefficient of X * Y
+PCA1X0Y2=                      / WCS, Axis 1, coefficient of Y^2
+PCA1X3Y0=                      / WCS, Axis 2, coefficient of X^3
+PCA1X2Y1=                      / WCS, Axis 2, coefficient of X^2 * Y
+PCA1X1Y2=                      / WCS, Axis 2, coefficient of X * Y^2
+PCA1X0Y3=                      / WCS, Axis 2, coefficient of Y^3
+PCA1X2Y0=                      / WCS, Axis 2, coefficient of X^2
+PCA1X1Y1=                      / WCS, Axis 2, coefficient of X * Y
+PCA1X0Y2=                      / WCS, Axis 2, coefficient of Y^2
+COMMENT
+COMMENT  PSF Description Parameters
+COMMENT
+PSFMOD  =                      / PSF Model number
+PSFFWHM =                      / PSF Full width at Half Maximum (pixels)
+PSFWIDX =                      / PSF Width in X coordinate (pixels)
+PSFWIDY =                      / PSF Width in Y coordinate (pixels)
+PSFTHETA=                      / PSF Orientation angle (degrees)
+PSF_EX1 =                      / PSF Extra parameter #1
+PSF_EX2 =                      / PSF Extra parameter #2
+COMMENT
+COMMENT  Photometry Calibration information
+COMMENT
+COMMENT   Formula for Photometry, based on keywords given in this header:
+COMMENT   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+COMMENT   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+COMMENT
+PHOTCODE=                      / Photometry reduction code identifier
+PHOTOCID=                      / Numerical code for reduction code
+PHOT_C  =              25.7150 / Elixir zero point - measured for camera run
+PHOT_CS =               0.0048 / Elixir zero point - scatter
+PHOT_NS =                   19 / Elixir zero point - N stars
+PHOT_NM =                    5 / Elixir zero point - N images
+PHOT_C0 =              25.7430 / Elixir zero point - nominal
+PHOT_X  =               0.0830 / Elixir zero point - color term
+PHOT_K  =              -0.0400 / Elixir zero point - airmass term
+PHOT_C1 = 'i_SDSS            ' / Elixir zero point - color 1
+PHOT_C2 = 'r_SDSS            ' / Elixir zero point - color 2
+COMMENT
+COMMENT  Some statistics on this image
+COMMENT
+NDETECT =                      / Number of detections
+MAGSAT  =                      / Magnitude at which sources saturate
+MAGCOMP =                      / Magnitude for which frame is 95% complete
+SKYVAL  =                      / Median sky value on detector
+SKYVAR  =                      / Variance of sky values
+BIASVAL =                      / Mean bias level of frame
+BIASVAR =                      / Variance of bias values
+COMMENT
+COMMENT  Images used to process this exposure
+COMMENT 
+DETREND1= '                  ' / 
+DETREND2= '                  ' / 
+DETREND3= '                  ' / 
+DETREND4= '                  ' / 
+DETREND5= '                  ' / 
+DETREND6= '                  ' / 
+DETREND7= '                  ' / 
+DETREND8= '                  ' / 
+COMMENT
+COMMENT  Quality Assurance Flags from IPP
+COMMENT
+QAFLAGS = '                  ' / IP QA flags
+END
Index: /trunk/icd-demo/raw/p4image.txt
===================================================================
--- /trunk/icd-demo/raw/p4image.txt	(revision 9127)
+++ /trunk/icd-demo/raw/p4image.txt	(revision 9127)
@@ -0,0 +1,93 @@
+
+XTENSION= 'IMAGE'               /
+BITPIX  =                    8  /
+NAXIS   =                    0  /
+COMMENT
+COMMENT  Calibration information for this sky cell
+COMMENT
+SKYCELL =                       / Sky Cell ID number
+REFID   =                       / Reference Sky Cell ID number
+SUBTRID =                       / ID of Sky Cell Image subtracted 
+FILTER  =                       / Filter 
+STACKID =                       / ID for this image stack
+NP2IMGS =                       / Number of P2 images contributing
+ANALVER =                       / Software Analysis Version
+COMMENT
+COMMENT  Astrometric Solution (up to linear terms)
+COMMENT
+NASTRO  =                 NNNN  / Number of astrometry stars
+CERROR  =              XXX.YYY  / Scatter in astrometry solution (MAS)
+CTYPE1  = 'RA---TAN'            / WCS Coordinate type
+CTYPE2  = 'DEC--TAN'            / WCS Coordinate type
+CRVAL1  =      321.30941666667  / WCS Ref value (RA in decimal degrees)
+CRVAL2  =     -5.1685277777778  / WCS Ref value (DEC in decimal degrees)
+CRPIX1  =    -1051.17692913657  / WCS Coordinate reference pixel
+CRPIX2  =     2033.40939404705  / WCS Coordinate reference pixel
+CD1_1   =  1.13378419402790E-4  / WCS Coordinate scale matrix
+CD1_2   =  8.93919113249280E-8  / WCS Coordinate scale matrix
+CD2_1   =  -5.4105516940550E-7  / WCS Coordinate scale matrix
+CD2_2   =  -1.1365323690945E-4  / WCS Coordinate scale matrix
+COMMENT
+COMMENT  Higher order terms in astrometric solution
+COMMENT
+POLYORD =                    3  / Polynomial Order
+PCA1X3Y0=                       / WCS, Axis 1, coefficient of X^3
+PCA1X2Y1=                       / WCS, Axis 1, coefficient of X^2 * Y
+PCA1X1Y2=                       / WCS, Axis 1, coefficient of X * Y^2
+PCA1X0Y3=                       / WCS, Axis 1, coefficient of Y^3
+PCA1X2Y0=                       / WCS, Axis 1, coefficient of X^2
+PCA1X1Y1=                       / WCS, Axis 1, coefficient of X * Y
+PCA1X0Y2=                       / WCS, Axis 1, coefficient of Y^2
+PCA1X3Y0=                       / WCS, Axis 2, coefficient of X^3
+PCA1X2Y1=                       / WCS, Axis 2, coefficient of X^2 * Y
+PCA1X1Y2=                       / WCS, Axis 2, coefficient of X * Y^2
+PCA1X0Y3=                       / WCS, Axis 2, coefficient of Y^3
+PCA1X2Y0=                       / WCS, Axis 2, coefficient of X^2
+PCA1X1Y1=                       / WCS, Axis 2, coefficient of X * Y
+PCA1X0Y2=                       / WCS, Axis 2, coefficient of Y^2
+COMMENT
+COMMENT  PSF Description Parameters
+COMMENT
+PSFMOD  =                       / PSF Model number
+PSFFWHM =                       / PSF Full width at Half Maximum (pixels)
+PSFWIDX =                       / PSF Width in X coordinate (pixels)
+PSFWIDY =                       / PSF Width in Y coordinate (pixels)
+PSFTHETA=                       / PSF Orientation angle (degrees)
+PSF_EX1 =                       / PSF Extra parameter #1
+PSF_EX2 =                       / PSF Extra parameter #2
+COMMENT
+COMMENT  Photometry Calibration information
+COMMENT
+COMMENT   Formula for Photometry, based on keywords given in this header:
+COMMENT   m = -2.5*log(DN) + 2.5*log(EXPTIME)
+COMMENT   M = m + PHOT_C + PHOT_K*(AIRMASS - 1) + PHOT_X*(PHOT_C1 - PHOT_C2)
+COMMENT
+PHOTCODE=                      / Photometry reduction code identifier
+PHOTOCID=                      / Numerical code for reduction code
+PHOT_C  =              25.7150 / Elixir zero point - measured for camera run
+PHOT_CS =               0.0048 / Elixir zero point - scatter
+PHOT_NS =                   19 / Elixir zero point - N stars
+PHOT_NM =                    5 / Elixir zero point - N images
+PHOT_C0 =              25.7430 / Elixir zero point - nominal
+PHOT_X  =               0.0830 / Elixir zero point - color term
+PHOT_K  =              -0.0400 / Elixir zero point - airmass term
+PHOT_C1 = 'i_SDSS            ' / Elixir zero point - color 1
+PHOT_C2 = 'r_SDSS            ' / Elixir zero point - color 2
+COMMENT
+COMMENT  Some statistics on this image
+COMMENT
+NDETECT =                      / Number of detections
+MAGSAT  =                      / Magnitude at which sources saturate
+MAGCOMP =                      / Magnitude for which frame is 95% complete
+SKYVAL  =                      / Median sky value on detector
+SKYVAR  =                      / Variance of sky values
+BIASVAL =                      / Mean bias level of frame
+BIASVAR =                      / Variance of bias values
+COMMENT
+COMMENT  P2 images used to generate this image stack
+COMMENT 
+COMMENT
+COMMENT  Quality Assurance Flags from IPP
+COMMENT
+QAFLAGS = '                  ' / IP QA flags
+END
Index: /trunk/icd-demo/raw/p4set.txt
===================================================================
--- /trunk/icd-demo/raw/p4set.txt	(revision 9127)
+++ /trunk/icd-demo/raw/p4set.txt	(revision 9127)
@@ -0,0 +1,8 @@
+SIMPLE  =                    T  / 
+BITPIX  =                    8  / FITS BITS/PIXEL
+NAXIS   =                    0  / NUMBER OF AXES
+EXTEND  =                    T  /
+DATE    = 'DD/MM/YY'            / Date file created
+NCELLS  =                  NNN  / Number of sky cell extensions
+CHECKSUM=                       / Checksum for this header
+END
Index: /trunk/icd-demo/raw/skycell.txt
===================================================================
--- /trunk/icd-demo/raw/skycell.txt	(revision 9127)
+++ /trunk/icd-demo/raw/skycell.txt	(revision 9127)
@@ -0,0 +1,56 @@
+SIMPLE  =                    T / FITS STANDARD
+BITPIX  =                    8 / FITS BITS/PIXEL
+NAXIS   =                    0 / NUMBER OF AXES
+EXTEND  =                    T /
+DATE    = 'DD/MM/YY'           / Date file created
+CHECKSUM=                      / Checksum for this header
+COMMENT
+COMMENT   Sky Cell Definition Metadata
+COMMENT
+END
+
+XTENSION= 'BINTABLE          ' / 
+BITPIX  =                    8 /
+NAXIS   =                    2 /
+NAXIS1  =                   68 /
+NAXIS2  =             NNNNNNNN /
+PCOUNT  =                    0 /
+GCOUNT  =                    1 /
+TFIELDS =                    9 /
+EXTNAME = 'SKY_CELL_TABLE    ' /
+COMMENT   
+COMMENT   This file defines the regions on the sky covered by
+COMMENT   each sky cell used by the IPP. For this sample, it
+COMMENT   is assumed each cell is a quadralateral defined by
+COMMENT   4 vertices on the sky.
+COMMENT
+CHECKSUM=                      / Checksum for this header
+DATASUM =                      / Checksum for table data
+TTYPE1  = 'ID                ' / Sky cell identifier
+TUNIT1  = '                  ' /
+TFORM1  = 'J                 ' /
+TTYPE2  = 'RA1               ' / RA of 1st cell vertex.
+TUNIT2  = 'DEGREES           ' /
+TFORM2  = 'D                 ' /
+TTYPE3  = 'DEC1              ' / DEC of 1st cell vertex.
+TUNIT3  = 'DEGREES           ' /
+TFORM3  = 'D                 ' /
+TTYPE4  = 'RA2               ' / RA of 2nd cell vertex.
+TUNIT4  = 'DEGREES           ' /
+TFORM4  = 'D                 ' /
+TTYPE5  = 'DEC2              ' / DEC of 2nd cell vertex.
+TUNIT5  = 'DEGREES           ' /
+TFORM5  = 'D                 ' /
+TTYPE6  = 'RA3               ' / RA of 34d cell vertex.
+TUNIT6  = 'DEGREES           ' /
+TFORM6  = 'D                 ' /
+TTYPE7  = 'DEC3              ' / DEC of 3rd cell vertex.
+TUNIT7  = 'DEGREES           ' /
+TFORM7  = 'D                 ' /
+TTYPE8  = 'RA4               ' / RA of 4th cell vertex.
+TUNIT8  = 'DEGREES           ' /
+TFORM8  = 'D                 ' /
+TTYPE9  = 'DEC4              ' / DEC of 4th cell vertex.
+TUNIT9  = 'DEGREES           ' /
+TFORM9  = 'D                 ' /
+END
Index: /trunk/icd-demo/src/icd-demo.c
===================================================================
--- /trunk/icd-demo/src/icd-demo.c	(revision 9126)
+++ /trunk/icd-demo/src/icd-demo.c	(revision 9127)
@@ -8,5 +8,5 @@
 int main (int argc, char **argv) {
 
-    int nFail;
+    unsigned int nFail;
 
     if (argc != 3) {
@@ -21,5 +21,5 @@
 
     psMetadata *header  = psMetadataLookupPtr (NULL, fd, "HEADER");
-    psFitsWriteBlank (fits, header);
+    psFitsWriteBlank (fits, header, "");
 
     // get the list pointers for the PSF_MODEL entries
@@ -45,8 +45,9 @@
 int parseFile (psFits *fits, char *file) {
 
-    int nFail;
+    unsigned int nFail;
     char unitWord[64];
     double min, max, rvalue, range;
 
+    fprintf (stderr, "reading %s\n", file);
     psMetadataItem *col;
     psRandom *rnd = psRandomAlloc (PS_RANDOM_TAUS, 0);
@@ -57,40 +58,22 @@
     psMetadata *blank  = psMetadataLookupPtr (NULL, fd, "BLANK");
     if (blank) {
-	psFitsWriteBlank (fits, blank);
-    }
-
-    psMetadata *header  = psMetadataLookupPtr (NULL, fd, "HEADER");
-    psMetadata *columns = psMetadataLookupPtr (NULL, fd, "COLUMNS");
-    psMetadataIterator *iter = psMetadataIteratorAlloc (columns, PS_LIST_HEAD, NULL);
-    char *extname       = psMetadataLookupStr (NULL, header, "EXTNAME");
-
-    psArray *table = psArrayAlloc (10);
-
-    // XXX insert unit values: we need a method to do this in psFitsWriteTable
-    int nCol = 1;
-    while ((col = psMetadataGetAndIncrement (iter)) != NULL) {
-	psMetadata *md = col->data.V;
-	char *unit = psMetadataLookupStr (NULL, md, "TUNIT");
-	if (strcasecmp (unit, "NONE")) {
-	    sprintf (unitWord, "TUNIT%d", nCol);
-	    psMetadataAddStr (header, PS_LIST_TAIL, unitWord, 0, "", unit);
-	}
-	nCol ++;
-    }
-    psMetadataIteratorSet (iter, PS_LIST_HEAD);
-
-    // make a total of NN fake data columns
-    for (int i = 0; i < 10; i++) {
-	
+	fprintf (stderr, "adding BLANK\n");
+	psFitsWriteBlank (fits, blank, "");
+    }
+
+    psMetadata *fitstable  = psMetadataLookupPtr (NULL, fd, "FITSTABLE");
+    if (fitstable) {
+	fprintf (stderr, "adding TABLE\n");
+	psMetadata *header  = psMetadataLookupPtr (NULL, fitstable, "HEADER");
+	psMetadata *columns = psMetadataLookupPtr (NULL, fitstable, "COLUMNS");
+	psMetadataIterator *iter = psMetadataIteratorAlloc (columns, PS_LIST_HEAD, NULL);
+	char *extname       = psMetadataLookupStr (NULL, header, "EXTNAME");
+
+	psArray *table = psArrayAlloc (10);
+
+	// XXX insert unit values: we need a method to do this in psFitsWriteTable
 	int nCol = 1;
-
-	psMetadata *row = psMetadataAlloc ();
-
 	while ((col = psMetadataGetAndIncrement (iter)) != NULL) {
-
 	    psMetadata *md = col->data.V;
-
-	    char *format = psMetadataLookupStr (NULL, md, "TFORM");
-	    char *comment = psMetadataLookupStr (NULL, md, "COMMENT");
 	    char *unit = psMetadataLookupStr (NULL, md, "TUNIT");
 	    if (strcasecmp (unit, "NONE")) {
@@ -98,106 +81,129 @@
 		psMetadataAddStr (header, PS_LIST_TAIL, unitWord, 0, "", unit);
 	    }
-
-	    if (!strcasecmp (format, "I")) {
-		int value;
-
-		char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
-		char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
-
-		min = atoi (minWord);
-		if (!strcasecmp (minWord, "NONE")) min = 0;
-		max = atoi (maxWord);
-		if (!strcasecmp (maxWord, "NONE")) max = 100;
-		range = max - min;
-
-		rvalue = psRandomUniform (rnd);
-		value = range * rvalue + min;
-
-		psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_S16, comment, value);
+	    nCol ++;
+	}
+	psMetadataIteratorSet (iter, PS_LIST_HEAD);
+
+	// make a total of NN fake data columns
+	for (int i = 0; i < 10; i++) {
+	
+	    int nCol = 1;
+
+	    psMetadata *row = psMetadataAlloc ();
+
+	    while ((col = psMetadataGetAndIncrement (iter)) != NULL) {
+
+		psMetadata *md = col->data.V;
+
+		char *format = psMetadataLookupStr (NULL, md, "TFORM");
+		char *comment = psMetadataLookupStr (NULL, md, "COMMENT");
+		char *unit = psMetadataLookupStr (NULL, md, "TUNIT");
+		if (strcasecmp (unit, "NONE")) {
+		    sprintf (unitWord, "TUNIT%d", nCol);
+		    psMetadataAddStr (header, PS_LIST_TAIL, unitWord, 0, "", unit);
+		}
+
+		if (!strcasecmp (format, "I")) {
+		    int value;
+
+		    char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
+		    char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
+
+		    min = atoi (minWord);
+		    if (!strcasecmp (minWord, "NONE")) min = 0;
+		    max = atoi (maxWord);
+		    if (!strcasecmp (maxWord, "NONE")) max = 100;
+		    range = max - min;
+
+		    rvalue = psRandomUniform (rnd);
+		    value = range * rvalue + min;
+
+		    psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_S16, comment, value);
+		}
+
+		if (!strcasecmp (format, "J")) {
+		    int value;
+
+		    char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
+		    char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
+
+		    min = atoi (minWord);
+		    if (!strcasecmp (minWord, "NONE")) min = 0;
+		    max = atoi (maxWord);
+		    if (!strcasecmp (maxWord, "NONE")) max = 100;
+		    range = max - min;
+
+		    rvalue = psRandomUniform (rnd);
+		    value = range * rvalue + min;
+
+		    psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_S32, comment, value);
+		}
+
+		if (!strcasecmp (format, "K")) {
+		    long int value;
+
+		    char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
+		    char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
+
+		    min = atoi (minWord);
+		    if (!strcasecmp (minWord, "NONE")) min = 0;
+		    max = atoi (maxWord);
+		    if (!strcasecmp (maxWord, "NONE")) max = 100;
+		    range = max - min;
+
+		    rvalue = psRandomUniform (rnd);
+		    value = range * rvalue + min;
+
+		    psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_S64, comment, value);
+		}
+
+		if (!strcasecmp (format, "E")) {
+		    float value;
+
+		    char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
+		    char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
+
+		    min = atoi (minWord);
+		    if (!strcasecmp (minWord, "NONE")) min = 0;
+		    max = atoi (maxWord);
+		    if (!strcasecmp (maxWord, "NONE")) max = 100;
+		    range = max - min;
+
+		    rvalue = psRandomUniform (rnd);
+		    value = range * rvalue + min;
+
+		    psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_F32, comment, value);
+		}
+
+		if (!strcasecmp (format, "D")) {
+		    double value;
+
+		    char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
+		    char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
+
+		    min = atoi (minWord);
+		    if (!strcasecmp (minWord, "NONE")) min = 0;
+		    max = atoi (maxWord);
+		    if (!strcasecmp (maxWord, "NONE")) max = 100;
+		    range = max - min;
+
+		    rvalue = psRandomUniform (rnd);
+		    value = range * rvalue + min;
+
+		    psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_F64, comment, value);
+		}
+
+		if (!strcasecmp (format, "A")) {
+		    char *value = NULL;
+		    psStringAppend (&value, "word %03d", i);
+		    psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_STRING, "", value);
+		}
 	    }
-
-	    if (!strcasecmp (format, "J")) {
-		int value;
-
-		char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
-		char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
-
-		min = atoi (minWord);
-		if (!strcasecmp (minWord, "NONE")) min = 0;
-		max = atoi (maxWord);
-		if (!strcasecmp (maxWord, "NONE")) max = 100;
-		range = max - min;
-
-		rvalue = psRandomUniform (rnd);
-		value = range * rvalue + min;
-
-		psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_S32, comment, value);
-	    }
-
-	    if (!strcasecmp (format, "K")) {
-		long int value;
-
-		char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
-		char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
-
-		min = atoi (minWord);
-		if (!strcasecmp (minWord, "NONE")) min = 0;
-		max = atoi (maxWord);
-		if (!strcasecmp (maxWord, "NONE")) max = 100;
-		range = max - min;
-
-		rvalue = psRandomUniform (rnd);
-		value = range * rvalue + min;
-
-		psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_S64, comment, value);
-	    }
-
-	    if (!strcasecmp (format, "E")) {
-		float value;
-
-		char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
-		char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
-
-		min = atoi (minWord);
-		if (!strcasecmp (minWord, "NONE")) min = 0;
-		max = atoi (maxWord);
-		if (!strcasecmp (maxWord, "NONE")) max = 100;
-		range = max - min;
-
-		rvalue = psRandomUniform (rnd);
-		value = range * rvalue + min;
-
-		psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_F32, comment, value);
-	    }
-
-	    if (!strcasecmp (format, "D")) {
-		double value;
-
-		char *minWord = psMetadataLookupStr (NULL, md, "TMIN");
-		char *maxWord = psMetadataLookupStr (NULL, md, "TMAX");
-
-		min = atoi (minWord);
-		if (!strcasecmp (minWord, "NONE")) min = 0;
-		max = atoi (maxWord);
-		if (!strcasecmp (maxWord, "NONE")) max = 100;
-		range = max - min;
-
-		rvalue = psRandomUniform (rnd);
-		value = range * rvalue + min;
-
-		psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_F64, comment, value);
-	    }
-
-	    if (!strcasecmp (format, "A")) {
-		char *value = NULL;
-		psStringAppend (&value, "word %03d", i);
-		psMetadataAdd (row, PS_LIST_TAIL, col->name, PS_DATA_STRING, "", value);
-	    }
+	    psArrayAdd (table, 100, row);
+	    psFree (row);
+	    psMetadataIteratorSet (iter, PS_LIST_HEAD);
 	}
-        psArrayAdd (table, 100, row);
-        psFree (row);
-	psMetadataIteratorSet (iter, PS_LIST_HEAD);
-    }
-    psFitsWriteTable (fits, header, table, extname);
+	psFitsInsertTable (fits, header, table, extname, true);
+    }
     return 1;
 }
Index: /trunk/icd-demo/src/icd-test.c
===================================================================
--- /trunk/icd-demo/src/icd-test.c	(revision 9127)
+++ /trunk/icd-demo/src/icd-test.c	(revision 9127)
@@ -0,0 +1,71 @@
+# include <stdio.h>
+# include <strings.h>
+# include <math.h>
+# include "pslib.h"
+
+int main (int argc, char **argv) {
+
+    if (argc != 3) {
+	fprintf (stderr, "USAGE: icd-demo (input) (output)\n");
+	exit (2);
+    }
+
+    // construct a sample FITS table based on the given descriptive metadata file
+    psFits *fits = psFitsOpen (argv[2], "w");
+
+    {
+	psMetadata *header  = psMetadataAlloc ();
+	psMetadataAddStr (header, PS_LIST_HEAD, "EXTID", 0, "", "blank");
+	psFitsWriteBlank (fits, header, "blank");
+    }
+
+    {
+	psMetadata *header  = psMetadataAlloc ();
+	psMetadataAddStr (header, PS_LIST_HEAD, "EXTID", 0, "", "blank1");
+	psFitsWriteBlank (fits, header, "blank1");
+    }
+
+    {
+	psMetadata *header  = psMetadataAlloc ();
+	psMetadataAddStr (header, PS_LIST_HEAD, "EXTID", 0, "", "table1");
+
+	psArray *table = psArrayAlloc (100);
+	for (int i = 0; i < 10; i++) {
+	
+	    psMetadata *row = psMetadataAlloc ();
+	    psMetadataAdd (row, PS_LIST_TAIL, "N", PS_DATA_S16, "", i);
+	    psMetadataAdd (row, PS_LIST_TAIL, "F", PS_DATA_F32, "", i*0.2);
+	    psMetadataAdd (row, PS_LIST_TAIL, "G", PS_DATA_F32, "", i*0.5);
+	    psArrayAdd (table, 100, row);
+	    psFree (row);
+	}
+
+	psFitsInsertTable (fits, header, table, "table1", true);
+    }
+
+    {
+	psMetadata *header  = psMetadataAlloc ();
+	psMetadataAddStr (header, PS_LIST_HEAD, "EXTID", 0, "", "blank2");
+	psFitsWriteBlank (fits, header, "blank2");
+    }
+
+    {
+	psMetadata *header  = psMetadataAlloc ();
+	psMetadataAddStr (header, PS_LIST_HEAD, "EXTID", 0, "", "table2");
+
+	psArray *table = psArrayAlloc (100);
+	for (int i = 0; i < 10; i++) {
+	
+	    psMetadata *row = psMetadataAlloc ();
+	    psMetadataAdd (row, PS_LIST_TAIL, "N", PS_DATA_S16, "", i);
+	    psMetadataAdd (row, PS_LIST_TAIL, "F", PS_DATA_F32, "", i*0.2);
+	    psMetadataAdd (row, PS_LIST_TAIL, "G", PS_DATA_F32, "", i*0.5);
+	    psArrayAdd (table, 100, row);
+	    psFree (row);
+	}
+
+	psFitsInsertTable (fits, header, table, "table2", true);
+    }
+
+    psFitsClose (fits);
+}
