Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 33779)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 33963)
@@ -69,4 +69,7 @@
   NAN_U_INT   = (signed int) 0xffffffff,
 } DVO_INT_NAN;
+
+// max path length
+# define DVO_MAX_PATH 1024
 
 /* RegImage.flag values */
@@ -453,4 +456,9 @@
 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt);
 
+float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt);
+float PhotM20 (PhotCode *code, Average *average, SecFilt *secfilt);
+float PhotM80 (PhotCode *code, Average *average, SecFilt *secfilt);
+float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt);
+
 float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code);
 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color);
@@ -516,4 +524,7 @@
 void dvo_catalog_test (Catalog *catalog, int halt);
 
+int dvo_catalog_backup (Catalog *catalog, int primary);
+int dvo_catalog_unlink_backup (Catalog *catalog, int primary);
+
 /* catmode-specific APIs */
 int dvo_catalog_load_raw (Catalog *catalog, int VERBOSE);
Index: trunk/Ohana/src/libdvo/include/dvodb.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvodb.h	(revision 33779)
+++ trunk/Ohana/src/libdvo/include/dvodb.h	(revision 33963)
@@ -32,4 +32,5 @@
       MAG_REF, 
       MAG_ERR, 
+      MAG_STDEV, 
       MAG_AVE_ERR, 
       MAG_PHOT_FLAGS, 
@@ -37,4 +38,7 @@
       MAG_NCODE,
       MAG_NPHOT,
+      MAG_20, 
+      MAG_80, 
+      MAG_UC_DIST, 
 };
 
@@ -327,4 +331,5 @@
 
 int dbExtractAveragesInitTransform (CoordTransformSystem target);
+int dbExtractAveragesInitAve (void);
 int dbExtractAveragesInit (void);
 
Index: trunk/Ohana/src/libdvo/src/HostTable.c
===================================================================
--- trunk/Ohana/src/libdvo/src/HostTable.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/HostTable.c	(revision 33963)
@@ -125,5 +125,5 @@
 
   for (i = 0; i < table->Nhosts; i++) {
-    if (table->index[table->hosts[i].hostID] == -1) {
+    if (table->index[table->hosts[i].hostID] != -1) {
       fprintf (stderr, "error: duplicate hostID %d\n", table->hosts[i].hostID);
       exit (1);
@@ -168,5 +168,5 @@
 
     // find the host which has finished
-    int j;
+    int Nout, j;
     int found = FALSE;
     for (j = 0; j < table->Nhosts; j++) {
@@ -180,5 +180,6 @@
       EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDOUT]);
       fprintf (stderr, "--- stdout from %s ---\n", table->hosts[j].hostname);
-      write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
+      Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
+      if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
       fprintf (stderr, "\n");
 	  
@@ -186,5 +187,6 @@
       EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDERR]);
       fprintf (stderr, "--- stderr from %s ---\n", table->hosts[j].hostname);
-      write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
+      Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
+      if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
       fprintf (stderr, "\n");
       if (WIFEXITED(status)) {
@@ -271,7 +273,8 @@
 	// if (table->hosts[i].stdout.Nbuffer > 0x10000) {
 	if (table->hosts[i].stdout.Nbuffer > 0x1000) {
-	  int printHead = VERBOSE || table->hosts[i].stdout.Nbuffer;
-	  if (printHead) fprintf (stdout, "--- stdout from %s ---\n", table->hosts[i].hostname);
-	  write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer);
+	  int printHead = VERBOSE || (table->hosts[i].stdout.Nbuffer > 0);
+	  if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stdout.Nbuffer);
+	  int Nout = write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer);
+	  if (Nout != table->hosts[i].stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
 	  FlushIOBuffer (&table->hosts[i].stdout);
 	  if (printHead) fprintf (stdout, "\n");
@@ -284,7 +287,8 @@
 	// if (table->hosts[i].stderr.Nbuffer > 0x10000) {
 	if (table->hosts[i].stderr.Nbuffer > 0x1000) {
-	  int printHead = VERBOSE || table->hosts[i].stderr.Nbuffer;
-	  if (printHead) fprintf (stdout, "--- stderr from %s ---\n", table->hosts[i].hostname);
-	  write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer);
+	  int printHead = VERBOSE || (table->hosts[i].stderr.Nbuffer > 0);
+	  if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stderr.Nbuffer);
+	  int Nout = write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer);
+	  if (Nout != table->hosts[i].stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
 	  FlushIOBuffer (&table->hosts[i].stderr);
 	  if (printHead) fprintf (stdout, "\n");
@@ -321,16 +325,18 @@
 	// read stdout
 	int printHead;
-	printHead = VERBOSE || host->stdout.Nbuffer;
+	printHead = VERBOSE || (host->stdout.Nbuffer > 0);
 	EmptyIOBuffer (&host->stdout, 100, host->stdio[HOST_STDOUT]);
-	if (printHead) fprintf (stdout, "--- stdout from %s ---\n", host->hostname);
-	write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer);
+	if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v2)\n", host->hostname, host->stdout.Nbuffer);
+	int Nout = write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer);
+	if (Nout != host->stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
 	FlushIOBuffer (&host->stdout);
 	if (printHead) fprintf (stdout, "\n");
 	    
 	// read stderr
-	printHead = VERBOSE || host->stderr.Nbuffer;
+	printHead = VERBOSE || (host->stderr.Nbuffer > 0);
 	EmptyIOBuffer (&host->stderr, 100, host->stdio[HOST_STDERR]);
-	if (printHead) fprintf (stdout, "--- stderr from %s ---\n", host->hostname);
-	write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer);
+	if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v2)\n", host->hostname, host->stderr.Nbuffer);
+	Nout = write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer);
+	if (Nout != host->stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
 	FlushIOBuffer (&host->stderr);
 	if (printHead) fprintf (stdout, "\n");
Index: trunk/Ohana/src/libdvo/src/dbExtractAverages.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dbExtractAverages.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dbExtractAverages.c	(revision 33963)
@@ -40,4 +40,8 @@
 int dbExtractAveragesInit () {
   GetTimeFormat (&TimeReference, &TimeFormat);
+  return (TRUE);
+}
+
+int dbExtractAveragesInitAve () {
   haveGalactic = FALSE;
   haveEcliptic = FALSE;
@@ -200,4 +204,7 @@
 	  }
 	  break;
+	case MAG_STDEV:
+	  value.Flt = PhotMstdev (field->photcode, average, secfilt);
+	  break;
 	case MAG_PHOT_FLAGS:
 	  if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) {
@@ -226,4 +233,13 @@
 	  break;
 
+	case MAG_20:
+	  value.Flt = PhotM20 (field->photcode, average, secfilt);
+	  break;
+	case MAG_80:
+	  value.Flt = PhotM80 (field->photcode, average, secfilt);
+	  break;
+	case MAG_UC_DIST:
+	  value.Flt = PhotUCdist (field->photcode, average, secfilt);
+	  break;
       }
       break;
Index: trunk/Ohana/src/libdvo/src/dbFields.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dbFields.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dbFields.c	(revision 33963)
@@ -46,4 +46,8 @@
   if (!strcasecmp (string, "ncode"))     return (MAG_NCODE);
   if (!strcasecmp (string, "nphot"))     return (MAG_NPHOT);
+  if (!strcasecmp (string, "stdev"))     return (MAG_STDEV);
+  if (!strcasecmp (string, "20"))        return (MAG_20);
+  if (!strcasecmp (string, "80"))        return (MAG_80);
+  if (!strcasecmp (string, "ucdist"))    return (MAG_UC_DIST);
   return (MAG_NONE);
 }
Index: trunk/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 33963)
@@ -211,5 +211,5 @@
   
   if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) {
-    if (VERBOSE) fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
+    fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
     return (FALSE);
   }
@@ -219,13 +219,13 @@
   switch (dvo_catalog_lock (catalog, catalog[0].lockmode)) {
   case DVO_CAT_OPEN_FAIL:
-    if (VERBOSE) fprintf (stderr, "can't lock file %s\n", catalog[0].filename);
+    fprintf (stderr, "can't lock file %s\n", catalog[0].filename);
     return (FALSE);
   case DVO_CAT_OPEN_OK:
     if (!dvo_catalog_load (catalog, VERBOSE)) {
-      if (VERBOSE) fprintf (stderr, "failure loading catalog\n");
+      fprintf (stderr, "failure loading catalog\n");
       return (FALSE);
     }
     if (!dvo_catalog_check (catalog, Nsecfilt, TRUE)) {
-      if (VERBOSE) fprintf (stderr, "can't reduce number of secondary filters\n");
+      fprintf (stderr, "can't reduce number of secondary filters\n");
       return (FALSE);
     }
@@ -499,2 +499,103 @@
 }
 
+// make a backup of this catalog (including the measure, secfilt, and missing tables as needed)
+int dvo_catalog_backup (Catalog *catalog, int primary) {
+
+  // skip empty cpt files
+  if (primary && !catalog->Naves_disk) {
+    return TRUE;
+  }
+
+  char tmpfilename[DVO_MAX_PATH];
+  int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename);
+  if (status >= DVO_MAX_PATH) {
+    fprintf (stderr, "path name too long: %s\n", catalog->filename);
+    return FALSE;
+  }
+      
+  // unlock the catalog here (closes file as well) (also closes subcat files Measure, Secfilt, Missing)
+  if (primary) {
+    status = dvo_catalog_unlock (catalog);
+    if (!status) {
+      fprintf (stderr, "failed to unlock catalog %s\n", catalog->filename);
+      return FALSE;
+    }
+  }
+
+  status = rename (catalog->filename, tmpfilename);
+  if (status) {
+    fprintf (stderr, "failed to rename catalog %s\n", catalog->filename);
+    return FALSE;
+  }
+      
+  // keep the same lockmode
+  int lockmode = catalog->lockmode;
+
+  // lock the new catalog file here (re-opens file as well) (does NOT open/lock the subcat files)
+  status = dvo_catalog_lock (catalog, lockmode);
+  if (!status) {
+    fprintf (stderr, "failed to lock new catalog file %s\n", catalog->filename);
+    return FALSE;
+  }
+
+  if (catalog[0].catmode == DVO_MODE_SPLIT) {
+    if (catalog[0].measure_catalog != NULL) {
+      if (!dvo_catalog_backup (catalog[0].measure_catalog, FALSE)) {
+	return FALSE;
+      }
+    }
+    if (catalog[0].missing_catalog != NULL) {
+      if (!dvo_catalog_backup (catalog[0].missing_catalog, FALSE)) {
+	return FALSE;
+      }
+    }
+    if (catalog[0].secfilt_catalog != NULL) {
+      if (!dvo_catalog_backup (catalog[0].secfilt_catalog, FALSE)) {
+	return FALSE;
+      }
+    }
+  }
+  return TRUE;
+}
+
+// make a backup of this catalog (including the measure, secfilt, and missing tables as needed)
+int dvo_catalog_unlink_backup (Catalog *catalog, int primary) {
+
+  if (primary && !catalog->Naves_disk) {
+    // skip empty files (empty when read, but output may not be empty)
+    return TRUE;
+  }
+
+  char tmpfilename[DVO_MAX_PATH];
+  int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename);
+  if (status >= DVO_MAX_PATH) {
+    fprintf (stderr, "path name too long: %s\n", catalog->filename);
+    return FALSE;
+  }
+      
+  status = unlink (tmpfilename);
+  if (status) {
+    fprintf (stderr, "failed to unlink catalog %s\n", catalog->filename);
+    return FALSE;
+  }
+      
+  if (catalog[0].catmode == DVO_MODE_SPLIT) {
+    if (catalog[0].measure_catalog != NULL) {
+      if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) {
+	return FALSE;
+      }
+    }
+    if (catalog[0].missing_catalog != NULL) {
+      if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) {
+	return FALSE;
+      }
+    }
+    if (catalog[0].secfilt_catalog != NULL) {
+      if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) {
+	return FALSE;
+      }
+    }
+  }
+  return TRUE;
+}
+
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 33963)
@@ -80,5 +80,5 @@
   // write PHU header
   if (!gfits_fwrite_header  (catalog->f, &catalog->header)) {
-    fprintf (stderr, "can't write primary header");
+    fprintf (stderr, "can't write primary header\n");
     return (FALSE);
   }
@@ -87,5 +87,5 @@
   gfits_create_matrix (&catalog->header, &matrix);
   if (!gfits_fwrite_matrix  (catalog->f, &matrix)) {
-    fprintf (stderr, "can't write primary matrix");
+    fprintf (stderr, "can't write primary matrix\n");
     gfits_free_matrix (&matrix);
     return (FALSE);
@@ -95,5 +95,5 @@
   // write the table data
   if (!gfits_fwrite_ftable_range (catalog->f, ftable, start, Nrows, Ndisk, Ntotal)) {
-    fprintf (stderr, "can't write table data");
+    fprintf (stderr, "can't write table data\n");
     return (FALSE);
   }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c	(revision 33963)
@@ -213,4 +213,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
  }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c	(revision 33963)
@@ -207,4 +207,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
  }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c	(revision 33963)
@@ -167,4 +167,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
  }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c	(revision 33963)
@@ -211,4 +211,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
  }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c	(revision 33963)
@@ -214,4 +214,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
  }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c	(revision 33963)
@@ -212,4 +212,5 @@
     out[i].M_20        = in[i].M_20;      
     out[i].M_80        = in[i].M_80;      
+    out[i].Mstdev      = in[i].Mstdev;      
     out[i].ubercalDist = in[i].ubercalDist;      
  }
@@ -234,4 +235,5 @@
     out[i].M_20        = in[i].M_20;      
     out[i].M_80        = in[i].M_80;      
+    out[i].Mstdev      = in[i].Mstdev;      
     out[i].ubercalDist = in[i].ubercalDist;      
   }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c	(revision 33963)
@@ -222,4 +222,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
   }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c	(revision 33963)
@@ -215,4 +215,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
   }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 33963)
@@ -222,4 +222,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
  }
Index: trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 33963)
@@ -222,4 +222,5 @@
     // added in PS1_V3
     out[i].Map         = 0;
+    out[i].Mstdev      = 0;
     out[i].ubercalDist = 0;
  }
Index: trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 33963)
@@ -476,4 +476,52 @@
 }
 
+float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) {
+
+  int Ns;
+  float Mstdev;
+
+  if (code == NULL) return NAN;
+
+  Ns = photcodes[0].hashNsec[code[0].code];
+  Mstdev  = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev;
+  return (Mstdev);
+}
+
+float PhotM20 (PhotCode *code, Average *average, SecFilt *secfilt) {
+
+  int Ns;
+  float M20;
+
+  if (code == NULL) return NAN;
+
+  Ns = photcodes[0].hashNsec[code[0].code];
+  M20  = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_20;
+  return (M20);
+}
+
+float PhotM80 (PhotCode *code, Average *average, SecFilt *secfilt) {
+
+  int Ns;
+  float M80;
+
+  if (code == NULL) return NAN;
+
+  Ns = photcodes[0].hashNsec[code[0].code];
+  M80  = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_80;
+  return (M80);
+}
+
+float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt) {
+
+  int Ns;
+  float Muc;
+
+  if (code == NULL) return NAN;
+
+  Ns = photcodes[0].hashNsec[code[0].code];
+  Muc  = (Ns == -1) ? NAN : secfilt[Ns].ubercalDist;
+  return (Muc);
+}
+
 // XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short)
 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) {
Index: trunk/Ohana/src/libdvo/src/flatcorr_io.c
===================================================================
--- trunk/Ohana/src/libdvo/src/flatcorr_io.c	(revision 33779)
+++ trunk/Ohana/src/libdvo/src/flatcorr_io.c	(revision 33963)
@@ -185,4 +185,6 @@
 float FlatCorrectionOffset (FlatCorrectionTable *flatcorr, int ID, int X, int Y) {
 
+  if (!flatcorr) return 0.0;
+
   // validate the flat_id (not out of range?)
   int seq = flatcorr->IDtoSeq[ID];
