Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 28855)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 29001)
@@ -85,29 +85,36 @@
 # define PHOT_MAG 0x06  /* generic magnitude; never stored */
 
-/* Image.code values.  these are codes to note bad images */
-# define ID_IMAGE_NEW   0x0000  /* no nrphot attempted */
-# define ID_IMAGE_NOCAL 0x0001  /* used within nrphot to mean "don't apply fit" */
-# define ID_IMAGE_POOR  0x0002  /* relphot says image is bad */
-# define ID_IMAGE_SKIP  0x0004  /* external information image is bad */
-# define ID_IMAGE_FEW   0x0008  /* currently too few measurements for good value */
+/* Image.code values -- these values are 32 bit (as of PS1_V1) */
+typedef enum {
+  ID_IMAGE_NEW          = 0x00000000,  /* no calibrations yet attempted */
+  ID_IMAGE_PHOTOM_NOCAL = 0x00000001,  /* user-set value used within relphot: ignore */
+  ID_IMAGE_PHOTOM_POOR  = 0x00000002,  /* relphot says image is bad (dMcal > limit) */
+  ID_IMAGE_PHOTOM_SKIP  = 0x00000004,  /* user-set value: assert that this image has bad photometry */
+  ID_IMAGE_PHOTOM_FEW   = 0x00000008,  /* currently too few measurements for photometry */
+  ID_IMAGE_ASTROM_NOCAL = 0x00000010,  /* user-set value used within relastro: ignore */
+  ID_IMAGE_ASTROM_POOR  = 0x00000020,  /* relastro says image is bad (dR,dD > limit) */
+  ID_IMAGE_ASTROM_FAIL  = 0x00000040,  /* relastro fit diverged, fit not applied */
+  ID_IMAGE_ASTROM_SKIP  = 0x00000080,  /* user-set value: assert that this image has bad astrometry */
+  ID_IMAGE_ASTROM_FEW   = 0x00000100,  /* currently too few measurements for astrometry */
+} DVOImageFlags;
 
 /* Measure.flags values -- these values are 32 bit (as of PS1_V1) */
 typedef enum {
-  ID_MEAS_NOCAL        = 0x0001,  // detection ignored for this analysis (photcode, time range) -- internal only 
-  ID_MEAS_POOR_PHOTOM  = 0x0002,  // detection is photometry outlier					     	  
-  ID_MEAS_SKIP_PHOTOM  = 0x0004,  // detection was ignored for photometry measurement			     	  
-  ID_MEAS_AREA         = 0x0008,  // detection near image edge						     
-  ID_MEAS_POOR_ASTROM  = 0x0010,  // detection is astrometry outlier					     	  
-  ID_MEAS_SKIP_ASTROM  = 0x0020,  // detection was ignored for astrometry measurement			     	  
-  ID_MEAS_USED_OBJ     = 0x0040,  // detection was used during opdate objects				     
-  ID_MEAS_USED_CHIP    = 0x0080,  // detection was used during update chips					     
-  ID_MEAS_BLEND_MEAS   = 0x0100,  // detection is within radius of multiple objects				     
-  ID_MEAS_BLEND_OBJ    = 0x0200,  // multiple detections within radius of object				     
-  ID_MEAS_UNDEF_3      = 0x0400,  // unused									     
-  ID_MEAS_UNDEF_4      = 0x0800,  // unused									     
-  ID_MEAS_BLEND_MEAS_X = 0x1000,  // detection is within radius of multiple objects across catalogs		     
-  ID_MEAS_ARTIFACT     = 0x2000,  // detection is thought to be non-astronomical				     
-  ID_MEAS_UNDEF_5      = 0x4000,  // unused									     
-  ID_MEAS_UNDEF_6      = 0x8000,  // unused									     
+  ID_MEAS_NOCAL        = 0x00000001,  // detection ignored for this analysis (photcode, time range) -- internal only 
+  ID_MEAS_POOR_PHOTOM  = 0x00000002,  // detection is photometry outlier					     	  
+  ID_MEAS_SKIP_PHOTOM  = 0x00000004,  // detection was ignored for photometry measurement			     	  
+  ID_MEAS_AREA         = 0x00000008,  // detection near image edge						     
+  ID_MEAS_POOR_ASTROM  = 0x00000010,  // detection is astrometry outlier					     	  
+  ID_MEAS_SKIP_ASTROM  = 0x00000020,  // detection was ignored for astrometry measurement			     	  
+  ID_MEAS_USED_OBJ     = 0x00000040,  // detection was used during opdate objects				     
+  ID_MEAS_USED_CHIP    = 0x00000080,  // detection was used during update chips					     
+  ID_MEAS_BLEND_MEAS   = 0x00000100,  // detection is within radius of multiple objects				     
+  ID_MEAS_BLEND_OBJ    = 0x00000200,  // multiple detections within radius of object				     
+  ID_MEAS_UNDEF_3      = 0x00000400,  // unused									     
+  ID_MEAS_UNDEF_4      = 0x00000800,  // unused									     
+  ID_MEAS_BLEND_MEAS_X = 0x00001000,  // detection is within radius of multiple objects across catalogs		     
+  ID_MEAS_ARTIFACT     = 0x00002000,  // detection is thought to be non-astronomical				     
+  ID_MEAS_UNDEF_5      = 0x00004000,  // unused									     
+  ID_MEAS_UNDEF_6      = 0x00008000,  // unused									     
 } DVOMeasureFlags;
 
@@ -147,4 +154,8 @@
   ID_STAR_USE_PM  = 0x00100000, // proper motion used (not AVE or PAR)
   ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM)
+  ID_OBJ_EXT      = 0x01000000, // extended in our data (eg, PS)
+  ID_OBJ_EXT_ALT  = 0x02000000, // extended in external data (eg, 2MASS)
+  ID_OBJ_GOOD     = 0x04000000, // good-quality measurement in our data (eg, PS)
+  ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS)
 } DVOAverageFlags;
 
Index: trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
===================================================================
--- trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c	(revision 28855)
+++ trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c	(revision 29001)
@@ -43,4 +43,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE")) {
     PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_elixir) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode);
     free (photcode_elixir);
@@ -49,4 +53,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE_ELIXIR")) {
     PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_elixir) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode);
     free (photcode_elixir);
@@ -55,4 +63,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_1")) {
     PhotCode_PS1_DEV_1 *photcode_ps1_dev_1 = gfits_table_get_PhotCode_PS1_DEV_1 (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_ps1_dev_1) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_PS1_DEV_1_To_Internal (photcode_ps1_dev_1, Ncode);
     free (photcode_ps1_dev_1);
@@ -61,4 +73,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_2")) {
     PhotCode_PS1_DEV_2 *photcode_ps1_dev_2 = gfits_table_get_PhotCode_PS1_DEV_2 (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_ps1_dev_2) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_PS1_DEV_2_To_Internal (photcode_ps1_dev_2, Ncode);
     free (photcode_ps1_dev_2);
@@ -67,4 +83,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_3")) {
     PhotCode_PS1_DEV_3 *photcode_ps1_dev_3 = gfits_table_get_PhotCode_PS1_DEV_3 (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_ps1_dev_3) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_PS1_DEV_3_To_Internal (photcode_ps1_dev_3, Ncode);
     free (photcode_ps1_dev_3);
@@ -73,4 +93,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE_PS1_V1")) {
     PhotCode_PS1_V1 *photcode_ps1_v1 = gfits_table_get_PhotCode_PS1_V1 (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_ps1_v1) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_PS1_V1_To_Internal (photcode_ps1_v1, Ncode);
     free (photcode_ps1_v1);
@@ -79,4 +103,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE_PS1_V2")) {
     PhotCode_PS1_V2 *photcode_ps1_v2 = gfits_table_get_PhotCode_PS1_V2 (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_ps1_v2) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_PS1_V2_To_Internal (photcode_ps1_v2, Ncode);
     free (photcode_ps1_v2);
@@ -85,4 +113,8 @@
   if (!strcmp (extname, "DVO_PHOTCODE_PS1_REF")) {
     PhotCode_PS1_REF *photcode_ps1_ref = gfits_table_get_PhotCode_PS1_REF (&db.ftable, &Ncode, &db.swapped);
+    if (!photcode_ps1_ref) {
+      fprintf (stderr, "ERROR: failed to read photcodes\n");
+      exit (2);
+    }
     photcode = PhotCode_PS1_REF_To_Internal (photcode_ps1_ref, Ncode);
     free (photcode_ps1_ref);
Index: trunk/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c
===================================================================
--- trunk/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c	(revision 28855)
+++ trunk/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c	(revision 29001)
@@ -14,5 +14,5 @@
   if (ftable[0].header[0].Naxis[0] != 136) { 
     fprintf (stderr, "ERROR: wrong format for CMF_PS1_V1_Alt: "OFF_T_FMT" vs %d\n",  ftable[0].header[0].Naxis[0], 136);
-    exit (2);
+    return (NULL);
   }
 
Index: trunk/Ohana/src/libdvo/src/coordops.c
===================================================================
--- trunk/Ohana/src/libdvo/src/coordops.c	(revision 28855)
+++ trunk/Ohana/src/libdvo/src/coordops.c	(revision 29001)
@@ -20,5 +20,10 @@
 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords) {
 
+  OhanaProjection proj;
+  OhanaProjectionMode mode;
   double X, Y, X2, XY, Y2, X3, Y3;
+
+  proj = GetProjection (coords[0].ctype);
+  mode = GetProjectionMode (proj);
 
   /** convert pixel coordinates to cartesian system **/
@@ -45,4 +50,9 @@
   }
 
+  if (mode == PROJ_MODE_CARTESIAN) {
+    *L += coords[0].crval1;
+    *M += coords[0].crval2;
+  }
+
   return (TRUE);
 }
@@ -64,11 +74,8 @@
   /** Locally Cartesian Projections **/
   if (mode == PROJ_MODE_CARTESIAN) {
-    *ra  = L + coords[0].crval1;
-    *dec = M + coords[0].crval2;
-
     /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */
     if (proj == PROJ_WRP) {
       if (!gotMosaic) return (FALSE);
-      XY_to_RD (ra, dec, *ra, *dec, &mosaic);
+      XY_to_RD (ra, dec, L, M, &mosaic);
     }
     return (TRUE);
@@ -183,5 +190,4 @@
 
   double phi, theta;
-  double Lo, Mo;
   double sphi, cphi, stht, ctht;
   double salp, calp, sdel, cdel, sdp, cdp;
@@ -201,11 +207,9 @@
     if (proj == PROJ_WRP) {
       if (!gotMosaic) return (FALSE);
-      RD_to_XY (&Lo, &Mo, ra, dec, &mosaic);
-      *L = (Lo - coords[0].crval1);
-      *M = (Mo - coords[0].crval2);
+      RD_to_XY (L, M, ra, dec, &mosaic);
       return (TRUE);
     }
-    *L = (ra  - coords[0].crval1);
-    *M = (dec - coords[0].crval2);
+    *L = ra;
+    *M = dec;
     return (TRUE);
   }
@@ -310,7 +314,17 @@
   double dX, dY, Lo, Mo, dL, dM;
   double dLdX, dLdY, dMdX, dMdY, Do;
+  OhanaProjection proj;
+  OhanaProjectionMode mode;
+
+  proj = GetProjection (coords[0].ctype);
+  mode = GetProjectionMode (proj);
 
   *x = 0;
   *y = 0;
+
+  if (mode == PROJ_MODE_CARTESIAN) {
+    L -= coords[0].crval1;
+    M -= coords[0].crval2;
+  }
 
   /* start with linear solution for X,Y */
@@ -422,4 +436,6 @@
 }
 
+enum {COORD_TYPE_NONE, COORD_TYPE_PC, COORD_TYPE_ROT, COORD_TYPE_CD, COORD_TYPE_LIN};
+
 int GetCoords (Coords *coords, Header *header) {
   
@@ -428,4 +444,5 @@
   double equinox;
   char *ctype;
+  int mode;
   
   rotate = 0.0;
@@ -437,25 +454,45 @@
   strcpy (coords[0].ctype, "NONE");
   
-  status = FALSE; 
-  if (gfits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) {
-    status  = gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
-    status &= gfits_scan (header, "CRPIX1", "%f", 1, &coords[0].crpix1);
-    status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2);  
-    status &= gfits_scan (header, "CRPIX2", "%f", 1, &coords[0].crpix2);
-
-    if (gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1)) {
-      status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
-      if (gfits_scan (header, "CROTA2", "%lf", 1, &rotate)) {
-	Lambda = coords[0].cdelt2 / coords[0].cdelt1;
-	coords[0].pc1_1 =  cos(rotate*RAD_DEG);
-	coords[0].pc1_2 = -sin(rotate*RAD_DEG) * Lambda;
-	coords[0].pc2_1 =  sin(rotate*RAD_DEG) / Lambda;
-	coords[0].pc2_2 =  cos(rotate*RAD_DEG);
-      }
-      if (gfits_scan (header, "PC001001", "%f", 1, &coords[0].pc1_1)) {
-	status &= gfits_scan (header, "PC001002", "%f", 1, &coords[0].pc1_2);
-	status &= gfits_scan (header, "PC002001", "%f", 1, &coords[0].pc2_1);
-	status &= gfits_scan (header, "PC002002", "%f", 1, &coords[0].pc2_2);
-      }
+  mode = COORD_TYPE_NONE;
+  {    
+    int haveCTYPE, haveCDELT, haveCROTA, haveCDij, havePCij, haveRAo;
+    float tmp;
+    char stmp[80];
+    
+    // there are a few different representations for scale and rotation.  choose an appropriate
+    // set: (CDELTi + CROTAi), (CDELTi + PCij), (CDij), 
+
+    haveCTYPE = gfits_scan (header, "CTYPE2",   "%s", 1, stmp);
+    haveCDELT = gfits_scan (header, "CDELT1",   "%f", 1, &tmp);
+    haveCROTA = gfits_scan (header, "CROTA1",   "%f", 1, &tmp);
+    haveCDij  = gfits_scan (header, "CD1_1",    "%f", 1, &tmp);
+    havePCij  = gfits_scan (header, "PC001001", "%f", 1, &tmp);
+    haveRAo   = gfits_scan (header, "RA_O",     "%f", 1, &tmp);
+    
+    if (haveCTYPE && havePCij  && haveCDELT) { mode = COORD_TYPE_PC;   goto gotit; }
+    if (haveCTYPE && haveCROTA && haveCDELT) { mode = COORD_TYPE_ROT;  goto gotit; }
+    if (haveCTYPE && haveCDij)               { mode = COORD_TYPE_CD;   goto gotit; }
+    if (haveRAo)                             { mode = COORD_TYPE_LIN;  goto gotit; }
+    // fprintf (stderr, "no valid WCS keywords\n");
+    return (FALSE);
+  }
+  
+gotit:
+
+  status = TRUE; 
+  switch (mode) {
+    case COORD_TYPE_PC:
+      status &= gfits_scan (header, "CTYPE2", 	"%s",  1, coords[0].ctype);
+      status &= gfits_scan (header, "CRVAL1", 	"%lf", 1, &coords[0].crval1);
+      status &= gfits_scan (header, "CRPIX1", 	"%f",  1, &coords[0].crpix1);
+      status &= gfits_scan (header, "CRVAL2", 	"%lf", 1, &coords[0].crval2);  
+      status &= gfits_scan (header, "CRPIX2", 	"%f",  1, &coords[0].crpix2);
+
+      status &= gfits_scan (header, "CDELT1", 	"%f",  1, &coords[0].cdelt1);
+      status &= gfits_scan (header, "CDELT2", 	"%f",  1, &coords[0].cdelt2);
+      status &= gfits_scan (header, "PC001001", "%f",  1, &coords[0].pc1_1);
+      status &= gfits_scan (header, "PC001002", "%f",  1, &coords[0].pc1_2);
+      status &= gfits_scan (header, "PC002001", "%f",  1, &coords[0].pc2_1);
+      status &= gfits_scan (header, "PC002002", "%f",  1, &coords[0].pc2_2);
 
       /* set NPLYTERM based on header.  if NPLYTERM is missing, it should have a 
@@ -491,24 +528,48 @@
 	  break;
       }
-    } else {
-      if (gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1)) {
-	status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
-	status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
-	status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
-	/* renormalize */
-	scale = hypot (coords[0].pc1_1, coords[0].pc1_2);
-	coords[0].cdelt1 = coords[0].cdelt2 = scale;
-	coords[0].pc1_1 /= scale;
-	coords[0].pc1_2 /= scale;
-	coords[0].pc2_1 /= scale;
-	coords[0].pc2_2 /= scale;
-      } else {
-	status = FALSE;
-      }
-    }
-  } else {
-    /* some of my thesis data uses this simple linear model - convert on read? */
-    if (gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) {
-      status  = gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
+      break;
+
+    case COORD_TYPE_ROT:
+      status &= gfits_scan (header, "CTYPE2", "%s",  1, coords[0].ctype);
+      status &= gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
+      status &= gfits_scan (header, "CRPIX1", "%f",  1, &coords[0].crpix1);
+      status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2);  
+      status &= gfits_scan (header, "CRPIX2", "%f",  1, &coords[0].crpix2);
+
+      status &= gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1);
+      status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
+
+      status &= gfits_scan (header, "CROTA2", "%lf", 1, &rotate);
+      Lambda = coords[0].cdelt2 / coords[0].cdelt1;
+      coords[0].pc1_1 =  cos(rotate*RAD_DEG);
+      coords[0].pc1_2 = -sin(rotate*RAD_DEG) * Lambda;
+      coords[0].pc2_1 =  sin(rotate*RAD_DEG) / Lambda;
+      coords[0].pc2_2 =  cos(rotate*RAD_DEG);
+      break;
+
+    case COORD_TYPE_CD:
+      status &= gfits_scan (header, "CTYPE2", "%s",  1, coords[0].ctype);
+      status &= gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
+      status &= gfits_scan (header, "CRPIX1", "%f",  1, &coords[0].crpix1);
+      status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2);  
+      status &= gfits_scan (header, "CRPIX2", "%f",  1, &coords[0].crpix2);
+
+      status &= gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1);
+      status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
+      status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
+      status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
+      /* renormalize */
+      scale = hypot (coords[0].pc1_1, coords[0].pc1_2);
+      coords[0].cdelt1 = coords[0].cdelt2 = scale;
+      coords[0].pc1_1 /= scale;
+      coords[0].pc1_2 /= scale;
+      coords[0].pc2_1 /= scale;
+      coords[0].pc2_2 /= scale;
+      break;
+
+    case COORD_TYPE_LIN:
+      /* some of my thesis data uses this simple linear model - convert on read? */
+      status &= gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1);
+      status &= gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
       status &= gfits_scan (header, "RA_Y", "%f", 1, &coords[0].pc1_2);
       status &= gfits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2);  
@@ -518,6 +579,7 @@
       coords[0].cdelt1 = coords[0].cdelt2 = 1.0;
       strcpy (coords[0].ctype, "GENE");
-    }
-  }
+      break;
+  }
+
   if (status) {
     if (!gfits_scan (header, "EQUINOX", "%lf", 1, &equinox)) {
@@ -530,6 +592,7 @@
     } 
   }
+
   if (!status) {
-    fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype);
+    // fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype);
     coords[0].crval1 = coords[0].crpix1 = coords[0].cdelt1 = 0.0;
     coords[0].crval2 = coords[0].crpix2 = coords[0].cdelt2 = 0.0;
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 28855)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 29001)
@@ -125,4 +125,8 @@
     /* no conversions currently defined */
     catalog[0].missing = gfits_table_get_Missing (&ftable, &catalog[0].Nmissing, NULL);
+    if (!catalog[0].missing) {
+      fprintf (stderr, "ERROR: failed to read missing\n");
+      exit (2);
+    }
     if (Nmissing != catalog[0].Nmiss_disk) {
       fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  catalog[0].Nmiss_disk);
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 28855)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 29001)
@@ -285,4 +285,8 @@
     /* no conversions currently defined : this just does the byte swap */
     catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
+    if (!catalog[0].missing) {
+      fprintf (stderr, "ERROR: failed to read missing\n");
+      exit (2);
+    }
     if (Nmissing != catalog[0].Nmiss_disk) {
       fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  catalog[0].Nmiss_disk);
@@ -473,4 +477,8 @@
     /* no conversions currently defined : this just does the byte swap */
     catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
+    if (!catalog[0].missing) {
+      fprintf (stderr, "ERROR: failed to read missing\n");
+      exit (2);
+    }
     if (Nmissing != Nrows) {
       fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  Nrows);
Index: trunk/Ohana/src/libdvo/src/dvo_convert.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert.c	(revision 28855)
+++ trunk/Ohana/src/libdvo/src/dvo_convert.c	(revision 29001)
@@ -32,4 +32,8 @@
     Average_##TYPE *tmpAverage; \
     tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL); \
+    if (!tmpAverage) { \
+      fprintf (stderr, "ERROR: failed to read averages\n"); \
+      exit (2); \
+    } \
     average = Average_##TYPE##_ToInternal (tmpAverage, *Naverage, primary); \
     free (tmpAverage); \
@@ -39,4 +43,8 @@
   if (!strcmp (extname, "DVO_AVERAGE")) {
     average = gfits_table_get_Average (ftable, Naverage, NULL);
+    if (!average) {
+      fprintf (stderr, "ERROR: failed to read averages\n");
+      exit (2);
+    }
     *format = DVO_FORMAT_INTERNAL;
     return (average);
@@ -111,4 +119,8 @@
     Measure_##TYPE *tmpMeasure; \
     tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL); \
+    if (!tmpMeasure) { \
+      fprintf (stderr, "ERROR: failed to read measures\n"); \
+      exit (2); \
+    } \
     measure = Measure_##TYPE##_ToInternal (tmpMeasure, *Nmeasure); \
     free (tmpMeasure); \
@@ -118,4 +130,8 @@
   if (!strcmp (extname, "DVO_MEASURE")) {
     measure = gfits_table_get_Measure (ftable, Nmeasure, NULL);
+    if (!measure) {
+      fprintf (stderr, "ERROR: failed to read measures\n");
+      exit (2);
+    }
     *format = DVO_FORMAT_INTERNAL;
     return (measure);
@@ -190,4 +206,8 @@
     SecFilt_##TYPE *tmpSecFilt; \
     tmpSecFilt = gfits_table_get_SecFilt_##TYPE (ftable, Nsecfilt, NULL); \
+    if (!tmpSecFilt) { \
+      fprintf (stderr, "ERROR: failed to read secfilts\n"); \
+      exit (2); \
+    } \
     secfilt = SecFilt_##TYPE##_ToInternal (tmpSecFilt, *Nsecfilt); \
     free (tmpSecFilt); \
@@ -197,4 +217,8 @@
   if (!strcmp (extname, "DVO_SECFILT")) {
     secfilt = gfits_table_get_SecFilt (ftable, Nsecfilt, NULL);
+    if (!secfilt) {
+      fprintf (stderr, "ERROR: failed to read secfilts\n");
+      exit (2);
+    }
     *format = DVO_FORMAT_INTERNAL;
     return (secfilt);
@@ -263,4 +287,8 @@
     Image_Elixir *tmpimage;
     tmpimage = gfits_table_get_Image_Elixir (ftable, &Nimage, NULL);
+    if (!tmpimage) {
+      fprintf (stderr, "ERROR: failed to read images\n");
+      exit (2);
+    }
     ftable[0].buffer = (char *) Image_Elixir_ToInternal (tmpimage, Nimage);
     free (tmpimage);
@@ -284,4 +312,8 @@
     *format = DVO_FORMAT_##FORMAT; \
     tmpimage = gfits_table_get_Image_##TYPE (ftable, &Nimage, NULL); \
+    if (!tmpimage) { \
+      fprintf (stderr, "ERROR: failed to read images\n"); \
+      exit (2); \
+    } \
     ftable[0].buffer = (char *) Image_##TYPE##_ToInternal (tmpimage, Nimage); \
     free (tmpimage); \
@@ -296,4 +328,8 @@
     Image *image;
     image = gfits_table_get_Image (ftable, &Nimage, NULL);
+    if (!image) {
+      fprintf (stderr, "ERROR: failed to read images\n");
+      exit (2);
+    }
     *format = DVO_FORMAT_INTERNAL;
     return (TRUE);
Index: trunk/Ohana/src/libdvo/src/skyregion_io.c
===================================================================
--- trunk/Ohana/src/libdvo/src/skyregion_io.c	(revision 28855)
+++ trunk/Ohana/src/libdvo/src/skyregion_io.c	(revision 29001)
@@ -40,4 +40,9 @@
   ALLOCATE (skytable, SkyTable, 1);
   skytable[0].regions = gfits_table_get_SkyRegion (&ftable, &skytable[0].Nregions, NULL);
+  if (!skytable[0].regions) {
+    fprintf (stderr, "ERROR: failed to read sky regions\n");
+    exit (2);
+  }
+
   ALLOCATE (skytable[0].filename, char *, skytable[0].Nregions);
   for (i = 0; i < skytable[0].Nregions; i++) {
