Index: /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/Makefile
===================================================================
--- /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/Makefile	(revision 34390)
+++ /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/Makefile	(revision 34391)
@@ -33,4 +33,5 @@
 $(SRC)/dvomergeUpdate_catalogs.$(ARCH).o \
 $(SRC)/dvomergeUpdate_threaded.$(ARCH).o \
+$(SRC)/dvomergeHistory.$(ARCH).o \
 $(SRC)/dvomergeFromList.$(ARCH).o \
 $(SRC)/dvomergeImageIDs.$(ARCH).o \
@@ -56,4 +57,5 @@
 $(SRC)/dvomerge_client.$(ARCH).o \
 $(SRC)/dvomergeUpdate_catalogs.$(ARCH).o \
+$(SRC)/dvomergeHistory.$(ARCH).o \
 $(SRC)/dvomergeImageIDs.$(ARCH).o \
 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \
Index: /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/include/dvomerge.h
===================================================================
--- /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/include/dvomerge.h	(revision 34390)
+++ /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/include/dvomerge.h	(revision 34391)
@@ -44,4 +44,35 @@
   char *notFound;
 } IDmapType;
+
+// struct to describe a sequence of dvomerges (Image.dat header)
+typedef struct {
+  int Nmerge;
+  char **IDs;
+} dmhImage;
+
+// struct to describe a sequence of dvomerges (Object table : cpt header)
+typedef struct {
+  int   Nmerge;
+  off_t  *size;
+  time_t *time;
+  char  **date;
+} dmhObject;
+
+// data on a single table, populated when a new file is merged
+typedef struct {
+  off_t  size;
+  time_t time;
+  char  *date;
+} dmhObjectStats;
+
+// struct to describe the current status of a single output file:
+// is it on this machine (valid)? have we already merged or not (missed)?
+// what is the collection of past merges (history)?  what is the real filename?
+typedef struct {
+  int valid;		      // is this object table on this machine?
+  int missed;		      // did we fail to merge into this table yet?
+  dmhObject *history;	      // complete sequence of previous merges
+  char *filename;	      // true filename on disk 
+} OutputStatus;
 
 int        main                   PROTO((int argc, char **argv));
@@ -130,2 +161,21 @@
 IDmapType *IDmapLoad               PROTO((char *filename));
 int        create_IDmap_lookup     PROTO((IDmapType *IDmap));
+
+// dvomerge history functions
+OutputStatus *OutputStatusInit (int N);
+int OutputStatusFree (OutputStatus *outstat, int N);
+
+int dmhObjectAdd (dmhObject *history, Header *header, dmhObjectStats *inStats);
+int dmhObjectCheck (dmhObject *history, dmhObjectStats *inStats);
+dmhObject *dmhObjectRead (char *filename);
+
+void dmhObjectStatsFree (dmhObjectStats *stats);
+dmhObjectStats *dmhObjectStatsRead (char *filename);
+
+int dmhImageAdd (FITS_DB *db, dmhImage *history, char *dbID);
+dmhImage *dmhImageRead (FITS_DB *db) ;
+int dmhImageCheck (dmhImage *history, char *dbID);
+
+char *dmhImageReadID (FITS_DB *db);
+int dvoCreateID (char *catdir);
+
Index: /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeHistory.c
===================================================================
--- /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeHistory.c	(revision 34390)
+++ /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeHistory.c	(revision 34391)
@@ -1,3 +1,3 @@
-# include "dvomerge.c"
+# include "dvomerge.h"
 
 // We track the dvomerge history (dmh) in the headers of the Image table (Image.dat) and
@@ -11,35 +11,4 @@
 // somewhat
 
-// struct to describe a sequence of dvomerges (Image.dat header)
-typedef struct {
-  int Nmerge;
-  char **IDs;
-} dmhImage;
-
-// struct to describe a sequence of dvomerges (Object table : cpt header)
-typedef struct {
-  int   Nmerge;
-  off_t  *size;
-  time_t *time;
-  char  **date;
-} dmhObject;
-
-// data on a single table, populated when a new file is merged
-typedef struct {
-  off_t  size;
-  time_t time;
-  char  *date;
-} dmhObjectStats;
-
-// struct to describe the current status of a single output file:
-// is it on this machine (valid)? have we already merged or not (missed)?
-// what is the collection of past merges (history)?  what is the real filename?
-typedef struct {
-  int valid;		      // is this object table on this machine?
-  int missed;		      // did we fail to merge into this table yet?
-  dmhTable *history;	      // complete sequence of previous merges
-  char *filename;	      // true filename on disk 
-} OutputStatus;
-
 // we have a sequence of dvomerge events.  
 // in the image table header, we want to track the IDs of the databases 
@@ -48,63 +17,9 @@
 // some (possible?) functions needed to track the history
 
-// given a dvo image db, add an ID to the header
-// XXX move this to libdvo and generate tools to update a database
-int dvoCreateID (char *catdir) {
-  
-  // open and read header
-  char filename[DVO_MAX_PATH];
-  snprintf (filename, DVO_MAX_PATH, "%s/Images.dat", catdir);
-
-  // open for update
-  FILE *file = fopen (filename, "r+");
-  if (!file) {
-    fprintf (stderr, "problem opening output file to read header %s\n", filename);
-    perror ("stats error message:");
-    exit (2);
-    // XXX should we generate an file with an empty table here?  
-  }
-
-  Header header;
-  if (!gfits_fread_header (file, &header)) {
-    fprintf (stderr, "problem reading header for output file %s\n", filename);
-    exit (2);
-  }
-      
-  // I have a header, I want to add ONE line.  double check there is enough space
-  char *p = gfits_header_field (&header, "END", 1);
-  if (p == NULL) {
-    fprintf (stderr, "header is missing END\n");
-    exit (1);
-  }
-  if (p - header.buffer + 80 == header.datasize) {
-    fprintf (stderr, "no free space in block, can't insert keyword\n");
-    exit (1);
-  }
-
-  int start_size = header.datasize;
+// user must pass in a char * of length DVO_DBID_LEN
+char *dmhImageReadID (FITS_DB *db) {
 
   char dbID[33];
-  long A = time(NULL);
-  srand48(A);
-  
-  for (i = 0; i < 32; i++) {
-    sprintf (&dbID[i], "%1x", (int)(16.0*drand48()));
-  }
-
-  gfits_modify (&header, "DVO_DB_ID", "%32s", 1, dbID);      
-  if (start_size != header.datasize) {
-    fprintf (stderr, "error: header buffer grew? (%d to %d bytes)\n", start_size, header.datasize);
-    exit (1);
-  }
-
-  fclose (file);
-  return TRUE;
-}
-
-// user must pass in a char * of length DVO_DB_ID_LEN
-char *dmhImageReadID (FITS_DB *db) {
-
-  char dbID[33];
-  status = gfits_scan (&db->header, "DVO_DB_ID", "%s", 1, dbID);      
+  int status = gfits_scan (&db->header, "DVO_DBID", "%s", 1, dbID);      
   if (!status) {
     return NULL;
@@ -118,5 +33,5 @@
 
   if (!db) return FALSE;
-  if (!db->header) return FALSE;
+  if (!db->header.buffer) return FALSE;
 
   dmhImage *history = NULL;
@@ -124,8 +39,7 @@
 
   // should track the number in the header (would overwrite)
-  status = gfits_scan (&db->header, "DM_NMERGE", "%d", 1, &history->Nmerge); 
+  int status = gfits_scan (&db->header, "NMERGE", "%d", 1, &history->Nmerge); 
   if (!status) {
-    fprintf (stderr, "failed to read DM_NMERGE\n");
-    exit (5);
+    history->Nmerge = 0;
   }
 
@@ -133,7 +47,9 @@
   ALLOCATE (history->IDs, char *, history->Nmerge);
 
+  int i;
+  char name[16], ID[80];
   for (i = 0; i < history->Nmerge; i++) {
     snprintf (name, 16, "DM_%05d", i);
-    status = gfits_scan (&header, name, "%s", ID);
+    status = gfits_scan (&db->header, name, "%s", 1, ID);
     if (!status) {
       fprintf (stderr, "failed to read %s\n", name);
@@ -145,17 +61,37 @@
 }
 
+// compare stats for the input to the full history for the output
+// have we merged this file?
+int dmhImageCheck (dmhImage *history, char *dbID) {
+
+  // if the input catalog does not exist, we did not miss it
+  // if the output catalog does not exist, we must have missed it
+
+  if (!dbID) return FALSE; // no ID to merge, probably an error to get here
+  if (!history) return FALSE; // we must not have merged since it does not exist
+
+  int i;
+  for (i = 0; i < history->Nmerge; i++) {
+    // do we match this size?
+    if (!strcmp(history->IDs[i], dbID)) return TRUE; // we match (already merged)
+  }
+  return FALSE; // no match, not yet merged
+}
+
 int dmhImageAdd (FITS_DB *db, dmhImage *history, char *dbID) {
 
   // update the arrays
-  last = history->Nmerge;
+  int last = history->Nmerge;
 
   history->Nmerge ++;
   REALLOCATE (history->IDs, char *, history->Nmerge);
 
-  history->IDs[last] = strcreate (ID);
-
+  history->IDs[last] = strcreate (dbID);
+
+  char name[16];
   snprintf (name, 16, "DM_%05d", last);
-  gfits_modify (&db->header, name, "%s", ID);
-
+  gfits_modify (&db->header, name, "%s", 1, dbID);
+
+  gfits_modify (&db->header, "NMERGE", "%d", 1, history->Nmerge);
   return TRUE;
 }
@@ -169,11 +105,12 @@
   int stat_result = stat (filename, &instats);
   if (stat_result) {
-    if (errno == ENOENT) return NULL
-    fprintf (stderr, "cannot read stats on input file %s\n", inlist[0].filename[i]);
+    if (errno == ENOENT) return NULL;
+    fprintf (stderr, "cannot read stats on input file %s\n", filename);
     perror ("stats error message:");
     exit (2);
   }
   
-  ALLOCATE (stats, dmhStatsType, 1);
+  dmhObjectStats *stats = NULL;  
+  ALLOCATE (stats, dmhObjectStats, 1);
   stats->size = instats.st_size;
   stats->time = instats.st_mtime;
@@ -183,4 +120,5 @@
 
 void dmhObjectStatsFree (dmhObjectStats *stats) {
+  if (!stats) return;
   if (stats->date) free (stats->date);
   free (stats);
@@ -192,5 +130,5 @@
   // if the file does not exist, return NULL (means 'missed')
   struct stat outstats;
-  stat_result = stat (filename, &outstats);
+  int stat_result = stat (filename, &outstats);
   if (stat_result) {
     if (errno == ENOENT) return NULL;
@@ -217,8 +155,7 @@
   ALLOCATE (history, dmhObject, 1);
 
-  status = gfits_scan (&outheader, "DM_NMERGE", "%d", 1, &history->Nmerge);      
+  int status = gfits_scan (&outheader, "NMERGE", "%d", 1, &history->Nmerge);      
   if (!status) {
-    fprintf (stderr, "failed to read DM_NMERGE\n");
-    exit (5);
+    history->Nmerge = 0;
   }
 
@@ -228,11 +165,13 @@
   ALLOCATE (history->date, char *, history->Nmerge);
 
+  int i;
   for (i = 0; i < history->Nmerge; i++) {
     off_t  size;
-    time_t time;
     char   date[80];
 
+    char name[16];
+    
     snprintf (name, 16, "MS_%05d", i);
-    status = gfits_scan (&header, name, OFF_T_FMT, &size);
+    status = gfits_scan (&outheader, name, OFF_T_FMT, 1, &size);
     if (!status) {
       fprintf (stderr, "failed to read %s\n", name);
@@ -242,5 +181,5 @@
 
     snprintf (name, 16, "MT_%05d", i);
-    status = gfits_scan (&header, name, "%s", date);
+    status = gfits_scan (&outheader, name, "%s", 1, date);
     if (!status) {
       fprintf (stderr, "failed to read %s\n", name);
@@ -250,13 +189,18 @@
     history->time[i] = ohana_date_to_sec (date);
   }
-
-  fclose (fout);
-
   return history;
 }
   
 // compare stats for the input to the full history for the output
+// have we merged this file?
 int dmhObjectCheck (dmhObject *history, dmhObjectStats *inStats) {
 
+  // if the input catalog does not exist, we did not miss it
+  // if the output catalog does not exist, we must have missed it
+
+  if (!inStats) return TRUE; // we do not need to merge something that does not exist...
+  if (!history) return FALSE; // we must not have merged since it does not exist
+
+  int i;
   for (i = 0; i < history->Nmerge; i++) {
     
@@ -267,14 +211,14 @@
     if (history->time[i] != inStats->time) continue;
 
-    return TRUE;  // we match (already found)
-  }
-  return FALSE;
+    return TRUE;  // we match (already merged)
+  }
+  return FALSE; // no match, not yet merged
 }
 
 // add the stats for the given input file to the output structure and header
-int dmhObjectAdd (dmhObject *history, Header *header, dmhObjectStats inStats) {
+int dmhObjectAdd (dmhObject *history, Header *header, dmhObjectStats *inStats) {
 
   // update the arrays
-  last = history->Nmerge;
+  int last = history->Nmerge;
 
   history->Nmerge ++;
@@ -287,17 +231,27 @@
   history->date[last] = inStats->date;
 
+  char name[16];
   snprintf (name, 16, "MS_%05d", last);
-  status = gfits_modify (&header, name, OFF_T_FMT, inStats->size);
-  if (!status) { error out};
+
+  int status = gfits_modify (header, name, OFF_T_FMT, 1, inStats->size); 
+  if (!status) { 
+    fprintf (stderr, "error: failed to add size to header (%d)\n", (int) inStats->size);
+    exit (1);
+  }
 
   snprintf (name, 16, "MT_%05d", last);
-  status = gfits_modify (&header, name, "%s", inStats->date);
-  if (!status) { error out};
-
-  gfits_modify (&db->header, "DM_NMERGE", "%d", history->Nmerge);
+  status = gfits_modify (header, name, "%s", 1, inStats->date);
+  if (!status) {     
+    fprintf (stderr, "error: failed to add date to header (%s)\n", inStats->date);
+    exit (1);
+  }
+
+  gfits_modify (header, "NMERGE", "%d", 1, history->Nmerge);
   return TRUE;
 }
 
 OutputStatus *OutputStatusInit (int N) {
+
+  int i;
 
   OutputStatus *outstat = NULL;
@@ -309,9 +263,10 @@
     outstat[i].filename = NULL;
   }
-
+  return outstat;
 }
 
 int OutputStatusFree (OutputStatus *outstat, int N) {
 
+  int i;
   for (i = 0; i < N; i++) {
     if (outstat[i].history)  { free (outstat[i].history); }
@@ -319,4 +274,4 @@
   }
   free (outstat);
-}
-
+  return TRUE;
+}
Index: /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeImageIDs.c
===================================================================
--- /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeImageIDs.c	(revision 34390)
+++ /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeImageIDs.c	(revision 34391)
@@ -25,7 +25,8 @@
     Shutdown ("can't read input image catalog %s", inDB.filename);
   }
+  dvo_image_unlock (&inDB); // unlock input
 
   // read the header for the database ID?
-  char *indbID = dvomergeHistoryReadID (&inDB);
+  char *indbID = dmhImageReadID (&inDB);
   if (!indbID) { 
     Shutdown ("this database is missing a DVO database ID; please generate one before merging\n"); 
@@ -53,7 +54,15 @@
   }
 
+  // have we already merged this database?
+  if (dmhImageCheck(history, indbID)) {
+    // if so, then just match the image IDs 
+    if (VERBOSE) fprintf (stderr, "already merged image table\n");
+    dvo_image_match_dbs(IDmap, &outDB, &inDB);
+    dvo_image_unlock (&outDB); // unlock output
+    return TRUE;
+  }
+
   // convert database table to internal structure & add to output image db
   dvo_image_merge_dbs(IDmap, &outDB, &inDB);
-  dvo_image_unlock (&inDB); // unlock input
 
   // add the new image db to merge history
@@ -62,7 +71,5 @@
     Shutdown ("error reading history for output database\n"); 
   }
-
-  // XXX I need to pass the history structure back out somehow...
-
+    
   SetProtect (TRUE);
   dvo_image_save (&outDB, VERBOSE);
Index: /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c	(revision 34390)
+++ /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c	(revision 34391)
@@ -36,5 +36,5 @@
     // are any of these output regions relevant to this machine?
     int found = FALSE;
-    for (j = 0; !found && (j < outlist[0].Nregions); j++) {
+    for (j = 0; j < outlist[0].Nregions; j++) {
       outstat[j].valid = HostTableTestHost(outlist[0].regions[j], HOST_ID);
       found = (found || outstat[j].valid);
@@ -48,6 +48,12 @@
     }
 
-    // get stats for history check
+    // get stats for history check, skip input catalog if file not found (NULL inStats)
     dmhObjectStats *inStats = dmhObjectStatsRead (inlist[0].filename[i]);
+    if (!inStats) {
+      if (VERBOSE) fprintf (stderr, "skipping %s, empty \n", inlist[0].filename[i]);
+      OutputStatusFree (outstat, outlist->Nregions);
+      SkyListFree (outlist); 
+      continue;
+    }
 
     // Check if any of the output files have NOT yet received data from this input file
@@ -65,9 +71,10 @@
       outstat[j].history = dmhObjectRead (outstat[j].filename);
 
-      outstat[j].missed = dmhObjectCheck (outstat[j].history, inStats);
+      // have we already merged this database?
+      outstat[j].missed = !dmhObjectCheck (outstat[j].history, inStats);
       missed = (missed || outstat[j].missed);
     }
     if (!missed) {
-      fprintf (stderr, "skipping %s, already merged\n", inlist[0].filename[i]);
+      if (VERBOSE) fprintf (stderr, "skipping %s, empty or already merged\n", inlist[0].filename[i]);
       OutputStatusFree (outstat, outlist->Nregions);
       dmhObjectStatsFree (inStats);
Index: /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/test/catdir.grizy/Images.dat
===================================================================
--- /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/test/catdir.grizy/Images.dat	(revision 34390)
+++ /branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/test/catdir.grizy/Images.dat	(revision 34391)
@@ -1,1 +1,1 @@
-SIMPLE  =                    T /                                                BITPIX  =                    8 /                                                NAXIS   =                    0 /                                                PCOUNT  =                    0 /                                                GCOUNT  =                    1 /                                                BSCALE  =         1.0000000000 /                                                BZERO   =         0.0000000000 /                                                EXTEND  =                    T /                                                NIMAGES =                    0 /                                                ZERO_PT =        25.0000000000 /                                                FORMAT  = 'ELIXIR            ' /                                                END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             XTENSION= 'BINTABLE          ' /                                                BITPIX  =                    8 /                                                NAXIS   =                    2 /                                                NAXIS1  =                  240 /                                                NAXIS2  =                    0 /                                                PCOUNT  =                    0 /                                                GCOUNT  =                    1 /                                                TFIELDS =                   50 /                                                EXTNAME = 'DVO_IMAGE_ELIXIR  ' /                                                TTYPE1  = 'CRVAL1            ' / coordinate at reference pixel                  TUNIT1  = '                  ' /                                                TFORM1  = 'D                 ' /                                                TSCAL1  =         1.0000000000 /                                                TZERO1  =         0.0000000000 /                                                TTYPE2  = 'CRVAL2            ' / coordinate at reference pixel                  TUNIT2  = '                  ' /                                                TFORM2  = 'D                 ' /                                                TSCAL2  =         1.0000000000 /                                                TZERO2  =         0.0000000000 /                                                TTYPE3  = 'CRPIX1            ' / coordinate of reference pixel                  TUNIT3  = '                  ' /                                                TFORM3  = 'E                 ' /                                                TSCAL3  =         1.0000000000 /                                                TZERO3  =         0.0000000000 /                                                TTYPE4  = 'CRPIX2            ' / coordinate of reference pixel                  TUNIT4  = '                  ' /                                                TFORM4  = 'E                 ' /                                                TSCAL4  =         1.0000000000 /                                                TZERO4  =         0.0000000000 /                                                TTYPE5  = 'CDELT1            ' / degrees per pixel                              TUNIT5  = '                  ' /                                                TFORM5  = 'E                 ' /                                                TSCAL5  =         1.0000000000 /                                                TZERO5  =         0.0000000000 /                                                TTYPE6  = 'CDELT2            ' / degrees per pixel                              TUNIT6  = '                  ' /                                                TFORM6  = 'E                 ' /                                                TSCAL6  =         1.0000000000 /                                                TZERO6  =         0.0000000000 /                                                TTYPE7  = 'PC1_1             ' / rotation matrix                                TUNIT7  = '                  ' /                                                TFORM7  = 'E                 ' /                                                TSCAL7  =         1.0000000000 /                                                TZERO7  =         0.0000000000 /                                                TTYPE8  = 'PC1_2             ' / rotation matrix                                TUNIT8  = '                  ' /                                                TFORM8  = 'E                 ' /                                                TSCAL8  =         1.0000000000 /                                                TZERO8  =         0.0000000000 /                                                TTYPE9  = 'PC2_1             ' / rotation matrix                                TUNIT9  = '                  ' /                                                TFORM9  = 'E                 ' /                                                TSCAL9  =         1.0000000000 /                                                TZERO9  =         0.0000000000 /                                                TTYPE10 = 'PC2_2             ' / rotation matrix                                TUNIT10 = '                  ' /                                                TFORM10 = 'E                 ' /                                                TSCAL10 =         1.0000000000 /                                                TZERO10 =         0.0000000000 /                                                TTYPE11 = 'POLYTERMS         ' / higher order warping terms                     TUNIT11 = '                  ' /                                                TFORM11 = '14E               ' /                                                TSCAL11 =         1.0000000000 /                                                TZERO11 =         0.0000000000 /                                                TTYPE12 = 'CTYPE             ' / coordinate type                                TUNIT12 = '                  ' /                                                TFORM12 = '15A               ' /                                                TSCAL12 =         1.0000000000 /                                                TZERO12 =         0.0000000000 /                                                TTYPE13 = 'NPOLYTERMS        ' / order of polynomial                            TUNIT13 = '                  ' /                                                TFORM13 = 'A                 ' /                                                TSCAL13 =         1.0000000000 /                                                TZERO13 =         0.0000000000 /                                                TTYPE14 = 'TZERO             ' / readout time (row 0)                           TUNIT14 = '                  ' /                                                TFORM14 = 'J                 ' /                                                TSCAL14 =         1.0000000000 /                                                TZERO14 =         0.0000000000 /                                                TTYPE15 = 'NSTAR             ' / number of stars on image                       TUNIT15 = '                  ' /                                                TFORM15 = 'J                 ' /                                                TSCAL15 =         1.0000000000 /                                                TZERO15 =         0.0000000000 /                                                TTYPE16 = 'SECZ              ' / airmass                                        TUNIT16 = 'milliairmass      ' /                                                TFORM16 = 'I                 ' /                                                TSCAL16 =         1.0000000000 /                                                TZERO16 =         0.0000000000 /                                                TTYPE17 = 'NX                ' / image width                                    TUNIT17 = '                  ' /                                                TFORM17 = 'I                 ' /                                                TSCAL17 =         1.0000000000 /                                                TZERO17 =         0.0000000000 /                                                TTYPE18 = 'NY                ' / image height                                   TUNIT18 = '                  ' /                                                TFORM18 = 'I                 ' /                                                TSCAL18 =         1.0000000000 /                                                TZERO18 =         0.0000000000 /                                                TTYPE19 = 'APMIFIT           ' / aperture correction                            TUNIT19 = 'millimag          ' /                                                TFORM19 = 'I                 ' /                                                TSCAL19 =         1.0000000000 /                                                TZERO19 =         0.0000000000 /                                                TTYPE20 = 'DAPMIFIT          ' / apmifit error                                  TUNIT20 = 'millimag          ' /                                                TFORM20 = 'I                 ' /                                                TSCAL20 =         1.0000000000 /                                                TZERO20 =         0.0000000000 /                                                TTYPE21 = 'SOURCE            ' / identifier for CCD,                            TUNIT21 = '                  ' /                                                TFORM21 = 'I                 ' /                                                TSCAL21 =         1.0000000000 /                                                TZERO21 =         0.0000000000 /                                                TTYPE22 = 'MCAL              ' / calibration mag                                TUNIT22 = 'millimag          ' /                                                TFORM22 = 'I                 ' /                                                TSCAL22 =         1.0000000000 /                                                TZERO22 =         0.0000000000 /                                                TTYPE23 = 'DMCAL             ' / error on Mcal                                  TUNIT23 = 'millimag          ' /                                                TFORM23 = 'I                 ' /                                                TSCAL23 =         1.0000000000 /                                                TZERO23 =         0.0000000000 /                                                TTYPE24 = 'XM                ' / image chisq                                    TUNIT24 = '10*log(value)     ' /                                                TFORM24 = 'I                 ' /                                                TSCAL24 =         1.0000000000 /                                                TZERO24 =         0.0000000000 /                                                TTYPE25 = 'NAME              ' / name of original image                         TUNIT25 = '                  ' /                                                TFORM25 = '32A               ' /                                                TSCAL25 =         1.0000000000 /                                                TZERO25 =         0.0000000000 /                                                TTYPE26 = 'DETECTION_LIMIT   ' / detection limit                                TUNIT26 = '10*mag            ' /                                                TFORM26 = 'B                 ' /                                                TSCAL26 =         1.0000000000 /                                                TZERO26 =         0.0000000000 /                                                TTYPE27 = 'SATURATION_LIMIT  ' / saturation limit                               TUNIT27 = '10*mag            ' /                                                TFORM27 = 'B                 ' /                                                TSCAL27 =         1.0000000000 /                                                TZERO27 =         0.0000000000 /                                                TTYPE28 = 'CERROR            ' / astrometric error                              TUNIT28 = '50*arcsec         ' /                                                TFORM28 = 'B                 ' /                                                TSCAL28 =         1.0000000000 /                                                TZERO28 =         0.0000000000 /                                                TTYPE29 = 'FWHM_X            ' / PSF x width                                    TUNIT29 = '25*arcsec         ' /                                                TFORM29 = 'B                 ' /                                                TSCAL29 =         1.0000000000 /                                                TZERO29 =         0.0000000000 /                                                TTYPE30 = 'FWHM_Y            ' / PSF y width                                    TUNIT30 = '25*arcsec         ' /                                                TFORM30 = 'B                 ' /                                                TSCAL30 =         1.0000000000 /                                                TZERO30 =         0.0000000000 /                                                TTYPE31 = 'TRATE             ' / scan rate                                      TUNIT31 = '100 usec/pixel    ' /                                                TFORM31 = 'B                 ' /                                                TSCAL31 =         1.0000000000 /                                                TZERO31 =         0.0000000000 /                                                TTYPE32 = 'EXPTIME           ' / exposure time                                  TUNIT32 = 'seconds           ' /                                                TFORM32 = 'E                 ' /                                                TSCAL32 =         1.0000000000 /                                                TZERO32 =         0.0000000000 /                                                TTYPE33 = 'CODE              ' / image quality flag                             TUNIT33 = '                  ' /                                                TFORM33 = 'A                 ' /                                                TSCAL33 =         1.0000000000 /                                                TZERO33 =         0.0000000000 /                                                TTYPE34 = 'CCDNUM            ' / CCD ID number                                  TUNIT34 = '                  ' /                                                TFORM34 = 'B                 ' /                                                TSCAL34 =         1.0000000000 /                                                TZERO34 =         0.0000000000 /                                                TTYPE35 = 'DUMMY             ' / unused                                         TUNIT35 = '                  ' /                                                TFORM35 = '20A               ' /                                                TSCAL35 =         1.0000000000 /                                                TZERO35 =         0.0000000000 /                                                TTYPE36 = 'ORDER             ' / Mrel 2D polynomical order                      TUNIT36 = '                  ' /                                                TFORM36 = 'I                 ' /                                                TSCAL36 =         1.0000000000 /                                                TZERO36 =         0.0000000000 /                                                TTYPE37 = 'MX                ' / Mrel polyterm                                  TUNIT37 = '                  ' /                                                TFORM37 = 'I                 ' /                                                TSCAL37 =         1.0000000000 /                                                TZERO37 =         0.0000000000 /                                                TTYPE38 = 'MY                ' / Mrel polyterm                                  TUNIT38 = '                  ' /                                                TFORM38 = 'I                 ' /                                                TSCAL38 =         1.0000000000 /                                                TZERO38 =         0.0000000000 /                                                TTYPE39 = 'MXX               ' / Mrel polyterm                                  TUNIT39 = '                  ' /                                                TFORM39 = 'I                 ' /                                                TSCAL39 =         1.0000000000 /                                                TZERO39 =         0.0000000000 /                                                TTYPE40 = 'MXY               ' / Mrel polyterm                                  TUNIT40 = '                  ' /                                                TFORM40 = 'I                 ' /                                                TSCAL40 =         1.0000000000 /                                                TZERO40 =         0.0000000000 /                                                TTYPE41 = 'MYY               ' / Mrel polyterm                                  TUNIT41 = '                  ' /                                                TFORM41 = 'I                 ' /                                                TSCAL41 =         1.0000000000 /                                                TZERO41 =         0.0000000000 /                                                TTYPE42 = 'MXXX              ' / Mrel polyterm                                  TUNIT42 = '                  ' /                                                TFORM42 = 'I                 ' /                                                TSCAL42 =         1.0000000000 /                                                TZERO42 =         0.0000000000 /                                                TTYPE43 = 'MXXY              ' / Mrel polyterm                                  TUNIT43 = '                  ' /                                                TFORM43 = 'I                 ' /                                                TSCAL43 =         1.0000000000 /                                                TZERO43 =         0.0000000000 /                                                TTYPE44 = 'MXYY              ' / Mrel polyterm                                  TUNIT44 = '                  ' /                                                TFORM44 = 'I                 ' /                                                TSCAL44 =         1.0000000000 /                                                TZERO44 =         0.0000000000 /                                                TTYPE45 = 'MYYY              ' / Mrel polyterm                                  TUNIT45 = '                  ' /                                                TFORM45 = 'I                 ' /                                                TSCAL45 =         1.0000000000 /                                                TZERO45 =         0.0000000000 /                                                TTYPE46 = 'MXXXX             ' / Mrel polyterm                                  TUNIT46 = '                  ' /                                                TFORM46 = 'I                 ' /                                                TSCAL46 =         1.0000000000 /                                                TZERO46 =         0.0000000000 /                                                TTYPE47 = 'MXXXY             ' / Mrel polyterm                                  TUNIT47 = '                  ' /                                                TFORM47 = 'I                 ' /                                                TSCAL47 =         1.0000000000 /                                                TZERO47 =         0.0000000000 /                                                TTYPE48 = 'MXXYY             ' / Mrel polyterm                                  TUNIT48 = '                  ' /                                                TFORM48 = 'I                 ' /                                                TSCAL48 =         1.0000000000 /                                                TZERO48 =         0.0000000000 /                                                TTYPE49 = 'MXYYY             ' / Mrel polyterm                                  TUNIT49 = '                  ' /                                                TFORM49 = 'I                 ' /                                                TSCAL49 =         1.0000000000 /                                                TZERO49 =         0.0000000000 /                                                TTYPE50 = 'MYYYY             ' / Mrel polyterm                                  TUNIT50 = '                  ' /                                                TFORM50 = 'I                 ' /                                                TSCAL50 =         1.0000000000 /                                                TZERO50 =         0.0000000000 /                                                END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
+SIMPLE  =                    T /                                                BITPIX  =                    8 /                                                NAXIS   =                    0 /                                                PCOUNT  =                    0 /                                                GCOUNT  =                    1 /                                                BSCALE  =         1.0000000000 /                                                BZERO   =         0.0000000000 /                                                EXTEND  =                    T /                                                NIMAGES =                    0 /                                                ZERO_PT =        25.0000000000 /                                                FORMAT  = 'ELIXIR            ' /                                                DVO_DBID= 'c2fa2cdbac0df952ae954ed04381e219' /                                  END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             XTENSION= 'BINTABLE          ' /                                                BITPIX  =                    8 /                                                NAXIS   =                    2 /                                                NAXIS1  =                  240 /                                                NAXIS2  =                    0 /                                                PCOUNT  =                    0 /                                                GCOUNT  =                    1 /                                                TFIELDS =                   50 /                                                EXTNAME = 'DVO_IMAGE_ELIXIR  ' /                                                TTYPE1  = 'CRVAL1            ' / coordinate at reference pixel                  TUNIT1  = '                  ' /                                                TFORM1  = 'D                 ' /                                                TSCAL1  =         1.0000000000 /                                                TZERO1  =         0.0000000000 /                                                TTYPE2  = 'CRVAL2            ' / coordinate at reference pixel                  TUNIT2  = '                  ' /                                                TFORM2  = 'D                 ' /                                                TSCAL2  =         1.0000000000 /                                                TZERO2  =         0.0000000000 /                                                TTYPE3  = 'CRPIX1            ' / coordinate of reference pixel                  TUNIT3  = '                  ' /                                                TFORM3  = 'E                 ' /                                                TSCAL3  =         1.0000000000 /                                                TZERO3  =         0.0000000000 /                                                TTYPE4  = 'CRPIX2            ' / coordinate of reference pixel                  TUNIT4  = '                  ' /                                                TFORM4  = 'E                 ' /                                                TSCAL4  =         1.0000000000 /                                                TZERO4  =         0.0000000000 /                                                TTYPE5  = 'CDELT1            ' / degrees per pixel                              TUNIT5  = '                  ' /                                                TFORM5  = 'E                 ' /                                                TSCAL5  =         1.0000000000 /                                                TZERO5  =         0.0000000000 /                                                TTYPE6  = 'CDELT2            ' / degrees per pixel                              TUNIT6  = '                  ' /                                                TFORM6  = 'E                 ' /                                                TSCAL6  =         1.0000000000 /                                                TZERO6  =         0.0000000000 /                                                TTYPE7  = 'PC1_1             ' / rotation matrix                                TUNIT7  = '                  ' /                                                TFORM7  = 'E                 ' /                                                TSCAL7  =         1.0000000000 /                                                TZERO7  =         0.0000000000 /                                                TTYPE8  = 'PC1_2             ' / rotation matrix                                TUNIT8  = '                  ' /                                                TFORM8  = 'E                 ' /                                                TSCAL8  =         1.0000000000 /                                                TZERO8  =         0.0000000000 /                                                TTYPE9  = 'PC2_1             ' / rotation matrix                                TUNIT9  = '                  ' /                                                TFORM9  = 'E                 ' /                                                TSCAL9  =         1.0000000000 /                                                TZERO9  =         0.0000000000 /                                                TTYPE10 = 'PC2_2             ' / rotation matrix                                TUNIT10 = '                  ' /                                                TFORM10 = 'E                 ' /                                                TSCAL10 =         1.0000000000 /                                                TZERO10 =         0.0000000000 /                                                TTYPE11 = 'POLYTERMS         ' / higher order warping terms                     TUNIT11 = '                  ' /                                                TFORM11 = '14E               ' /                                                TSCAL11 =         1.0000000000 /                                                TZERO11 =         0.0000000000 /                                                TTYPE12 = 'CTYPE             ' / coordinate type                                TUNIT12 = '                  ' /                                                TFORM12 = '15A               ' /                                                TSCAL12 =         1.0000000000 /                                                TZERO12 =         0.0000000000 /                                                TTYPE13 = 'NPOLYTERMS        ' / order of polynomial                            TUNIT13 = '                  ' /                                                TFORM13 = 'A                 ' /                                                TSCAL13 =         1.0000000000 /                                                TZERO13 =         0.0000000000 /                                                TTYPE14 = 'TZERO             ' / readout time (row 0)                           TUNIT14 = '                  ' /                                                TFORM14 = 'J                 ' /                                                TSCAL14 =         1.0000000000 /                                                TZERO14 =         0.0000000000 /                                                TTYPE15 = 'NSTAR             ' / number of stars on image                       TUNIT15 = '                  ' /                                                TFORM15 = 'J                 ' /                                                TSCAL15 =         1.0000000000 /                                                TZERO15 =         0.0000000000 /                                                TTYPE16 = 'SECZ              ' / airmass                                        TUNIT16 = 'milliairmass      ' /                                                TFORM16 = 'I                 ' /                                                TSCAL16 =         1.0000000000 /                                                TZERO16 =         0.0000000000 /                                                TTYPE17 = 'NX                ' / image width                                    TUNIT17 = '                  ' /                                                TFORM17 = 'I                 ' /                                                TSCAL17 =         1.0000000000 /                                                TZERO17 =         0.0000000000 /                                                TTYPE18 = 'NY                ' / image height                                   TUNIT18 = '                  ' /                                                TFORM18 = 'I                 ' /                                                TSCAL18 =         1.0000000000 /                                                TZERO18 =         0.0000000000 /                                                TTYPE19 = 'APMIFIT           ' / aperture correction                            TUNIT19 = 'millimag          ' /                                                TFORM19 = 'I                 ' /                                                TSCAL19 =         1.0000000000 /                                                TZERO19 =         0.0000000000 /                                                TTYPE20 = 'DAPMIFIT          ' / apmifit error                                  TUNIT20 = 'millimag          ' /                                                TFORM20 = 'I                 ' /                                                TSCAL20 =         1.0000000000 /                                                TZERO20 =         0.0000000000 /                                                TTYPE21 = 'SOURCE            ' / identifier for CCD,                            TUNIT21 = '                  ' /                                                TFORM21 = 'I                 ' /                                                TSCAL21 =         1.0000000000 /                                                TZERO21 =         0.0000000000 /                                                TTYPE22 = 'MCAL              ' / calibration mag                                TUNIT22 = 'millimag          ' /                                                TFORM22 = 'I                 ' /                                                TSCAL22 =         1.0000000000 /                                                TZERO22 =         0.0000000000 /                                                TTYPE23 = 'DMCAL             ' / error on Mcal                                  TUNIT23 = 'millimag          ' /                                                TFORM23 = 'I                 ' /                                                TSCAL23 =         1.0000000000 /                                                TZERO23 =         0.0000000000 /                                                TTYPE24 = 'XM                ' / image chisq                                    TUNIT24 = '10*log(value)     ' /                                                TFORM24 = 'I                 ' /                                                TSCAL24 =         1.0000000000 /                                                TZERO24 =         0.0000000000 /                                                TTYPE25 = 'NAME              ' / name of original image                         TUNIT25 = '                  ' /                                                TFORM25 = '32A               ' /                                                TSCAL25 =         1.0000000000 /                                                TZERO25 =         0.0000000000 /                                                TTYPE26 = 'DETECTION_LIMIT   ' / detection limit                                TUNIT26 = '10*mag            ' /                                                TFORM26 = 'B                 ' /                                                TSCAL26 =         1.0000000000 /                                                TZERO26 =         0.0000000000 /                                                TTYPE27 = 'SATURATION_LIMIT  ' / saturation limit                               TUNIT27 = '10*mag            ' /                                                TFORM27 = 'B                 ' /                                                TSCAL27 =         1.0000000000 /                                                TZERO27 =         0.0000000000 /                                                TTYPE28 = 'CERROR            ' / astrometric error                              TUNIT28 = '50*arcsec         ' /                                                TFORM28 = 'B                 ' /                                                TSCAL28 =         1.0000000000 /                                                TZERO28 =         0.0000000000 /                                                TTYPE29 = 'FWHM_X            ' / PSF x width                                    TUNIT29 = '25*arcsec         ' /                                                TFORM29 = 'B                 ' /                                                TSCAL29 =         1.0000000000 /                                                TZERO29 =         0.0000000000 /                                                TTYPE30 = 'FWHM_Y            ' / PSF y width                                    TUNIT30 = '25*arcsec         ' /                                                TFORM30 = 'B                 ' /                                                TSCAL30 =         1.0000000000 /                                                TZERO30 =         0.0000000000 /                                                TTYPE31 = 'TRATE             ' / scan rate                                      TUNIT31 = '100 usec/pixel    ' /                                                TFORM31 = 'B                 ' /                                                TSCAL31 =         1.0000000000 /                                                TZERO31 =         0.0000000000 /                                                TTYPE32 = 'EXPTIME           ' / exposure time                                  TUNIT32 = 'seconds           ' /                                                TFORM32 = 'E                 ' /                                                TSCAL32 =         1.0000000000 /                                                TZERO32 =         0.0000000000 /                                                TTYPE33 = 'CODE              ' / image quality flag                             TUNIT33 = '                  ' /                                                TFORM33 = 'A                 ' /                                                TSCAL33 =         1.0000000000 /                                                TZERO33 =         0.0000000000 /                                                TTYPE34 = 'CCDNUM            ' / CCD ID number                                  TUNIT34 = '                  ' /                                                TFORM34 = 'B                 ' /                                                TSCAL34 =         1.0000000000 /                                                TZERO34 =         0.0000000000 /                                                TTYPE35 = 'DUMMY             ' / unused                                         TUNIT35 = '                  ' /                                                TFORM35 = '20A               ' /                                                TSCAL35 =         1.0000000000 /                                                TZERO35 =         0.0000000000 /                                                TTYPE36 = 'ORDER             ' / Mrel 2D polynomical order                      TUNIT36 = '                  ' /                                                TFORM36 = 'I                 ' /                                                TSCAL36 =         1.0000000000 /                                                TZERO36 =         0.0000000000 /                                                TTYPE37 = 'MX                ' / Mrel polyterm                                  TUNIT37 = '                  ' /                                                TFORM37 = 'I                 ' /                                                TSCAL37 =         1.0000000000 /                                                TZERO37 =         0.0000000000 /                                                TTYPE38 = 'MY                ' / Mrel polyterm                                  TUNIT38 = '                  ' /                                                TFORM38 = 'I                 ' /                                                TSCAL38 =         1.0000000000 /                                                TZERO38 =         0.0000000000 /                                                TTYPE39 = 'MXX               ' / Mrel polyterm                                  TUNIT39 = '                  ' /                                                TFORM39 = 'I                 ' /                                                TSCAL39 =         1.0000000000 /                                                TZERO39 =         0.0000000000 /                                                TTYPE40 = 'MXY               ' / Mrel polyterm                                  TUNIT40 = '                  ' /                                                TFORM40 = 'I                 ' /                                                TSCAL40 =         1.0000000000 /                                                TZERO40 =         0.0000000000 /                                                TTYPE41 = 'MYY               ' / Mrel polyterm                                  TUNIT41 = '                  ' /                                                TFORM41 = 'I                 ' /                                                TSCAL41 =         1.0000000000 /                                                TZERO41 =         0.0000000000 /                                                TTYPE42 = 'MXXX              ' / Mrel polyterm                                  TUNIT42 = '                  ' /                                                TFORM42 = 'I                 ' /                                                TSCAL42 =         1.0000000000 /                                                TZERO42 =         0.0000000000 /                                                TTYPE43 = 'MXXY              ' / Mrel polyterm                                  TUNIT43 = '                  ' /                                                TFORM43 = 'I                 ' /                                                TSCAL43 =         1.0000000000 /                                                TZERO43 =         0.0000000000 /                                                TTYPE44 = 'MXYY              ' / Mrel polyterm                                  TUNIT44 = '                  ' /                                                TFORM44 = 'I                 ' /                                                TSCAL44 =         1.0000000000 /                                                TZERO44 =         0.0000000000 /                                                TTYPE45 = 'MYYY              ' / Mrel polyterm                                  TUNIT45 = '                  ' /                                                TFORM45 = 'I                 ' /                                                TSCAL45 =         1.0000000000 /                                                TZERO45 =         0.0000000000 /                                                TTYPE46 = 'MXXXX             ' / Mrel polyterm                                  TUNIT46 = '                  ' /                                                TFORM46 = 'I                 ' /                                                TSCAL46 =         1.0000000000 /                                                TZERO46 =         0.0000000000 /                                                TTYPE47 = 'MXXXY             ' / Mrel polyterm                                  TUNIT47 = '                  ' /                                                TFORM47 = 'I                 ' /                                                TSCAL47 =         1.0000000000 /                                                TZERO47 =         0.0000000000 /                                                TTYPE48 = 'MXXYY             ' / Mrel polyterm                                  TUNIT48 = '                  ' /                                                TFORM48 = 'I                 ' /                                                TSCAL48 =         1.0000000000 /                                                TZERO48 =         0.0000000000 /                                                TTYPE49 = 'MXYYY             ' / Mrel polyterm                                  TUNIT49 = '                  ' /                                                TFORM49 = 'I                 ' /                                                TSCAL49 =         1.0000000000 /                                                TZERO49 =         0.0000000000 /                                                TTYPE50 = 'MYYYY             ' / Mrel polyterm                                  TUNIT50 = '                  ' /                                                TFORM50 = 'I                 ' /                                                TSCAL50 =         1.0000000000 /                                                TZERO50 =         0.0000000000 /                                                END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
