Index: /trunk/Ohana/src/libautocode/Makefile.Targets
===================================================================
--- /trunk/Ohana/src/libautocode/Makefile.Targets	(revision 33646)
+++ /trunk/Ohana/src/libautocode/Makefile.Targets	(revision 33647)
@@ -10,4 +10,5 @@
 $(ASRC)/average-ps1-v1.$(ARCH).o \
 $(ASRC)/average-ps1-v2.$(ARCH).o \
+$(ASRC)/average-ps1-v3.$(ARCH).o \
 $(ASRC)/average-ps1-ref.$(ARCH).o \
 $(ASRC)/secfilt.$(ARCH).o \
@@ -20,4 +21,5 @@
 $(ASRC)/secfilt-ps1-v1.$(ARCH).o \
 $(ASRC)/secfilt-ps1-v2.$(ARCH).o \
+$(ASRC)/secfilt-ps1-v3.$(ARCH).o \
 $(ASRC)/secfilt-ps1-ref.$(ARCH).o \
 $(ASRC)/measure.$(ARCH).o \
@@ -30,4 +32,5 @@
 $(ASRC)/measure-ps1-v1.$(ARCH).o \
 $(ASRC)/measure-ps1-v2.$(ARCH).o \
+$(ASRC)/measure-ps1-v3.$(ARCH).o \
 $(ASRC)/measure-ps1-ref.$(ARCH).o \
 $(ASRC)/missing.$(ARCH).o \
@@ -39,4 +42,5 @@
 $(ASRC)/photcode-ps1-v1.$(ARCH).o \
 $(ASRC)/photcode-ps1-v2.$(ARCH).o \
+$(ASRC)/photcode-ps1-v3.$(ARCH).o \
 $(ASRC)/photcode-ps1-ref.$(ARCH).o \
 $(ASRC)/image.$(ARCH).o \
@@ -50,4 +54,5 @@
 $(ASRC)/image-ps1-v1.$(ARCH).o \
 $(ASRC)/image-ps1-v2.$(ARCH).o \
+$(ASRC)/image-ps1-v3.$(ARCH).o \
 $(ASRC)/image-ps1-ref.$(ARCH).o \
 $(ASRC)/regimage.$(ARCH).o \
@@ -69,5 +74,7 @@
 $(ASRC)/GSCRegion.$(ARCH).o \
 $(ASRC)/AddstarClientOptions.$(ARCH).o \
-$(ASRC)/SkyRegion.$(ARCH).o
+$(ASRC)/SkyRegion.$(ARCH).o \
+$(ASRC)/FlatCorrectionImage.$(ARCH).o \
+$(ASRC)/FlatCorrection.$(ARCH).o
 
 AINCS = \
@@ -82,4 +89,5 @@
 $(AINC)/average-ps1-v1.h \
 $(AINC)/average-ps1-v2.h \
+$(AINC)/average-ps1-v3.h \
 $(AINC)/average-ps1-ref.h \
 $(AINC)/secfilt.h \
@@ -92,4 +100,5 @@
 $(AINC)/secfilt-ps1-v1.h \
 $(AINC)/secfilt-ps1-v2.h \
+$(AINC)/secfilt-ps1-v3.h \
 $(AINC)/secfilt-ps1-ref.h \
 $(AINC)/measure.h \
@@ -102,4 +111,5 @@
 $(AINC)/measure-ps1-v1.h \
 $(AINC)/measure-ps1-v2.h \
+$(AINC)/measure-ps1-v3.h \
 $(AINC)/measure-ps1-ref.h \
 $(AINC)/missing.h \
@@ -111,4 +121,5 @@
 $(AINC)/photcode-ps1-v1.h \
 $(AINC)/photcode-ps1-v2.h \
+$(AINC)/photcode-ps1-v3.h \
 $(AINC)/photcode-ps1-ref.h \
 $(AINC)/image.h \
@@ -122,4 +133,5 @@
 $(AINC)/image-ps1-v1.h \
 $(AINC)/image-ps1-v2.h \
+$(AINC)/image-ps1-v3.h \
 $(AINC)/image-ps1-ref.h \
 $(AINC)/regimage.h \
@@ -141,5 +153,7 @@
 $(AINC)/GSCRegion.h \
 $(AINC)/AddstarClientOptions.h \
-$(AINC)/SkyRegion.h
+$(AINC)/SkyRegion.h \
+$(AINC)/FlatCorrectionImage.h \
+$(AINC)/FlatCorrection.h
 
 # $(ASRC)/Stars.$(ARCH).o 
Index: /trunk/Ohana/src/libautocode/def/FlatCorrection.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/FlatCorrection.d	(revision 33647)
+++ /trunk/Ohana/src/libautocode/def/FlatCorrection.d	(revision 33647)
@@ -0,0 +1,9 @@
+STRUCT  FlatCorrection
+EXTNAME FLAT_CORRECTION
+TYPE    BINTABLE
+SIZE    16
+
+FIELD   ID,	   ID,	           int
+FIELD   x,	   X,	           int
+FIELD   y,	   Y,	           int
+FIELD   offset,    OFFSET,	   float
Index: /trunk/Ohana/src/libautocode/def/FlatCorrectionImage.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/FlatCorrectionImage.d	(revision 33647)
+++ /trunk/Ohana/src/libautocode/def/FlatCorrectionImage.d	(revision 33647)
@@ -0,0 +1,14 @@
+STRUCT  FlatCorrectionImage
+EXTNAME FLAT_CORRECTION_IMAGE
+TYPE    BINTABLE
+SIZE    32
+
+FIELD   tstart,	   TSTART,	   e_time, 
+FIELD   tstop,	   TSTOP,	   e_time, 
+FIELD   ID,	   ID,	           int
+FIELD   Nx,	   NX,	           int
+FIELD   Ny,	   NY,	           int
+FIELD   DX,	   DX,             int
+FIELD   DY,        DY,             int
+FIELD   photcode,  PHOTCODE,	   short
+FIELD   padding,   PADDING,	   short
Index: /trunk/Ohana/src/libautocode/def/SkyRegion.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/SkyRegion.d	(revision 33646)
+++ /trunk/Ohana/src/libautocode/def/SkyRegion.d	(revision 33647)
@@ -8,10 +8,26 @@
 FIELD   Dmin,	   D_MIN,	   float, 
 FIELD   Dmax,	   D_MAX,	   float, 
-FIELD   childS,	   CHILD_S,	   int,           sequence number in full table of first child
-FIELD   childE,	   CHILD_E,	   int,           sequence number in full table of last child + 1
-FIELD   parent,	   PARENT,	   int,           sequence number in full table of parent
-FIELD   index,     INDEX,          int,           sequence number in full table of this entry
-FIELD   depth,	   DEPTH,	   char,          depth of this entry
-FIELD   child,	   CHILD,	   char,          does this entry have children?
-FIELD   table,	   TABLE,	   char,          does this entry have a table?
-FIELD   name,      NAME,           char[21],      name / filename
+FIELD   childS,	   CHILD_S,	   int,            sequence number in full table of first child
+FIELD   childE,	   CHILD_E,	   int,            sequence number in full table of last child + 1
+FIELD   parent,	   PARENT,	   int,            sequence number in full table of parent
+FIELD   index,     INDEX,          int,            sequence number in full table of this entry
+FIELD   depth,	   DEPTH,	   char,           depth of this entry
+FIELD   child,	   CHILD,	   char,           does this entry have children?
+FIELD   table,	   TABLE,	   char,           does this entry have a table?
+FIELD   name,      NAME,           char[18],       name / filename
+FIELD   hostFlags, HOST_FLAGS,     char,           flags to define host / backup usage
+FIELD   hostID,    HOST_ID,        unsigned char,  host ID where data is stored
+FIELD   backupID,  BACKUP_ID,      unsigned char,  host ID where backup is stored
+
+# note : 2012.02.05 : stole 3 bytes from 'name' to use for host ID and
+#        related (no DBs were created with more than 17 bytes in the
+#        name).  The hostID points at an entry in the host table (text
+#        file, with name given in SkyTable PHU header).  There is no
+#        safety on this, but it is recoverable (by examining the
+#        directories) if misplaced.
+ 
+#        Note that SkyTables from databases generated in the past may
+#        have garbage characters here.  To ensure catch this
+#        condition, we add a header keyword to SkyTables in which the
+#        hostID has been set; if that is not present, the SkyTable
+#        loading software should init these bytes to 0 (== unassigned).
Index: /trunk/Ohana/src/libautocode/def/average-ps1-v2.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/average-ps1-v2.d	(revision 33646)
+++ /trunk/Ohana/src/libautocode/def/average-ps1-v2.d	(revision 33647)
@@ -9,6 +9,6 @@
 FIELD R,              RA,          double,          RA,                	       	  decimal degrees 
 FIELD D,              DEC,         double,          DEC,               	       	  decimal degrees 
-FIELD dR,             RA_ERR,      float,           RA error                      arcsec
-FIELD dD,             DEC_ERR,     float,           DEC error                     arcsec
+FIELD dR,             RA_ERR,      float,           RA error,                     arcsec
+FIELD dD,             DEC_ERR,     float,           DEC error,                    arcsec
 
 FIELD uR,             U_RA,        float,           RA*cos(D) proper-motion,      arcsec/year
Index: /trunk/Ohana/src/libautocode/def/average-ps1-v3.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/average-ps1-v3.d	(revision 33647)
+++ /trunk/Ohana/src/libautocode/def/average-ps1-v3.d	(revision 33647)
@@ -0,0 +1,62 @@
+STRUCT       Average_PS1_V3
+EXTNAME      DVO_AVERAGE_PS1_V3
+TYPE         BINTABLE
+SIZE         120
+DESCRIPTION  DVO Average Object Table
+
+# elements of data structure / FITS table
+
+FIELD R,              RA,          double,          RA,                	       	  decimal degrees 
+FIELD D,              DEC,         double,          DEC,               	       	  decimal degrees 
+FIELD dR,             RA_ERR,      float,           RA error,                     arcsec
+FIELD dD,             DEC_ERR,     float,           DEC error,                    arcsec
+
+FIELD uR,             U_RA,        float,           RA*cos(D) proper-motion,      arcsec/year
+FIELD uD,             U_DEC,       float,           DEC proper-motion,            arcsec/year
+FIELD duR,            V_RA_ERR,    float,           RA*cos(D) p-m error,          arcsec/year
+FIELD duD,            V_DEC_ERR,   float,           DEC p-m error,                arcsec/year
+FIELD P,              PAR,         float,           parallax,			  arcsec
+FIELD dP,             PAR_ERR,     float,           parallax error,               arcsec
+
+FIELD ChiSqAve,       CHISQ_POS,   float,           astrometry analysis chisq
+FIELD ChiSqPM,        CHISQ_PM,    float,           astrometry analysis chisq
+FIELD ChiSqPar,       CHISQ_PAP,   float,           astrometry analysis chisq
+FIELD Tmean,          MEAN_EPOCH,  int,   	    mean epoch (PM,PAR ref),       unix time seconds
+FIELD Trange,         TIME_RANGE,  int,   	    mean epoch (PM,PAR ref),       unix time seconds
+
+FIELD Xp,             SIGMA_POS,   float, 	    position scatter,   	  1/100 arcsec
+FIELD Npos,           NUMBER_POS,  unsigned short,  number of detections used for astrometry
+
+# this limits us to a max of 64k measurements per object
+FIELD Nmeasure,       NMEASURE,    unsigned short,  number of psf measurements
+FIELD Nmissing,       NMISSING,    unsigned short,  number of missings
+FIELD Nextend,        NEXTEND,     unsigned short,  number of extended measurements
+
+FIELD measureOffset,  OFF_MEASURE, uint32_t,   	    offset to first psf measurement
+FIELD missingOffset,  OFF_MISSING, uint32_t,   	    offset to first missing obs
+FIELD extendOffset,   OFF_EXTEND,  uint32_t,   	    offset to first extended measurement
+
+# 'flags' was called 'code' prior to 2009.02.07
+FIELD flags,          FLAGS,       uint32_t,        average object flags (star; ghost; etc)
+FIELD photFlagsUpper, PHOTFLAGS_U, uint32_t,        upper bit of 2 bit summary of per-measure photflags
+FIELD photFlagsLower, PHOTFLAGS_L, uint32_t,        lower bit of 2 bit summary of per-measure photflags
+
+# objID + catID gives a unique ID for all objects in the database
+FIELD objID,          OBJ_ID,      unsigned int,    unique ID for object in table
+FIELD catID,          CAT_ID,      unsigned int,    unique ID for table in which object was first realized
+FIELD extID,          EXT_ID,      uint64_t,        external ID for object (eg PSPS objID)
+
+# 2*8 + 1*8 + 12*4 + 7*4 + 4*2
+
+# photflagsUpper & photflagsLower: we have Nmeasures of a given source
+# using psphot. each of these as a photFlag field, with bits
+# describing the detection quality.  photflagsUpper and photFlagsLower
+# represent a 2 bit value (0-3) which defines the frequency of a given
+# bit in the measurements:
+# for a given bit, if that bit is raised for these percentile ranges,
+# the following bits are set:
+# min |  max | L | U
+#  0% |  25% | 0 | 0 
+# 25% |  50% | 1 | 0 
+# 50% |  75% | 0 | 1 
+# 75% | 100% | 1 | 1 
Index: /trunk/Ohana/src/libautocode/def/average.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/average.d	(revision 33646)
+++ /trunk/Ohana/src/libautocode/def/average.d	(revision 33647)
@@ -2,5 +2,5 @@
 EXTNAME      DVO_AVERAGE
 TYPE         BINTABLE
-SIZE         112
+SIZE         120
 DESCRIPTION  DVO Average Object Table
 
@@ -39,4 +39,6 @@
 # 'flags' was called 'code' prior to 2009.02.07
 FIELD flags,          FLAGS,       uint32_t,        average object flags (star; ghost; etc)
+FIELD photFlagsUpper, PHOTFLAGS_U, uint32_t,        upper bit of 2 bit summary of per-measure photflags
+FIELD photFlagsLower, PHOTFLAGS_L, uint32_t,        lower bit of 2 bit summary of per-measure photflags
 
 # objID + catID gives a unique ID for all objects in the database
@@ -54,2 +56,15 @@
 # *** 20100331 : new fields needed to assess astrometry analysis quality:
 
+
+# photflagsUpper & photflagsLower: we have Nmeasures of a given source
+# using psphot. each of these as a photFlag field, with bits
+# describing the detection quality.  photflagsUpper and photFlagsLower
+# represent a 2 bit value (0-3) which defines the frequency of a given
+# bit in the measurements:
+# for a given bit, if that bit is raised for these percentile ranges,
+# the following bits are set:
+# min |  max | L | U
+#  0% |  25% | 0 | 0 
+# 25% |  50% | 1 | 0 
+# 50% |  75% | 0 | 1 
+# 75% | 100% | 1 | 1 
Index: /trunk/Ohana/src/libautocode/def/image-ps1-v3.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/image-ps1-v3.d	(revision 33647)
+++ /trunk/Ohana/src/libautocode/def/image-ps1-v3.d	(revision 33647)
@@ -0,0 +1,75 @@
+STRUCT       Image_PS1_V3
+EXTNAME      DVO_IMAGE_PS1_V3
+TYPE         BINTABLE
+SIZE         360
+DESCRIPTION  DVO Image Table 
+
+# elements of the image structure
+
+SUBSTRUCT coords,           COORDS,               Coords,        astrometric data
+SUBFIELD  crval1,           CRVAL1,               double,   	 coordinate at reference pixel
+SUBFIELD  crval2,           CRVAL2,               double,  	 coordinate at reference pixel
+SUBFIELD  crpix1,           CRPIX1,               float,   	 coordinate of reference pixel
+SUBFIELD  crpix2,           CRPIX2,               float,   	 coordinate of reference pixel
+SUBFIELD  cdelt1,           CDELT1,               float,   	 degrees per pixel
+SUBFIELD  cdelt2,           CDELT2,               float,    	 degrees per pixel
+SUBFIELD  pc1_1,            PC1_1,                float,    	 rotation matrix
+SUBFIELD  pc1_2,            PC1_2,                float,    	 rotation matrix
+SUBFIELD  pc2_1,            PC2_1,                float,    	 rotation matrix
+SUBFIELD  pc2_2,            PC2_2,                float,    	 rotation matrix
+SUBFIELD  polyterms,        POLYTERMS,            float[7][2],	 higher order warping terms
+SUBFIELD  ctype,            CTYPE,                char[15],      coordinate type
+SUBFIELD  Npolyterms,       NPOLYTERMS,           char,     	 order of polynomial
+# 120 bytes
+
+FIELD 	  tzero,            TZERO,                e_time,         readout time (row 0)
+FIELD 	  nstar,            NSTAR,                unsigned int,   number of stars on image
+FIELD 	  secz,             SECZ,                 float,      	  airmass,                   mag
+FIELD 	  NX,               NX,                   unsigned short, image width
+FIELD 	  NY,               NY,                   unsigned short, image height
+FIELD 	  apmifit,          APMIFIT,              float,      	  aperture correction,       mag
+FIELD 	  dapmifit,         DAPMIFIT,             float,      	  apmifit error,             mag
+FIELD 	  Mcal,             MCAL,                 float,      	  calibration mag,           mag
+FIELD 	  dMcal,            DMCAL,                float,      	  error on Mcal,             mag
+FIELD 	  Xm,               XM,                   short,      	  image chisq,               10*log(value)
+FIELD 	  photcode,         PHOTCODE,             short,      	  identifier for CCD,
+FIELD 	  exptime,          EXPTIME,              float,          exposure time,             seconds
+FIELD     sidtime,          ST,			  float,          sidereal time of exposure
+FIELD     latitude,         LAT,		  float,          observatory latitude,      degrees
+# 40 bytes
+
+FIELD     RAo,              RA_CENTER,            float,          image center,              degrees
+FIELD     DECo,             DEC_CENTER,           float,          image center,              degrees
+FIELD     Radius,           RADIUS,               float,          image radius,              degrees
+FIELD     DUMMY,            DUMMY,                float,          dummy
+
+# should we define the max length of name as a macro?
+FIELD 	  name,             NAME,                 char[121],      name of original image 
+FIELD 	  detection_limit,  DETECTION_LIMIT,      unsigned char,  detection limit,           10*mag
+FIELD 	  saturation_limit, SATURATION_LIMIT,     unsigned char,  saturation limit,          10*mag
+FIELD 	  cerror,           CERROR,               unsigned char,  astrometric error,         50*arcsec
+FIELD 	  fwhm_x,           FWHM_X,               unsigned char,  PSF x width,               25*arcsec
+FIELD 	  fwhm_y,           FWHM_Y,               unsigned char,  PSF y width,               25*arcsec
+FIELD 	  trate,            TRATE,                unsigned char,  scan rate,                 100 usec/pixel
+FIELD 	  ccdnum,           CCDNUM,               unsigned char,  CCD ID number
+FIELD 	  flags,            FLAGS,                unsigned int,   image quality flags
+FIELD 	  imageID,          IMAGE_ID,             unsigned int,   internal image ID
+FIELD 	  parentID,         PARENT_ID,            unsigned int,   associated ref image
+FIELD 	  externID,         EXTERN_ID,            unsigned int,   external image ID
+FIELD 	  sourceID,         SOURCE_ID,            unsigned short, analysis source ID
+# 48 bytes 
+
+FIELD 	  nLinkAstrom,      NLINK_ASTROM,         short,      	  mean number of matched measurements for astrometry
+FIELD 	  nLinkPhotom,      NLINK_PHOTOM,         short,      	  mean number of matched measurements for astrometry
+FIELD 	  ubercalDist,      UBERCAL_DIST,         short,      	  distance to nearest ubercal image
+
+FIELD 	  dXpixSys,         XPIX_SYS_ERR,         float,      	  systematic astrometry error in X
+FIELD 	  dYpixSys,         YPIX_SYS_ERR,         float,      	  systematic astrometry error in Y
+
+FIELD 	  dMagSys,          MAG_SYS_ERR,          float,      	  systematic photometry error
+FIELD 	  nFitAstrom,       N_FIT_ASTROM,         short,      	  number of stars used for astrometry cal
+FIELD 	  nFitPhotom,       N_FIT_PHOTOM,         short,      	  number of stars used for photometry cal
+
+FIELD 	  photom_map_id,    PHOTOM_MAP_ID,        unsigned int,   reference to 2D zero point map
+FIELD 	  astrom_map_id,    ASTROM_MAP_ID,        unsigned int,   reference to 2D astrometry map
+# nFitPhotom lands on the old location of Mxxxx, which was used to mean nFitPhotom in some cases
Index: /trunk/Ohana/src/libautocode/def/image.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/image.d	(revision 33646)
+++ /trunk/Ohana/src/libautocode/def/image.d	(revision 33647)
@@ -1,3 +1,3 @@
- STRUCT       Image
+STRUCT       Image
 EXTNAME      DVO_IMAGE
 TYPE         BINTABLE
@@ -63,5 +63,5 @@
 FIELD 	  nLinkAstrom,      NLINK_ASTROM,         short,      	  mean number of matched measurements for astrometry
 FIELD 	  nLinkPhotom,      NLINK_PHOTOM,         short,      	  mean number of matched measurements for astrometry
-FIELD 	  dummy3,           DUMMY3,               short,      	  place holder for byte boundaries
+FIELD 	  ubercalDist,      UBERCAL_DIST,         short,      	  distance to nearest ubercal image
 
 FIELD 	  dXpixSys,         XPIX_SYS_ERR,         float,      	  systematic astrometry error in X
Index: /trunk/Ohana/src/libautocode/def/measure-ps1-v3.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/measure-ps1-v3.d	(revision 33647)
+++ /trunk/Ohana/src/libautocode/def/measure-ps1-v3.d	(revision 33647)
@@ -0,0 +1,82 @@
+STRUCT       Measure_PS1_V3
+EXTNAME      DVO_MEASURE_PS1_V3
+TYPE         BINTABLE
+SIZE         152
+DESCRIPTION  DVO Detection Measurement Table 
+
+FIELD dR,             D_RA,         float,          RA offset,                	  arcsec
+FIELD dD,             D_DEC,        float,          DEC offset,               	  arcsec
+FIELD M,              MAG,          float,          catalog mag,       	       	  mag
+FIELD Mcal,           M_CAL,        float,          image cal mag,	          mag
+FIELD Map,            M_APER,       float,          aperture mag,		  mag
+FIELD dM,             MAG_ERR,      float,          mag error,                    mag
+FIELD dMcal,          MAG_CAL_ERR,  float,          systematic calibration error, mag
+FIELD dt,             M_TIME,       float,          exposure time,                2.5*log(exptime)
+
+# note that with airmass = 1.0 / cos(90 - alt), we have full alt/az representation
+FIELD airmass,        AIRMASS,      float,          (airmass - 1),		  airmass
+FIELD az,             AZ,           float,          telescope azimuth
+
+# new field elements needed for Pan-STARRS:
+FIELD Xccd,           X_CCD,        float,          X coord on chip,               pixels
+FIELD Yccd,           Y_CCD,        float,          Y coord on chip,               pixels
+
+# could these be packed into fewer bits?
+FIELD Sky,            SKY_FLUX,     float,          local estimate of sky flux,    counts/sec
+FIELD dSky,           SKY_FLUX_ERR, float,          local estimate of sky flux,    counts/sec
+
+FIELD t,              TIME,         int,   	    time in seconds (UNIX)
+FIELD averef,         AVE_REF,      unsigned int,   reference to average entry      
+
+# internally, this is an unsigned int; however, we do NOT convert with TZERO/TSCAL on output
+FIELD detID,          DET_ID,       unsigned int,   detection ID
+FIELD imageID,        IMAGE_ID,     unsigned int,   reference to DVO image ID
+FIELD objID,          OBJ_ID,       unsigned int,   unique ID for object in table
+FIELD catID,          CAT_ID,       unsigned int,   unique ID for table in which object was first realized
+
+# PSPS uses a 64-bit detection ID
+FIELD extID,          EXT_ID,       uint64_t,       external ID (eg PSPS detID)
+
+# do we need more resolution than a short? should this be a log?
+FIELD psfQual,        PSF_QF,       float,          psf coverage/quality factor
+FIELD psfChisq,       PSF_CHISQ,    float,          psf fit chisq
+FIELD psfNdof,        PSF_NDOF,     int,            psf degrees of freedom
+FIELD psfNpix,        PSF_NPIX,     int,            psf number of pixels
+FIELD crNsigma,       CR_NSIGMA,    float,          Nsigma deviation towards CR
+FIELD extNsigma,      EXT_NSIGMA,   float,          Nsigma deviation towards EXT
+
+# model shape parameters
+FIELD FWx,            FWHM_MAJOR,   short,          object fwhm major axis,         1/100 of pixels
+FIELD FWy,            FWHM_MINOR,   short,          object fwhm minor axis,         1/100 of pixels 
+FIELD theta,          PSF_THETA,    short,          angle wrt ccd X dir,            (0xffff/360) deg
+
+# moments
+FIELD Mxx,            MXX,          short,          second moments in pixel coords, 1/100 of pixels
+FIELD Mxy,            MXY,          short,          second moments in pixel coords, 1/100 of pixels
+FIELD Myy,            MYY,          short,          second moments in pixel coords, 1/100 of pixels
+
+# fractional exposure time
+FIELD t_msec,         TIME_MSEC,    unsigned short, time fraction of second,       milliseconds
+FIELD photcode,       PHOTCODE,     unsigned short, photcode
+
+# position errors
+FIELD dXccd,          X_CCD_ERR,    short,          X coord error on chip,          1/100 of pixels
+FIELD dYccd,          Y_CCD_ERR,    short,          Y coord error on chip,          1/100 of pixels
+FIELD dRsys,          POS_SYS_ERR,  short,          systematic error from astrom,   1/100 of pixels
+
+FIELD pad,            PAD,          char[4],        padding
+
+# local astrometry scales
+FIELD posangle,       POSANGLE,     short,          position angle sky to chip,     (0xffff/360) deg
+FIELD pltscale,       PLTSCALE,     float,          plate scale,                    arcsec/pixel
+
+FIELD dbFlags,        DB_FLAGS,     unsigned int,   flags supplied by analysis in database
+FIELD photFlags,      PHOT_FLAGS,   unsigned int,   flags supplied by photometry program
+
+
+# 19 x float
+# 6 x int or unsigned int
+# 11 x short or unsigned short
+# 3 x uint64_t
+
+# = 
Index: /trunk/Ohana/src/libautocode/def/photcode-ps1-v3.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/photcode-ps1-v3.d	(revision 33647)
+++ /trunk/Ohana/src/libautocode/def/photcode-ps1-v3.d	(revision 33647)
@@ -0,0 +1,33 @@
+STRUCT       PhotCode_PS1_V3
+EXTNAME      DVO_PHOTCODE_PS1_V3
+TYPE         BINTABLE
+SIZE         112
+DESCRIPTION  DVO Photcode Description Table 
+
+# elements of data structure / FITS table
+FIELD  code,         	  CODE,          	 unsigned short, code number (stored in Measure.source) 
+FIELD  name,         	  NAME,          	 char[32],       name for filter combination 
+FIELD  type,         	  TYPE,          	 char,           PRI/SEC/DEP/REF 
+FIELD  dummy,        	  DUMMY,         	 char[3],        padding
+FIELD  C,            	  C_LAM,         	 short,          primary phot calibration terms (millimags) 
+FIELD  dC,           	  C_LAM_ERR,     	 short,          primary phot calibration terms (millimags) 
+FIELD  dX,           	  X_ERR,         	 short,          primary phot calibration terms (millimags) 
+FIELD  K,            	  K,             	 float,          secondary phot calibration terms (millimags) 
+FIELD  c1,           	  C1,            	 int,            color is average.M[c1] - average.M[c2] 
+FIELD  c2,           	  C2,            	 int,            color is average.M[c1] - average.M[c2] 
+FIELD  equiv,        	  EQUIV,         	 int,            this dependent filter is equivalent to equiv PRI/SEC
+FIELD  Nc,           	  NC,            	 int,            number of color terms 
+FIELD  X,            	  X,             	 float[4],       color terms $X[0]*mc + X[1]*mc^2 + X[2]*mc^3$, etc 
+FIELD  astromErrSys,      ASTROM_ERR_SYS,  	 float,          systematic astrometry error (arcsec)
+FIELD  astromErrScale,    ASTROM_ERR_SCALE,  	 float,          astrometric error scale
+FIELD  astromErrMagScale, ASTROM_ERR_MAG_SCALE,  float,          astrometric error / mag error scale
+FIELD  astromPoorMask,    ASTROM_POOR_MASK,      int,            detections matching this mask should only be used in emergencies
+FIELD  astromBadMask,     ASTROM_BAD_MASK,       int,            detections matching this mask should not be used
+FIELD  photomErrSys,   	  PHOTOM_ERR_SYS,  	 float,          systematic photometric error
+FIELD  photomPoorMask, 	  PHOTOM_POOR_MASK,  	 int,            detections matching this mask should only be used in emergencies
+FIELD  photomBadMask,  	  PHOTOM_BAD_MASK,  	 int,            detections matching this mask should not be used
+
+#   dR_total^2 =  dR_sys^2 + AS * dR_obs^2 + MS * dM_obs^2
+#   dR_sys : systematicAstrometryError
+#   AS     : astrometryErrorScale
+#   MS     : astrometryErrorMagScale
Index: /trunk/Ohana/src/libautocode/def/photcode.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/photcode.d	(revision 33646)
+++ /trunk/Ohana/src/libautocode/def/photcode.d	(revision 33647)
@@ -2,5 +2,5 @@
 EXTNAME      DVO_PHOTCODE_RAW
 TYPE         BINTABLE
-SIZE         104
+SIZE         112
 DESCRIPTION  DVO Photcode Description Table 
 
@@ -22,9 +22,9 @@
 FIELD  astromErrScale,    ASTROM_ERR_SCALE,  	 float,          astrometric error scale
 FIELD  astromErrMagScale, ASTROM_ERR_MAG_SCALE,  float,          astrometric error / mag error scale
-FIELD  astromPoorMask,    ASTROM_POOR_MASK,      short,          detections matching this mask should only be used in emergencies
-FIELD  astromBadMask,     ASTROM_BAD_MASK,       short,          detections matching this mask should not be used
+FIELD  astromPoorMask,    ASTROM_POOR_MASK,      int,            detections matching this mask should only be used in emergencies
+FIELD  astromBadMask,     ASTROM_BAD_MASK,       int,            detections matching this mask should not be used
 FIELD  photomErrSys,   	  PHOTOM_ERR_SYS,  	 float,          systematic photometric error
-FIELD  photomPoorMask, 	  PHOTOM_POOR_MASK,  	 short,          detections matching this mask should only be used in emergencies
-FIELD  photomBadMask,  	  PHOTOM_BAD_MASK,  	 short,          detections matching this mask should not be used
+FIELD  photomPoorMask, 	  PHOTOM_POOR_MASK,  	 int,            detections matching this mask should only be used in emergencies
+FIELD  photomBadMask,  	  PHOTOM_BAD_MASK,  	 int,            detections matching this mask should not be used
 
 #   dR_total^2 =  dR_sys^2 + AS * dR_obs^2 + MS * dM_obs^2
Index: /trunk/Ohana/src/libautocode/def/secfilt-ps1-v3.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/secfilt-ps1-v3.d	(revision 33647)
+++ /trunk/Ohana/src/libautocode/def/secfilt-ps1-v3.d	(revision 33647)
@@ -0,0 +1,18 @@
+STRUCT       SecFilt_PS1_V3
+EXTNAME      DVO_SECFILT_PS1_V3
+TYPE         BINTABLE
+SIZE         32
+DESCRIPTION  DVO SecFilt : Secondary Filter Data 
+
+# elements of data structure / FITS table
+FIELD  M,     	    MAG,      	  float,      average mag in this band,              mags
+FIELD  Map,    	    MAG_AP,    	  float,      ave aperture mag in this band,         mags
+FIELD  dM,    	    MAG_ERR,  	  float,      formal error on average mag,           mags
+FIELD  Xm,    	    MAG_CHI,  	  float,      chisq on average mag,                  [100*log(value)]
+FIELD  flags, 	    FLAGS,    	  uint32_t,   photometry flags
+FIELD  Ncode, 	    NCODE,    	  short,      number of detections in band
+FIELD  Nused, 	    NUSED,    	  short,      number of detections used in average
+FIELD  M_20,  	    MAG_20,   	  short,      lower 20percent mag,                   millimags
+FIELD  M_80,  	    MAG_80,   	  short,      upper 20percent mag,                   millimags
+FIELD  ubercalDist, UBERCAL_DIST, short,      number of images from an ubercal-image
+FIELD  dummy,       DUMMY,        char[2],    padding
Index: /trunk/Ohana/src/libautocode/def/secfilt.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/secfilt.d	(revision 33646)
+++ /trunk/Ohana/src/libautocode/def/secfilt.d	(revision 33647)
@@ -2,16 +2,20 @@
 EXTNAME      DVO_SECFILT
 TYPE         BINTABLE
-SIZE         24
+SIZE         32
 DESCRIPTION  DVO SecFilt : Secondary Filter Data 
 
 # elements of data structure / FITS table
-FIELD  M,     MAG,      float,                other mags,       mags
-FIELD  dM,    MAG_ERR,  float,                scatter on mag,   mags
-FIELD  Xm,    MAG_CHI,  float,                chisq on average mag,     [100*log(value)]
-FIELD  flags, FLAGS,    uint32_t,             photometry flags
-FIELD  Ncode, NCODE,    short,                number of detections in band
-FIELD  Nused, NUSED,    short,                number of detections used in average
-FIELD  M_20,  MAG_20,   short,                lower 20percent mag,      millimags
-FIELD  M_80,  MAG_80,   short,                upper 20percent mag,      millimags
+FIELD  M,     	    MAG,      	  float,      average mag in this band,              mags
+FIELD  Map,    	    MAG,      	  float,      average mag in this band,              mags
+FIELD  dM,    	    MAG_ERR,  	  float,      formal error on average mag,           mags
+FIELD  Xm,    	    MAG_CHI,  	  float,      chisq on average mag,                  [100*log(value)]
+FIELD  flags, 	    FLAGS,    	  uint32_t,   photometry flags
+FIELD  Ncode, 	    NCODE,    	  short,      number of detections in band
+FIELD  Nused, 	    NUSED,    	  short,      number of detections used in average
+FIELD  M_20,  	    MAG_20,   	  short,      lower 20percent mag,                   millimags
+FIELD  M_80,  	    MAG_80,   	  short,      upper 20percent mag,                   millimags
+FIELD  ubercalDist, UBERCAL_DIST, short,      number of images from an ubercal-image
+FIELD  dummy,       DUMMY,        char[2],    padding
 
 # *** 20090206 : new fields : M_20, M_80; dropped dummy
+# *** 20120302 : new fields : ubercalDist, Map, dummy[2byte]
