Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 29537)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 29938)
@@ -58,10 +58,10 @@
 // these are used as NAN for types of int values
 typedef enum {
-    NAN_S_CHAR  = 0x7f,
-    NAN_U_CHAR  = 0xff,   // was NO_ERR
-    NAN_S_SHORT = 0x7fff, // was NO_MAG
-    NAN_U_SHORT = 0xffff, 
-    NAN_S_INT   = 0x7fffffff,
-    NAN_U_INT   = 0xffffffff,
+  NAN_S_CHAR  = 0x7f,
+  NAN_U_CHAR  = 0xff,   // was NO_ERR
+  NAN_S_SHORT = 0x7fff, // was NO_MAG
+  NAN_U_SHORT = 0xffff, 
+  NAN_S_INT   = 0x7fffffff,
+  NAN_U_INT   = (signed int) 0xffffffff,
 } DVO_INT_NAN;
 
@@ -135,17 +135,17 @@
 /* Average.code values -- these values are 32 bit (as of PS1_V1) */
 typedef enum {
-  ID_STAR_FEW     = 0x00000001, // used within relphot: skip star 
-  ID_STAR_POOR    = 0x00000002, // used within relphot: skip star 
-  ID_PROPER       = 0x00000400, // star with large proper motion 
-  ID_TRANSIENT    = 0x00001000, // is this mutually exclusive with USNO?  
-  ID_VARIABLE     = 0x00002000, // not currently set? 
-  ID_ASTEROID     = 0x00002000, // identified with an asteroid 
-  ID_BAD_OBJECT   = 0x00004000, // if all measurements are bad, set this bit 
+  ID_STAR_FEW     = 0x00000001, // used within relphot: skip star
+  ID_STAR_POOR    = 0x00000002, // used within relphot: skip star
+  ID_PROPER       = 0x00000400, // star with large proper motion
+  ID_TRANSIENT    = 0x00001000, // is this mutually exclusive with USNO?
+  ID_VARIABLE     = 0x00002000, // not currently set?
+  ID_ASTEROID     = 0x00002000, // identified with an asteroid
+  ID_BAD_OBJECT   = 0x00004000, // if all measurements are bad, set this bit
   ID_MOVING       = 0x00008000, // is a moving object
-  ID_ROCK         = 0x0000a000, // 0x8000 + 0x2000 
-  ID_GHOST        = 0x0000c001, // 0x8000 + 0x4000 + 0x0001 
-  ID_TRAIL        = 0x0000c002, // 0x8000 + 0x4000 + 0x0002 
-  ID_BLEED        = 0x0000c003, // 0x8000 + 0x4000 + 0x0003  
-  ID_COSMIC       = 0x0000c004, // 0x8000 + 0x4000 + 0x0004  
+  ID_ROCK         = 0x0000a000, // 0x8000 + 0x2000
+  ID_GHOST        = 0x0000c001, // 0x8000 + 0x4000 + 0x0001
+  ID_TRAIL        = 0x0000c002, // 0x8000 + 0x4000 + 0x0002
+  ID_BLEED        = 0x0000c003, // 0x8000 + 0x4000 + 0x0003
+  ID_COSMIC       = 0x0000c004, // 0x8000 + 0x4000 + 0x0004
   ID_STAR_FIT_AVE = 0x00010000, // average position fitted
   ID_STAR_FIT_PM  = 0x00020000, // proper motion fitted
@@ -156,6 +156,6 @@
   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)
+  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;
 
@@ -233,5 +233,5 @@
      *** that is just silly, and bad: convert to using Nsec_mem, Nsec_disk, Nsec_off.
      *** unless we always require the secfilt and average entries to be loaded sychronously.
-   */
+     */
 
   /* pointers to split data files */
@@ -293,4 +293,5 @@
 int isRegisteredMosaic (void);
 off_t GetRegisteredMosaic (void);
+off_t *GetChipMatch (void);
 int GetMosaicCoords (Coords *coords);
 int FindMosaicForImage (Image *images, off_t Nimages, off_t entry);
Index: trunk/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 29537)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 29938)
@@ -302,4 +302,6 @@
 int dvo_catalog_save (Catalog *catalog, char VERBOSE) {
 
+  int status = FALSE;
+
   // set the 'sorted' header keyword
   gfits_modify_alt (&catalog[0].header, "SORTED",  "%t", 1, catalog[0].sorted);
@@ -308,11 +310,11 @@
   switch (catalog[0].catmode) {
     case DVO_MODE_RAW:
-      dvo_catalog_save_raw (catalog, VERBOSE);
+      status = dvo_catalog_save_raw (catalog, VERBOSE);
       break;
     case DVO_MODE_MEF:
-      dvo_catalog_save_mef (catalog, VERBOSE);
+      status = dvo_catalog_save_mef (catalog, VERBOSE);
       break;
     case DVO_MODE_SPLIT:
-      dvo_catalog_save_split (catalog, VERBOSE);
+      status = dvo_catalog_save_split (catalog, VERBOSE);
       break;
     default:
@@ -320,5 +322,5 @@
       exit (2);
   }
-  return (TRUE);
+  return (status);
 }
 
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 29537)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 29938)
@@ -66,5 +66,5 @@
   /* read Average table data (or skip) */
   if (catalog[0].catflags & LOAD_AVES) {
-    if (!gfits_fread_ftable_data (f, &ftable)) {
+    if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
       if (VERBOSE) fprintf (stderr, "can't read table average data");
       return (FALSE);
@@ -94,5 +94,5 @@
   /* read Measure table data */
   if (catalog[0].catflags & LOAD_MEAS) {
-    if (!gfits_fread_ftable_data (f, &ftable)) {
+    if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
       if (VERBOSE) fprintf (stderr, "can't read table measure data");
       return (FALSE);
@@ -119,5 +119,5 @@
   /* read Missing table data */
   if (catalog[0].catflags & LOAD_MISS) {
-    if (!gfits_fread_ftable_data (f, &ftable)) {
+    if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
       if (VERBOSE) fprintf (stderr, "can't read table missing data");
       return (FALSE);
@@ -149,5 +149,5 @@
   /* read secfilt table data */
   if (catalog[0].catflags & LOAD_SECF) {
-    if (!gfits_fread_ftable_data (f, &ftable)) {
+    if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
       if (VERBOSE) fprintf (stderr, "can't read table secfilt data");
       return (FALSE);
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 29537)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 29938)
@@ -218,5 +218,5 @@
     }
     /* read Average table data : format is irrelevant here */
-    if (!gfits_fread_ftable_data (catalog[0].f, &ftable)) { 
+    if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 
       if (VERBOSE) fprintf (stderr, "can't read table average data");
       return (FALSE);
@@ -249,5 +249,5 @@
     // XXX this allows an empty Measure catalog with non-empty Average catalog : is that OK?
     /* read Measure table data */
-    if (!gfits_fread_ftable_data (catalog[0].measure_catalog[0].f, &ftable)) {
+    if (!gfits_fread_ftable_data (catalog[0].measure_catalog[0].f, &ftable, FALSE)) {
       if (VERBOSE) fprintf (stderr, "can't read table measure data\n");
       return (FALSE);
@@ -279,5 +279,5 @@
   if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_MISS)) {
     /* read Missing table data */
-    if (!gfits_fread_ftable_data (catalog[0].missing_catalog[0].f, &ftable)) {
+    if (!gfits_fread_ftable_data (catalog[0].missing_catalog[0].f, &ftable, FALSE)) {
       if (VERBOSE) fprintf (stderr, "can't read table missing data\n");
       return (FALSE);
@@ -313,5 +313,5 @@
   if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_SECF)) {
     /* read secfilt table data */
-    if (!gfits_fread_ftable_data (catalog[0].secfilt_catalog[0].f, &ftable)) {
+    if (!gfits_fread_ftable_data (catalog[0].secfilt_catalog[0].f, &ftable, FALSE)) {
       if (VERBOSE) fprintf (stderr, "can't read table secfilt data\n");
       return (FALSE);
Index: trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 29537)
+++ trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 29938)
@@ -557,9 +557,11 @@
       }
     }
-    if (entry == -1) {
-      // entry is missing fail (no printfs in this file)
-      free(map);
-      return(FALSE);
-    }
+    // if (entry == -1) {
+    //   // entry is missing fail (no printfs in this file)
+    //   free(map);
+    //   return(FALSE);
+    // }
+
+    // if entry is still -1, we will skip this one (not map into the output db)
     map[i] = entry;
   }
Index: trunk/Ohana/src/libdvo/src/fits_db.c
===================================================================
--- trunk/Ohana/src/libdvo/src/fits_db.c	(revision 29537)
+++ trunk/Ohana/src/libdvo/src/fits_db.c	(revision 29938)
@@ -83,5 +83,5 @@
     return (FALSE);
   }
-  if (!gfits_fread_ftable_data (db[0].f, &db[0].ftable)) {
+  if (!gfits_fread_ftable_data (db[0].f, &db[0].ftable, FALSE)) {
     fprintf (stderr, "can't read table data");
     gfits_db_free (db);
Index: trunk/Ohana/src/libdvo/src/mosaic_astrom.c
===================================================================
--- trunk/Ohana/src/libdvo/src/mosaic_astrom.c	(revision 29537)
+++ trunk/Ohana/src/libdvo/src/mosaic_astrom.c	(revision 29938)
@@ -17,4 +17,9 @@
 }
 
+/* what is the currently registered mosaic image? */
+off_t *GetChipMatch () {
+  return (ChipMatch);
+}
+
 /* given an image array and a current entry of type WRP, find matching DIS & Register it */
 int FindMosaicForImage (Image *images, off_t Nimages, off_t entry) {
@@ -40,5 +45,5 @@
   if (strcmp(&images[entry].coords.ctype[4], "-WRP")) {
     /* not a wrp image, do nothing */
-    return (TRUE); /* error or not */
+    return (entry + 1); /* error or not */
   }
 
@@ -52,5 +57,5 @@
     RegisterMosaic (&images[i].coords);
     iDIS = i;
-    return (TRUE);
+    return (i + 1);
   }
 
@@ -62,5 +67,5 @@
     RegisterMosaic (&images[i].coords);
     iDIS = i;
-    return (TRUE);
+    return (i + 1);
   }
   return (FALSE);
@@ -74,5 +79,5 @@
   if (strcmp(&images[entry].coords.ctype[4], "-WRP")) {
     /* not a wrp image, do nothing */
-    return (TRUE); /* error or not? */
+    return (entry + 1); /* error or not? */
   }
 
@@ -85,5 +90,5 @@
   RegisterMosaic (&images[N].coords);
   iDIS = N;
-  return (TRUE);
+  return (N + 1);
 }
 
@@ -165,8 +170,18 @@
   SortDISindex (DIStzero, DISentry, Ndis);
 
+  // ChipMatch has a few possible values: 
+  // -3 : image is a mosaic (DIS)
+  // -2 : image is an unassigned WRP image
+  // -1 : image is not a WRP or DIS images
+  // >= 0 : value is the mosaic seq number for this WRP image 
+
   /* find all matched WRP images */
   ALLOCATE (ChipMatch, off_t, Nimages);
   for (i = 0; i < Nimages; i++) {
     ChipMatch[i] = -1;
+    if (!strcmp(&images[i].coords.ctype[4], "-DIS")) {
+      ChipMatch[i] = -3;
+      continue;
+    }
     if (strcmp(&images[i].coords.ctype[4], "-WRP")) continue;
 
