Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.c	(revision 26764)
@@ -181,4 +181,14 @@
 #define PSC_REFRACT_CONST 55.7	/* Standard refraction ("/tanz) at STP */
 #endif
+
+/* Return default values for current fit*/
+int psc_defaults(double *pscale, double *d2, double *d3, double *airdens)
+{
+   *pscale = PS_scale;
+   *d2 = PS_d2;
+   *d3 = PS_d3;
+   *airdens = PS_airdens;
+   return(0);
+}
 
 /* Enable application of chip offsets (um, mrad)? */
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.h	(revision 26764)
@@ -244,2 +244,5 @@
 /* Enable application of chip offsets (um, mrad)? */
 int psc_load_otaoff(const char *fname);
+
+/* Return default values for current fit*/
+int psc_defaults(double *pscale, double *d2, double *d3, double *airdens);
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf.c	(revision 26764)
@@ -111,6 +111,10 @@
 /* Load up results (with a few sanity checks!) */
    if(psfout != NULL && alg != PSF_2DIM) {
-      psfout->ix = 0;
-      psfout->iy = 0;
+//      psfout->ix = 0;
+//      psfout->iy = 0;
+// 091211: JT this is a harmless lie, supposed to be highest pixel
+      psfout->ix = xu;
+      psfout->iy = yu;
+//
       psfout->x0 = xu;
       psfout->y0 = yu;
@@ -128,4 +132,12 @@
 	 psfextra->xfw = xfwhm;
 	 psfextra->yfw = yfwhm;
+         psfextra->majfw = 0.0;
+         psfextra->minfw = 0.0;
+         psfextra->thfw = 0.0;
+         psfextra->wpeak = 0.0;
+         psfextra->wbkgnd = 0.0;
+         psfextra->dflux = 0.0;
+         psfextra->dbkgnd = 0.0;
+         psfextra->rmsbkgnd = 0.0;
       }
       if(alg == PSF_BIN) psfextra->binfactor = extra;
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf2dim.f
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf2dim.f	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf2dim.f	(revision 26764)
@@ -188,6 +188,8 @@
       wpar(9) = 0.5
 * WAUX: NXPATCH, NYPATCH, NX, XOFF, YOFF, EADU, EXTRASKY, IGNORE_VALUE, INIT
-      waux(1) = min(n,nx-1-mx) + n + 1
-      waux(2) = min(n,ny-1-my) + n + 1
+C      waux(1) = min(n,nx-1-mx) + n + 1
+C      waux(2) = min(n,ny-1-my) + n + 1
+      waux(1) = min(2*n+1, nx-1-iwxs)
+      waux(2) = min(2*n+1, ny-1-iwys)
       waux(3) = nx
       waux(4) = iwxs
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c	(revision 26764)
@@ -72,5 +72,5 @@
       ymid = (cell->burn[k].y0m + cell->burn[k].y1m +
 	      cell->burn[k].y0p + cell->burn[k].y1p + 2) / 4;
-      i = cell->burn[k].nfit / 2;
+      i = ABS(cell->burn[k].nfit) / 2;
       printf("%3d %5d %3d %5d %5d %3d %5d %3d %5d %5d %2d %1d %1d %6.3f %8d\n", 
 	     k, 
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c	(revision 26764)
@@ -50,5 +50,5 @@
       fprintf(stderr, "\rerror: burntool could not open file `%s'\n",
 	      ifilename);
-      exit(EXIT_FAILURE);
+      exit(-314);
    }
    nextend = fh_extensions(ihu);
@@ -57,5 +57,5 @@
 	      ifilename);
 #ifndef JT2DHACK
-      exit(EXIT_FAILURE);
+      exit(-315);
 #endif
    }
@@ -343,7 +343,6 @@
              ifilename);
      if(persist_fits_remove_tables(ihu, deltablefitsfile) != FH_SUCCESS) {
-       exit(EXIT_FAILURE);
-     }
-     else {
+       exit(-316);
+     } else {
        exit(EXIT_SUCCESS);
      }
@@ -365,8 +364,8 @@
 /* Read the persistence data for this OTA */
    if(persistfile != NULL) {			/* Text data file */
-      if(persist_read(OTA, persistfile)) exit(EXIT_FAILURE);
+      if(persist_read(OTA, persistfile)) exit(-317);
    } else if(persistfitsfile != NULL) {		/* FITS table */
       if(persist_fits_read(OTA, persistfitsfile) != FH_SUCCESS)
-	 exit(EXIT_FAILURE);
+	 exit(-318);
    }
 
@@ -427,5 +426,5 @@
                  "\rerror: Cannot read EXTNAME from `%s' for extension #%d\n",
                  ifilename, ext);
-         exit(EXIT_FAILURE);
+         exit(-319);
       }
       if(fh_get_str(ehu, "XTENSION", xtension, sizeof(xtension)) != FH_SUCCESS) {
@@ -433,5 +432,5 @@
 		 "\rerror: Cannot read XTENSION from `%s' for extension #%d\n",
 		 ifilename, ext);
-	 exit(EXIT_FAILURE);	 
+	 exit(-320);
       }
       if(!strcmp("TABLE", xtension)) {
@@ -461,5 +460,5 @@
          fprintf(stderr,
                  "\rerror: Illegal cell number %d from '%s'\n", cell, extname);
-	 exit(EXIT_FAILURE);
+	 exit(-321);
       }
 
@@ -487,5 +486,5 @@
           (naxis >= 3 && fh_get_NAXIS3(ehu, &naxis3) != FH_SUCCESS)) {
          fprintf(stderr, "\rerror: Cannot get NAXIS*'\n");
-         exit(EXIT_FAILURE);
+         exit(-322);
       }
       if (naxis != 2) {
@@ -503,5 +502,5 @@
 	 }
 	 fprintf(stderr, "\rerror: 32bpp support not yet implemented in burntool.\n");
-	 exit(EXIT_FAILURE);
+	 exit(-324);
       }
 /* Check BSCALE and warn if it is anything other than 1.0.
@@ -525,5 +524,8 @@
       }
 
-      buf = (IMTYPE*)malloc(naxis1*naxis2*naxis3*sizeof(short));
+      if( (buf = (IMTYPE*)malloc(naxis1*naxis2*naxis3*sizeof(short))) == NULL) {
+	 fprintf(stderr, "\rerror: failed to alloc FITS buffer\n");
+	 exit(-325);
+      }
       if (fh_read_padded_image(ehu, fh_file_desc(ehu), buf,
 			       naxis1*naxis2*naxis3*sizeof(short),
@@ -531,6 +533,6 @@
 	 fprintf(stderr, "\rerror: failed to read image data for extension `%s'.\n",
 		 extname);
-	 free(buf);
-	 exit(EXIT_FAILURE);
+//	 free(buf);
+	 exit(-326);
       }
 
@@ -617,6 +619,6 @@
 	       fprintf(stderr, "\rerror: failed to re-write image data for extension `%s'.\n",
 		       extname);
-	       free(buf);
-	       exit(EXIT_FAILURE);
+//	       free(buf);
+	       exit(-327);
 	    }
 	 }
@@ -667,5 +669,9 @@
    if(2*SKY_MARG*ny > nmedian_buf) {
       if(median_buf != NULL) free(median_buf);
-      median_buf = (int *)calloc(2*SKY_MARG*ny, sizeof(int));
+      if( (median_buf = (int *)calloc(2*SKY_MARG*ny, sizeof(int))) == NULL) {
+	 fprintf(stderr, "\rerror: failed to alloc median buffer\n");
+	 exit(-667);
+      }
+
       nmedian_buf = 2*SKY_MARG*ny;
    }
@@ -674,5 +680,8 @@
    if(NX*NY > nimbuf) {
       if(imbuf != NULL) free(imbuf);
-      imbuf = (int *)calloc(NX*NY, sizeof(DTYPE));
+      if( (imbuf = (int *)calloc(NX*NY, sizeof(DTYPE))) == NULL) {
+	 fprintf(stderr, "\rerror: failed to alloc cell copy\n");
+	 exit(-668);
+      }
       nimbuf = NX*NY;
    }
@@ -681,5 +690,8 @@
    if(NX*NY > nmbuf) {
       if(mbuf != NULL) free(mbuf);
-      mbuf = (int *)calloc(NX*NY, sizeof(MTYPE));
+      if( (mbuf = (int *)calloc(NX*NY, sizeof(MTYPE))) == NULL) {
+	 fprintf(stderr, "\rerror: failed to alloc mask buffer\n");
+	 exit(-669);
+      }
       nmbuf = NX*NY;
    }
@@ -688,5 +700,8 @@
    if(NX*NY > nmsbuf) {
       if(msbuf != NULL) free(msbuf);
-      msbuf = (int *)calloc(NX*NY, sizeof(MTYPE));
+      if( (msbuf = (int *)calloc(NX*NY, sizeof(MTYPE))) == NULL) {
+	 fprintf(stderr, "\rerror: failed to alloc veto buffer\n");
+	 exit(-670);
+      }
       nmsbuf = NX*NY;
    }
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h	(revision 26764)
@@ -208,4 +208,5 @@
 STATIC int wlinearfit(int npt, double *x, double *y, 
 		      double *w, double *a, double *b);
+STATIC int linearrms(int npt, double *x, double *y, double a, double b, double *rms);
 STATIC int int_median(int n, int *key);
 STATIC double double_median(int n, double *key);
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnutils.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnutils.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnutils.c	(revision 26764)
@@ -290,2 +290,13 @@
    return(0);
 }
+
+/****************************************************************/
+/* Return of RMS relative to Fit y = ax + b */
+STATIC int linearrms(int npt, double *x, double *y, double a, double b, 
+		     double *rms)
+{
+   *rms = 0.0;
+   while(--npt >= 0) *rms += (y[npt]-a*x[npt]-b)*(y[npt]-a*x[npt]-b);
+   if(*rms > 0) *rms = sqrt(*rms);
+   return(0);
+}
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1	(revision 26764)
@@ -60,4 +60,6 @@
 	correction is applied) and they will propagate from input to output
 	until they finally achieve a legal fit with negligible amplitude.
+	Note that if burntool decides that a fit had a bad slope but was 
+	non-negligible it negates the "nfit" width parameter of the fit box.
 
 	Burntool also identifies really blasted areas which are saturated from
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persist_fits.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persist_fits.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persist_fits.c	(revision 26764)
@@ -222,4 +222,8 @@
       for(k=0; k<cell[j].npersist; k++) 
       {
+/* Retire old burns */
+	 if(cell[j].time - cell[j].persist[k].time > EXPIRE_TRAIL_TIME)
+	    continue;
+
 	 if(PERSIST_RETAIN) {
 /* Keep fits which have a dubious slope */
@@ -233,5 +237,5 @@
 	 }
          num_areas++;
-         num_fits += cell[j].persist[k].nfit;
+         num_fits += ABS(cell[j].persist[k].nfit);
       }
 
@@ -253,5 +257,5 @@
 	 }
          num_areas++;
-         num_fits += cell[j].burn[k].nfit;
+         num_fits += ABS(cell[j].burn[k].nfit);
       }
    }
@@ -308,5 +312,5 @@
       (fh_table_write_value(table, data, row, AREA_TABLE_COL_EXFIT, &(area->exfit)) != FH_SUCCESS))
    {
-      fprintf(stderr, "error: Error writing data to row %d of area table.\n", row);
+      fprintf(stderr, "\rerror: Error writing data to row %d of area table.\n", row);
       return FH_BAD_VALUE;
    }
@@ -346,4 +350,8 @@
       for(k=0; k<cell[j].npersist; k++) 
       {
+/* Retire old burns */
+	 if(cell[j].time - cell[j].persist[k].time > EXPIRE_TRAIL_TIME)
+	    continue;
+
 	 if(PERSIST_RETAIN) {
 /* Keep fits which have a dubious slope */
@@ -422,5 +430,5 @@
       (fh_table_write_value(table, data, row, FIT_TABLE_COL_ZERO, &zero) != FH_SUCCESS))
    {
-      fprintf(stderr, "error: Error writing data to row %d of fit table.\n", row);
+      fprintf(stderr, "\rerror: Error writing data to row %d of fit table.\n", row);
       return FH_BAD_VALUE;
    }
@@ -460,4 +468,8 @@
       for(k=0; k<cell[j].npersist; k++) 
       {
+/* Retire old burns */
+	 if(cell[j].time - cell[j].persist[k].time > EXPIRE_TRAIL_TIME)
+	    continue;
+
 	 if(PERSIST_RETAIN) {
 /* Keep fits which have a dubious slope */
@@ -468,5 +480,5 @@
 	    if(cell[j].persist[k].fiterr) continue;
 	 }
-	 for(i=0; i<cell[j].persist[k].nfit; i++) 
+	 for(i=0; i<ABS(cell[j].persist[k].nfit); i++) 
          {
             result = write_fit_row(hu, data, table, row++,
@@ -493,5 +505,5 @@
 	 }
 
-	 for(i=0; i<cell[j].burn[k].nfit; i++) 
+	 for(i=0; i<ABS(cell[j].burn[k].nfit); i++) 
          {
             result = write_fit_row(hu, data, table, row++,
@@ -534,5 +546,5 @@
    {
       fprintf(stderr,
-              "error: Unable to get cell number from row %d of burn area table\n",
+              "\rerror: Unable to get cell number from row %d of burn area table\n",
               row);
       return FH_BAD_VALUE;
@@ -542,5 +554,5 @@
    if((cell_num < 0) || (cell_num > MAXCELL))
    {
-      fprintf(stderr, "error: illegal cell %d in area table row %d\n",
+      fprintf(stderr, "\rerror: illegal cell %d in area table row %d\n",
               cell_num, row);
       boxbuf[row].cell = -1;
@@ -576,5 +588,5 @@
    {
       fprintf(stderr,
-              "error: Error reading values from row %d of burn area table\n",
+              "\rerror: Error reading values from row %d of burn area table\n",
               row);
       boxbuf[row].nfit = 0;
@@ -583,5 +595,5 @@
    
    /* Make space for fits (to be read later). */
-   if(boxbuf[row].nfit > 0)
+   if(ABS(boxbuf[row].nfit) > 0)
    {
       /* This shouldn't happen, but be nice and don't leak. */
@@ -590,7 +602,14 @@
       if(boxbuf[row].yfit) free(boxbuf[row].yfit);
 
-      boxbuf[row].zero = (double *)calloc(boxbuf[row].nfit, sizeof(double));
-      boxbuf[row].xfit = (int *)calloc(boxbuf[row].nfit, sizeof(int));
-      boxbuf[row].yfit = (int *)calloc(boxbuf[row].nfit, sizeof(int));
+      boxbuf[row].zero = (double *)calloc(ABS(boxbuf[row].nfit), sizeof(double));
+      boxbuf[row].xfit = (int *)calloc(ABS(boxbuf[row].nfit), sizeof(int));
+      boxbuf[row].yfit = (int *)calloc(ABS(boxbuf[row].nfit), sizeof(int));
+
+      if(boxbuf[row].zero == NULL ||
+	 boxbuf[row].xfit == NULL ||
+	 boxbuf[row].yfit == NULL) {
+	 fprintf(stderr, "\rerror: failed to alloc boxbuf\n");
+	 exit(-671);
+      }
       boxbuf[row].fiterr = 0;
    }
@@ -627,5 +646,5 @@
       (fh_get_int(hu, "TFIELDS", &num_cols) != FH_SUCCESS))
    {
-      fprintf(stderr, "error: Unable to find required keywords for area table dimensions\n");
+      fprintf(stderr, "\rerror: Unable to find required keywords for area table dimensions\n");
       return FH_NOT_FOUND;
    }
@@ -634,5 +653,5 @@
    if(num_cols != table->num_cols) 
    {
-      fprintf(stderr, "error: %d-column area table found, expected %d cols.\n",
+      fprintf(stderr, "\rerror: %d-column area table found, expected %d cols.\n",
               num_cols, table->num_cols);
       return FH_BAD_VALUE;
@@ -642,5 +661,5 @@
    {
       fprintf(stderr, 
-              "error: too many boxes in area table. Max is %d, got %d\n",
+              "\rerror: too many boxes in area table. Max is %d, got %d\n",
               MAXBURN, num_rows);
       return FH_BAD_VALUE;
@@ -654,5 +673,5 @@
    {
       fprintf(stderr, 
-              "error: Unable to allocate %d bytes for area table.\n",
+              "\rerror: Unable to allocate %d bytes for area table.\n",
               table->table_size);
       return FH_NO_MEMORY;
@@ -662,5 +681,5 @@
                     table->table_size, FH_TYPESIZE_8) != FH_SUCCESS)
    {
-      fprintf(stderr, "error: Unable to map area table body for reading.\n");
+      fprintf(stderr, "\rerror: Unable to map area table body for reading.\n");
       free(data);
       return FH_INVALID;
@@ -713,5 +732,5 @@
    {
       fprintf(stderr,
-              "error: Unable to get cell number from row %d of fit table\n",
+              "\rerror: Unable to get cell number from row %d of fit table\n",
               row);
       return FH_BAD_VALUE;
@@ -720,5 +739,5 @@
    if((*cell < 0) || (*cell > MAXCELL))
    {
-      fprintf(stderr, "error: illegal cell %d in fit table row %d\n",
+      fprintf(stderr, "\rerror: illegal cell %d in fit table row %d\n",
               *cell, row);
       
@@ -733,5 +752,5 @@
    {
       fprintf(stderr,
-              "error: Error reading values from row %d of burn area table\n",
+              "\rerror: Error reading values from row %d of burn area table\n",
               row);
       return FH_BAD_VALUE;
@@ -782,5 +801,5 @@
       (fh_get_int(hu, "TFIELDS", &num_cols) != FH_SUCCESS))
    {
-      fprintf(stderr, "error: Unable to find required keywords for fit table dimensions\n");
+      fprintf(stderr, "\rerror: Unable to find required keywords for fit table dimensions\n");
       return FH_NOT_FOUND;
    }
@@ -789,5 +808,5 @@
    if(num_cols != table->num_cols) 
    {
-      fprintf(stderr, "error: %d-column fit table found, expected %d cols.\n",
+      fprintf(stderr, "\rerror: %d-column fit table found, expected %d cols.\n",
               num_cols, table->num_cols);
       return FH_BAD_VALUE;
@@ -805,5 +824,5 @@
    {
       fprintf(stderr, 
-              "error: Unable to allocate %d bytes for area table.\n",
+              "\rerror: Unable to allocate %d bytes for area table.\n",
               table->table_size);
       return FH_NO_MEMORY;
@@ -811,5 +830,5 @@
    if(fh_read_image(hu, fh_file_desc(hu), data, table->table_size, FH_TYPESIZE_8) != FH_SUCCESS)
    {
-      fprintf(stderr, "error: Unable to read fit table body.\n");
+      fprintf(stderr, "\rerror: Unable to read fit table body.\n");
       free(data);
       return FH_INVALID;
@@ -821,5 +840,5 @@
    for(area = 0; area < num_areas; area++)
    {
-      for(i = 0; i < boxbuf[area].nfit; i++)
+      for(i = 0; i < ABS(boxbuf[area].nfit); i++)
       {
          if((result = read_fit(hu, table, data, fit_table_row, 
@@ -836,5 +855,5 @@
          {
             fprintf(stderr, 
-                    "error: Fit in table row %d does not match current area "
+                    "\rerror: Fit in table row %d does not match current area "
                     "(table cell=%d cx=%d cy=%d vs. area cell=%d cx=%d cy=%d)\n",
                     fit_table_row,
@@ -891,5 +910,5 @@
    {
       fprintf(stderr, 
-              "error: unable to create header structure for FITS file \"%s\"\n",
+              "\rerror: unable to create header structure for FITS file \"%s\"\n",
               filename);
       return FH_NO_MEMORY;
@@ -899,6 +918,5 @@
    if ((result = fh_file(phu, filename, FH_FILE_RDONLY)) != FH_SUCCESS)
    {
-      fprintf(stderr, 
-              "error: unable to open FITS file \"%s\"\n",
+      fprintf(stderr, "\rerror: unable to open FITS file \"%s\"\n",
               filename);
       fh_destroy(phu);
@@ -911,6 +929,5 @@
    if(!area_hu || !fit_hu) 
    {
-      fprintf(stderr, 
-              "error: Unable to find persistence info in FITS file.\n");
+      fprintf(stderr, "\rerror: Unable to find persistence info in FITS file.\n");
       fh_destroy(phu);
       return FH_NOT_FOUND;
@@ -926,4 +943,5 @@
       free(fit_table.strbuf);
       fh_destroy(phu);
+      fprintf(stderr, "\rerror: Unable to read area table from FITS file.\n");
       return result;
    }
@@ -935,4 +953,5 @@
       free(fit_table.strbuf);
       fh_destroy(phu);
+      fprintf(stderr, "\rerror: Unable to read fit table from FITS file.\n");
       return result;
    }
@@ -961,5 +980,8 @@
       for(k=0; k<MAXCELL; k++) {
          if( (i=cell[k].npersist) > 0) {
-            cell[k].persist = (OBJBOX *)calloc(i, sizeof(OBJBOX));
+            if( (cell[k].persist = (OBJBOX *)calloc(i, sizeof(OBJBOX))) == NULL) {
+	       fprintf(stderr, "\rerror: failed to alloc cell persist buffer\n");
+	       exit(-672);
+	    }
             cell[k].npersist = 0;
          }
@@ -1018,5 +1040,5 @@
    {
       fprintf(stderr, 
-              "error: Unable to write correction info to FITS file. Correction FITS tables already exist.\n");
+              "\rerror: Unable to write correction info to FITS file. Correction FITS tables already exist.\n");
       return FH_NO_SPACE;
    }
@@ -1025,5 +1047,5 @@
    if ((fd = fh_file_desc(phu)) == -1)
    {
-      fprintf(stderr, "error: header passed has no associated file.\n");
+      fprintf(stderr, "\rerror: header passed has no associated file.\n");
       return FH_INVALID;
    }
@@ -1033,5 +1055,5 @@
    {
       fprintf(stderr,
-              "error: Unable to seek to end of file.\n");
+              "\rerror: Unable to seek to end of file.\n");
       return FH_IN_ERRNO;
    }
@@ -1042,5 +1064,5 @@
    {
       fprintf(stderr, 
-              "error: Unable to create headers for correction FITS tables.\n");
+              "\rerror: Unable to create headers for correction FITS tables.\n");
       if(area_hu) fh_destroy(area_hu);
       if(fit_hu) fh_destroy(fit_hu);
@@ -1066,5 +1088,5 @@
       (fh_munmap_table(area_hu) != FH_SUCCESS))
    {
-      fprintf(stderr, "error: Error encountered writing area table to FITS file.\n");
+      fprintf(stderr, "\rerror: Error encountered writing area table to FITS file.\n");
       fh_destroy(fit_hu);
       free(area_table.strbuf);
@@ -1087,5 +1109,5 @@
       (fh_munmap_table(fit_hu) != FH_SUCCESS))
    {
-      fprintf(stderr, "error: Error encountered writing area table to FITS file.\n");
+      fprintf(stderr, "\rerror: Error encountered writing area table to FITS file.\n");
       free(area_table.strbuf);
       free(fit_table.strbuf);
@@ -1149,5 +1171,5 @@
    if(fh_get_int(phu_in, "NEXTEND", &num_extensions) != FH_SUCCESS)
    {
-      fprintf(stderr, "error: Unable to get NEXTEND from input primary FITS header.\n");
+      fprintf(stderr, "\rerror: Unable to get NEXTEND from input primary FITS header.\n");
       return FH_INVALID;
    }
@@ -1157,5 +1179,5 @@
    {
       fprintf(stderr, 
-              "error: Unable to find persistence info in FITS file.\n");
+              "\rerror: Unable to find persistence info in FITS file.\n");
       return FH_INVALID;
    }
@@ -1175,5 +1197,5 @@
    if((fd_out = open(fileout, O_CREAT | O_RDWR, 0644)) < 0)
    {
-      fprintf(stderr, "error: Failed to open \"%s\" for output.\n",
+      fprintf(stderr, "\rerror: Failed to open \"%s\" for output.\n",
               fileout);
       exit(EXIT_FAILURE);
@@ -1192,5 +1214,5 @@
       (fh_write(phu_out, fd_out) != FH_SUCCESS))
    {
-      fprintf(stderr, "error: Unable to copy primary header to \"%s\"\n",
+      fprintf(stderr, "\rerror: Unable to copy primary header to \"%s\"\n",
               fileout);
       fh_destroy(phu_out);
@@ -1209,5 +1231,5 @@
       if(!(ehu_in = fh_ehu(phu_in, i)))
       {
-         fprintf(stderr, "error: Unable to read extension %d from input FITS file\n", i);
+         fprintf(stderr, "\rerror: Unable to read extension %d from input FITS file\n", i);
          fh_destroy(phu_out);
          close(fd_out);
@@ -1217,5 +1239,5 @@
       if (fh_get_str(ehu_in, "EXTNAME", extname, sizeof(extname)) != FH_SUCCESS)
       {
-         fprintf(stderr, "error: Unable to get EXTNAME from extension %d in input FITS file.\n", i); 
+         fprintf(stderr, "\rerror: Unable to get EXTNAME from extension %d in input FITS file.\n", i); 
          fh_destroy(phu_out);
          close(fd_out);
@@ -1233,5 +1255,5 @@
             (fh_reserve(ehu_out, (2880/80)) != FH_SUCCESS))
          {
-            fprintf(stderr, "error: Unable to copy extension %d to %s.\n", i, fileout); 
+            fprintf(stderr, "\rerror: Unable to copy extension %d to %s.\n", i, fileout); 
             fh_destroy(phu_out);
             close(fd_out);
@@ -1248,5 +1270,5 @@
             (fh_copy_padded_image(ehu_out, fd_out, fh_file_desc(ehu_in)) != FH_SUCCESS))
          {
-            fprintf(stderr, "error: Unable to copy extension %d to %s.\n", i, fileout); 
+            fprintf(stderr, "\rerror: Unable to copy extension %d to %s.\n", i, fileout); 
             fh_destroy(phu_out);
             close(fd_out);
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c	(revision 26764)
@@ -51,9 +51,16 @@
 	     &boxbuf[nbox].slope, &boxbuf[nbox].nfit,
 	     &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit);
-      if(boxbuf[nbox].nfit > 0) {
-	 boxbuf[nbox].zero = (double *)calloc(boxbuf[nbox].nfit, sizeof(double));
-	 boxbuf[nbox].xfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int));
-	 boxbuf[nbox].yfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int));
-	 for(i=0; i<boxbuf[nbox].nfit; i++) {
+      if(ABS(boxbuf[nbox].nfit) > 0) {
+	 boxbuf[nbox].zero = (double *)calloc(ABS(boxbuf[nbox].nfit), sizeof(double));
+	 boxbuf[nbox].xfit = (int *)calloc(ABS(boxbuf[nbox].nfit), sizeof(int));
+	 boxbuf[nbox].yfit = (int *)calloc(ABS(boxbuf[nbox].nfit), sizeof(int));
+	 if(boxbuf[nbox].zero == NULL ||
+	    boxbuf[nbox].xfit == NULL ||
+	    boxbuf[nbox].yfit == NULL) {
+	    fprintf(stderr, "\rerror: failed to alloc boxbuf\n");
+	    exit(-673);
+	 }
+
+	 for(i=0; i<ABS(boxbuf[nbox].nfit); i++) {
 	    if(fgets(line, 1024, fp) == NULL) {
 	       fprintf(stderr, "\rerror: short read of burn lines\n");
@@ -85,5 +92,8 @@
    for(k=0; k<MAXCELL; k++) {
       if( (i=cell[k].npersist) > 0) {
-	 cell[k].persist = (OBJBOX *)calloc(i, sizeof(OBJBOX));
+	 if( (cell[k].persist = (OBJBOX *)calloc(i, sizeof(OBJBOX))) == NULL) {
+	    fprintf(stderr, "\rerror: failed to alloc cell persist buffer\n");
+	    exit(-674);
+	 }
 	 cell[k].npersist = 0;
       }
@@ -149,9 +159,9 @@
 	 k = boxid[kp];
 	 zk = 0.0;
-	 if(box[k].nfit > 0) zk = box[k].zero[box[k].nfit/2];
+	 if(ABS(box[k].nfit) > 0) zk = box[k].zero[ABS(box[k].nfit)/2];
 	 for(jp=kp+1; jp<n; jp++) {
 	    j = boxid[jp];
 	    zj = 0.0;
-	    if(box[j].nfit > 0) zj = box[j].zero[box[j].nfit/2];
+	    if(ABS(box[j].nfit) > 0) zj = box[j].zero[ABS(box[j].nfit)/2];
 	    if(ABS(yctr[jp]-yctr[kp]) > DIFFERENT_STREAK) {
 /* Trim back the feebler streak */
@@ -242,4 +252,8 @@
       for(k=0; k<cell[j].npersist; k++) {
 
+/* Retire old burns */
+	 if(cell[j].time - cell[j].persist[k].time > EXPIRE_TRAIL_TIME)
+	    continue;
+
 	 if(PERSIST_RETAIN) {
 /* Keep fits which have a dubious slope */
@@ -265,5 +279,5 @@
 		 cell[j].persist[k].slope, cell[j].persist[k].nfit,
 		 cell[j].persist[k].sxfit, cell[j].persist[k].exfit);
-	 for(i=0; i<cell[j].persist[k].nfit; i++) {
+	 for(i=0; i<ABS(cell[j].persist[k].nfit); i++) {
 	    fprintf(fp, "%3d %3d %8.4f\n", cell[j].persist[k].xfit[i], 
 		    cell[j].persist[k].yfit[i], cell[j].persist[k].zero[i]);
@@ -301,5 +315,5 @@
 		 cell[j].burn[k].slope, cell[j].burn[k].nfit,
 		 cell[j].burn[k].sxfit, cell[j].burn[k].exfit);
-	 for(i=0; i<cell[j].burn[k].nfit; i++) {
+	 for(i=0; i<ABS(cell[j].burn[k].nfit); i++) {
 	    fprintf(fp, "%3d %3d %8.4f\n", cell[j].burn[k].xfit[i], 
 		    cell[j].burn[k].yfit[i], cell[j].burn[k].zero[i]);
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/psfstamp.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/psfstamp.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/psfstamp.c	(revision 26764)
@@ -112,5 +112,9 @@
 
 /* Make a postage stamp for it */
-      box[k].stamp = (IMTYPE *)calloc(size*size, sizeof(IMTYPE));
+      if( (box[k].stamp = (IMTYPE *)calloc(size*size, sizeof(IMTYPE))) == NULL) {
+	 fprintf(stderr, "\rerror: failed to stamp buffer\n");
+	 exit(-675);
+      }
+
       sum = 0;
       for(j=y0; j<=y1; j++) {
@@ -136,5 +140,5 @@
    int i, k, l, nstar, fdout, otacx, otacy, xid, yid, ntot=0, sumax;
    int cellcount, ota_xid, ota_yid;
-   double scale, phi, fwhm[3], q[5], qt, xfp, yfp, pi=4*atan(1.0);
+   double scale, phi, fwhm[3], q[7], qt, xfp, yfp, pi=4*atan(1.0);
    IMTYPE *median_image;
    CELL *cell;
@@ -171,5 +175,8 @@
 
 /* Create a median image and write as the first one */
-   median_image = (IMTYPE *)calloc(nx*ny, sizeof(IMTYPE));
+   if( (median_image = (IMTYPE *)calloc(nx*ny, sizeof(IMTYPE))) == NULL) {
+      fprintf(stderr, "\rerror: failed to alloc median PSF image\n");
+      exit(-676);
+   }
    for(i=0; i<nx*ny; i++) {
       nstar = 0;
@@ -256,15 +263,18 @@
    int k, l, cellx, celly, ota_xid, ota_yid, nfwave, nqavg;
    double xota, yota, xfp, yfp, phi;
-   double fwhm[3], q[5], fw[MAXPSFMEDIAN];
+   double fwhm[3], q[7], fw[MAXPSFMEDIAN];
    double m2[MAXPSFMEDIAN], qp[MAXPSFMEDIAN], qc[MAXPSFMEDIAN];
    double qt[MAXPSFMEDIAN], fwavg[MAXPSFMEDIAN];
+   double qpavg[MAXPSFMEDIAN], qcavg[MAXPSFMEDIAN], qtavg[MAXPSFMEDIAN];
    double q3c[MAXPSFMEDIAN], q3s[MAXPSFMEDIAN];
-   double qpavg[MAXPSFMEDIAN], qcavg[MAXPSFMEDIAN], qtavg[MAXPSFMEDIAN];
    double q3cavg[MAXPSFMEDIAN], q3savg[MAXPSFMEDIAN];
+   double q1c[MAXPSFMEDIAN], q1s[MAXPSFMEDIAN];
+   double q1cavg[MAXPSFMEDIAN], q1savg[MAXPSFMEDIAN];
    int nstar[MAXCELL], nfw[MAXCELL];
    double fwmed[MAXCELL], m2med[MAXCELL];
    double qpmed[MAXCELL], qcmed[MAXCELL], qtmed[MAXCELL];
    double q3cmed[MAXCELL], q3smed[MAXCELL];
-   double qpmacro, qcmacro, qtmacro, fwmacro, q3cmacro, q3smacro;
+   double q1cmed[MAXCELL], q1smed[MAXCELL];
+   double qpmacro, qcmacro, qtmacro, fwmacro, q3cmacro, q3smacro, q1cmacro, q1smacro;
    FILE *fp;
    CELL *cell;
@@ -310,4 +320,6 @@
 		     q3c[nstar[k]] = q[3];
 		     q3s[nstar[k]] = q[4];
+		     q1c[nstar[k]] = q[5];
+		     q1s[nstar[k]] = q[6];
 /* Get the position in the focal plane and therefore the qt statistic */
 		     psc_cell_to_pixel(cellx, celly, 0.5*PSC_HCELL/PSC_PIXEL, 
@@ -333,7 +345,10 @@
 		  q3cmed[k] = double_median(nstar[k], q3c);
 		  q3smed[k] = double_median(nstar[k], q3s);
+		  q1cmed[k] = double_median(nstar[k], q1c);
+		  q1smed[k] = double_median(nstar[k], q1s);
 	       } else {
 		  m2med[k] = qpmed[k] = qcmed[k] = qtmed[k] = -99.99;
 		  q3cmed[k] = q3smed[k] = -99.99;
+		  q1cmed[k] = q1smed[k] = -99.99;
 	       }
 /* Toss these results into the macrocell median hopper */
@@ -348,4 +363,6 @@
 		     q3cavg[nqavg] = q3c[l];
 		     q3savg[nqavg] = q3s[l];
+		     q1cavg[nqavg] = q1c[l];
+		     q1savg[nqavg] = q1s[l];
 		     nqavg++;
 		  }
@@ -359,5 +376,7 @@
 	 q3cmacro = double_median(nqavg, q3cavg);
 	 q3smacro = double_median(nqavg, q3savg);
-	 if(nqavg == 0) qpmacro = qcmacro = qtmacro = q3cmacro = q3smacro = -99.99;
+	 q1cmacro = double_median(nqavg, q1cavg);
+	 q1smacro = double_median(nqavg, q1savg);
+	 if(nqavg == 0) qpmacro = qcmacro = qtmacro = q3cmacro = q3smacro = q1cmacro = q1smacro = -99.99;
 	 fwmacro = double_median(nfwave, fwavg);
 
@@ -370,9 +389,11 @@
 	       cell = ota + k;
 
-	       fprintf(fp, "ext=xy%1d%1d bias=%d sky=%d rmssky=%d npsf=%d fwhm=%.2f fwmed=%.2f m2=%.2f qp=%.3f qc=%.3f qt=%.3f q3c=%.3f q3s=%.3f qpm=%.3f qcm=%.3f qtm=%.3f q3cm=%.3f q3sm=%.3f\n", 
+	       fprintf(fp, "ext=xy%1d%1d bias=%d sky=%d rmssky=%d npsf=%d fwhm=%.2f fwmed=%.2f m2=%.2f qp=%.3f qc=%.3f qt=%.3f q3c=%.3f q3s=%.3f q1c=%.3f q1s=%.3f qpm=%.3f qcm=%.3f qtm=%.3f q3cm=%.3f q3sm=%.3f q1cm=%.3f q1sm=%.3f\n", 
 		       cellx, celly, cell->bias, cell->sky, cell->rms, 
 		       nstar[k], fwmed[k], fwmacro, m2med[k], 
-		       qpmed[k], qcmed[k], qtmed[k], q3cmed[k], q3smed[k],
-		       qpmacro, qcmacro, qtmacro, q3cmacro, q3smacro);
+		       qpmed[k], qcmed[k], qtmed[k], q3cmed[k], q3smed[k], 
+		       q1cmed[k], q1smed[k],
+		       qpmacro, qcmacro, qtmacro, q3cmacro, q3smacro, 
+		       q1cmacro, q1smacro);
 	    }
 	 }
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c	(revision 26764)
@@ -193,4 +193,8 @@
    cell->burn = (OBJBOX *)calloc(cell->nburn, sizeof(OBJBOX));
    cell->star = (OBJBOX *)calloc(cell->nstar, sizeof(OBJBOX));
+   if( cell->burn == NULL || cell->star == NULL) {
+      fprintf(stderr, "\rerror: failed to alloc burn box\n");
+      exit(-678);
+   }
 
 /* Copy the boxes to the cell info structure */
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c	(revision 26764)
@@ -137,4 +137,8 @@
    box->xfit = (int *)calloc(xe-xs+1, sizeof(int));
    box->yfit = (int *)calloc(xe-xs+1, sizeof(int));
+   if(box->zero == NULL || box->xfit == NULL || box->yfit == NULL) {
+      fprintf(stderr, "\rerror: failed to alloc box memory\n");
+      exit(-679);
+   }
 /* Some defaults */
    box->slope = 0.0;
@@ -226,6 +230,11 @@
 /* FIXME: sanity check fits */
    if(slope >= FIT_MAX_SLOPE || slope < FIT_MIN_SLOPE) {
+/* Check whether it's a significant trail (but with wrong slope) or just 
+ * noise.  In the former case negate box->nfit, 
+ * in the latter case set it to zero. */
+      linearrms(nfit, ybuf+y1, zbuf+y1, slope, zero, &trial);
       box->slope = slope;
-      box->nfit = 0;
+      if(trial > 2*rms) box->nfit = -box->nfit;
+      else box->nfit = 0;
       box->fiterr = FIT_SLOPE_ERROR;
       return(-1);
@@ -268,5 +277,8 @@
 /* FIXME: what's a really good criterion for negligible fit? */
 /* 100 pixels up fit is zsum or ~zsum/e */
-      if(zsum > NEGLIGIBLE_TRAIL*rms) {
+//      if(zsum > NEGLIGIBLE_TRAIL*rms) {
+      if(zsum > NEGLIGIBLE_TRAIL*rms ||
+/* 100113: but also evaluate at the end of the fit for stubby trails */
+	 zbuf[y2]*zsum > NEGLIGIBLE_TRAIL*rms) {
 
 /* Ascertain the starting point of where the fit is good */
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/general.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/general.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/general.h	(revision 26764)
@@ -79,4 +79,5 @@
 MK_PFL( 10.0,   BZERO   ,1, "Zero factor"                                     )
 MK_PFL( 11.0,	BSCALE  ,1, "Scale factor"                                    )
+MK_STR( 12.0,	BUNIT   ,   "fits-data * BSCALE + BZERO = these units"        )
 
 /*
@@ -90,4 +91,13 @@
 MK_CMT(   50.5, CMTSUM5 ,   ""                                                )
 MK_STR(   51.0, CMMTOBS ,   ""                                                )
+MK_STR(   51.1, CMMTOBS1,   ""                                                )
+MK_STR(   51.2, CMMTOBS2,   ""                                                )
+MK_STR(   51.3, CMMTOBS3,   ""                                                )
+MK_STR(   51.4, CMMTOBS4,   ""                                                )
+MK_STR(   51.5, CMMTOBS5,   ""                                                )
+MK_STR(   51.6, CMMTOBS6,   ""                                                )
+MK_STR(   51.7, CMMTOBS7,   ""                                                )
+MK_STR(   51.8, CMMTOBS8,   ""                                                )
+MK_STR(   51.9, CMMTOBS9,   ""                                                )
 MK_STR(   52.0, CMMTSEQ ,   ""                                                )
 MK_STR(   53.0, OBJECT  ,   ""                                                )
@@ -127,5 +137,9 @@
 
 MK_STR(   95.0, OBSTYPE,    "Observation/Exposure type"                       )
-MK_PFL(   96.0, EXPTIME,3,  "Exposure time (seconds)"                         )
-MK_PFL(   96.1, EXPREQ ,3,  "Exposure time requested (seconds)"               )
-MK_PFL(   97.0, DARKTIME,3, "Dark current time (seconds)"                     )
+MK_PFL(   96.0, EXPTIME,3,  "[sec] Exposure time"                             )
+MK_PFL(   96.1, EXPREQ ,3,  "[sec] Exposure time requested"                   )
+MK_PFL(   97.0, DARKTIME,3, "[sec] Dark current time"                         )
+MK_INT(   97.5,  PONTIME,   "[sec] Time since last detector \"power on\""     )
+MK_INT(   97.6,  SATTIME,   "[sec] Time since last detected saturation event" )
+MK_INT(   97.7,  TRKTIME,   "[sec] Time since last detected tracking error"   )
+MK_INT(   97.8,  VDOTIME,   "[sec] Time since \"video\" command used"         )
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_all.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_all.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_all.h	(revision 26764)
@@ -20,2 +20,3 @@
 #include "gpc_wcs.h"
 #include "gpc_plant.h"
+#include "gpc_postprocess.h"
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_detector.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_detector.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_detector.h	(revision 26764)
@@ -69,13 +69,22 @@
 MK_INT(  152.1, SATURATE,   "[ADU] Saturation value"                          )
 MK_FLT(  155.0,	GAIN    ,3, "[e/ADU] est. gain from xray"                     )
-MK_FLT(  155.9, XRNOISE, 2, "[ADU] RMS noise in overscan on xray"             )
-MK_FLT(  156.0,	RDNOISE ,2, "[ADU] RMS Read noise on overscan"                )
+MK_FLT(  155.9, XRNOISE, 3, "[e] RMS noise in overscan on xray"               )
+MK_FLT(  156.0, RDNOISE ,3, "[e] Read noise"                                  )
 MK_FLT(  157.0, DCURRENT,5, "[ADU/pixel/sec] Dark current"                    )
 MK_FLT(  157.1, DARKCUR ,5, "[e-/pixel/hour] Dark current"                    )
 MK_STR(  158.0,	QEPOINTS,   "QE%@wavelength in nm"                            )
 MK_INT(  159.0, BIASLVL,    "[ADU] Bias level (overscan mean)"                )
-MK_INT(  159.2, BACKEST,    "[ADU] Background level est., overscan corrected" )
+MK_INT(  159.2, BACKEST,    "[ADU] Background level estimation"               )
 MK_STR(  165.0,	DETSTAT	,   "Detector status"                                 )
 MK_FLT(  166.0, DETTEM  ,3, "[C] Detector temperature"                        )
+MK_CMT(  166.1, CMTDETT1,   "If DETTEMOV is T, DETTEMP was overridden. Old"   )
+MK_CMT(  166.2, CMTDETT2,   "temp. is CDETTEM and new temp. was derived as:"  )
+MK_CMT(  166.3, CMTDETT3,   "V = (ADU-B) / (A*32768)"                         )
+MK_CMT(  166.4, CMTDETT4,   "T = 3369-sqrt[3369^2+1313^2*(13.1*V-1)/(V-1)]"   )
+MK_BLN(  166.5, DETTEMOV,   "Detector temperature overridden"                 )
+MK_INT(  166.6, DETTEADU,   "[ADU] Detector temperature A/D measurement"      )
+MK_PFL(  166.7, DETTCOFA,3, "Coefficient A used in overriding detector temp." )
+MK_INT(  166.8, DETTCOFB,   "Coefficient B used in overriding detector temp." )
+MK_FLT(  166.9, CDETTEM ,3, "[C] Detector temperature calc. by controller"    )
 MK_PFL(  170.0,	PIXSIZE ,3, "[um] Pixel size for both axes"                   )
 MK_PFL(  171.1,	PIXSIZE1,3, "[um] Pixel size for axis 1"                      )
@@ -105,4 +114,5 @@
 MK_INT(  185.2,	CCDBIN2	,   "Binning factor along axis 2"                     )
 MK_INT(  186.1, PRESCAN1,   "Prescan count on axis 1"                         )
+MK_INT(  186.11,PRESCANX,   "Post-xtrig-bias portion of prescan1"             )
 MK_INT(  186.2, PRESCAN2,   "Prescan count on axis 2"                         )
 MK_INT(  187.1, OVRSCAN1,   "Overscan count on axis 1"                        )
@@ -144,4 +154,20 @@
 MK_INT(  198.07,CON_UP,     "[seconds] Controller up-time"                    )
 MK_STR(  198.08,CON_VSUM,   "Device operating point md5sum"                   )
+MK_INT(  198.10,FPGASER,    "Controller FPGA board serial number"             )
+MK_STR(  198.11,FPGAVER,    "Controller FPGA board version"                   )
+MK_STR(  198.12,FPGATAR,    "Controller FPGA board target system"             )
+MK_STR(  198.13,FPGAEC,     "Controller FPGA board engineering changes"       )
+MK_INT(  198.20,DAQ3USER,   "Controller DAQ3U board serial number"            )
+MK_STR(  198.21,DAQ3UVER,   "Controller DAQ3U board version"                  )
+MK_STR(  198.22,DAQ3UTAR,   "Controller DAQ3U board target system"            )
+MK_STR(  198.23,DAQ3UEC,    "Controller DAQ3U board engineering changes"      )
+MK_INT(  198.20,PREAMSER,   "Controller Preamp board serial number"           )
+MK_STR(  198.21,PREAMVER,   "Controller Preamp board version"                 )
+MK_STR(  198.22,PREAMTAR,   "Controller Preamp board target system"           )
+MK_STR(  198.23,PREAMEC,    "Controller Preamp board engineering changes"     )
+MK_INT(  198.30,DAQLBSER,   "DAQ3U loopback test board serial number"         )
+MK_STR(  198.31,DAQLBVER,   "DAQ3U loopback test board version"               )
+MK_STR(  198.32,DAQLBTAR,   "DAQ3U loopback test board target system"         )
+MK_STR(  198.33,DAQLBEC,    "DAQ3U loopback test board engineering changes"   )
 MK_INT(  198.40,TSP_SHOP,   "Milliseconds from last clean to shutter open"    )
 MK_INT(  198.41,TSP_SHCL,   "Milliseconds from last clean to shutter close"   )
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_instrument.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_instrument.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_instrument.h	(revision 26764)
@@ -63,4 +63,9 @@
 MK_PFL( 1009.11,L3AIRTMP,1, "[C] Air temperature in space above L3"           )
 MK_PFL( 1009.12,L3DEWPT, 1, "[C] Calculated dew point in space above L3"      )
+MK_PFL( 1009.20,ENHUMID, 1, "[%] Rel. humidity of cam. evironment (ferit)"    )
+MK_PFL( 1009.21,ENAIRTMP,1, "[C] Air temperature of camera environment"       )
+MK_PFL( 1009.22,ENDEWPT, 1, "[C] Calculated dew point of camera environment"  )
+MK_STR( 1009.30,GLYSTAT,    "Camera heat exchanger glycol status"             )
+MK_STR( 1009.31,GLYMODE,    "Camera heat exchanger glycol mode"               )
 MK_STR( 1010.0, FILTSTAT,   "Filter mechanism status"                         )
 MK_STR( 1010.1, FILTERID,   "Filter glass identification"                     )
@@ -80,2 +85,17 @@
 MK_INT( 1224.0, SH_ARMPN  , "motion controller input pins"                    )
 MK_PFL( 1225.0, SH_DIODE,1, "Vref/4096 (Vref=5V nominal) photodiode volts"    )
+MK_STR( 1260.1, CS_LIGHT,   "Cal screen laser status during exposure"         )
+MK_STR( 1261.0, CS_LIMIT,   "Cal screen laser exposure limit: time|volt"      )
+MK_PFL( 1262.0, CS_WAVE,1,  "Cal screen laser wavelength"                     )
+MK_PFL( 1263.0, CS_EXPT,1,  "Cal screen laser exposure time"                  )
+MK_PFL( 1264.0, CS_VOLTS,3, "Cal screen laser photodiode limit voltage"       )
+MK_PFL( 1265.1, CS_INTV1,3, "Cal screen photodiode integrator pre-voltage"    )
+MK_PFL( 1265.2, CS_INTV2,3, "Cal screen photodiode integrator start-voltage"  )
+MK_PFL( 1265.3, CS_INTV3,3, "Cal screen photodiode integrator stop-voltage"   )
+MK_PFL( 1265.4, CS_INTV4,3, "Cal screen photodiode integrator post-voltage"   )
+MK_PFL( 1266.1, CS_INTT1,3, "Cal screen photodiode integrator pre-seconds"    )
+MK_PFL( 1266.2, CS_INTT2,3, "Cal screen photodiode integrator exposure sec"   )
+MK_PFL( 1266.3, CS_INTT3,3, "Cal screen photodiode integrator post-seconds"   )
+MK_PFL( 1267.0, CS_SHOP,3,  "GPC1 shutter open start"                         )
+MK_PFL( 1268.0, CS_SHCL,3,  "GPC1 shutter close start"                        )
+
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_shutter.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_shutter.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_shutter.h	(revision 26764)
@@ -57,13 +57,13 @@
 MK_STR(  201.0,	SHUTSTAT,   "Shutter status"                                  )
 MK_STR(  201.1,	SHUTERR,    "Shutter error code"                              )
-MK_STR(  202.00,SHUTOPEN,   "Shutter open time (TAI)"                         )
-MK_STR(  202.01,SHUTCLOS,   "Shutter close time (TAI)"                        )
-MK_PFL(  202.02,SHUTOPWN,6, "Shutter open uncertainty before SHUTOPEN (sec)"  )
-MK_PFL(  202.03,SHUTCLWN,6, "Shutter close uncertainty before SHUTCLOS (sec)" )
-MK_STR(  202.04,SHUTOUTC,   "Shutter open time (UTC)"                         )
-MK_STR(  202.05,SHUTCUTC,   "Shutter close time (UTC)"                        )
-MK_INT(  202.06,SHUTLEAP,   "Leap seconds used in TAI-UTC conversion (sec)"   )
-MK_PFL(  202.07,SHUTREQ, 6, "Requested exposure duration (sec)"               )
-MK_PFL(  202.08,SHUTTIME,6, "Actual exposure duration (sec)"                  )
+MK_STR(  202.00,SHUTOPEN,   "[TAI date time] Shutter open time"               )
+MK_STR(  202.01,SHUTCLOS,   "[TAI date time] Shutter close time"              )
+MK_PFL(  202.02,SHUTOPWN,6, "[sec] Shutter open uncertainty before SHUTOPEN"  )
+MK_PFL(  202.03,SHUTCLWN,6, "[sec] Shutter close uncertainty before SHUTCLOS" )
+MK_STR(  202.04,SHUTOUTC,   "[UTC date time] Shutter open time"               )
+MK_STR(  202.05,SHUTCUTC,   "[UTC date time] Shutter close time"              )
+MK_INT(  202.06,SHUTLEAP,   "[sec] Leap seconds used in TAI-UTC conversion"   )
+MK_PFL(  202.07,SHUTREQ, 6, "[sec] Requested exposure duration"               )
+MK_PFL(  202.08,SHUTTIME,6, "[sec] Actual exposure duration"                  )
 MK_STR(  202.09,SHUTOPBL,   "Shutter blade in aperture at start of exposure"  )
 MK_STR(  202.10,SHUTCLBL,   "Shutter blade in aperture at end of exposure"    )
Index: /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_telescope.h
===================================================================
--- /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_telescope.h	(revision 26763)
+++ /branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_telescope.h	(revision 26764)
@@ -70,77 +70,121 @@
 MK_STR(  503.0, TELSTAT ,   "Telescope control system status"                 )
 MK_STR(  503.1, DOMSTAT ,   "Telescope enclosure status"                      )
-MK_STR(  503.2, GUISTAT ,   "Telescope guiding system status"                 )
-MK_STR(  503.3, GUICONF ,   "Telescope guiding configuration"                 )
-MK_STR(  503.4, GUIKERN ,   "Filter kernel used for guiding"                  )
-MK_PFL(  503.5, GUIGAIX ,2, "Telescope guiding gain factor (x offset)"        )
-MK_PFL(  503.6, GUIGAIY ,2, "Telescope guiding gain factor (y offset)"        )
-MK_PFL(  503.7, GUIRATE ,1, "Telescope guiding rate (Hz)"                     )
 MK_VAL(  521.1, EQUINOX ,   "Telescope equinox of coordinates"                )
 MK_VAL(  521.2, EPOCH   ,   "Telescope equinox of coordinates"                )
-MK_PFL(  522.1, RA      ,6, "Telescope Right Ascension (degrees)"             )
-MK_PFL(  522.2, DEC     ,6, "Telescope Declination (degrees)"                 )
-MK_PFL(  522.3, AZ      ,6, "Telescope azimuth (degrees)"                     )
-MK_PFL(  522.4, ALT     ,6, "Telescope pointing altitude (degrees)"           )
-MK_PFL(  522.5, ROT     ,6, "Telescope rotator angle (degrees)"               )
-MK_PFL(  522.6, POSANGLE,6, "Telescope position angle (degrees)"              )
-MK_PFL(  523.0, COMRA   ,6, "Commanded telescope Right Ascension (degrees)"   )
-MK_PFL(  523.1, COMDEC  ,6, "Commanded telescope Declination (degrees)"       )
-MK_PFL(  523.2, COMAZ   ,6, "Commanded telescope azimuth (degrees)"           )
-MK_PFL(  523.3, COMALT  ,6, "Commanded telescope pointing altitude (degrees)" )
-MK_PFL(  523.4, COMROT  ,6, "Commanded telescope rotator angle (degrees)"     )
-MK_PFL(  523.5, MOONANG ,6, "Angular distance to moon (degrees)" )
+MK_PFL(  522.1, RA      ,6, "[deg] Telescope FOV center Right Ascension"      )
+MK_PFL(  522.2, DEC     ,6, "[deg] Telescope FOV center Declination"          )
+MK_STR(  522.21,RASTRNG ,   "[deg:mm:ss] Telescope sexagesimal Right Ascen."  )
+MK_STR(  522.22,DECSTRNG,   "[deg:mm:ss] Telescope sexagesimal Declination"   )
+MK_PFL(  522.3, AZ      ,6, "[deg] Telescope azimuth"                         )
+MK_PFL(  522.4, ALT     ,6, "[deg] Telescope pointing altitude"               )
+MK_PFL(  522.5, ROT     ,6, "[deg] Telescope rotator angle"                   )
+MK_PFL(  522.6, POSANGLE,6, "[deg] Telescope position angle"                  )
+MK_PFL(  523.0, COMRA   ,6, "[deg] Commanded telescope Right Ascension"       )
+MK_PFL(  523.1, COMDEC  ,6, "[deg] Commanded telescope Declination"           )
+MK_PFL(  523.2, COMAZ   ,6, "[deg] Commanded telescope azimuth"               )
+MK_PFL(  523.3, COMALT  ,6, "[deg] Commanded telescope pointing altitude"     )
+MK_PFL(  523.4, COMROT  ,6, "[deg] Commanded telescope rotator angle"         )
+MK_PFL(  523.5, MOONANG ,6, "[deg] Angular distance to moon"                  )
+MK_PFL(  523.6, AIRMASS ,3, "Airmass at start of observation"                 )
 MK_CMT(  530.00,CMTTELO1,   "NOTE: Telescope RA DEC or ALT AZ already include")
 MK_CMT(  530.10,CMTTELO2,   "      the following offsets.  Do not re-apply!"  )
-MK_PFL(  532.1, TELOFRA ,6, "Telescope offset in RA (degrees)"                )
-MK_PFL(  532.2, TELOFDEC,6, "Telescope offset in DEC (degrees)"               )
-MK_PFL(  532.3, TELOFAZ ,6, "Telescope offset in AZ (degrees)"                )
-MK_PFL(  532.4, TELOFALT,6, "Telescope offset in ALT (degrees)"               )
-MK_PFL(  532.5, TELOFROT,6, "Telescope offset in ROT (degrees)"               )
-MK_PFL(  532.7, TELOFX  ,6, "Telescope offset in camera X (degrees)"          )
-MK_PFL(  532.8, TELOFY  ,6, "Telescope offset in camera Y (degrees)"          )
-MK_PFL(  540.1, AIRMASS ,3, "Airmass at start of observation"                 )
-MK_PFL(  541.1, M1X     ,6, "Primary mirror x position (um)"                  )
-MK_PFL(  541.2, M1Y     ,6, "Primary mirror y position (um)"                  )
-MK_PFL(  541.3, M1Z     ,6, "Primary mirror z position (um)"                  )
-MK_PFL(  541.4, M1TIP   ,6, "Primary mirror tip (arcsec)"                     )
-MK_PFL(  541.5, M1TILT  ,6, "Primary mirror tilt (arcsec)"                    )
-MK_PFL(  542.1, M2X     ,6, "Secondary mirror x position (um)"                )
-MK_PFL(  542.2, M2Y     ,6, "Secondary mirror y position (um)"                )
-MK_PFL(  542.3, M2Z     ,6, "Secondary mirror z position (um)"                )
-MK_PFL(  542.4, M2TIP   ,6, "Secondary mirror tip (arcsec)"                   )
-MK_PFL(  542.5, M2TILT  ,6, "Secondary mirror tilt (arcsec)"                  )
+MK_PFL(  532.1, TELOFRA ,6, "[deg] Telescope offset in RA"                    )
+MK_PFL(  532.2, TELOFDEC,6, "[deg] Telescope offset in DEC"                   )
+MK_PFL(  532.3, TELOFAZ ,6, "[deg] Telescope offset in AZ"                    )
+MK_PFL(  532.4, TELOFALT,6, "[deg] Telescope offset in ALT"                   )
+MK_PFL(  532.5, TELOFROT,6, "[deg] Telescope offset in ROT"                   )
+MK_PFL(  532.7, TELOFX  ,6, "[deg] Telescope offset in camera X"              )
+MK_PFL(  532.8, TELOFY  ,6, "[deg] Telescope offset in camera Y"              )
+
+/*
+ * Guiding
+ */
+MK_STR(  540.00,GUISTAT ,   "Telescope guiding system status"                 )
+MK_STR(  540.01,GUICONF ,   "Telescope guiding configuration"                 )
+MK_STR(  540.02,GUISTAR ,   "Telescope guiding (single or multi-star)"        )
+MK_BLN(  540.03,GUIROTEN,   "Telescope guiding rotation enabled"              )
+MK_PFL(  540.10,GUIGAIX ,2, "Telescope guiding gain factor (x offset)"        )
+MK_PFL(  540.11,GUIGAIY ,2, "Telescope guiding gain factor (y offset)"        )
+MK_PFL(  540.12,GUIRATE ,1, "[Hz] Telescope guiding rate"                     )
+MK_STR(  540.20,GUIKERN ,   "Filter kernel used for guiding"                  )
+MK_STR(  540.21,GUIKERN1,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.22,GUIKERN2,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.23,GUIKERN3,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.24,GUIKERN4,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.25,GUIKERN5,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.26,GUIKERN6,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.27,GUIKERN7,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.28,GUIKERN8,   "Filter kernel used for guiding (cont)"           )
+MK_STR(  540.29,GUIKERN9,   "Filter kernel used for guiding (cont)"           )
+MK_INT(  540.30,GUIKLEN ,   "Number of taps in filter kernel"                 )
+MK_INT(  540.31,GUIKSUM ,   "Sum of all filter kernel taps"                   )
+MK_INT(  540.40,GUINSTAR,   "Number of guide stars sought"                    )
+MK_INT(  540.41,GUINOK,     "Number of guide stars used (median)"             )
+MK_INT(  540.42,GUIERR,     "90 percentile of guide fit error codes"          )
+MK_PFL(  540.43,GUIDR,   2, "[arcsec] median RMS of guide star offsets"       )
+MK_PFL(  540.50,GUIXMED, 2, "[arcsec] median x offset of guide stars"         )
+MK_PFL(  540.51,GUIX50,  2, "[arcsec] 50% range of guide star x"              )
+MK_PFL(  540.52,GUIX90,  2, "[arcsec] 90% range of guide star x"              )
+MK_PFL(  540.60,GUIYMED, 2, "[arcsec] median y offset of guide stars"         )
+MK_PFL(  540.61,GUIY50,  2, "[arcsec] 50% range of guide star y"              )
+MK_PFL(  540.62,GUIY90,  2, "[arcsec] 90% range of guide star y"              )
+MK_PFL(  540.70,GUIROT,  4, "[deg] median rotation offset of guide stars"     )
+MK_PFL(  540.71,GUIROT50,4, "[deg] 50% range of rotation offset"              )
+MK_PFL(  540.72,GUIROT90,4, "[deg] 90% range of rotation offset"              )
+MK_PFL(  540.80,GUIFWMED,2, "[arcsec] median guide star FWHM"                 )
+MK_PFL(  540.81,GUIFW50, 2, "[arcsec] 50% range of guide star FWHM"           )
+MK_PFL(  540.82,GUIFW90, 2, "[arcsec] 90% range of guide star FWHM"           )
+MK_PFL(  540.90,GUIM1MED,2, "[mag] median zeropoint"                          )
+MK_PFL(  540.91,GUIM150, 2, "[mag] 50% range of median zeropoint"             )
+MK_PFL(  540.92,GUIM190, 2, "[mag] 90% range of median zeropoint"             )
+MK_PFL(  540.93,GUIXTNCT,2, "[mag] total extinction during exposure"          )
+MK_PFL(  540.94,GUIZPRMS,2, "[mag] median RMS scatter of zeropoints"          )
+
+/*
+ * Mirror info
+ */
+MK_PFL(  541.1, M1X     ,6, "[um] Primary mirror x position"                  )
+MK_PFL(  541.2, M1Y     ,6, "[um] Primary mirror y position"                  )
+MK_PFL(  541.3, M1Z     ,6, "[um] Primary mirror z position"                  )
+MK_PFL(  541.4, M1TIP   ,6, "[arcsec] Primary mirror tip"                     )
+MK_PFL(  541.5, M1TILT  ,6, "[arcsec] Primary mirror tilt"                    )
+MK_PFL(  542.1, M2X     ,6, "[um] Secondary mirror x position"                )
+MK_PFL(  542.2, M2Y     ,6, "[um] Secondary mirror y position"                )
+MK_PFL(  542.3, M2Z     ,6, "[um] Secondary mirror z position"                )
+MK_PFL(  542.4, M2TIP   ,6, "[arcsec] Secondary mirror tip"                   )
+MK_PFL(  542.5, M2TILT  ,6, "[arcsec] Secondary mirror tilt"                  )
 MK_STR(  543.0, M1M2MODV,   "Telescope mirror position model version"         )
-MK_PFL(  543.1, M1NOMX  ,6, "Modeled Primary mirror x position (um)"          )
-MK_PFL(  543.2, M1NOMY  ,6, "Modeled Primary mirror y position (um)"          )
-MK_PFL(  543.3, M1NOMZ  ,6, "Modeled Primary mirror z position (um)"          )
-MK_PFL(  543.4, M1NOMTIP,6, "Modeled Primary mirror tip (arcsec)"             )
-MK_PFL(  543.5, M1NOMTIL,6, "Modeled Primary mirror tilt (arcsec)"            )
-MK_PFL(  544.1, M2NOMX  ,6, "Modeled Secondary mirror x position (um)"        )
-MK_PFL(  544.2, M2NOMY  ,6, "Modeled Secondary mirror y position (um)"        )
-MK_PFL(  544.3, M2NOMZ  ,6, "Modeled Secondary mirror z position (um)"        )
-MK_PFL(  544.4, M2NOMTIP,6, "Modeled Secondary mirror tip (arcsec)"           )
-MK_PFL(  544.5, M2NOMTIL,6, "Modeled Secondary mirror tilt (arcsec)"          )
-MK_STR(  550.1, TELTEMTR,   "Mid truss temperatures (C)"                      )
-MK_STR(  550.2, TELTEMSP,   "Spider temperatures (C)"                         )
-MK_STR(  550.3, TELTEMMS,   "Primary mirror support temps (C)"                )
-MK_STR(  550.4, TELTEMM1,   "Primary mirror temps (C)"                        )
-MK_STR(  550.5, TELTEMM2,   "Secondary mirror temps (C)"                      )
-MK_STR(  550.6, TELTEMEX,   "Miscellaneous temperatures (C)"                  )
+MK_PFL(  543.1, M1NOMX  ,6, "[um] Modeled Primary mirror x position"          )
+MK_PFL(  543.2, M1NOMY  ,6, "[um] Modeled Primary mirror y position"          )
+MK_PFL(  543.3, M1NOMZ  ,6, "[um] Modeled Primary mirror z position"          )
+MK_PFL(  543.4, M1NOMTIP,6, "[arcsec] Modeled Primary mirror tip"             )
+MK_PFL(  543.5, M1NOMTIL,6, "[arcsec] Modeled Primary mirror tilt"            )
+MK_PFL(  544.1, M2NOMX  ,6, "[um] Modeled Secondary mirror x position"        )
+MK_PFL(  544.2, M2NOMY  ,6, "[um] Modeled Secondary mirror y position"        )
+MK_PFL(  544.3, M2NOMZ  ,6, "[um] Modeled Secondary mirror z position"        )
+MK_PFL(  544.4, M2NOMTIP,6, "[arcsec] Modeled Secondary mirror tip"           )
+MK_PFL(  544.5, M2NOMTIL,6, "[arcsec] Modeled Secondary mirror tilt"          )
+MK_STR(  550.1, TELTEMTR,   "[C] MTL 11,12,2,3,5,6,8,9"                       )
+MK_STR(  550.2, TELTEMSP,   "[C] IS 10,1,4,7 O 10,1,4,7"                      )
+MK_STR(  550.3, TELTEMMS,   "[C] M1 Perim. 12,3,6,9,Air"                      )
+MK_STR(  550.4, TELTEMM1,   "[C] M1I 12,3,6,9 O12,3,6,9"                      )
+MK_STR(  550.5, TELTEMM2,   "[C] M2 I 12,O 12,3,3,6,6,9,9"                    )
+MK_STR(  550.6, TELTEMEX,   "[C] M2 Can Air,Surf,CentSec 12,3,6,9"            )
 
 /*
  * Wavefront
  */
-MK_PFL(  551.01,WVFA    ,14,"Wavefront A actuator force (N)"                  )
-MK_PFL(  551.02,WVFB    ,14,"Wavefront B actuator force (N)"                  )
-MK_PFL(  551.03,WVFC    ,14,"Wavefront C actuator force (N)"                  )
-MK_PFL(  551.04,WVFD    ,14,"Wavefront D actuator force (N)"                  )
-MK_PFL(  551.05,WVFE    ,14,"Wavefront E actuator force (N)"                  )
-MK_PFL(  551.06,WVFF    ,14,"Wavefront F actuator force (N)"                  )
-MK_PFL(  551.07,WVFG    ,14,"Wavefront G actuator force (N)"                  )
-MK_PFL(  551.08,WVFH    ,14,"Wavefront H actuator force (N)"                  )
-MK_PFL(  551.09,WVFI    ,14,"Wavefront I actuator force (N)"                  )
-MK_PFL(  551.10,WVFJ    ,14,"Wavefront J actuator force (N)"                  )
-MK_PFL(  551.11,WVFK    ,14,"Wavefront K actuator force (N)"                  )
-MK_PFL(  551.12,WVFL    ,14,"Wavefront L actuator force (N)"                  )
+MK_PFL(  551.01,WVFA    ,14,"[N] Wavefront A actuator force"                  )
+MK_PFL(  551.02,WVFB    ,14,"[N] Wavefront B actuator force"                  )
+MK_PFL(  551.03,WVFC    ,14,"[N] Wavefront C actuator force"                  )
+MK_PFL(  551.04,WVFD    ,14,"[N] Wavefront D actuator force"                  )
+MK_PFL(  551.05,WVFE    ,14,"[N] Wavefront E actuator force"                  )
+MK_PFL(  551.06,WVFF    ,14,"[N] Wavefront F actuator force"                  )
+MK_PFL(  551.07,WVFG    ,14,"[N] Wavefront G actuator force"                  )
+MK_PFL(  551.08,WVFH    ,14,"[N] Wavefront H actuator force"                  )
+MK_PFL(  551.09,WVFI    ,14,"[N] Wavefront I actuator force"                  )
+MK_PFL(  551.10,WVFJ    ,14,"[N] Wavefront J actuator force"                  )
+MK_PFL(  551.11,WVFK    ,14,"[N] Wavefront K actuator force"                  )
+MK_PFL(  551.12,WVFL    ,14,"[N] Wavefront L actuator force"                  )
 
 /*
@@ -151,5 +195,5 @@
 MK_PFL(  560.3, ENVWIN,  1, "[m/s]         Weather, wind speed"               )
 MK_PFL(  560.4, ENVDIR,  1, "[deg E. of N] Weather, wind direction"           )
-MK_PFL(  561.0, SEEING,  1, "[arcsec]      Weather, seeing from DIMM, FWHM"   )
+MK_PFL(  561.0, SEEING,  3, "[arcsec]      Weather, seeing from DIMM, FWHM"   )
 
 /* 
@@ -157,10 +201,8 @@
  *
  *TYPE --IDX--  KEYWORD- PRC -------------------COMMENT----------------------*/
-MK_PFL( 586.02, HA      ,16,"Hour angle at start (degrees)"                   )
-MK_PFL( 586.03,	ST      ,16,"Sidereal time at start (hours)"                  )
-MK_PFL( 586.04,	ZD      ,16,"Zenith distance (degrees)"                       )
-MK_STR( 587.00,	RASTRNG ,   "Actual Right Ascension (incl offset)"            )
-MK_STR( 587.01,	DECSTRNG,   "Actual Declination (incl offset)"                )
+MK_PFL( 586.02, HA      ,16,"[deg] Hour angle at start"                       )
+MK_PFL( 586.03,	ST      ,16,"[hours] Sidereal time at start"                  )
+MK_PFL( 586.04,	ZD      ,16,"[deg] Zenith distance"                           )
 MK_STR( 587.02,	HASTRNG ,   "Hour angle at start"                             )
 MK_STR( 587.03,	STSTRNG ,   "Sidereal time at start"                          )     
-MK_STR( 587.04,	ZDSTRNG ,   "Zenith distance (deg:mm:ss)"                     )                   
+MK_STR( 587.04,	ZDSTRNG ,   "[deg:mm:ss] Zenith distance"                     )                   
Index: /branches/eam_branches/20091201/ippconfig/gpc1/camera.config
===================================================================
--- /branches/eam_branches/20091201/ippconfig/gpc1/camera.config	(revision 26763)
+++ /branches/eam_branches/20091201/ippconfig/gpc1/camera.config	(revision 26764)
@@ -149,3 +149,3 @@
 PHOTCODE.RULE           STR     {DETECTOR}.{FILTER.ID}.{CHIP.NAME}	# Rule for generating photcode
 
-BURNTOOL.STATE.GOOD     S16     13  # Value for burntool_state with the most recent bt version.
+BURNTOOL.STATE.GOOD     S16     14  # Value for burntool_state with the most recent bt version.
Index: /branches/eam_branches/20091201/ppImage/src/ppImageBurntoolMask.c
===================================================================
--- /branches/eam_branches/20091201/ppImage/src/ppImageBurntoolMask.c	(revision 26763)
+++ /branches/eam_branches/20091201/ppImage/src/ppImageBurntoolMask.c	(revision 26764)
@@ -3,5 +3,5 @@
 #endif
 
-/* #define PPIMAGE_BURNTOOL_DEBUG 1 */
+#define PPIMAGE_BURNTOOL_DEBUG 1
 
 #include "ppImage.h"
@@ -47,7 +47,7 @@
 
     if (psMetadataLookupS32(&status,rowMD,"cell") == burntool_cell) {
-      if (((options->burntoolTrails & 0x01)&&(psMetadataLookupS32(&status,rowMD,"nfit") == 0))||
-	  ((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1))||
-	  ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0))) {
+      if ((psMetadataLookupS32(&status,rowMD,"nfit") != 0)&&
+	  (((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1))||
+	   ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)))) {
 	/*       If the fit fails, burntool reports zero here.  This
 		 signifies that it expected to see a trail (else why
@@ -70,8 +70,8 @@
 	  if (psMetadataLookupS32(&status,rowMD,"up") == 0) {
 	    for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {
-/* #ifdef PPIMAGE_BURNTOOL_DEBUG */
-/* 	      psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", */
-/* 		       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); */
-/* #endif */
+#ifdef PPIMAGE_BURNTOOL_DEBUG
+	      psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
+		       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
+#endif
 	      image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
 	    }
@@ -79,8 +79,8 @@
 	  else {
 	    for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) {
-/* #ifdef PPIMAGE_BURNTOOL_DEBUG */
-/* 	      psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", */
-/* 		       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); */
-/* #endif */
+#ifdef PPIMAGE_BURNTOOL_DEBUG
+	      psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
+		       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
+#endif
 	      image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
 	    }
