Index: trunk/Ohana/src/addstar/src/GetFileMode.c
===================================================================
--- trunk/Ohana/src/addstar/src/GetFileMode.c	(revision 35263)
+++ trunk/Ohana/src/addstar/src/GetFileMode.c	(revision 35416)
@@ -20,5 +20,8 @@
   havePHOT_VER = gfits_scan (header, "PHOT_VER", "%s", 1, ctmp);
   haveTARG_VER = gfits_scan (header, "TARG_VER", "%s", 1, ctmp);
-  if (havePHOT_VER && haveTARG_VER) return SDSS_OBJ;
+  if (havePHOT_VER && haveTARG_VER) {
+    if (VERBOSE) fprintf (stderr, "found SDSS objects\n");
+    return SDSS_OBJ;
+  }
 
   if (haveNaxis && (Naxis == 2)) {
@@ -28,6 +31,8 @@
     if ((Nx > 0) && (Ny > 0)) {
       if (haveCTYPE && !strcmp (&ctype[4], "-WRP")) {
+	if (VERBOSE) fprintf (stderr, "found MOSAIC CMP\n");
 	return MOSAIC_CMP;
       }
+      if (VERBOSE) fprintf (stderr, "found SIMPLE CMP\n");
       return SIMPLE_CMP;
     }
@@ -36,6 +41,8 @@
   if (haveNaxis && (TEXTMODE || !simple)) {
     if (haveCTYPE && !strcmp (&ctype[4], "-WRP")) {
+      if (VERBOSE) fprintf (stderr, "found MOSAIC CMP\n");
       return MOSAIC_CMP;
     }
+    if (VERBOSE) fprintf (stderr, "found SIMPLE CMP\n");
     return SIMPLE_CMP;
   }
@@ -43,21 +50,27 @@
   if (!extend && strcmp (&ctype[4], "-DIS")) {
     if (!strcmp (&ctype[4], "-WRP")) {
+      if (VERBOSE) fprintf (stderr, "found MOSAIC CMF\n");
       return MOSAIC_CMF;
     }
+    if (VERBOSE) fprintf (stderr, "found SIMPLE CMF\n");
     return SIMPLE_CMF;
   }
 
   if (!extend && !strcmp (&ctype[4], "-DIS")) {
+    if (VERBOSE) fprintf (stderr, "found MOSAIC PHU\n");
     return MOSAIC_PHU;
   }
 
   if (extend && strcmp (&ctype[4], "-DIS")) {
+    if (VERBOSE) fprintf (stderr, "found SIMPLE MEF\n");
     return SIMPLE_MEF;
   }
 
   if (extend && !strcmp (&ctype[4], "-DIS")) {
+    if (VERBOSE) fprintf (stderr, "found MOSAIC MEF\n");
     return MOSAIC_MEF;
   }
 
+  if (VERBOSE) fprintf (stderr, "extension type is unknown\n");
   return (NONE);
 }
Index: trunk/Ohana/src/addstar/src/MatchHeaders.c
===================================================================
--- trunk/Ohana/src/addstar/src/MatchHeaders.c	(revision 35263)
+++ trunk/Ohana/src/addstar/src/MatchHeaders.c	(revision 35416)
@@ -61,4 +61,7 @@
     if (!strcmp (exttype, "PS1_SV1")) goto keep;
     if (!strcmp (exttype, "PS1_SV2")) goto keep;
+    if (!strcmp (exttype, "PS1_DV3")) {
+      goto keep;
+    }
     continue;
 
Index: trunk/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 35263)
+++ trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 35416)
@@ -15,4 +15,5 @@
 Stars     *Convert_PS1_SV1_Alt	  PROTO((FTable *table, unsigned int *nstars));
 Stars     *Convert_PS1_SV2	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_DV3        PROTO((FTable *table, unsigned int *nstars));
 
 // given a file with the pointer at the start of the table block and the 
@@ -78,4 +79,7 @@
     stars = Convert_PS1_SV2 (&table, &Nstars);
   }
+  if (!strcmp (type, "PS1_DV3")) {
+    stars = Convert_PS1_DV3 (&table, &Nstars);
+  }
   if (stars == NULL) {
     fprintf (stderr, "invalid table type %s\n", type);
@@ -962,3 +966,85 @@
 }
 
-
+Stars *Convert_PS1_DV3 (FTable *table, unsigned int *nstars) {
+
+  off_t Nstars; 
+  unsigned int i;
+  double ZeroPt;
+  Stars *stars;
+  CMF_PS1_DV3 *ps1data;
+
+  ps1data = gfits_table_get_CMF_PS1_DV3 (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
+  ZeroPt = GetZeroPoint();
+
+  ALLOCATE (stars, Stars, Nstars);
+  for (i = 0; i < Nstars; i++) {
+    InitStar (&stars[i]);
+    stars[i].measure.Xccd       = ps1data[i].X;
+    stars[i].measure.Yccd       = ps1data[i].Y;
+    stars[i].measure.dXccd      = ToShortPixels(ps1data[i].dX);
+    stars[i].measure.dYccd      = ToShortPixels(ps1data[i].dY);
+
+    stars[i].measure.posangle   = ToShortDegrees(ps1data[i].posangle);
+    stars[i].measure.pltscale   = ps1data[i].pltscale;
+
+    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
+      stars[i].measure.M      = NAN;
+    } else {
+      stars[i].measure.M      = ps1data[i].M + ZeroPt;
+    }
+    stars[i].measure.dM         = ps1data[i].dM;
+    stars[i].measure.dMcal      = ps1data[i].dMcal;
+    stars[i].measure.Map        = ps1data[i].Map + ZeroPt;
+                        
+    stars[i].measure.Mkron      = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;
+    stars[i].measure.dMkron     = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;
+                        
+    // these fluxes are converted from counts to counts/sec in FilterStars.c
+    stars[i].measure.FluxPSF    = ps1data[i].Flux;
+    stars[i].measure.dFluxPSF   = ps1data[i].dFlux;
+    stars[i].measure.FluxKron   = ps1data[i].kronFlux;
+    stars[i].measure.dFluxKron  = ps1data[i].kronFluxErr;
+
+    stars[i].measure.Sky        = ps1data[i].sky;
+    stars[i].measure.dSky       = ps1data[i].dSky;
+                        
+    stars[i].measure.psfChisq   = ps1data[i].psfChisq;
+    stars[i].measure.psfQF      = ps1data[i].psfQF;
+    stars[i].measure.psfQFperf  = ps1data[i].psfQFperf;
+    stars[i].measure.psfNdof    = ps1data[i].psfNdof;
+    stars[i].measure.psfNpix    = ps1data[i].psfNpix;
+    stars[i].measure.crNsigma   = ps1data[i].crNsigma;
+    stars[i].measure.extNsigma  = ps1data[i].extNsigma;
+
+    stars[i].measure.FWx        = ToShortPixels(ps1data[i].fx);
+    stars[i].measure.FWy        = ToShortPixels(ps1data[i].fy);
+    stars[i].measure.theta      = ToShortDegrees(ps1data[i].df);
+
+    stars[i].measure.Mxx        = ToShortPixels(ps1data[i].Mxx);
+    stars[i].measure.Mxy        = ToShortPixels(ps1data[i].Mxy);
+    stars[i].measure.Myy        = ToShortPixels(ps1data[i].Myy);
+                        
+    stars[i].measure.photFlags  = ps1data[i].flags;
+
+    // this is may optionally be replaced by the internal sequence (see FilterStars.c)
+    stars[i].measure.detID      = ps1data[i].detID; 
+
+    // the Average fields and the following Measure fields are set in FilterStars after
+    // the image metadata is in hand:  dR, dD, Mcal, dt, airmass, az, t, imageID, extID.
+
+    // averef is set in find_matches
+
+    // dbFlags is zero on ingest.
+
+    // the following fields are currently not being set anywhere: t_msec
+  }    
+  *nstars = Nstars;
+  return (stars);
+}
+
+
+
Index: trunk/Ohana/src/addstar/src/load2mass_catalog.c
===================================================================
--- trunk/Ohana/src/addstar/src/load2mass_catalog.c	(revision 35263)
+++ trunk/Ohana/src/addstar/src/load2mass_catalog.c	(revision 35416)
@@ -20,31 +20,11 @@
     // XXX for now, the output objects will have limited astrometric interpretation...
     // XXX every 3 stars represents 3 measurements and 1 average
+    dvo_average_init (&catalog[0].average[Nave]);
     catalog[0].average[Nave].R     = stars[i].average.R;
     catalog[0].average[Nave].D     = stars[i].average.D;
-    catalog[0].average[Nave].dR    = 0;
-    catalog[0].average[Nave].dD    = 0;
-    catalog[0].average[Nave].uR    = 0;
-    catalog[0].average[Nave].uD    = 0;
-    catalog[0].average[Nave].duR   = 0;
-    catalog[0].average[Nave].duD   = 0;
-    catalog[0].average[Nave].P     = 0;
-    catalog[0].average[Nave].dP    = 0;
-
-    // XXX for now, set the average mag data to NULL
-    catalog[0].average[Nave].Nmeasure  	   = 0;
-    catalog[0].average[Nave].Nmissing  	   = 0;
-    catalog[0].average[Nave].ChiSqAve  	   = NAN_S_SHORT;
     catalog[0].average[Nave].measureOffset = Nmeas;
-    catalog[0].average[Nave].missingOffset = -1;
-    catalog[0].average[Nave].flags         = 0;
 
     for (j = 0; j < Nsec; j++) {
-      catalog[0].secfilt[Nave*Nsec+j].M     = NAN;
-      catalog[0].secfilt[Nave*Nsec+j].dM    = NAN;
-      catalog[0].secfilt[Nave*Nsec+j].Xm    = NAN_S_SHORT;
-      catalog[0].secfilt[Nave*Nsec+j].M_20  = NAN_S_SHORT;
-      catalog[0].secfilt[Nave*Nsec+j].M_80  = NAN_S_SHORT;
-      catalog[0].secfilt[Nave*Nsec+j].Ncode = 0;
-      catalog[0].secfilt[Nave*Nsec+j].Nused = 0;
+      dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsec+j]);
     }
 
