Index: branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/get2mass_full.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/get2mass_full.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/get2mass_full.c	(revision 23239)
@@ -1,4 +1,6 @@
 # include "addstar.h"
 # include "2mass.h"
+
+// XXX check to see if desired output format is PS1_V1 or later?  (use 16bit version if not?)
 
 // fill in the data for a JHK triplet star.  takes a pointer to the start of the line the
@@ -171,12 +173,12 @@
 
   switch (qual) {
-    case 'X': star[0].measure.photFlags |= 0x0000; break;
-    case 'U': star[0].measure.photFlags |= 0x0001; break;
-    case 'F': star[0].measure.photFlags |= 0x0002; break;
-    case 'E': star[0].measure.photFlags |= 0x0003; break;
-    case 'A': star[0].measure.photFlags |= 0x0004; break;
-    case 'B': star[0].measure.photFlags |= 0x0005; break;
-    case 'C': star[0].measure.photFlags |= 0x0006; break;
-    case 'D': star[0].measure.photFlags |= 0x0007; break;
+    case 'A': star[0].measure.photFlags |= 0x00000001; break; // was: 0x0004
+    case 'B': star[0].measure.photFlags |= 0x00000002; break; // was: 0x0005
+    case 'C': star[0].measure.photFlags |= 0x00000004; break; // was: 0x0006
+    case 'D': star[0].measure.photFlags |= 0x00000008; break; // was: 0x0007
+    case 'E': star[0].measure.photFlags |= 0x00000010; break; // was: 0x0003
+    case 'F': star[0].measure.photFlags |= 0x00000020; break; // was: 0x0002
+    case 'U': star[0].measure.photFlags |= 0x00000040; break; // was: 0x0001
+    case 'X': star[0].measure.photFlags |= 0x00000080; break; // was: 0x0000
     default: 
       fprintf (stderr, "error!\n");
@@ -189,11 +191,11 @@
 
   switch (qual) {
-    case '0': star[0].measure.photFlags |= 0x0000; break;
-    case '1': star[0].measure.photFlags |= 0x0010; break;
-    case '2': star[0].measure.photFlags |= 0x0020; break;
-    case '3': star[0].measure.photFlags |= 0x0030; break;
-    case '4': star[0].measure.photFlags |= 0x0040; break;
-    case '6': star[0].measure.photFlags |= 0x0050; break;
-    case '9': star[0].measure.photFlags |= 0x0060; break;
+    case '0': star[0].measure.photFlags |= 0x00000100; break; // was: 0x0000 
+    case '1': star[0].measure.photFlags |= 0x00000200; break; // was: 0x0010 
+    case '2': star[0].measure.photFlags |= 0x00000400; break; // was: 0x0020 
+    case '3': star[0].measure.photFlags |= 0x00000800; break; // was: 0x0030 
+    case '4': star[0].measure.photFlags |= 0x00001000; break; // was: 0x0040 
+    case '6': star[0].measure.photFlags |= 0x00002000; break; // was: 0x0050 
+    case '9': star[0].measure.photFlags |= 0x00004000; break; // was: 0x0060 
     default: 
       fprintf (stderr, "error!\n");
@@ -206,10 +208,10 @@
 
   switch (qual) {
-    case 'p': star[0].measure.photFlags |= 0x0000; break;
-    case 'c': star[0].measure.photFlags |= 0x0100; break;
-    case 'd': star[0].measure.photFlags |= 0x0200; break;
-    case 's': star[0].measure.photFlags |= 0x0300; break;
-    case 'b': star[0].measure.photFlags |= 0x0400; break;
-    case '0': star[0].measure.photFlags |= 0x0500; break;
+    case 'p': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0000
+    case 'c': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0100
+    case 'd': star[0].measure.photFlags |= 0x00040000; break; // was: 0x0200
+    case 's': star[0].measure.photFlags |= 0x00080000; break; // was: 0x0300
+    case 'b': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0400
+    case '0': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0500
     default: 
       fprintf (stderr, "error!\n");
@@ -222,7 +224,7 @@
 
   switch (qual) {
-    case '0': star[0].measure.photFlags &= ~0x0008; break;
-    case '1': star[0].measure.photFlags &= ~0x0008; break;
-    default:  star[0].measure.photFlags |=  0x0008; break;
+    case '0': star[0].measure.photFlags &= ~0x00300000; break; // was: ~0x0008
+    case '1': star[0].measure.photFlags |=  0x00100000; break; // was: ~0x0008
+    default:  star[0].measure.photFlags |=  0x00200000; break; // was:  0x0008
   }      
   return (TRUE);
@@ -232,8 +234,7 @@
 
   switch (qual) {
-    case '0': star[0].measure.photFlags &= ~0x0080; break;
-    case '1': star[0].measure.photFlags &= ~0x0080; break;
-    default:  
-      star[0].measure.photFlags |= 0x0080; 
+    case '0': star[0].measure.photFlags &= ~0x00c00000; break; // was: ~0x0080 
+    case '1': star[0].measure.photFlags |=  0x00400000; break; // was: ~0x0080 
+    default:  star[0].measure.photFlags |=  0x00800000;	       // was:  0x0080
       star[0].measure.extNsigma = 100.0;
       break;
@@ -245,7 +246,7 @@
 
   switch (qual) {
-    case '0': star[0].measure.photFlags &= ~0x0800; break;
-    case '1': star[0].measure.photFlags &= ~0x0800; break;
-    default:  star[0].measure.photFlags |=  0x0800; break;
+    case '0': star[0].measure.photFlags &= ~0x03000000; break; // was: ~0x0800
+    case '1': star[0].measure.photFlags |=  0x01000000; break; // was: ~0x0800
+    default:  star[0].measure.photFlags |=  0x02000000; break; // was:  0x0800
   }      
   return (TRUE);
@@ -255,7 +256,7 @@
 
   switch (qual) {
-    case '0': star[0].measure.photFlags &= ~0x1000; break;
-    case '1': star[0].measure.photFlags &= ~0x1000; break;
-    default:  star[0].measure.photFlags |=  0x1000; break;
+    case '0': star[0].measure.photFlags &= ~0x0c000000; break; // was: ~0x1000
+    case '1': star[0].measure.photFlags |=  0x04000000; break; // was: ~0x1000
+    default:  star[0].measure.photFlags |=  0x08000000; break; // was:  0x1000
   }      
   return (TRUE);
@@ -265,6 +266,6 @@
 
   switch (qual) {
-    case '0': star[0].measure.photFlags &= ~0x2000; break;
-    case '1': star[0].measure.photFlags |=  0x2000; break;
+    case '0': star[0].measure.photFlags &= ~0x10000000; break; // was: ~0x2000
+    case '1': star[0].measure.photFlags |=  0x10000000; break; // was:  0x2000
     default:  abort();
   }      
@@ -272,2 +273,9 @@
 }
 
+// unused photFlags:
+// 0x0000.8000
+// 0x0004.0000
+// 0x0008.0000
+// 0x2000.0000
+// 0x4000.0000
+// 0x8000.0000
Index: branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/sky_tessalation.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/sky_tessalation.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/sky_tessalation.c	(revision 23239)
@@ -240,11 +240,18 @@
   // integer number of dec zones between -90 and +90
 
-  nDEC = 180.0 / CELLSIZE;
-  dDEC = 180.0 / nDEC;
+  // in fact, we place a single image on each pole, so the real range of dec is 180.0 - CELLSIZE:
+
+  nDEC = (180.0 - CELLSIZE) / CELLSIZE;
+  dDEC = (180.0 - CELLSIZE) / nDEC;
+  nDEC += 2;
+
+  // a test
+  // for (dec = 0.0 + 0.5*dDEC; dec < +90.0; dec += dDEC) {
 
   // generate the a collection of rectangles for each ring
-  for (dec = -90.0 + 0.5*dDEC; dec < +90.0; dec += dDEC) {
+  for (dec = -90.0; dec < +90.0 + 0.5*dDEC; dec += dDEC) {
 
     ring = sky_rectangle_ring (dec, dDEC, &Nring);
+    if (!ring) continue;
 
     // subdivide each image (Nx x Ny subcells)
@@ -529,7 +536,7 @@
 SkyRectangle *sky_rectangle_ring (float dec, float dDEC, int *nring) {
 
-  int i, nRA, NX, NY;
-  float dRA, decLower;
+  int i, NX, NY, nRA;
   SkyRectangle *ring;
+  float theta, dRA;
 
   // 'dec' is a guess at the center of the cell; in fact, we need to choose decLower and
@@ -537,9 +544,62 @@
 
   // we can determine the 'lower' bound (bound closest to the equator):
-  decLower = (dec > 0.0) ? dec - 0.5*dDEC : dec + 0.5*dDEC;
-
-  // Subdivide the 'lower' bound into an integer number of segments:
-  nRA = cos(dec*RAD_DEG) * 360.0 / CELLSIZE; // CELLSIZE is a projection size
-  dRA = 360.0 / nRA;                         // dRA is a size in RA degrees
+  float decLower = (dec > 0.0) ? dec - 0.5*dDEC : dec + 0.5*dDEC;
+
+  // solve for actual cellsize (\theta):  tan(\delta_{n+1} - \theta/2) = tan(\delta_n + \theta/2)cos(\alpha_n / 2)
+  float decUpper = (dec > 0.0) ? dec + dDEC : dec - dDEC;
+
+  if (fabs(dec) + 0.5*dDEC > 90.0) {
+    // onPole = TRUE;
+    theta = dDEC;
+    nRA = 1;
+    dRA = theta / cos(decLower*RAD_DEG); // make a square at the pole
+  } else {
+    // onPole = FALSE;
+    // Subdivide the 'lower' bound into an integer number of segments:
+    nRA = cos(RAD_DEG*decLower) * 360.0 / CELLSIZE; // CELLSIZE is a projection size
+    dRA = 360.0 / nRA;                         // dRA is a size in RA degrees == \alpha_n
+
+    // tan(decUpper - theta/2) = tan(dec + theta/2) cos(dRA / 2);
+
+    // we solve this equation for theta (fairly ugly: expand the tangents into sin/cos, expand the 
+    // sum-of-angle sine and cosine, multiply through, convert via half-angle formulae and write 
+    // as a quadratic expression in sine(theta/2)
+  
+    float sd1 = sin(RAD_DEG*decUpper);
+    float cd1 = cos(RAD_DEG*decUpper);
+    float sd2 = sin(RAD_DEG*dec);
+    float cd2 = cos(RAD_DEG*dec);
+    float   k = cos(RAD_DEG*dRA/2.0);
+
+    float c1 =  (sd1*cd2 + sd2*cd1)*(1.0 - k);
+    float c2 =  (sd1*cd2 - sd2*cd1)*(1.0 + k);
+    float c3 = -(sd1*sd2 + cd1*cd2)*(1.0 + k); 
+
+    float A = SQ(c3) + SQ(c2);
+    float B = 2*c1*c3;
+    float C = SQ(c1) - SQ(c2);
+
+    float arg = SQ(B) - 4.0*A*C;
+
+    float root;
+
+    if (dec >= 0.0) {
+      root = (-B + sqrt (arg)) / (2.0*A);
+      theta = +DEG_RAD*asin(root);
+    } else {
+      root = (-B - sqrt (arg)) / (2.0*A);
+      theta = -DEG_RAD*asin(root);
+    }
+
+    // the negative solution yields a negative cellsize 
+    // float root2 = (-B - sqrt (arg)) / (2.0*A);
+    // float theta2 = DEG_RAD*asin(root2);
+
+    // test lines:
+    // float r1 = tan(RAD_DEG*(decUpper - 0.5*theta1));
+    // float r2 = tan(RAD_DEG*(dec + 0.5*theta1));
+    // fprintf (stdout, "%f %f  %f  %f  %f %f  %f %f  %f %f %f\n", dec, decUpper, dRA, arg, root1, root2, theta1, theta2, r1, r2, k*r2);
+  }
+  fprintf (stdout, "%f %f  %f x %f (%d)\n", dec, decUpper, dRA, theta, nRA);
 
   // I think we need to return the value of dec for the next ring, but I am not sure...
@@ -559,6 +619,6 @@
   
     // range values are in projected degrees
-    NX = cos(dec*RAD_DEG) * dRA  * 3600.0 / SCALE;
-    NY =                    dDEC * 3600.0 / SCALE;
+    NX = cos(decLower*RAD_DEG) * dRA   * 3600.0 / SCALE;
+    NY =                         theta * 3600.0 / SCALE;
 
     // crpix1,crpix2 is the projection center
@@ -576,7 +636,7 @@
 
 
-    fprintf (stderr, "%f %f  : %f %f\n", 
-	     ring[i].coords.crval1, ring[i].coords.crval2, 
-	     ring[i].coords.crpix1, ring[i].coords.crpix2);
+    // fprintf (stderr, "%f %f  : %f %f\n", 
+    // ring[i].coords.crval1, ring[i].coords.crval2, 
+    // ring[i].coords.crpix1, ring[i].coords.crpix2);
   }
 
Index: branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/base/get_fwhm.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/base/get_fwhm.c	(revision 23239)
+++ branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/base/get_fwhm.c	(revision 23239)
@@ -0,0 +1,130 @@
+# include "imregister.h"
+
+/* see note at end of file */
+double get_fwhm (char *filename) {
+
+  FILE *f;
+  char line[1024];
+  double *fwhm, *mag, *Mag, *FWHM, *Nfwhm, flags;
+  double F, value, Mlim, Vmode, Fmin, Fmax;
+  int i, N, n, Nwant, bin, mode, Nmode;
+
+  /* get sextract file (has fwhm info) */
+  f = fopen (filename, "r");
+  if (f == (FILE *) NULL) {
+    fprintf (stderr, "ERROR: can't open file.sdat\n");
+    return (-1.0);
+  }
+
+  n = 0;
+  N = 1000;
+  ALLOCATE (fwhm, double, N);
+  ALLOCATE (mag, double, N);
+  
+  /* load in data from file */
+  while (scan_line (f, line) != EOF) {
+    dparse (&flags, 2, line);
+    if (flags > 0) continue;
+    dparse (&mag[n], 4, line);
+    if (mag[n] > 0) continue;
+    dparse (&fwhm[n], 1, line);
+    n++;
+    if (n == N) {
+      N += 1000;
+      REALLOCATE (fwhm, double, N);
+      REALLOCATE (mag, double, N);
+    }
+  }    
+  if (n == 0) { return (-1.0); }
+
+  /* find the mag threshold */
+  ALLOCATE (Mag, double, n);
+  memcpy (Mag, mag, n*sizeof(double));
+  dsort (Mag, n);
+  Nwant = MIN (MAX (0.25*n, 10), n-1);
+  Mlim = Mag[Nwant];
+
+  /* create subset of fwhm with mag < Mlim */
+  ALLOCATE (FWHM, double, n);
+  ALLOCATE (Nfwhm, double, 1024);
+  bzero (FWHM, n*sizeof(double));
+  bzero (Nfwhm, 1024*sizeof(double));
+  
+  N = 0;
+  for (i = 0; i < n; i++) {
+    if (mag[i] > Mlim) continue;
+    FWHM[N] = fwhm[i];
+    N++;
+
+    /* accumulate mag histogram */
+    bin = fwhm[i]*10.0;
+    if (bin < 0) continue;
+    if (bin > 999) continue;
+    Nfwhm[bin] ++;
+  }
+
+  /* find the mode (bin size = 0.1 pixels) */
+  mode = 0; 
+  Nmode = Nfwhm[mode];
+  for (i = 0; i < 1000; i++) {
+    if (Nfwhm[i] > Nmode) {
+      mode = i;
+      Nmode = Nfwhm[i];
+    }
+  }
+  Vmode = mode * 0.1;
+  Fmin = Vmode - 0.2;
+  Fmax = Vmode + 0.2;
+
+  /* average bins within 0.2 of mode */
+  F = 0;
+  n = 0;
+  for (i = 0; i < N; i++) {
+    if (FWHM[i] < Fmin) continue;
+    if (FWHM[i] > Fmax) continue;
+    n++;
+    F+=FWHM[i];
+  }
+  if (n > 3) {
+    value = F / n;
+    return (value);
+  }
+
+  /* if we don't get the answer from the above, resort to median */
+  dsort (FWHM, N);
+  F = 0;
+  n = 0;
+  for (i = 0.25*N; i < 0.75*N; i++) {
+    n++;
+    F+=FWHM[i];
+  }
+  if (n > 0) {
+    value = F / n;
+  } else {
+    value = -1;
+  }
+  return (value);
+
+}
+
+/* 
+
+   calculate the fwhm from the data in the given file.
+   The file contains output from sextractor (or other program, perhaps).
+   The columns that matter are: 
+     1) fwhm (pixels)
+     2) flags
+     4) mag
+
+   this function determines the magnitude range for the file,
+   selects stars in the upper 25% of that magnitude range (by number),
+   rejecting bad stars (flags > 0) along the way
+   
+   the resulting list of fwhms are examined for the mode, in 0.1 pixel bins.
+   stars with fwhm within 0.2 pix of that mode are averaged to find the
+   best fwhm value.
+
+   in the database, a value of 0 means the measurement has not been tried.
+   a value of -1 means the measurement failed
+
+*/
Index: branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/detrend/usage.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/detrend/usage.c	(revision 23239)
+++ branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/detrend/usage.c	(revision 23239)
@@ -0,0 +1,30 @@
+# include "imregister.h"
+# include "detrend.h"
+
+int usage () {
+  
+  fprintf (stderr, "detsearch : select images from the detrend database\n");
+  fprintf (stderr, " USAGE: detsearch [-options...]\n");
+  fprintf (stderr, " -h : show this list\n");
+  fprintf (stderr, " --help : show this list\n");
+  fprintf (stderr, " -image filename (ccd) (mode) : find matching detrend data for this image \n");
+  fprintf (stderr, " -type (type) : limit selection by image type (bias, dark, flat, etc)\n");
+  fprintf (stderr, " -time yyyy/mm/dd,HH:MM:SS : specify time for selection\n");
+  fprintf (stderr, " -ccd (N) : limit selection to this ccd\n");
+  fprintf (stderr, " -filter (name) : limit selection to this filter\n");
+  fprintf (stderr, " -exptime (value) : limit selection to match this exposure time\n");
+  fprintf (stderr, " -tstop : display end of valid time range\n");
+  fprintf (stderr, " -treg  : display time of image registration\n");
+  fprintf (stderr, " -ve    : Elixir verbose (SUCCESS / ERROR) \n");
+  fprintf (stderr, " -quiet : Elixir quiet (no SUCCESS / ERROR) \n");
+  fprintf (stderr, " -close : select detrend data which is closest in time, overlap not forced\n");
+  fprintf (stderr, " -entry (value) : limit selection to match this entry\n");
+  fprintf (stderr, " -match (value) : only list the Nth matched entry\n");
+  fprintf (stderr, " -label (word)  : limit selection to match this label\n");
+  fprintf (stderr, " -select : force selection of the 'best' match\n");
+  fprintf (stderr, " -del    : delete the matched entries\n");
+  fprintf (stderr, " -delete : delete the matched entries\n");
+  fprintf (stderr, " -modify (entry) (value) : change entry in the selection to value\n");
+  fprintf (stderr, "   possible -modify entries: label, order, tstart, tstop\n");
+  exit (2);
+}
Index: branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/imreg/load_probes.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/imreg/load_probes.c	(revision 23239)
+++ branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/imreg/load_probes.c	(revision 23239)
@@ -0,0 +1,108 @@
+# include "imregister.h"
+# define NBYTES 1024
+# define WINDOW 1800
+/* probes are updated every 600 seconds.  give us some leeway here */
+
+int load_probes (char *filename, unsigned long tzero, int *wantprobe, double *values, int Nprobe) {
+
+  FILE *f;
+  char line[256], closeline[256], *buffer, *c, *p;
+  int nprobe, probe[10];
+  int i, Nstart, Nread, Nbytes, Nshift, Nleft, done, close_enough;
+  double time, jdstart, tmp;
+  int Nsec, sec;
+
+  f = fopen (filename, "r");
+  if (f == (FILE *) NULL) {
+    fprintf (stderr, "can't open DataLogger file: %s\n", filename);
+    return (FALSE);
+  }
+
+  /* assume fixed format */
+  scan_line (f, line);
+  scan_line (f, line);
+  scan_line (f, line);
+  sscanf (line, "%*s %*s %*s %*s %lf", &jdstart);
+  Nsec = (jdstart - 2440587.5)*86400;
+  if (tzero < Nsec - WINDOW) {
+    fprintf (stderr, "missing time in DataLogger file\n");
+    return (FALSE);
+  }
+
+  scan_line (f, line);
+  scan_line (f, line);
+  scan_line (f, line);
+  sscanf (line, "%*s %*s %d", &nprobe);
+  for (i = 0; (i < nprobe) && (i < 10); i++) {
+    dparse (&tmp, i+4, line);
+    probe[i] = tmp;
+  }
+
+  /* check that probes match desired probes -- demand same order in file */
+  if (nprobe != Nprobe) {
+    fprintf (stderr, "wrong number of probes\n");
+    return (FALSE);
+  }
+  for (i = 0; (i < nprobe) && (i < 10); i++) {
+    if (probe[i] != wantprobe[i]) {
+      fprintf (stderr, "probe mismatch\n");
+      return (FALSE);
+    }
+  }
+  
+  ALLOCATE (buffer, char, NBYTES+1);
+    
+  Nstart = 0;
+  done = FALSE;
+  close_enough = FALSE;
+  while (!done && ((Nread = fread (&buffer[Nstart], 1, NBYTES - Nstart, f)) > 0)) {
+    Nbytes = Nread + Nstart;
+    buffer[Nbytes] = 0;
+    
+    /* we are using strchr lib functions - buffer can't have NULLs */
+    c = strrchr (buffer, '\n');
+    if (c == (char *) NULL) c = &buffer[Nbytes-1];
+    Nshift = c - buffer + 1;
+    
+    /* limit searches to the range buffer[0] - buffer[Nshift] */
+    p = &buffer[0];
+    while (1) {
+      c = strchr (p, '\n');
+      if (c == (char *) NULL) break;
+      if (c > &buffer[Nshift]) break;
+      *c = 0;
+      dparse (&time, 0, p);
+      sec = Nsec + time*86400;
+      if (sec + WINDOW > tzero) {
+	strcpy (closeline, p);
+	close_enough = TRUE;
+      }
+      if (sec > tzero) {
+	for (i = 0; i < Nprobe; i++) {
+	  dparse (&values[i], i+5, p);
+	}
+	free (buffer);
+	return (TRUE);
+      }
+      *c = '\n';
+      p = c + 1;
+    }
+    
+    Nleft  = Nbytes - Nshift;
+    if (Nleft > 0) memmove (buffer, &buffer[Nshift], Nleft);
+    
+    Nstart = Nleft;
+  }
+
+  if (close_enough) {
+    for (i = 0; i < Nprobe; i++) {
+      dparse (&values[i], i+5, closeline);
+    }
+    free (buffer);
+    return (TRUE);
+  }
+
+  fprintf (stderr, "time not in DataLogger file %ld\n", tzero);
+  free (buffer);
+  return (FALSE);
+}
Index: branches/cnb_branches/cnb_branch_20090215/dbconfig/changes.txt
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/dbconfig/changes.txt	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/dbconfig/changes.txt	(revision 23239)
@@ -795,6 +795,4 @@
 ALTER TABLE magicInputSkyfile DROP PRIMARY KEY, ADD PRIMARY KEY(magic_id, diff_id, node);
 
-
-
 -- Version: 1.1.48
 
@@ -834,4 +832,6 @@
     WHERE warpImfile.skycell_id IS NULL;
 
-
-
+-- Version: 1.1.49 (change detrend sequence)
+
+show create table detResidImfile;
+alter table detResidImfile drop foreign key detResidImfile_ibfk_3;
Index: branches/cnb_branches/cnb_branch_20090215/dbconfig/config.md
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/dbconfig/config.md	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/dbconfig/config.md	(revision 23239)
@@ -2,4 +2,4 @@
     pkg_name        STR     ippdb
     pkg_namespace   STR     ippdb
-    pkg_version     STR     1.1.48
+    pkg_version     STR     1.1.49
 END
Index: branches/cnb_branches/cnb_branch_20090215/dbconfig/det.md
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/dbconfig/det.md	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/dbconfig/det.md	(revision 23239)
@@ -90,14 +90,15 @@
     class_id    STR         64      # Primary Key
     uri         STR         255
-    recipe      STR         64
-    bg          F64         0.0
-    bg_stdev    F64         0.0
-    bg_mean_stdev   F64     0.0
-    user_1      F64         0.0
-    user_2      F64         0.0
-    user_3      F64         0.0
-    user_4      F64         0.0
-    user_5      F64         0.0
-#   XXX does it make sense to 'clean' the stacked imfiled?
+    # XXX missing path_base
+    recipe      STR         64
+    bg          F64         0.0
+    bg_stdev    F64         0.0
+    bg_mean_stdev   F64     0.0
+    user_1      F64         0.0
+    user_2      F64         0.0
+    user_3      F64         0.0
+    user_4      F64         0.0
+    user_5      F64         0.0
+    #   XXX does it make sense to 'clean' the stacked imfiled? (EAM: yes)
     data_state  STR         64      # full, cleaned, purged (only track end states; request states are in detRunSummary by iteration)
     fault       S16         0       # Key NOT NULL
@@ -148,18 +149,4 @@
     fault       S16         0       # Key NOT NULL
 END
-
-#detMasterFrame METADATA
-#    det_id      S64         0       # Primary Key
-#    iteration   S32         0       # Primary Key
-#    comment     STR         255
-#END
-#
-## drop?
-#detMasterImfile METADATA
-#    det_id      S64         0       # Primary Key
-#    class_id    STR         64      # Primary Key
-#    uri         STR         255
-#    recipe      STR         64
-#END
 
 detResidImfile METADATA
Index: branches/cnb_branches/cnb_branch_20090215/doc/misc/detnorm.rework.txt
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/doc/misc/detnorm.rework.txt	(revision 23239)
+++ branches/cnb_branches/cnb_branch_20090215/doc/misc/detnorm.rework.txt	(revision 23239)
@@ -0,0 +1,76 @@
+
+I've been running the detrend analysis on the new gpc1 flats, and
+discovered an important issue.  These chips have significant gain
+variations across the devices.  
+
+We need to have detrend.normstats run on the results of the
+detResidImfiles, rather than detProcessedImfiles.  This requires
+altering the processing sequence from this:
+
+* process each of the input images (detrend.process.imfile)
+* generate a stack for each chip (detrend.stack.imfile)
+* use the stats from the processed chips to determine per-chip
+renormalizations for the stacks. the goal in this step is to yield a
+flat-field image for which a flattened input image is flat across the
+entire mosaic, not just each chip.  (detrend.normstats.imfile)
+* apply the normalization to each of the stacks (detrend.norm.imfile)
+* generate mosaic-wide stats and jpegs for the normalized flats
+(detrend.norm.exp)
+* apply the normalized flats to the processed images (detrend.resid.imfile)
+* generate per-exposure stats and jpegs for the residual images.
+(detrend.resid.exp)
+
+The problem is that, with a large gain variation across each chip, the
+measurement of the per-chip stats from the processed images is not a
+good measurement of the flattened mean value on that chip.  We really
+should be measuring the statistics from the flattened images.  Paul
+and I discussed the pipeline organization and have concluded that we
+can re-work the detrend pipeline without too much work to achieve this
+if we perform the flat-fielding before the normalization, and do the
+following steps:
+
+* process each of the input images (detrend.process.imfile)
+* generate a stack for each chip (detrend.stack.imfile)
+* apply the flats to the processed images (detrend.resid.imfile)
+* use the stats from the residual chips to determine per-chip
+renormalizations for the stacks (detrend.normstats.imfile)
+* apply the normalization to each of the stacks (detrend.norm.imfile)
+* generate mosaic-wide stats and jpegs for the normalized flats
+(detrend.norm.exp)
+* generate per-exposure stats and jpegs for the residual images,
+applying the normalizations on-the-fly. (detrend.resid.exp)
+
+--
+
+Tasks to do:
+
+* ppStack could do an approximate normalization on the fly (perhaps
+  not needed; perhaps already done? what is the output scaling of the
+  resulting flat stack?)
+
+* dettool -toresidimfile should trigger on completed detStackedImfile
+  (not detNormalizedImfile) (DONE)
+
+* dettool -tonormalizedstat should trigger on completed
+  detResidImfile, not detStackedImfile (DONE)
+
+* detrend_norm_calc.pl needs to read the stats from detResidImfile,
+  not detProcessedImfile (DONE)
+
+* detrend.norm.imfile uses the results of detrend_norm_calc.pl as
+  before (DONE)
+
+* detrend.resid.exp applies the normalizations on-the-fly to the b1
+  and b2 input images, and to the exposure-wide stats pushed into the
+  db. (DONE)
+
+* detrend.resid.exp blocks until detrend.norm.exp is done
+
+*** the 'verify' analysis needs to be modified.  I think we can keep
+    it as it was (detrend.process.imfile -> detrend.resid.imfile ->
+    detrend.resid.exp) where the resid imfile is generated using the
+    detNormalizedImfile rather than the detStackedImfile.  Does
+    detrend.resid.exp need to be modified for 'verify' mode to *avoid*
+    applying the normalization?
+
+
Index: branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_apply.pl
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_apply.pl	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_apply.pl	(revision 23239)
@@ -38,5 +38,5 @@
     'iteration|n=s'     => \$iter,       # Iteration
     'class_id|i=s'      => \$class_id,   # Class ID
-    'value|v=s'         => \$value,      # Value to multiple (for normalisation)
+    'value|v=s'         => \$value,      # Value to apply (for normalisation)
     'input_uri|u=s'     => \$input_uri,  # Input file
     'camera|c=s'        => \$camera,     # Camera
Index: branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_calc.pl
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_calc.pl	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_calc.pl	(revision 23239)
@@ -90,6 +90,7 @@
 my @files;                      # The input files
 {
-    my $command = "$dettool -processedimfile";
-    $command .= " -det_id $det_id"; # Command to run
+    my $command = "$dettool -residimfile";
+    $command .= " -det_id $det_id";
+    $command .= " -iteration $iter";
     $command .= " -included"; # only use the inputs for this detrend run to calculate the norm
     $command .= " -dbname $dbname" if defined $dbname;
@@ -98,5 +99,5 @@
     print "Running [$command]...\n" if $verbose;
     if (not run(\@command, \$stdin, \$stdout, \$stderr)) {
-        &my_die("Unable to perform dettool -processedimfile on detrend $det_id/$iter: $?",
+        &my_die("Unable to perform dettool -residimfile on detrend $det_id/$iter: $?",
                 $det_id, $iter, $PS_EXIT_SYS_ERROR);
     }
Index: branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_resid_exp.pl
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_resid_exp.pl	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_resid_exp.pl	(revision 23239)
@@ -88,7 +88,54 @@
 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe;
 
+# variables used for I/O
+my ($command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
+
+# Get list of normalizations by class_id : stored as $norms; save to temp file for ppImage runs below
+my (%norms, $normsName);
+{
+    # dettool command to select imfile data for this exp_id
+    $command  = "$dettool -normalizedstat";
+    $command .= " -det_id $det_id";
+    $command .= " -iteration $iter";
+    $command .= " -dbname $dbname" if defined $dbname;
+    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform dettool -residimfile: $error_code\n");
+        exit($error_code);
+    }
+    if (@$stdout_buf == 0) {
+	&my_die("No normalizations were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
+    }
+
+    # Parse the stdout buffer into a metadata
+    my $mdcParser = PS::IPP::Metadata::Config->new;
+    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
+
+    # parse the file info in the metadata
+    my $normsMD = parse_md_list($metadata) or
+        &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
+
+
+    # write the normalizations to a file as a metadata config file in the form: class_id F32 value
+    # XXX a possible optimization: if there is only one imfile, skip normalization
+    my $normsFile;
+    ($normsFile, $normsName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.norms.XXXX", UNLINK => !$save_temps );
+    print "saving norms to $normsName\n";
+    foreach my $norm (@$normsMD) {
+	my $class_id = $norm->{class_id};
+	my $normalization = $norm->{norm};
+
+	$norms{$class_id} = $normalization;
+        printf $normsFile "$class_id F32 $normalization\n", 
+    }
+    close $normsFile;
+}
+
 # Get list of imfile files
 my $cmdflags;
-my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
+my (@files);
 {
     # dettool command to select imfile data for this exp_id
@@ -105,5 +152,7 @@
         exit($error_code);
     }
-    # XXX report an error message if stdout_buf is empty
+    if (@$stdout_buf == 0) {
+	&my_die("No imfiles were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
+    }
 
     # Parse the stdout buffer into a metadata
@@ -112,13 +161,47 @@
         &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
 
+    # since I can't figure out how to do input and output within PERL, I'm writing the (modified) metadata to a temp file
+    my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps );
+
     # parse the file info in the metadata
-    $files = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
-
-    # since I can't figure out how to do input and output within PERL, I'm writing to a temp file
-    my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps );
-    print "saving stats to $statName\n";
-    foreach my $line (@$stdout_buf) {
-        print $statFile $line;
+    # as we parse the list of files and their stats, apply the normalization to the relevant fields
+    # also, write out the modified metadata set
+    foreach my $mdItem (@$metadata) {
+	if ($mdItem->{class} ne "metadata") {
+	    carp "MD element ", $mdItem->{name}, " isn't of type METADATA --- ignored.\n";
+	    next;
+	}
+	my %hash;		# Hash element
+	my $mdComponents = $mdItem->{value}; # Components of the metadata
+
+	# determine the class_id for this block:
+	my $class_id;
+	foreach my $data (@$mdComponents) {
+	    unless ($data->{name} eq "class_id") { next; }
+	    $class_id = $data->{value};
+	    last;
+	}
+
+	# a new metadata block
+	print $statFile "rawResidImfile  METADATA\n";
+
+	# modify and save the data in this block:
+	foreach my $data (@$mdComponents) {
+	    my $norm = $norms{$class_id};
+
+	    # fields to modify by the normalization:
+	    if ($data->{name} eq "bg")            { $data->{value} *= $norm; }
+	    if ($data->{name} eq "bg_stdev")      { $data->{value} *= $norm; }
+	    if ($data->{name} eq "bg_mean_stdev") { $data->{value} *= $norm; }
+	    if ($data->{name} eq "bg_skewness")   { $data->{value} *= $norm; }
+	    if ($data->{name} eq "bg_kurtosis")   { $data->{value} *= $norm; }
+	    if ($data->{name} eq "bin_stdev")     { $data->{value} *= $norm; }
+
+	    # write out the metadata, save on the array of hashes
+	    print $statFile "  $data->{name}  $data->{type}  $data->{value}\n";
+	    $hash{$data->{name}} = $data->{value};
+	}
+	print $statFile "END\n";
+	push @files, \%hash;
     }
     close $statFile;
@@ -154,5 +237,5 @@
 my ($list1File, $list1Name) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.b1.list.XXXX", UNLINK => !$save_temps );
 my ($list2File, $list2Name) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.b2.list.XXXX", UNLINK => !$save_temps );
-foreach my $file (@$files) {
+foreach my $file (@files) {
     print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
     print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
@@ -165,7 +248,9 @@
 unless ($no_op) {
     # Make the jpeg for binning 1
+    # XXX EAM : supply the collection of normalizations as a metadata
     $command = "$ppImage -list $list1Name $outroot"; # Command to run
     $command .= " -recipe PPIMAGE PPIMAGE_J1";
     $command .= " -recipe JPEG $recipe";
+    $command .= " -normlist $normsName";
     $command .= " -dbname $dbname" if defined $dbname;
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -178,7 +263,9 @@
 
     # Make the jpeg for binning 2
+    # XXX EAM : supply the collection of normalizations as a metadata
     $command = "$ppImage -list $list2Name $outroot"; # Command to run
     $command .= " -recipe PPIMAGE PPIMAGE_J2";
     $command .= " -recipe JPEG $recipe";
+    $command .= " -normlist $normsName";
     $command .= " -dbname $dbname" if defined $dbname;
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -215,5 +302,5 @@
 my @fluxes;
 
-foreach my $file (@$files) {
+foreach my $file (@files) {
     my $name      = $file->{class_id};
     my $mean      = $file->{bg};        # Mean for this imfile
Index: branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/ipp_cleanup.pl
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/ipp_cleanup.pl	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/ipp_cleanup.pl	(revision 23239)
@@ -45,10 +45,18 @@
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die("Unable to set up", $stage_id, $PS_EXIT_CONFIG_ERROR); # this is used for PATH, NEB filename conversions
 
-# $mode must be one of "goto_cleaned", "goto_scrubbed", or "goto_purged"
-# goto_cleaned and goto_scrubbed both result in 'cleaned': scrubbed allows chips without config files to
-# be cleaned (they cannot be recovered, but the small data is left behind)
+# $mode must be one of "goto_cleaned", "goto_scrubbed", or
+# "goto_purged" goto_cleaned and goto_scrubbed both result in
+# 'cleaned' on success ('scrubbed' allows chips without config files
+# to be cleaned; they cannot be recovered, but the small data is left
+# behind). XXX make 'scrubbed' a data_state?
 unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) {
     die "invalid cleanup mode $mode\n";
 }
+
+my $error_state;
+if ($mode eq "goto_cleaned")  { $error_state = "error_cleaned";  }
+if ($mode eq "goto_scrubbed") { $error_state = "error_scrubbed"; }
+if ($mode eq "goto_purged")   { $error_state = "error_purged";   }
+
 
 my %stages = ( chip => 1, camera => 1, fake => 1, warp => 1, stack => 1, diff  => 1);
@@ -148,7 +156,8 @@
             }
         } else {
-            # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will stop be run
-            my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1";
-            $command .= " -dbname $dbname" if defined $dbname;
+
+	    # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
+	    my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state";
+	    $command .= " -dbname $dbname" if defined $dbname;
 
             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -216,9 +225,13 @@
 
     if ($status)  {
-        my $command = "$camtool -cam_id $stage_id -updaterun";
+        my $command;
         if ($mode eq "goto_cleaned") {
-            $command .= " -state cleaned";
-        } else {
-            $command .= " -state purged";
+            $command = "$camtool -updaterun -cam_id $stage_id -set_state cleaned";
+	}
+        if ($mode eq "goto_scrubbed") {
+            $command = "$camtool -updaterun -cam_id $stage_id -set_state cleaned";
+	}
+        if ($mode eq "goto_purged") {
+            $command = "$camtool -updaterun -cam_id $stage_id -set_state purged";
         }
         $command .= " -dbname $dbname" if defined $dbname;
@@ -230,5 +243,6 @@
         }
     } else {
-        my $command = "$camtool -updateprocessedexp -cam_id $stage_id -code 1";
+	# since 'camera' has only a single imfile, we can just update the run
+        my $command = "$camtool -updaterun -cam_id $stage_id -set_state $error_state";
         $command .= " -dbname $dbname" if defined $dbname;
 
@@ -319,7 +333,6 @@
             }
          } else {
-            # XXX: -updateskyfile mode does not exist, need to add it
-            my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1";
-            $command .= " -dbname $dbname" if defined $dbname;
+	    my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state";
+	    $command .= " -dbname $dbname" if defined $dbname;
 
             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -337,6 +350,6 @@
 # left TODO
 # fake : faketool : -pendingcleanupimfile (loop over imfiles)
-# stack: stacktool : -pendingcleanupskyfile (loop over skyfiles)
-# diff:  difftool : -pendingcleanupskyfile
+# stack: stacktool : -pendingcleanupskyfile
+# diff:  difftool : -pendingcleanupskyfile (loop over skyfiles)
 
 die "ipp_cleanup.pl -stage $stage not yet implemented\n";
@@ -367,4 +380,5 @@
 }
 
+# XXX we currently do not set the error state in the db on my_die
 sub my_die
 {
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/automate.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/automate.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/automate.pro	(revision 23239)
@@ -175,4 +175,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -283,4 +287,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -373,4 +381,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -448,4 +460,9 @@
   end
 
+  task.exit    crash
+    book setword automate $pageName pantaskState INIT.REGULAR
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/calibration.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/calibration.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/calibration.pro	(revision 23239)
@@ -90,4 +90,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -166,4 +170,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword calBook $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/camera.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/camera.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/camera.pro	(revision 23239)
@@ -104,4 +104,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -177,4 +181,11 @@
   task.exit default
     process_exit camPendingExp $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword camPendingExp $options:0 pantaskState CRASH
   end
 
@@ -236,4 +247,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -289,4 +304,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword camPendingCleanup $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/chip.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/chip.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/chip.pro	(revision 23239)
@@ -111,4 +111,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -188,4 +192,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword chipPendingImfile $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
@@ -235,4 +246,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -291,4 +306,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -344,4 +363,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword chipPendingCleanup $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.correct.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.correct.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.correct.pro	(revision 23239)
@@ -85,7 +85,11 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
-    showcommand
+    showcommand timeout
   end
 end
@@ -145,4 +149,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingCorrectImfile $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.mkruns.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.mkruns.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.mkruns.pro	(revision 23239)
@@ -34,4 +34,9 @@
   end
 
+  task.exit crash
+    # send someone email?
+    echo "unable to define a new detrend run"
+  end
+
   # operation timed out?  is the database down?
   task.exit timeout
@@ -60,4 +65,9 @@
   # default exit status
   task.exit default
+    echo "unable to define a new detrend run"
+  end
+
+  task.exit crash
+    # send someone email?
     echo "unable to define a new detrend run"
   end
@@ -92,4 +102,9 @@
   end
 
+  task.exit crash
+    # send someone email?
+    echo "unable to define a new detrend run"
+  end
+
   # operation timed out?  is the database down?
   task.exit timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.norm.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.norm.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.norm.pro	(revision 23239)
@@ -168,4 +168,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -225,4 +229,11 @@
   task.exit    default
     process_exit detPendingNormStatImfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingNormStatImfile $options:0 pantaskState CRASH
   end
 
@@ -278,4 +289,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -342,4 +357,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingNormImfile $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
@@ -395,4 +417,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -452,4 +478,11 @@
   task.exit    default
     process_exit detPendingNormExp $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingNormExp $options:0 pantaskState CRASH
   end
 
@@ -506,4 +539,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -558,4 +595,9 @@
   task.exit    default
     process_exit detCleanupNormStatImfile $options:0 $JOB_STATUS
+  end
+
+  task.exit    crash
+    showcommand crash
+    book setword detCleanupNormStatImfile $options:0 pantaskState CRASH
   end
 
@@ -612,4 +654,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -665,4 +711,9 @@
   task.exit    default
     process_exit detCleanupNormImfile $options:0 $JOB_STATUS
+  end
+
+  task.exit    crash
+    showcommand crash
+    book setword detCleanupNormImfile $options:0 pantaskState CRASH
   end
 
@@ -719,4 +770,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -773,4 +828,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword detCleanupNormExp $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.process.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.process.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.process.pro	(revision 23239)
@@ -136,7 +136,11 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
-    showcommand
+    showcommand timeout
   end
 end
@@ -202,4 +206,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingProcessedImfile $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
@@ -255,4 +266,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -319,4 +334,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingProcessedExp $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
@@ -371,4 +393,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -424,4 +450,11 @@
   task.exit    default
     process_exit detCleanupProcessedImfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detCleanupProcessedImfile $options:0 pantaskState CRASH
   end
 
@@ -479,4 +512,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -533,4 +570,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detCleanupProcessedExp $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.reject.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.reject.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.reject.pro	(revision 23239)
@@ -83,7 +83,11 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
-    showcommand failure
+    showcommand timeout
   end
 end
@@ -143,4 +147,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detRejectExp $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.resid.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.resid.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.resid.pro	(revision 23239)
@@ -129,4 +129,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -203,4 +207,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingResidImfile $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
@@ -254,4 +265,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -320,4 +335,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingResidExp $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
@@ -372,4 +394,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -426,4 +452,11 @@
   task.exit    default
     process_exit detCleanupResidImfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detCleanupResidImfile $options:0 pantaskState CRASH
   end
 
@@ -481,4 +514,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -536,4 +573,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detCleanupResidExp $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.stack.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.stack.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.stack.pro	(revision 23239)
@@ -101,4 +101,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -163,4 +167,11 @@
   task.exit    default
     process_exit detPendingStackedImfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detPendingStackedImfile $options:0 pantaskState CRASH
   end
 
@@ -217,4 +228,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -272,4 +287,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword detCleanupStackedImfile $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/diff.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/diff.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/diff.pro	(revision 23239)
@@ -112,4 +112,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -173,4 +177,11 @@
   task.exit    default
     process_exit diffSkyfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword diffSkyfile $options:0 pantaskState CRASH
   end
 
@@ -229,4 +240,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -282,4 +297,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword diffCleanup $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/fake.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/fake.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/fake.pro	(revision 23239)
@@ -176,4 +176,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword fakePendingImfile $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
@@ -219,4 +226,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -278,4 +289,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -331,4 +346,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword fakePendingCleanup $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/flatcorr.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/flatcorr.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/flatcorr.pro	(revision 23239)
@@ -104,4 +104,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -157,4 +161,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -229,4 +237,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword flatcorrBook $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/magic.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/magic.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/magic.pro	(revision 23239)
@@ -118,4 +118,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -189,4 +193,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword magicToTree $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
@@ -239,4 +248,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -302,4 +315,9 @@
   task.exit    default
     process_exit magicToProcess $options:0 $JOB_STATUS
+  end
+
+  task.exit    crash
+    showcommand crash
+    book setword magicToProcess $options:0 pantaskState CRASH
   end
 
@@ -353,4 +371,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -423,4 +445,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword magicToDS $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/pstamp.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/pstamp.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/pstamp.pro	(revision 23239)
@@ -97,4 +97,8 @@
     end
 
+    task.exit   crash
+        showcommand crash
+    end
+
     task.exit   timeout
         showcommand timeout
@@ -136,4 +140,8 @@
     end
 
+    task.exit   crash
+        showcommand crash
+    end
+
     task.exit   timeout
         showcommand timeout
@@ -178,4 +186,9 @@
         showcommand failure
         process_exit pstampRequest $options:0 $JOB_STATUS
+    end
+
+    task.exit crash
+        showcommand crash
+        book setword pstampRequest $options:0 pantaskState CRASH
     end
 
@@ -219,4 +232,8 @@
     end
 
+    task.exit   crash
+        showcommand crash
+    end
+
     task.exit   timeout
         showcommand timeout
@@ -263,4 +280,9 @@
         process_exit pstampFinish $options:0 $JOB_STATUS
         showcommand failure
+    end
+
+    task.exit crash
+        showcommand crash
+        book setword pstampFinish $options:0 pantaskState CRASH.run
     end
 
@@ -307,4 +329,8 @@
     end
 
+    task.exit   crash
+        showcommand crash
+    end
+
     task.exit   timeout
         showcommand timeout
@@ -362,4 +388,11 @@
     end
 
+    task.exit crash
+        echo pstamp.job.run task.crash $JOB_ID status: $JOB_STATUS
+        process_exit pstampJob $options:0 $JOB_STATUS
+        showcommand crash
+        book setword pstampJob $options:0 pantaskState CRASH
+    end
+
     task.exit timeout
         echo pstamp.job.run task.timeout $JOB_ID status: $JOB_STATUS
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/register.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/register.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/register.pro	(revision 23239)
@@ -180,4 +180,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -255,4 +259,11 @@
   task.exit default
     process_exit regPendingImfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword regPendingImfile $options:0 pantaskState CRASH
   end
 
@@ -306,4 +317,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -392,4 +407,16 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword regPendingExp $options:0 pantaskState CRASH
+  end
+
+  task.exit    crash
+    showcommand crash
+    book setword regPendingExp $options:0 pantaskState CRASH
+  end
+
   # operation times out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/replicate.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/replicate.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/replicate.pro	(revision 23239)
@@ -102,4 +102,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -158,4 +162,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword replicatePending $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/stack.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/stack.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/stack.pro	(revision 23239)
@@ -112,4 +112,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -172,4 +176,11 @@
   task.exit    default
     process_exit stackSumSkyfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword stackSumSkyfile $options:0 pantaskState CRASH
   end
 
@@ -229,4 +240,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -282,4 +297,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword stackCleanup $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/summit.copy.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/summit.copy.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/summit.copy.pro	(revision 23239)
@@ -126,4 +126,7 @@
         showcommand failure
     end
+    task.exit crash
+        showcommand crash
+    end
     task.exit timeout
         showcommand timeout
@@ -182,4 +185,7 @@
     showcommand failure
   end
+  task.exit     crash
+    showcommand crash
+  end
   task.exit     timeout
     showcommand timeout
@@ -228,4 +234,7 @@
           queueprint stderr
         end
+    end
+    task.exit crash
+        showcommand crash
     end
     task.exit timeout
@@ -296,4 +305,9 @@
         showcommand failure
         process_exit pzPendingExp $options:0 $JOB_STATUS
+    end
+
+    task.exit crash
+        showcommand crash
+        book setword pzPendingExp $options:0 pantaskState CRASH
     end
 
@@ -344,4 +358,7 @@
         showcommand failure
     end
+    task.exit     crash
+        showcommand crash
+    end
     task.exit     timeout
         showcommand timeout
@@ -413,4 +430,7 @@
         book setword pzPendingImfile $pageName filename $FILENAME
 
+	stdout $LOGDIR/summit.copy.log
+	stderr $LOGDIR/summit.copy.log
+
         $run = summit_copy.pl --uri $URI --filename $FILENAME --exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --end_stage reg --workdir $workdir --dbname $DBNAME --timeout 120 --verbose --copies 2
 	if ($COMPRESS) 
@@ -442,4 +462,9 @@
     end
 
+    task.exit crash
+        showcommand crash
+        book setword pzPendingImfile $options:0 pantaskState CRASH
+    end 
+
     # operation timed out?
     task.exit timeout
@@ -476,4 +501,7 @@
     task.exit default
         showcommand failure
+    end
+    task.exit crash
+        showcommand crash
     end
     task.exit timeout
@@ -518,4 +546,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTasks/warp.pro
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTasks/warp.pro	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTasks/warp.pro	(revision 23239)
@@ -127,4 +127,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -185,4 +189,11 @@
   task.exit    default
     process_exit warpInputExp $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword warpInputExp $options:0 pantaskState CRASH
   end
 
@@ -239,4 +250,8 @@
   task.exit    default
     showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
   end
 
@@ -303,4 +318,11 @@
   end
 
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword warpPendingSkyCell $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
@@ -357,4 +379,8 @@
   end
 
+  task.exit    crash
+    showcommand crash
+  end
+
   # operation times out?
   task.exit    timeout
@@ -410,4 +436,9 @@
   end
 
+  task.exit    crash
+    showcommand crash
+    book setword warpPendingCleanup $options:0 pantaskState CRASH
+  end
+
   # operation timed out?
   task.exit    timeout
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/scripts/test_create_detrend.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/scripts/test_create_detrend.sql	(revision 23239)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/scripts/test_create_detrend.sql	(revision 23239)
@@ -0,0 +1,135 @@
+-- disable constraints
+
+DROP TABLE IF EXISTS detRun;
+DROP TABLE IF EXISTS detProcessedImfile;
+DROP TABLE IF EXISTS detNormalizedStatImfile;
+DROP TABLE IF EXISTS detResidImfile;
+
+CREATE TABLE detRun (
+    det_id BIGINT AUTO_INCREMENT,
+    iteration INT,
+    det_type VARCHAR(64),
+    mode VARCHAR(64),
+    state VARCHAR(64),
+    filelevel VARCHAR(64),
+    workdir VARCHAR(255),
+    camera VARCHAR(64),
+    telescope VARCHAR(64),
+    exp_type VARCHAR(64),
+    reduction VARCHAR(64),
+    filter VARCHAR(64),
+    airmass_min FLOAT,
+    airmass_max FLOAT,
+    exp_time_min FLOAT,
+    exp_time_max FLOAT,
+    ccd_temp_min FLOAT,
+    ccd_temp_max FLOAT,
+    posang_min DOUBLE,
+    posang_max DOUBLE,
+    registered DATETIME,
+    time_begin DATETIME,
+    time_end DATETIME,
+    use_begin DATETIME,
+    use_end DATETIME,
+    solang_min FLOAT,
+    solang_max FLOAT,
+    label VARCHAR(64),
+    ref_det_id BIGINT,
+    ref_iter INT,
+    -- parent INT, :: dropping this
+    PRIMARY KEY(det_id),
+    KEY(det_id),
+    KEY(iteration),
+    KEY(det_type),
+    KEY(mode),
+    KEY(state),
+    KEY(label),
+    -- KEY(parent), :: dropping this
+    INDEX(det_id, iteration))
+ENGINE=innodb DEFAULT CHARSET=latin1;
+
+CREATE TABLE detProcessedImfile (
+    det_id BIGINT,
+    exp_id BIGINT,
+    class_id VARCHAR(64),
+    uri VARCHAR(255),
+    recipe VARCHAR(64),
+    bg DOUBLE,
+    bg_stdev DOUBLE,
+    bg_mean_stdev DOUBLE,
+    fringe_0 DOUBLE,
+    fringe_1 DOUBLE,
+    fringe_2 DOUBLE,
+    user_1 DOUBLE,
+    user_2 DOUBLE,
+    user_3 DOUBLE,
+    user_4 DOUBLE,
+    user_5 DOUBLE,
+    path_base VARCHAR(255),
+    data_state VARCHAR(64),
+    fault SMALLINT NOT NULL,
+    PRIMARY KEY(det_id, exp_id, class_id),
+    KEY(fault),
+    INDEX(det_id, class_id),
+    INDEX(det_id, exp_id)
+    -- FOREIGN KEY (det_id, exp_id)
+    --     REFERENCES  detInputExp(det_id, exp_id),
+    -- FOREIGN KEY (exp_id, class_id)
+    --     REFERENCES  rawImfile(exp_id, class_id)
+) ENGINE=innodb DEFAULT CHARSET=latin1;
+
+CREATE TABLE detNormalizedStatImfile (
+    det_id BIGINT,
+    iteration INT,
+    class_id VARCHAR(64),
+    norm FLOAT,
+    data_state VARCHAR(64),
+    fault SMALLINT NOT NULL,
+    PRIMARY KEY(det_id, iteration, class_id),
+    KEY(fault)
+    -- FOREIGN KEY (det_id, iteration)
+    -- REFERENCES  detInputExp(det_id, iteration),
+    -- FOREIGN KEY (det_id, iteration, class_id)
+    -- REFERENCES  detStackedImfile(det_id, iteration, class_id)
+) ENGINE=innodb DEFAULT CHARSET=latin1;
+
+CREATE TABLE detResidImfile (
+    det_id BIGINT,
+    iteration INT,
+    ref_det_id BIGINT,
+    ref_iter INT,
+    exp_id BIGINT,
+    class_id VARCHAR(64),
+    uri VARCHAR(255),
+    recipe VARCHAR(64),
+    bg DOUBLE,
+    bg_stdev DOUBLE,
+    bg_mean_stdev DOUBLE,
+    bg_skewness DOUBLE,
+    bg_kurtosis DOUBLE,
+    bin_stdev DOUBLE,
+    fringe_0 DOUBLE,
+    fringe_1 DOUBLE,
+    fringe_2 DOUBLE,
+    fringe_resid_0 DOUBLE,
+    fringe_resid_1 DOUBLE,
+    fringe_resid_2 DOUBLE,
+    user_1 DOUBLE,
+    user_2 DOUBLE,
+    user_3 DOUBLE,
+    user_4 DOUBLE,
+    user_5 DOUBLE,
+    path_base VARCHAR(255),
+    data_state VARCHAR(64),
+    fault SMALLINT NOT NULL,
+    PRIMARY KEY(det_id, iteration, exp_id, class_id),
+    KEY(fault),
+    INDEX(det_id, iteration, exp_id)
+    -- FOREIGN KEY (det_id, iteration, exp_id)
+    -- REFERENCES  detInputExp(det_id, iteration, exp_id),
+    -- FOREIGN KEY (det_id, exp_id, class_id)
+    -- REFERENCES  detProcessedImfile(det_id, exp_id, class_id),
+    -- FOREIGN KEY (ref_det_id, ref_iter)
+    -- REFERENCES  detNormalizedExp(det_id, iteration)
+) ENGINE=innodb DEFAULT CHARSET=latin1;
+
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/scripts/test_insert_detrend.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/scripts/test_insert_detrend.sql	(revision 23239)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/scripts/test_insert_detrend.sql	(revision 23239)
@@ -0,0 +1,47 @@
+-- create a fake detrun, add fake detProcessedImfile entries, etc
+
+insert into 
+       detRun (det_id, det_type, iteration, camera, workdir,   state, mode) 
+       values (1,      'flat',           0, 'GPC1', 'testdir', 'run', 'master');
+
+insert into 
+       detProcessedImfile (det_id, class_id) 
+       values (1, 'ccd00');
+
+insert into 
+       detProcessedImfile (det_id, class_id) 
+       values (1, 'ccd01');
+
+insert into 
+       detResidImfile (det_id, iteration, class_id) 
+       values (1, 0, 'ccd00');
+
+insert into 
+       detResidImfile (det_id, iteration, class_id) 
+       values (1, 0, 'ccd01');
+
+insert into 
+       detNormalizedStatImfile (det_id, iteration, class_id) 
+       values (1, 0, 'ccd01');
+
+insert into 
+       detNormalizedStatImfile (det_id, iteration, class_id) 
+       values (1, 0, 'ccd00');
+
+update detRun set iteration = 1 where det_id = 1;
+
+insert into 
+       detResidImfile (det_id, iteration, class_id) 
+       values (1, 1, 'ccd00');
+
+insert into 
+       detResidImfile (det_id, iteration, class_id) 
+       values (1, 1, 'ccd01');
+
+insert into 
+       detNormalizedStatImfile (det_id, iteration, class_id) 
+       values (1, 1, 'ccd00');
+
+insert into 
+       detNormalizedStatImfile (det_id, iteration, class_id) 
+       values (1, 1, 'ccd01');
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/chiptool_change_imfile_data_state.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/chiptool_change_imfile_data_state.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/chiptool_change_imfile_data_state.sql	(revision 23239)
@@ -7,8 +7,6 @@
     chip_id = %lld
     AND class_id = '%s'
-    -- only update if chipRun.state has the expected value
-    AND (
-        SELECT state from chipRun where chipRun.chip_id = chipProcessedImfile.chip_id
-    ) = '%s'
-    
-
+--    -- only update if chipRun.state has the expected value
+--    AND (
+--        SELECT state from chipRun where chipRun.chip_id = chipProcessedImfile.chip_id
+--    ) = '%s'
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_processedimfile.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_processedimfile.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_processedimfile.sql	(revision 23239)
@@ -1,2 +1,3 @@
+-- is this DISTINCT needed?
 SELECT DISTINCT
   detRun.det_type,
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_residimfile.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_residimfile.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_residimfile.sql	(revision 23239)
@@ -2,9 +2,13 @@
    detRun.det_type,
    detRun.mode,
-   detResidImfile.*,
-   rawExp.exp_time
- FROM detResidImfile
- JOIN detRun
-   USING(det_id, iteration)
- JOIN rawExp
-   USING(exp_id)
+   rawExp.exp_time,
+   detResidImfile.*
+FROM detResidImfile
+JOIN detRun
+  USING(det_id, iteration)
+JOIN detInputExp
+  ON detRun.det_id = detInputExp.det_id
+  AND detRun.iteration = detInputExp.iteration
+  AND detResidImfile.exp_id = detInputExp.exp_id
+JOIN rawExp
+  ON rawExp.exp_id = detResidImfile.exp_id
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_tonormalizedstat.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_tonormalizedstat.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_tonormalizedstat.sql	(revision 23239)
@@ -1,58 +1,33 @@
--- select detRun.det_id (det_id)
--- select detRun.iteration
--- by:
--- find the current iteration bassed on det_id
--- find all exp_ids in the current det_id/iteration from detInputExp
--- sort to detInputExp.imfiles to find the largest value per det_id/iter
--- compare imfiles to the number of detStackedImfiles by class_id
--- and:
--- ???
--- det_id is not in detStackedImfile;
--- iteration is not in detStackedImfile;
-
-SELECT
-    det_id,
-    det_type,
-    iteration,
-    camera,
-    workdir,
-    class_id
-FROM
-    (SELECT DISTINCT
-        detRun.det_id,
-        detRun.det_type,
-        detRun.iteration,
-        detRun.workdir,
-        rawExp.camera,
-        detStackedImfile.class_id,
-        rawImfile.class_id as rawimfile_class_id
-    FROM detRun
-    JOIN detInputExp
-        ON detRun.det_id = detInputExp.det_id
-        AND detRun.iteration = detInputExp.iteration
-    JOIN rawExp
-        ON detInputExp.exp_id = rawExp.exp_id
-    JOIN rawImfile
-        ON rawExp.exp_id = rawImfile.exp_id
-    LEFT JOIN detStackedImfile
-        ON detInputExp.det_id = detStackedImfile.det_id
-        AND detInputExp.iteration = detStackedImfile.iteration
-        AND rawImfile.class_id = detStackedImfile.class_id
-    LEFT JOIN detNormalizedStatImfile
-        ON detStackedImfile.det_id = detNormalizedStatImfile.det_id
-        AND detStackedImfile.iteration = detNormalizedStatImfile.iteration
-        AND detStackedImfile.class_id = detNormalizedStatImfile.class_id
-    WHERE
-        detRun.state = 'run'
-        AND detRun.mode = 'master'
-        AND detNormalizedStatImfile.det_id IS NULL
-        AND detNormalizedStatImfile.iteration IS NULL
-        AND detNormalizedStatImfile.class_id IS NULL
-    GROUP BY
---        rawExp.exp_id,
-        detRun.iteration,
-        detRun.det_id
-    HAVING
-        COUNT(rawImfile.class_id) = COUNT(detStackedImfile.class_id)
-        AND SUM(detStackedImfile.fault) = 0
-    ) as tonormalizedstat
+-- a det_run + iteration is ready for normstat when: all detResidImfile entries for that iteration corresponding to all detProcessedImfile entries are available 
+SELECT 
+  detRun.det_id, 
+  detRun.det_type, 
+  detRun.iteration, 
+  detRun.camera, 
+  detRun.workdir, 
+  detProcessedImfile.class_id,
+  COUNT(detProcessedImfile.class_id),
+  COUNT(detResidImfile.class_id)
+FROM detRun
+JOIN detProcessedImfile
+    ON  detProcessedImfile.det_id    = detRun.det_id
+LEFT JOIN detResidImfile
+    ON  detResidImfile.det_id    = detProcessedImfile.det_id
+    AND detResidImfile.class_id  = detProcessedImfile.class_id
+    AND detResidImfile.iteration = detRun.iteration
+LEFT JOIN detNormalizedStatImfile
+    ON  detNormalizedStatImfile.det_id    = detRun.det_id    
+    AND detNormalizedStatImfile.iteration = detRun.iteration 
+    AND detNormalizedStatImfile.class_id  = detProcessedImfile.class_id
+WHERE
+    detRun.state = 'run'
+    AND detRun.mode = 'master'
+    AND detNormalizedStatImfile.det_id IS NULL
+    AND detNormalizedStatImfile.iteration IS NULL
+    AND detNormalizedStatImfile.class_id IS NULL
+GROUP BY
+    detRun.iteration,
+    detRun.det_id
+HAVING
+    COUNT(detProcessedImfile.class_id) = COUNT(detResidImfile.class_id)
+    AND SUM(detResidImfile.fault) = 0
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidexp.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidexp.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidexp.sql	(revision 23239)
@@ -5,4 +5,6 @@
 -- id, detrend type, and whether the exposure was included in the stack for
 -- this iteration.
+
+-- require the corresponding detNormalizedExp to complete before starting
 
 -- select detRun.det_id
@@ -41,4 +43,6 @@
         detResidImfile.class_id
     FROM detRun
+    JOIN detNormalizedExp
+    	USING(det_id, iteration)
     JOIN detInputExp
         USING(det_id, iteration)
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidimfile.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidimfile.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidimfile.sql	(revision 23239)
@@ -13,5 +13,6 @@
     detProcessedImfile.class_id,
     detProcessedImfile.uri,
-    detNormalizedImfile.uri AS det_uri,
+--  detNormalizedImfile.uri AS det_uri,
+    detStackedImfile.uri AS det_uri,
     detRun.det_id AS ref_det_id,
     detRun.iteration AS ref_iter,
@@ -26,11 +27,17 @@
     ON detRun.det_id = detProcessedImfile.det_id
     AND detInputExp.exp_id = detProcessedImfile.exp_id
-JOIN detNormalizedImfile
-    ON detRun.det_id = detNormalizedImfile.det_id
-    AND detRun.iteration = detNormalizedImfile.iteration
-    AND detProcessedImfile.class_id = detNormalizedImfile.class_id
-JOIN detNormalizedExp
-    ON detRun.det_id = detNormalizedExp.det_id
-    AND detRun.iteration = detNormalizedExp.iteration
+JOIN detStackedImfile
+    ON detRun.det_id = detStackedImfile.det_id
+    AND detRun.iteration = detStackedImfile.iteration
+    AND detProcessedImfile.class_id = detStackedImfile.class_id
+-- EAM : replacing detNormalizedImfile with detStackedImfile to change the sequencing
+-- JOIN detNormalizedImfile
+--     ON detRun.det_id = detNormalizedImfile.det_id
+--     AND detRun.iteration = detNormalizedImfile.iteration
+--     AND detProcessedImfile.class_id = detNormalizedImfile.class_id
+-- EAM : we there is no reason to wait for all stacks to complete before continuing
+-- JOIN detNormalizedExp
+--     ON detRun.det_id = detNormalizedExp.det_id
+--     AND detRun.iteration = detNormalizedExp.iteration
 LEFT JOIN detResidImfile
     ON detRun.det_id = detResidImfile.det_id
@@ -41,6 +48,7 @@
     detRun.state = 'run'
     AND detRun.mode = 'master'
-    AND detNormalizedImfile.fault = 0
-    AND detNormalizedExp.fault = 0
+    AND detStackedImfile.fault = 0
+--  AND detNormalizedImfile.fault = 0
+--  AND detNormalizedExp.fault = 0
     AND detResidImfile.det_id IS NULL
     AND detResidImfile.iteration IS NULL
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/pxadmin_create_tables.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/pxadmin_create_tables.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/pxadmin_create_tables.sql	(revision 23239)
@@ -737,7 +737,5 @@
     REFERENCES  detInputExp(det_id, iteration, exp_id),
     FOREIGN KEY (det_id, exp_id, class_id)
-    REFERENCES  detProcessedImfile(det_id, exp_id, class_id),
-    FOREIGN KEY (ref_det_id, ref_iter)
-    REFERENCES  detNormalizedExp(det_id, iteration)
+    REFERENCES  detProcessedImfile(det_id, exp_id, class_id)
 ) ENGINE=innodb DEFAULT CHARSET=latin1;
 
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/share/warptool_change_skyfile_data_state.sql
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/share/warptool_change_skyfile_data_state.sql	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/share/warptool_change_skyfile_data_state.sql	(revision 23239)
@@ -9,7 +9,5 @@
     AND skycell_id = '%s'
     -- only update if chipRun.state has the expected value
-    AND (
-        SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id
-    ) = '%s'
-    
-
+--    AND (
+--        SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id
+--    ) = '%s'
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptool.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptool.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptool.c	(revision 23239)
@@ -52,9 +52,10 @@
 static bool runMode(pxConfig *config);
 static bool tocleanedimfileMode(pxConfig *config);
-static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
+// static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
 static bool tofullimfileMode(pxConfig *config);
 static bool topurgedimfileMode(pxConfig *config);
 static bool exportrunMode(pxConfig *config);
 static bool importrunMode(pxConfig *config);
+static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state);
 
 # define MODECASE(caseName, func) \
@@ -92,5 +93,5 @@
         MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
         MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
-        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
+        // MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
         MODECASE(CHIPTOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
         MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
@@ -651,13 +652,36 @@
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
-
-    if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
+    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
+    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+
+    if (state && code) {
+        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
+        return false;
+    }
+
+    if (state) {
+      // make sure that the state string is valid
+      if (!pxIsValidState(state)) {
+        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
+        return false;
+      }
+      if (!change_imfile_data_state(config, state, "unknown")) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         return false;
-    }
-    psFree(where);
-
-    return true;
+      }
+      return true;
+    }
+
+    if (code) {
+      if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
+        return false;
+      }
+      psFree(where);
+      return true;
+    }
+
+    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
+    return false;
 }
 
@@ -1195,4 +1219,9 @@
 // shared code for the modes -tocleanedimfile -tofullimfile -topurgedimfile
 
+// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
+// this is getting fairly messy now that we have added a few additional target and
+// destination states.  I'm disabling these restrictions for now; is there are better way
+// to enforce the allowed state transitions?
+
 static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state)
 {
@@ -1210,6 +1239,8 @@
     }
 
+    // XXX this feature is disabled (run_state is ignored)
     // note only updates if chipRun.state = run_state
-    if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id, run_state)) {
+
+    if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         // rollback
@@ -1246,8 +1277,4 @@
 {
     return change_imfile_data_state(config, "cleaned", "goto_cleaned");
-}
-static bool tocleanedimfile_from_scrubbedMode(pxConfig *config)
-{
-    return change_imfile_data_state(config, "cleaned", "goto_scrubbed");
 }
 static bool tofullimfileMode(pxConfig *config)
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptoolConfig.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptoolConfig.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptoolConfig.c	(revision 23239)
@@ -172,7 +172,8 @@
     // -updateprocessedimfile
     psMetadata *updateprocessedimfileArgs = psMetadataAlloc();
-    psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",  0,            "search by chip ID", 0);
-    psMetadataAddStr(updateprocessedimfileArgs,  PS_LIST_TAIL, "-class_id",           0, "search by class ID", NULL);
-    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code (required)", 0);
+    psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",    0, "search by chip ID", 0);
+    psMetadataAddStr(updateprocessedimfileArgs,  PS_LIST_TAIL, "-class_id",  0, "search by class ID", NULL);
+    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",       0, "set fault code", 0);
+    psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-set_state",  0, "set state", NULL);
 
     // -promoteexp
@@ -234,9 +235,9 @@
     psMetadataAddStr(tocleanedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
 
-    // -tocleanedimfile_from_scrubbed
-    psMetadata *tocleanedimfile_from_scrubbedArgs = psMetadataAlloc();
-    psMetadataAddS64(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
-    psMetadataAddStr(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
-
+//    // -tocleanedimfile_from_scrubbed
+//    psMetadata *tocleanedimfile_from_scrubbedArgs = psMetadataAlloc();
+//    psMetadataAddS64(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
+//    psMetadataAddStr(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
+//
     // -tofullimfile
     psMetadata *tofullimfileArgs = psMetadataAlloc();
@@ -280,5 +281,5 @@
     PXOPT_ADD_MODE("-run",                  "show runs",                            CHIPTOOL_MODE_RUN,                  runArgs);
     PXOPT_ADD_MODE("-tocleanedimfile",      "set imfile state to cleaned",          CHIPTOOL_MODE_TOCLEANEDIMFILE,      tocleanedimfileArgs);
-    PXOPT_ADD_MODE("-tocleanedimfile_from_scrubbed", "set imfile state to cleaned (for goto_scrubbed)", CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedArgs);
+    //    PXOPT_ADD_MODE("-tocleanedimfile_from_scrubbed", "set imfile state to cleaned (for goto_scrubbed)", CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedArgs);
     PXOPT_ADD_MODE("-tofullimfile",         "set imfile state to full",              CHIPTOOL_MODE_TOFULLIMFILE,         tofullimfileArgs);
     PXOPT_ADD_MODE("-topurgedimfile",       "set imfile state to purged",            CHIPTOOL_MODE_TOPURGEDIMFILE,       topurgedimfileArgs);
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettoolConfig.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettoolConfig.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettoolConfig.c	(revision 23239)
@@ -640,13 +640,14 @@
     // -residimfile
     psMetadata *residimfileArgs = psMetadataAlloc();
-    psMetadataAddS64(residimfileArgs, PS_LIST_TAIL, "-det_id",  0,            "search for detrend ID", 0);
-    psMetadataAddS32(residimfileArgs, PS_LIST_TAIL, "-iteration",  0,            "search for iteration number", 0);
-    psMetadataAddS64(residimfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by detrend ID", 0);
-    psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-class_id",  0,            "search for class ID", NULL);
-    psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-recip",  0,            "search for recipe", NULL);
-    psMetadataAddU64(residimfileArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
+    psMetadataAddS64(residimfileArgs,  PS_LIST_TAIL, "-det_id",  0,            "search for detrend ID", 0);
+    psMetadataAddS32(residimfileArgs,  PS_LIST_TAIL, "-iteration",  0,            "search for iteration number", 0);
+    psMetadataAddS64(residimfileArgs,  PS_LIST_TAIL, "-exp_id",  0,            "search by detrend ID", 0);
+    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-class_id",  0,            "search for class ID", NULL);
+    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-recip",  0,            "search for recipe", NULL);
+    psMetadataAddU64(residimfileArgs,  PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
     psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-faulted",  0,            "only return imfiles with a fault status set", false);
     psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
-    psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-select_state",  0,            "search for state", NULL);
+    psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-included",  0,            "restrict results to exposures 'includeded' in the current iteration", false);
+    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-select_state",  0,            "search for state", NULL);
 
     // -revertresidimfile
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_processedimfile.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_processedimfile.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_processedimfile.c	(revision 23239)
@@ -165,11 +165,4 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    bool hasWhere = false;
-
-    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
-    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
-    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
-    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
-
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-det_id", "detProcessedImfile.det_id", "==");
@@ -179,4 +172,10 @@
     PXOPT_COPY_STR(config->args, where, "-select_mode", "detRun.mode", "==");
 
+    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
+
+    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
+    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
+
     psString query = pxDataGet("dettool_processedimfile.sql");
     if (!query) {
@@ -186,4 +185,5 @@
     }
 
+    bool hasWhere = false;
     if (psListLength(where->list)) {
         psString whereClause = psDBGenerateWhereSQL(where, NULL);
@@ -211,4 +211,5 @@
 
     if (faulted) {
+        // list only faulted rows
 	psStringAppend(&query, " %s", " detProcessedImfile.fault != 0");
     } else {
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_residimfile.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_residimfile.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_residimfile.c	(revision 23239)
@@ -159,5 +159,7 @@
     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
+
     PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
+    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
 
     psString query = pxDataGet("dettool_residimfile.sql");
@@ -175,4 +177,14 @@
     }
     psFree(where);
+
+    // restrict search to included imfiles
+    if (included) {
+	if (hasWhere) {
+	    psStringAppend(&query, " AND detInputExp.include = 1");
+	} else {
+	    psStringAppend(&query, " WHERE detInputExp.include = 1");
+	}
+	hasWhere = true;
+    }
 
     if (hasWhere) {
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptool.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptool.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptool.c	(revision 23239)
@@ -55,4 +55,5 @@
 static bool updateskyfileMode(pxConfig *config);
 
+static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state);
 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
 static bool isValidMode(pxConfig *config, const char *mode);
@@ -1604,4 +1605,9 @@
 // shared code for the modes -tocleanedskyfile -tofullskyfile -topurgedskyfile
 
+// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
+// this is getting fairly messy now that we have added a few additional target and
+// destination states.  I'm disabling these restrictions for now; is there are better way
+// to enforce the allowed state transitions?
+
 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state)
 {
@@ -1619,6 +1625,8 @@
     }
 
+    // XXX this feature is disabled (run_state is ignored)
     // note only updates if warpRun.state = run_state
-    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) {
+
+    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         // rollback
@@ -1668,14 +1676,37 @@
     PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
     PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
+    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
     PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
 
-    psString query = pxDataGet("warptool_updateskyfile.sql");
-
-    if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-    psFree(query);
-
-    return true;
-}
+    if (state && code) {
+        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
+        return false;
+    }
+
+    if (state) {
+      // make sure that the state string is valid
+      if (!pxIsValidState(state)) {
+        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
+        return false;
+      }
+      if (!change_skyfile_data_state(config, state, "unknown")) {
+        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
+        return false;
+      }
+      return true;
+    }
+
+    if (code) {
+      psString query = pxDataGet("warptool_updateskyfile.sql");
+
+      if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
+      }
+      psFree(query);
+      return true;
+    }
+
+    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
+    return false;
+}
Index: branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptoolConfig.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptoolConfig.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptoolConfig.c	(revision 23239)
@@ -348,9 +348,10 @@
     psMetadataAddStr(tofullskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL);
 
-    // -toupdateskyfile
+    // -updateskyfile
     psMetadata *updateskyfileArgs = psMetadataAlloc();
-    psMetadataAddS64(updateskyfileArgs, PS_LIST_TAIL, "-warp_id", 0,    "warptool ID to update", 0);
+    psMetadataAddS64(updateskyfileArgs, PS_LIST_TAIL, "-warp_id",    0, "warptool ID to update", 0);
     psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL);
-    psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code",  0,      "new fault code", 0);
+    psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code",       0, "set fault code", 0);
+    psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-set_state",  0, "set state", NULL);
 
     psFree(now);
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/dvo.ps1v1.photcodes
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/dvo.ps1v1.photcodes	(revision 23239)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/dvo.ps1v1.photcodes	(revision 23239)
@@ -0,0 +1,906 @@
+
+# this file defines the layout for the PS1 working science database.  it has
+# average photcodes of grizy for PS1 and JHK for 2MASS and UKIDSS references
+
+# this file contains the list of valid photometry codes.  there should
+# be one code for each combination of CCD, filter, and telescope (and
+# possibly additional ones if filter transmission reduces with time).
+# The code on each line is a unique number, while the name is a
+# representative name.  The type defines how the photometry is
+# treated.  There can only be one primary photcode.  There should only
+# be a few secondary photcodes: these are the calibrated values for
+# stars.  The dependent photcodes are those which are equivalent to a
+# primary or secondary photcode, and are equated after photometric
+# solutions.  Reference photcodes are for anything without a dynamic
+# solution: the reference values are provided externally.
+
+# NOTE: the photcodes defined below supplement CFHT Elixir values.
+# Do not use this photcode file with old CFHT DVO databases.
+
+# camera ranges used in this file:
+# megacam:  u: 100-139, g: 200-239, r: 300-339, i: 400-439, z: 500-539
+# cfh12k:   B: 140-152, V: 240-252, R: 340-352, I: 440-452, Z: 540-552, NB: 600-693
+# mosaic2:  B: 160-167, V: 260-267, VR: 360-367, R: 460-467, I: 560-567
+# PS1 ISP:  g: 3200,      r: 3300,      i: 3400,      z: 3500,      y: 3600
+# PS1 TC3:  g: 3280-3296, r: 3380-3396, i: 3480-3496, z: 3580-3596, y: 3680-3696, 
+# PS1 GPC1: g: 3201-3264, r: 3301-3364, i: 3401-3464, z: 3501-3564, y: 3601-3664
+
+# external references: 1000 - 2999
+
+#                                                                                       astrometry  photometry     astr mask      phot mask
+# code name		    type  zero  airmass offset  c1    c2  slope  <color> eq     sys  scale  sys  scale     poor   bad     poor   bad 
+  1     g                    sec   0.000  0.000 0.000  1003  1004 0.0160     0  1051   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  2     r                    sec   0.000  0.000 0.000  1003  1004 0.0080     0  1052   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3     i                    sec   0.000  0.000 0.000  1003  1004 0.0280     0  1053   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4     z                    sec   0.000  0.000 0.000  1003  1004 0.1070     0  1054   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  5     y                    sec   0.000  0.000 0.000     -     - 0.0000     0  1054   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  6     J                    sec   0.000  0.000 0.000     -     - 0.0000     0  2011   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  7     H                    sec   0.000  0.000 0.000     -     - 0.0000     0  2012   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  8     K                    sec   0.000  0.000 0.000     -     - 0.0000     0  2013   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+
+  1010  U_L92                ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1011  B_L92                ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1012  V_L92                ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1013  R_L92                ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1014  I_L92                ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  1020  U_STET               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1021  B_STET               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1022  V_STET               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1023  R_STET               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1024  I_STET               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  1050  u_SDSS               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1051  g_SDSS               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1052  r_SDSS               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1053  i_SDSS               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1054  z_SDSS               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  1055  U_SDSS               dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1056  G_SDSS               dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1057  R_SDSS               dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1058  I_SDSS               dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1059  Z_SDSS               dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+# the 30 different SDSS photcodes for the SDSSmosaic camera... 6 columns of CCDs (camcols) x 5 filters.
+# Added by Sebastian Jester jester@mpia.de
+# These likely need work!
+  1060  SDSS.r.11            dep   0.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1061  SDSS.r.12            dep   0.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1062  SDSS.r.13            dep   0.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1063  SDSS.r.14            dep   0.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1064  SDSS.r.15            dep   0.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1065  SDSS.r.16            dep   0.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1066  SDSS.i.21            dep   0.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1067  SDSS.i.22            dep   0.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1068  SDSS.i.23            dep   0.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1069  SDSS.i.24            dep   0.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1070  SDSS.i.25            dep   0.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1071  SDSS.i.26            dep   0.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1072  SDSS.u.31            dep   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1073  SDSS.u.32            dep   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1074  SDSS.u.33            dep   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1075  SDSS.u.34            dep   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1076  SDSS.u.35            dep   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1077  SDSS.u.36            dep   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1078  SDSS.z.41            dep   0.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1079  SDSS.z.42            dep   0.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1080  SDSS.z.43            dep   0.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1081  SDSS.z.44            dep   0.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1082  SDSS.z.45            dep   0.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1083  SDSS.z.46            dep   0.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1084  SDSS.g.51            dep   0.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1085  SDSS.g.52            dep   0.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1086  SDSS.g.53            dep   0.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1087  SDSS.g.54            dep   0.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1088  SDSS.g.55            dep   0.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+  1089  SDSS.g.56            dep   0.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
+
+  1100  GSC                  ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  1000  USNO_BLUE            ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1001  USNO_RED             ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1002  USNO_J               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1003  USNO_F               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1004  USNO_N               ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  1110  USNO.098.RED         dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1111  USNO.098-0.RED70     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1112  USNO.098-0.RG630     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1113  USNO.103AD.MULTI     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1114  USNO.103AD.YEL3      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1115  USNO.103AD.YEL8      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1116  USNO.103AE.#12       dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1117  USNO.103AE.AMB2      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1118  USNO.103AE.AMB3      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1119  USNO.103AE.AMB4      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1120  USNO.103AE.AMB5      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1121  USNO.103AE.AMB6      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1122  USNO.103AE.AMB7      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1123  USNO.103AE.AMB8      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1124  USNO.103AE.NONE      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1125  USNO.103AE.RED66     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1126  USNO.103AE.RED67     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1127  USNO.103AE.RED68     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1128  USNO.103AE.RED69     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1129  USNO.103AE.RED70     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1130  USNO.103AE.RED71     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1131  USNO.103AE.RED73     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1132  USNO.103AE.RG2444    dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1133  USNO.103AE.RP2444    dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1134  USNO.103AO.NONE      dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1135  USNO.IIIAF.OG590     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1136  USNO.IIIAF.RG600     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1137  USNO.IIIAF.RG610     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1138  USNO.IIIAF.RG630     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1139  USNO.IIIAJ.GG358     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1140  USNO.IIIAJ.GG385     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1141  USNO.IIIAJ.GG395     dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1142  USNO.IVN.RG715       dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1143  USNO.IVN.RG9         dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  1144  USNO.IVN.WR88A       dep  20.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  2020  TYCHO_B              ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  2021  TYCHO_V              ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  2011  2MASS_J              ref   0.000  0.000 0.000     -     - 0.0000     0     6   0.050 0.000 1.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  2012  2MASS_H              ref   0.000  0.000 0.000     -     - 0.0000     0     7   0.050 0.000 1.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  2013  2MASS_K              ref   0.000  0.000 0.000     -     - 0.0000     0     8   0.050 0.000 1.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+# these were used for the synthetic photometry catalog based on 2mass					       										
+  3001  PS_g                 ref   0.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3002  PS_r                 ref   0.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3003  PS_i                 ref   0.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3004  PS_z                 ref   0.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3005  PS_y                 ref   0.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+### megacam photcodes:
+  100   MEGACAM.u.00         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  101   MEGACAM.u.01         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  102   MEGACAM.u.02         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  103   MEGACAM.u.03         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  104   MEGACAM.u.04         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  105   MEGACAM.u.05         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  106   MEGACAM.u.06         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  107   MEGACAM.u.07         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  108   MEGACAM.u.08         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  109   MEGACAM.u.09         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  110   MEGACAM.u.10         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  111   MEGACAM.u.11         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  112   MEGACAM.u.12         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  113   MEGACAM.u.13         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  114   MEGACAM.u.14         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  115   MEGACAM.u.15         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  116   MEGACAM.u.16         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  117   MEGACAM.u.17         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  118   MEGACAM.u.18         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  119   MEGACAM.u.19         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  120   MEGACAM.u.20         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  121   MEGACAM.u.21         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  122   MEGACAM.u.22         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  123   MEGACAM.u.23         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  124   MEGACAM.u.24         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  125   MEGACAM.u.25         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  126   MEGACAM.u.26         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  127   MEGACAM.u.27         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  128   MEGACAM.u.28         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  129   MEGACAM.u.29         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  130   MEGACAM.u.30         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  131   MEGACAM.u.31         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  132   MEGACAM.u.32         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  133   MEGACAM.u.33         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  134   MEGACAM.u.34         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  135   MEGACAM.u.35         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  136   MEGACAM.u.36         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  137   MEGACAM.u.37         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  138   MEGACAM.u.38         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  139   MEGACAM.u.39         dep  25.280 -0.350 0.000     -     - 0.0000     0     -   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  200   MEGACAM.g.00         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  201   MEGACAM.g.01         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  202   MEGACAM.g.02         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  203   MEGACAM.g.03         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  204   MEGACAM.g.04         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  205   MEGACAM.g.05         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  206   MEGACAM.g.06         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  207   MEGACAM.g.07         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  208   MEGACAM.g.08         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  209   MEGACAM.g.09         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  210   MEGACAM.g.10         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  211   MEGACAM.g.11         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  212   MEGACAM.g.12         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  213   MEGACAM.g.13         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  214   MEGACAM.g.14         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  215   MEGACAM.g.15         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  216   MEGACAM.g.16         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  217   MEGACAM.g.17         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  218   MEGACAM.g.18         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  219   MEGACAM.g.19         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  220   MEGACAM.g.20         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  221   MEGACAM.g.21         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  222   MEGACAM.g.22         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  223   MEGACAM.g.23         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  224   MEGACAM.g.24         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  225   MEGACAM.g.25         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  226   MEGACAM.g.26         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  227   MEGACAM.g.27         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  228   MEGACAM.g.28         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  229   MEGACAM.g.29         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  230   MEGACAM.g.30         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  231   MEGACAM.g.31         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  232   MEGACAM.g.32         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  233   MEGACAM.g.33         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  234   MEGACAM.g.34         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  235   MEGACAM.g.35         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  236   MEGACAM.g.36         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  237   MEGACAM.g.37         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  238   MEGACAM.g.38         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  239   MEGACAM.g.39         dep  26.460 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  300   MEGACAM.r.00         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  301   MEGACAM.r.01         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  302   MEGACAM.r.02         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  303   MEGACAM.r.03         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  304   MEGACAM.r.04         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  305   MEGACAM.r.05         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  306   MEGACAM.r.06         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  307   MEGACAM.r.07         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  308   MEGACAM.r.08         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  309   MEGACAM.r.09         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  310   MEGACAM.r.10         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  311   MEGACAM.r.11         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  312   MEGACAM.r.12         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  313   MEGACAM.r.13         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  314   MEGACAM.r.14         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  315   MEGACAM.r.15         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  316   MEGACAM.r.16         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  317   MEGACAM.r.17         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  318   MEGACAM.r.18         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  319   MEGACAM.r.19         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  320   MEGACAM.r.20         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  321   MEGACAM.r.21         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  322   MEGACAM.r.22         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  323   MEGACAM.r.23         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  324   MEGACAM.r.24         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  325   MEGACAM.r.25         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  326   MEGACAM.r.26         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  327   MEGACAM.r.27         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  328   MEGACAM.r.28         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  329   MEGACAM.r.29         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  330   MEGACAM.r.30         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  331   MEGACAM.r.31         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  332   MEGACAM.r.32         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  333   MEGACAM.r.33         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  334   MEGACAM.r.34         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  335   MEGACAM.r.35         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  336   MEGACAM.r.36         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  337   MEGACAM.r.37         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  338   MEGACAM.r.38         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  339   MEGACAM.r.39         dep  25.978 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  400   MEGACAM.i.00         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  401   MEGACAM.i.01         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  402   MEGACAM.i.02         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  403   MEGACAM.i.03         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  404   MEGACAM.i.04         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  405   MEGACAM.i.05         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  406   MEGACAM.i.06         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  407   MEGACAM.i.07         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  408   MEGACAM.i.08         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  409   MEGACAM.i.09         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  410   MEGACAM.i.10         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  411   MEGACAM.i.11         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  412   MEGACAM.i.12         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  413   MEGACAM.i.13         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  414   MEGACAM.i.14         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  415   MEGACAM.i.15         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  416   MEGACAM.i.16         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  417   MEGACAM.i.17         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  418   MEGACAM.i.18         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  419   MEGACAM.i.19         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  420   MEGACAM.i.20         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  421   MEGACAM.i.21         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  422   MEGACAM.i.22         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  423   MEGACAM.i.23         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  424   MEGACAM.i.24         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  425   MEGACAM.i.25         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  426   MEGACAM.i.26         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  427   MEGACAM.i.27         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  428   MEGACAM.i.28         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  429   MEGACAM.i.29         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  430   MEGACAM.i.30         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  431   MEGACAM.i.31         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  432   MEGACAM.i.32         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  433   MEGACAM.i.33         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  434   MEGACAM.i.34         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  435   MEGACAM.i.35         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  436   MEGACAM.i.36         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  437   MEGACAM.i.37         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  438   MEGACAM.i.38         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  439   MEGACAM.i.39         dep  25.744 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  500   MEGACAM.z.00         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  501   MEGACAM.z.01         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  502   MEGACAM.z.02         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  503   MEGACAM.z.03         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  504   MEGACAM.z.04         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  505   MEGACAM.z.05         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  506   MEGACAM.z.06         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  507   MEGACAM.z.07         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  508   MEGACAM.z.08         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  509   MEGACAM.z.09         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  510   MEGACAM.z.10         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  511   MEGACAM.z.11         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  512   MEGACAM.z.12         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  513   MEGACAM.z.13         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  514   MEGACAM.z.14         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  515   MEGACAM.z.15         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  516   MEGACAM.z.16         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  517   MEGACAM.z.17         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  518   MEGACAM.z.18         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  519   MEGACAM.z.19         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  520   MEGACAM.z.20         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  521   MEGACAM.z.21         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  522   MEGACAM.z.22         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  523   MEGACAM.z.23         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  524   MEGACAM.z.24         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  525   MEGACAM.z.25         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  526   MEGACAM.z.26         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  527   MEGACAM.z.27         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  528   MEGACAM.z.28         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  529   MEGACAM.z.29         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  530   MEGACAM.z.30         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  531   MEGACAM.z.31         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  532   MEGACAM.z.32         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  533   MEGACAM.z.33         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  534   MEGACAM.z.34         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  535   MEGACAM.z.35         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  536   MEGACAM.z.36         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  537   MEGACAM.z.37         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  538   MEGACAM.z.38         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  539   MEGACAM.z.39         dep  24.800 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+### cfh12k photcodes
+  140   CFH12K.B.00          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  141   CFH12K.B.01          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  142   CFH12K.B.02          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  143   CFH12K.B.03          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  144   CFH12K.B.04          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  145   CFH12K.B.05          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  146   CFH12K.B.06          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  147   CFH12K.B.07          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  148   CFH12K.B.08          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  149   CFH12K.B.09          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  150   CFH12K.B.10          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  151   CFH12K.B.11          dep  26.000 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  240   CFH12K.V.00          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  241   CFH12K.V.01          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  242   CFH12K.V.02          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  243   CFH12K.V.03          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  244   CFH12K.V.04          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  245   CFH12K.V.05          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  246   CFH12K.V.06          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  247   CFH12K.V.07          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  248   CFH12K.V.08          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  249   CFH12K.V.09          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  250   CFH12K.V.10          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  251   CFH12K.V.11          dep  26.150 -0.120 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  340   CFH12K.R.00          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  341   CFH12K.R.01          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  342   CFH12K.R.02          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  343   CFH12K.R.03          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  344   CFH12K.R.04          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  345   CFH12K.R.05          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  346   CFH12K.R.06          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  347   CFH12K.R.07          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  348   CFH12K.R.08          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  349   CFH12K.R.09          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  350   CFH12K.R.10          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  351   CFH12K.R.11          dep  26.190 -0.090 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  440   CFH12K.I.00          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  441   CFH12K.I.01          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  442   CFH12K.I.02          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  443   CFH12K.I.03          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  444   CFH12K.I.04          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  445   CFH12K.I.05          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  446   CFH12K.I.06          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  447   CFH12K.I.07          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  448   CFH12K.I.08          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  449   CFH12K.I.09          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  450   CFH12K.I.10          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  451   CFH12K.I.11          dep  26.135 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  540   CFH12K.Z.00          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  541   CFH12K.Z.01          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  542   CFH12K.Z.02          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  543   CFH12K.Z.03          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  544   CFH12K.Z.04          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  545   CFH12K.Z.05          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  546   CFH12K.Z.06          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  547   CFH12K.Z.07          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  548   CFH12K.Z.08          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  549   CFH12K.Z.09          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  550   CFH12K.Z.10          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  551   CFH12K.Z.11          dep  25.830 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  600   CFH12K.Ha.00         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  601   CFH12K.Ha.01         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  602   CFH12K.Ha.02         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  603   CFH12K.Ha.03         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  604   CFH12K.Ha.04         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  605   CFH12K.Ha.05         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  606   CFH12K.Ha.06         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  607   CFH12K.Ha.07         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  608   CFH12K.Ha.08         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  609   CFH12K.Ha.09         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  610   CFH12K.Ha.10         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  611   CFH12K.Ha.11         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  612   CFH12K.HaOff.00      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  613   CFH12K.HaOff.01      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  614   CFH12K.HaOff.02      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  615   CFH12K.HaOff.03      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  616   CFH12K.HaOff.04      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  617   CFH12K.HaOff.05      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  618   CFH12K.HaOff.06      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  619   CFH12K.HaOff.07      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  620   CFH12K.HaOff.08      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  621   CFH12K.HaOff.09      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  622   CFH12K.HaOff.10      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  623   CFH12K.HaOff.11      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  624   CFH12K.CN.00         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  625   CFH12K.CN.01         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  626   CFH12K.CN.02         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  627   CFH12K.CN.03         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  628   CFH12K.CN.04         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  629   CFH12K.CN.05         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  630   CFH12K.CN.06         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  631   CFH12K.CN.07         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  632   CFH12K.CN.08         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  633   CFH12K.CN.09         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  634   CFH12K.CN.10         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  635   CFH12K.CN.11         dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  636   CFH12K.TiO.00        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  637   CFH12K.TiO.01        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  638   CFH12K.TiO.02        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  639   CFH12K.TiO.03        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  640   CFH12K.TiO.04        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  641   CFH12K.TiO.05        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  642   CFH12K.TiO.06        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  643   CFH12K.TiO.07        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  644   CFH12K.TiO.08        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  645   CFH12K.TiO.09        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  646   CFH12K.TiO.10        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  647   CFH12K.TiO.11        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  648   CFH12K.NB920.00      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  649   CFH12K.NB920.01      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  650   CFH12K.NB920.02      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  651   CFH12K.NB920.03      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  652   CFH12K.NB920.04      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  653   CFH12K.NB920.05      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  654   CFH12K.NB920.06      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  655   CFH12K.NB920.07      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  678   CFH12K.NB920.08      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  679   CFH12K.NB920.09      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  680   CFH12K.NB920.10      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  681   CFH12K.NB920.11      dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  682   CFH12K.B2F.00        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  683   CFH12K.B2F.01        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  684   CFH12K.B2F.02        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  685   CFH12K.B2F.03        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  686   CFH12K.B2F.04        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  687   CFH12K.B2F.05        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  688   CFH12K.B2F.06        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  689   CFH12K.B2F.07        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  690   CFH12K.B2F.08        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  691   CFH12K.B2F.09        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  692   CFH12K.B2F.10        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  693   CFH12K.B2F.11        dep  25.000  0.040 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  3200  ISP-Apogee-01.g      dep  19.250  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3300  ISP-Apogee-01.r      dep  19.150  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3400  ISP-Apogee-01.i      dep  18.500  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3500  ISP-Apogee-01.z      dep  17.250  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  3600  ISP-Apogee-01.y      dep  14.150  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  4100  SIMTEST.g.Chip       dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4200  SIMTEST.r.Chip       dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4300  SIMTEST.i.Chip       dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4400  SIMTEST.z.Chip       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4500  SIMTEST.y.Chip       dep  25.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+ 14100  SIMTEST.g.SkyChip    dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+ 14200  SIMTEST.r.SkyChip    dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+ 14300  SIMTEST.i.SkyChip    dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+ 14400  SIMTEST.z.SkyChip    dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+ 14500  SIMTEST.y.SkyChip    dep  25.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+
+  4101  SIMMOSAIC.g.00       dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4102  SIMMOSAIC.g.01       dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4103  SIMMOSAIC.g.02       dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4104  SIMMOSAIC.g.03       dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4201  SIMMOSAIC.r.00       dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4202  SIMMOSAIC.r.01       dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4203  SIMMOSAIC.r.02       dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4204  SIMMOSAIC.r.03       dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4301  SIMMOSAIC.i.00       dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4302  SIMMOSAIC.i.01       dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4303  SIMMOSAIC.i.02       dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4304  SIMMOSAIC.i.03       dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4401  SIMMOSAIC.z.00       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4402  SIMMOSAIC.z.01       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4403  SIMMOSAIC.z.02       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4404  SIMMOSAIC.z.03       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4501  SIMMOSAIC.y.00       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4502  SIMMOSAIC.y.01       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4503  SIMMOSAIC.y.02       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  4504  SIMMOSAIC.y.03       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+# 2007.10.02 : predicted g zero-points from 2006 NSF proposal						       											
+  10001 GPC1.g.XY01          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10002 GPC1.g.XY02          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10003 GPC1.g.XY03          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10004 GPC1.g.XY04          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10005 GPC1.g.XY05          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10006 GPC1.g.XY06          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10010 GPC1.g.XY10          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10011 GPC1.g.XY11          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10012 GPC1.g.XY12          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10013 GPC1.g.XY13          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10014 GPC1.g.XY14          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10015 GPC1.g.XY15          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10016 GPC1.g.XY16          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10017 GPC1.g.XY17          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10020 GPC1.g.XY20          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10021 GPC1.g.XY21          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10022 GPC1.g.XY22          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10023 GPC1.g.XY23          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10024 GPC1.g.XY24          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10025 GPC1.g.XY25          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10026 GPC1.g.XY26          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10027 GPC1.g.XY27          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10030 GPC1.g.XY30          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10031 GPC1.g.XY31          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10032 GPC1.g.XY32          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10033 GPC1.g.XY33          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10034 GPC1.g.XY34          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10035 GPC1.g.XY35          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10036 GPC1.g.XY36          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10037 GPC1.g.XY37          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10040 GPC1.g.XY40          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10041 GPC1.g.XY41          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10042 GPC1.g.XY42          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10043 GPC1.g.XY43          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10044 GPC1.g.XY44          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10045 GPC1.g.XY45          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10046 GPC1.g.XY46          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10047 GPC1.g.XY47          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10050 GPC1.g.XY50          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10051 GPC1.g.XY51          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10052 GPC1.g.XY52          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10053 GPC1.g.XY53          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10054 GPC1.g.XY54          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10055 GPC1.g.XY55          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10056 GPC1.g.XY56          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10057 GPC1.g.XY57          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10060 GPC1.g.XY60          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10061 GPC1.g.XY61          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10062 GPC1.g.XY62          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10063 GPC1.g.XY63          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10064 GPC1.g.XY64          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10065 GPC1.g.XY65          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10066 GPC1.g.XY66          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10067 GPC1.g.XY67          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10071 GPC1.g.XY71          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10072 GPC1.g.XY72          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10073 GPC1.g.XY73          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10074 GPC1.g.XY74          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10075 GPC1.g.XY75          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10076 GPC1.g.XY76          dep  24.900  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+# 2007.10.02 : predicted r zero-points from 2006 NSF proposal						       											
+  10101 GPC1.r.XY01          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10102 GPC1.r.XY02          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10103 GPC1.r.XY03          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10104 GPC1.r.XY04          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10105 GPC1.r.XY05          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10106 GPC1.r.XY06          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10110 GPC1.r.XY10          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10111 GPC1.r.XY11          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10112 GPC1.r.XY12          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10113 GPC1.r.XY13          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10114 GPC1.r.XY14          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10115 GPC1.r.XY15          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10116 GPC1.r.XY16          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10117 GPC1.r.XY17          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10120 GPC1.r.XY20          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10121 GPC1.r.XY21          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10122 GPC1.r.XY22          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10123 GPC1.r.XY23          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10124 GPC1.r.XY24          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10125 GPC1.r.XY25          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10126 GPC1.r.XY26          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10127 GPC1.r.XY27          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10130 GPC1.r.XY30          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10131 GPC1.r.XY31          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10132 GPC1.r.XY32          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10133 GPC1.r.XY33          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10134 GPC1.r.XY34          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10135 GPC1.r.XY35          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10136 GPC1.r.XY36          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10137 GPC1.r.XY37          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10140 GPC1.r.XY40          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10141 GPC1.r.XY41          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10142 GPC1.r.XY42          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10143 GPC1.r.XY43          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10144 GPC1.r.XY44          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10145 GPC1.r.XY45          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10146 GPC1.r.XY46          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10147 GPC1.r.XY47          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10150 GPC1.r.XY50          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10151 GPC1.r.XY51          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10152 GPC1.r.XY52          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10153 GPC1.r.XY53          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10154 GPC1.r.XY54          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10155 GPC1.r.XY55          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10156 GPC1.r.XY56          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10157 GPC1.r.XY57          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10160 GPC1.r.XY60          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10161 GPC1.r.XY61          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10162 GPC1.r.XY62          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10163 GPC1.r.XY63          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10164 GPC1.r.XY64          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10165 GPC1.r.XY65          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10166 GPC1.r.XY66          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10167 GPC1.r.XY67          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10171 GPC1.r.XY71          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10172 GPC1.r.XY72          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10173 GPC1.r.XY73          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10174 GPC1.r.XY74          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10175 GPC1.r.XY75          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10176 GPC1.r.XY76          dep  25.100  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+# 2007.10.02 : predicted i zero-points from 2006 NSF proposal						       											
+  10201 GPC1.i.XY01          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10202 GPC1.i.XY02          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10203 GPC1.i.XY03          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10204 GPC1.i.XY04          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10205 GPC1.i.XY05          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10206 GPC1.i.XY06          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10210 GPC1.i.XY10          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10211 GPC1.i.XY11          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10212 GPC1.i.XY12          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10213 GPC1.i.XY13          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10214 GPC1.i.XY14          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10215 GPC1.i.XY15          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10216 GPC1.i.XY16          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10217 GPC1.i.XY17          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10220 GPC1.i.XY20          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10221 GPC1.i.XY21          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10222 GPC1.i.XY22          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10223 GPC1.i.XY23          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10224 GPC1.i.XY24          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10225 GPC1.i.XY25          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10226 GPC1.i.XY26          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10227 GPC1.i.XY27          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10230 GPC1.i.XY30          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10231 GPC1.i.XY31          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10232 GPC1.i.XY32          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10233 GPC1.i.XY33          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10234 GPC1.i.XY34          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10235 GPC1.i.XY35          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10236 GPC1.i.XY36          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10237 GPC1.i.XY37          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10240 GPC1.i.XY40          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10241 GPC1.i.XY41          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10242 GPC1.i.XY42          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10243 GPC1.i.XY43          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10244 GPC1.i.XY44          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10245 GPC1.i.XY45          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10246 GPC1.i.XY46          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10247 GPC1.i.XY47          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10250 GPC1.i.XY50          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10251 GPC1.i.XY51          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10252 GPC1.i.XY52          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10253 GPC1.i.XY53          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10254 GPC1.i.XY54          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10255 GPC1.i.XY55          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10256 GPC1.i.XY56          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10257 GPC1.i.XY57          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10260 GPC1.i.XY60          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10261 GPC1.i.XY61          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10262 GPC1.i.XY62          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10263 GPC1.i.XY63          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10264 GPC1.i.XY64          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10265 GPC1.i.XY65          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10266 GPC1.i.XY66          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10267 GPC1.i.XY67          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10271 GPC1.i.XY71          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10272 GPC1.i.XY72          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10273 GPC1.i.XY73          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10274 GPC1.i.XY74          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10275 GPC1.i.XY75          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10276 GPC1.i.XY76          dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+# 2007.10.02 : predicted z zero-points from 2006 NSF proposal						       											
+  10301 GPC1.z.XY01          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10302 GPC1.z.XY02          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10303 GPC1.z.XY03          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10304 GPC1.z.XY04          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10305 GPC1.z.XY05          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10306 GPC1.z.XY06          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10310 GPC1.z.XY10          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10311 GPC1.z.XY11          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10312 GPC1.z.XY12          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10313 GPC1.z.XY13          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10314 GPC1.z.XY14          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10315 GPC1.z.XY15          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10316 GPC1.z.XY16          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10317 GPC1.z.XY17          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10320 GPC1.z.XY20          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10321 GPC1.z.XY21          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10322 GPC1.z.XY22          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10323 GPC1.z.XY23          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10324 GPC1.z.XY24          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10325 GPC1.z.XY25          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10326 GPC1.z.XY26          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10327 GPC1.z.XY27          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10330 GPC1.z.XY30          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10331 GPC1.z.XY31          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10332 GPC1.z.XY32          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10333 GPC1.z.XY33          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10334 GPC1.z.XY34          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10335 GPC1.z.XY35          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10336 GPC1.z.XY36          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10337 GPC1.z.XY37          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10340 GPC1.z.XY40          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10341 GPC1.z.XY41          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10342 GPC1.z.XY42          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10343 GPC1.z.XY43          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10344 GPC1.z.XY44          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10345 GPC1.z.XY45          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10346 GPC1.z.XY46          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10347 GPC1.z.XY47          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10350 GPC1.z.XY50          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10351 GPC1.z.XY51          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10352 GPC1.z.XY52          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10353 GPC1.z.XY53          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10354 GPC1.z.XY54          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10355 GPC1.z.XY55          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10356 GPC1.z.XY56          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10357 GPC1.z.XY57          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10360 GPC1.z.XY60          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10361 GPC1.z.XY61          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10362 GPC1.z.XY62          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10363 GPC1.z.XY63          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10364 GPC1.z.XY64          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10365 GPC1.z.XY65          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10366 GPC1.z.XY66          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10367 GPC1.z.XY67          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10371 GPC1.z.XY71          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10372 GPC1.z.XY72          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10373 GPC1.z.XY73          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10374 GPC1.z.XY74          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10375 GPC1.z.XY75          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10376 GPC1.z.XY76          dep  24.600  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+													       										
+# 2007.10.02 : predicted y zero-points from 2006 NSF proposal						       											
+  10401 GPC1.y.XY01          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10402 GPC1.y.XY02          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10403 GPC1.y.XY03          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10404 GPC1.y.XY04          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10405 GPC1.y.XY05          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10406 GPC1.y.XY06          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10410 GPC1.y.XY10          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10411 GPC1.y.XY11          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10412 GPC1.y.XY12          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10413 GPC1.y.XY13          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10414 GPC1.y.XY14          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10415 GPC1.y.XY15          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10416 GPC1.y.XY16          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10417 GPC1.y.XY17          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10420 GPC1.y.XY20          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10421 GPC1.y.XY21          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10422 GPC1.y.XY22          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10423 GPC1.y.XY23          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10424 GPC1.y.XY24          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10425 GPC1.y.XY25          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10426 GPC1.y.XY26          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10427 GPC1.y.XY27          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10430 GPC1.y.XY30          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10431 GPC1.y.XY31          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10432 GPC1.y.XY32          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10433 GPC1.y.XY33          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10434 GPC1.y.XY34          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10435 GPC1.y.XY35          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10436 GPC1.y.XY36          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10437 GPC1.y.XY37          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10440 GPC1.y.XY40          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10441 GPC1.y.XY41          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10442 GPC1.y.XY42          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10443 GPC1.y.XY43          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10444 GPC1.y.XY44          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10445 GPC1.y.XY45          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10446 GPC1.y.XY46          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10447 GPC1.y.XY47          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10450 GPC1.y.XY50          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10451 GPC1.y.XY51          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10452 GPC1.y.XY52          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10453 GPC1.y.XY53          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10454 GPC1.y.XY54          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10455 GPC1.y.XY55          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10456 GPC1.y.XY56          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10457 GPC1.y.XY57          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10460 GPC1.y.XY60          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10461 GPC1.y.XY61          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10462 GPC1.y.XY62          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10463 GPC1.y.XY63          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10464 GPC1.y.XY64          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10465 GPC1.y.XY65          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10466 GPC1.y.XY66          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10467 GPC1.y.XY67          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10471 GPC1.y.XY71          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10472 GPC1.y.XY72          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10473 GPC1.y.XY73          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10474 GPC1.y.XY74          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10475 GPC1.y.XY75          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  10476 GPC1.y.XY76          dep  22.200  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+  11000 GPC1.g.SkyChip       dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  11100 GPC1.r.SkyChip       dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  11200 GPC1.i.SkyChip       dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  11300 GPC1.z.SkyChip       dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+  11400 GPC1.y.SkyChip       dep  25.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000	
+
+# mosaic2 photcodes
+
+  160  MOSAIC2.B.00          dep  25.107  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  161  MOSAIC2.B.01          dep  25.120  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  162  MOSAIC2.B.02          dep  25.115  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  163  MOSAIC2.B.03          dep  25.111  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  164  MOSAIC2.B.04          dep  25.111  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  165  MOSAIC2.B.05          dep  25.101  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  166  MOSAIC2.B.06          dep  25.106  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  167  MOSAIC2.B.07          dep  25.104  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  260  MOSAIC2.V.00          dep  25.448  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  261  MOSAIC2.V.01          dep  25.472  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  262  MOSAIC2.V.02          dep  25.472  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  263  MOSAIC2.V.03          dep  25.476  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  264  MOSAIC2.V.04          dep  25.475  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  265  MOSAIC2.V.05          dep  25.471  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  266  MOSAIC2.V.06          dep  25.472  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  267  MOSAIC2.V.07          dep  25.475  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  360  MOSAIC2.VR.00         dep  25.636  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  361  MOSAIC2.VR.01         dep  25.633  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  362  MOSAIC2.VR.02         dep  25.648  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  363  MOSAIC2.VR.03         dep  25.632  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  364  MOSAIC2.VR.04         dep  25.628  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  365  MOSAIC2.VR.05         dep  25.616  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  366  MOSAIC2.VR.06         dep  25.629  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  367  MOSAIC2.VR.07         dep  25.624  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  460  MOSAIC2.R.00          dep  25.636  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  461  MOSAIC2.R.01          dep  25.633  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  462  MOSAIC2.R.02          dep  25.648  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  463  MOSAIC2.R.03          dep  25.632  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  464  MOSAIC2.R.04          dep  25.628  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  465  MOSAIC2.R.05          dep  25.616  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  466  MOSAIC2.R.06          dep  25.629  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  467  MOSAIC2.R.07          dep  25.624  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+
+  560  MOSAIC2.I.00          dep  24.911  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  561  MOSAIC2.I.01          dep  24.882  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  562  MOSAIC2.I.02          dep  24.924  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  563  MOSAIC2.I.03          dep  24.906  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  564  MOSAIC2.I.04          dep  24.906  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  565  MOSAIC2.I.05          dep  24.877  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  566  MOSAIC2.I.06          dep  24.887  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
+  567  MOSAIC2.I.07          dep  24.912  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000	
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/gpc1/ppImage.config
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/gpc1/ppImage.config	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/gpc1/ppImage.config	(revision 23239)
@@ -9,4 +9,7 @@
 OVERSCAN.STAT           STR     MEDIAN
 OVERSCAN.BOXCAR         S32     3
+
+# Normalization class
+NORM.CLASS              STR     CHIP             # How to find the per-class normalizations
 
 OLDDARK                 BOOL    FALSE
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-mef.mdc
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-mef.mdc	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-mef.mdc	(revision 23239)
@@ -98,8 +98,9 @@
 PPSUB.INPUT.MASK        INPUT    @FILES        FPA        MASK
 PPSUB.INPUT.VARIANCE    INPUT    @FILES        FPA        VARIANCE
+PPSUB.INPUT.SOURCES     INPUT    @FILES        FPA        CMF
 PPSUB.REF               INPUT    @FILES        FPA        IMAGE
 PPSUB.REF.MASK          INPUT    @FILES        FPA        MASK
 PPSUB.REF.VARIANCE      INPUT    @FILES        FPA        VARIANCE
-PPSUB.SOURCES           INPUT    @FILES        FPA        CMF
+PPSUB.REF.SOURCES       INPUT    @FILES        FPA        CMF
 
 ## files used by ppstack
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-simple.mdc
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-simple.mdc	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-simple.mdc	(revision 23239)
@@ -61,8 +61,9 @@
 PPSUB.INPUT.MASK        INPUT    @FILES        FPA        MASK
 PPSUB.INPUT.VARIANCE    INPUT    @FILES        FPA        VARIANCE
+PPSUB.INPUT.SOURCES     INPUT    @FILES        FPA        CMF
 PPSUB.REF               INPUT    @FILES        FPA        IMAGE
 PPSUB.REF.MASK          INPUT    @FILES        FPA        MASK
 PPSUB.REF.VARIANCE      INPUT    @FILES        FPA        VARIANCE
-PPSUB.SOURCES           INPUT    @FILES        FPA        CMF
+PPSUB.REF.SOURCES       INPUT    @FILES        FPA        CMF
 
 ## files used by ppstack
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-split.mdc
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-split.mdc	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-split.mdc	(revision 23239)
@@ -73,8 +73,9 @@
 PPSUB.INPUT.MASK        INPUT    @FILES        FPA        MASK
 PPSUB.INPUT.VARIANCE    INPUT    @FILES        FPA        VARIANCE
+PPSUB.INPUT.SOURCES    	INPUT 	 @FILES        FPA        CMF
 PPSUB.REF               INPUT    @FILES        FPA        IMAGE
 PPSUB.REF.MASK          INPUT    @FILES        FPA        MASK
 PPSUB.REF.VARIANCE      INPUT    @FILES        FPA        VARIANCE
-PPSUB.SOURCES      	INPUT 	 @FILES        FPA        CMF
+PPSUB.REF.SOURCES    	INPUT 	 @FILES        FPA        CMF
 
 ## files used by ppstack
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppImage.config
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppImage.config	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppImage.config	(revision 23239)
@@ -40,4 +40,7 @@
 NONLIN.SOURCE           STR     CHIP.NAME       # How to determine the source
 NONLIN.DATA             STR     nonlin.dat      # Filename for lookup table
+
+# Normalization class
+NORM.CLASS              STR     FPA             # How to find the per-class normalizations
 
 OLDDARK		BOOL	FALSE		# Use old-style darks?
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppStack.config
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppStack.config	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppStack.config	(revision 23239)
@@ -32,12 +32,16 @@
 
 ZP.RADIUS	F32	1.0		# Radius (pixels) for matching sources
-ZP.ITER		S32	1000		# Maximum iterations for zero point
+ZP.ITER.1	S32	5		# Iterations for zero point; pass 1
+ZP.ITER.2	S32	1000		# Iterations for zero point; pass 2
 ZP.TOL		F32	1.0e-6		# Tolerance for zero point iterations
 ZP.TRANS.ITER	S32	2		# Iterations for transparency determination
 ZP.TRANS.REJ	F32	3.0		# Rejection threshold for transparency determination
 ZP.TRANS.THRESH	F32	1.0		# Threshold for transparency determination
-ZP.STAR.REJ	F32	3.0		# Rejection threshold for stars
+ZP.STAR.REJ.1	F32	20.0		# Rejection threshold for stars; pass 1
+ZP.STAR.REJ.2	F32	3.0		# Rejection threshold for stars; pass 2
 ZP.STAR.LIMIT	F32	1.0e-2		# Limit on star rejection fraction for successful iteration
-ZP.STAR.SYS	F32	0.05		# Estimated systematic error
+ZP.STAR.SYS.1	F32	0.10		# Estimated systematic error; pass 1
+ZP.STAR.SYS.2	F32	0.05		# Estimated systematic error; pass 2
+ZP.MATCH	F32	0.3		# Fraction of images to match for good star
 ZP.AIRMASS	METADATA		# Airmass terms by filter
 	g	F32	0.0
Index: branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppSub.config
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppSub.config	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppSub.config	(revision 23239)
@@ -5,4 +5,5 @@
 SPATIAL.ORDER   S32	0		# Spatial polynomial order
 REGION.SIZE	F32	0		# Iso-kernel region size (pixels)
+SOURCE.RADIUS	F32	3.0		# Source matching radius (pixels)
 STAMP.SPACING   F32	200		# Typical spacing between stamps (pixels)
 STAMP.FOOTPRINT S32	20		# Size of stamps (pixels)
Index: branches/cnb_branches/cnb_branch_20090215/ppArith/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppArith/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppArith/src/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 bin_PROGRAMS = ppArith
 
-PPARITH_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PPARITH_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PPARITH_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PPARITH_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PPARITH_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PPARITH_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# 
+# # Force recompilation of ppArithVersion.c, since it gets the version information
+# ppArithVersion.c: FORCE
+# 	touch ppArith.c
+# FORCE: ;
 
-# Force recompilation of ppArithVersion.c, since it gets the version information
-ppArithVersion.c: FORCE
-	touch ppArith.c
-FORCE: ;
-
-ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS) -DPPARITH_VERSION=\"$(PPARITH_VERSION)\" -DPPARITH_BRANCH=\"$(PPARITH_BRANCH)\" -DPPARITH_SOURCE=\"$(PPARITH_SOURCE)\"
+ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS) -DPPARITH_VERSION=$(SVN_VERSION) -DPPARITH_BRANCH=$(SVN_BRANCH) -DPPARITH_SOURCE=$(SVN_SOURCE)
 ppArith_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPARITH_LIBS)
 
Index: branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArithVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArithVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArithVersion.c	(revision 23239)
@@ -22,6 +22,4 @@
 #include "ppArith.h"
 
-psString ppArithVersion(void)
-{
 #ifndef PPARITH_VERSION
 #error "PPARITH_VERSION is not set"
@@ -30,13 +28,21 @@
 #error "PPARITH_BRANCH is not set"
 #endif
-    return psStringCopy(PPARITH_BRANCH "@" PPARITH_VERSION);
+#ifndef PPARITH_SOURCE
+#error "PPARITH_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString ppArithVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PPARITH_BRANCH), xstr(PPARITH_VERSION));
+    return value;
 }
 
 psString ppArithSource(void)
 {
-#ifndef PPARITH_SOURCE
-#error "PPARITH_SOURCE is not set"
-#endif
-    return psStringCopy(PPARITH_SOURCE);
+    return psStringCopy(xstr(PPARITH_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/ppImage/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppImage/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppImage/src/Makefile.am	(revision 23239)
@@ -4,14 +4,14 @@
 	ppImage.h 
 
-PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PPIMAGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+#PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+#PPIMAGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+#PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
 
 # Force recompilation of ppImageVersion.c, since it gets the version information
-ppImageVersion.c: FORCE
-	touch ppImageVersion.c
-FORCE: ;
+# ppImageVersion.c: FORCE
+# 	touch ppImageVersion.c
+# FORCE: ;
 
-ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPIMAGE_VERSION=\"$(PPIMAGE_VERSION)\" -DPPIMAGE_BRANCH=\"$(PPIMAGE_BRANCH)\" -DPPIMAGE_SOURCE=\"$(PPIMAGE_SOURCE)\"
+ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPIMAGE_VERSION=$(SVN_VERSION) -DPPIMAGE_BRANCH=$(SVN_BRANCH) -DPPIMAGE_SOURCE=$(SVN_SOURCE)
 ppImage_LDFLAGS = $(PPIMAGE_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 ppImage_SOURCES = \
Index: branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImage.h
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImage.h	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImage.h	(revision 23239)
@@ -86,4 +86,6 @@
     int remnanceSize;                   // Size for remnance detection
     float remnanceThresh;               // Threshold for remnance detection
+
+    char *normClass;			// class to use for per-class normalization 
 } ppImageOptions;
 
Index: branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageArguments.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageArguments.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageArguments.c	(revision 23239)
@@ -14,4 +14,5 @@
     fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n");
     fprintf(stderr, "\t-norm VALUE: Divide through by this value when done.\n");
+    fprintf(stderr, "\t-normlist file.mdc: normalizations by class_id.\n");
     fprintf(stderr, "\n");
     fprintf(stderr, "Input options (single file / file list):\n");
@@ -128,10 +129,23 @@
     }
 
-    // Optional normalisation factor
+    // Optional normalization factor
     if ((argnum = psArgumentGet(argc, argv, "-norm"))) {
         psArgumentRemove(argnum, &argc, argv);
         float norm = atof(argv[argnum]);
-        psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALISATION", 0,
+        psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALIZATION", 0,
                          "Normalisation to apply", norm);
+        psArgumentRemove(argnum, &argc, argv);
+    }
+
+    // Optional per-class normalization table
+    if ((argnum = psArgumentGet(argc, argv, "-normlist"))) {
+        psArgumentRemove(argnum, &argc, argv);
+
+	unsigned int nFail = 0;
+	psMetadata *normlist = psMetadataConfigRead (NULL, &nFail, argv[argnum], false);
+	// XXX allow this file to be in nebulous?
+
+        psMetadataAddMetadata(config->arguments, PS_LIST_TAIL, "NORMALIZATION.TABLE", 0, "Normalization to apply", normlist);
+	psFree (normlist);
         psArgumentRemove(argnum, &argc, argv);
     }
Index: branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageDetrendReadout.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageDetrendReadout.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageDetrendReadout.c	(revision 23239)
@@ -54,4 +54,5 @@
         if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.");
+	    psFree(detview);
             return false;
         }
@@ -67,4 +68,5 @@
         if (!pmDarkApply(input, dark, options->maskValue)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark.");
+	    psFree(detview);
             return false;
         }
@@ -75,4 +77,5 @@
                         options->remnanceSize, options->remnanceThresh)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance.");
+	    psFree(detview);
             return false;
         }
@@ -83,4 +86,5 @@
         pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER");
         if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) {
+	    psFree(detview);
             return false;
         }
@@ -91,11 +95,12 @@
         pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT");
         if (!pmFlatField(input, flat, options->flatMask)) {
+	    psFree(detview);
             return false;
         }
     }
 
-    // Normalisation by a (known) constant
+    // Normalization by a single (known) constant
     bool mdok;                          // Status of MD lookup
-    float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALISATION");
+    float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALIZATION");
     if (mdok && isfinite(norm) && norm != 1.0) {
         pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
@@ -108,7 +113,52 @@
     }
 
+# if (1)
+    // Normalization by per-class values
+    psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE");
+    if (normlist) {
+	pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");
+
+	// get the menu of class IDs
+        psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID"); 
+        if (!menu) {
+            psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration");
+	    psFree(detview);
+            return false;
+        }
+	// get the rule for class_id for the desired class
+        const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass); 
+        if (!rule) {
+            psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass);
+	    psFree(detview);
+            return false;
+        }
+	// get the class_id from the rule
+        char *classID = pmFPAfileNameFromRule(rule, inputFile, view);
+        if (!classID) {
+            psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule);
+	    psFree(detview);
+            return false;
+        }
+
+	// get normalization from the class_id
+	float norm = psMetadataLookupF32 (&mdok, normlist, classID);
+
+        pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
+        psString comment = NULL;        // Comment to add
+        psStringAppend(&comment, "Normalization: %f", norm);
+        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, "");
+        psFree(comment);
+
+	// apply the normalization
+        psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32));
+
+	psFree (classID);
+    }
+# endif
+
     if (options->doFringe) {
         pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE");
         if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) {
+	    psFree(detview);
             return false;
         }
Index: branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageOptions.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageOptions.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageOptions.c	(revision 23239)
@@ -81,4 +81,7 @@
     options->remnanceThresh  = 25.0;    // Threshold for remnance detection
 
+    // per-class normalization source
+    options->normClass       = NULL;    // per-class normalizations refer to this class
+
     return options;
 }
@@ -278,4 +281,7 @@
     options->remnanceThresh = psMetadataLookupS32(NULL, recipe, "REMNANCE.THRESH");
 
+    // per-class normalization source (just a reference; don't free)
+    options->normClass = psMetadataLookupStr(NULL, recipe, "NORM.CLASS");
+
     return options;
 }
Index: branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageVersion.c	(revision 23239)
@@ -5,6 +5,4 @@
 #include "ppImage.h"
 
-psString ppImageVersion(void)
-{
 #ifndef PPIMAGE_VERSION
 #error "PPIMAGE_VERSION is not set"
@@ -13,13 +11,21 @@
 #error "PPIMAGE_BRANCH is not set"
 #endif
-    return psStringCopy(PPIMAGE_BRANCH "@" PPIMAGE_VERSION);
+#ifndef PPIMAGE_SOURCE
+#error "PPIMAGE_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString ppImageVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PPIMAGE_BRANCH), xstr(PPIMAGE_VERSION));
+    return value;
 }
 
 psString ppImageSource(void)
 {
-#ifndef PPIMAGE_SOURCE
-#error "PPIMAGE_SOURCE is not set"
-#endif
-    return psStringCopy(PPIMAGE_SOURCE);
+    return psStringCopy (xstr(PPIMAGE_SOURCE));
 }
 
@@ -27,5 +33,5 @@
 {
     psString version = ppImageVersion();  // Version, to return
-    psString source = ppImageSource();    // Source
+    psString source = ppImageSource(); // Source
 
     psStringPrepend(&version, "ppImage ");
Index: branches/cnb_branches/cnb_branch_20090215/ppMerge/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppMerge/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppMerge/src/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 bin_PROGRAMS = ppMerge
 
-PPMERGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PPMERGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PPMERGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PPMERGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PPMERGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PPMERGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# 
+# # Force recompilation of ppMergeVersion.c, since it gets the version information
+# ppMergeVersion.c: FORCE
+# 	touch ppMergeVersion.c
+# FORCE: ;
 
-# Force recompilation of ppMergeVersion.c, since it gets the version information
-ppMergeVersion.c: FORCE
-	touch ppMergeVersion.c
-FORCE: ;
-
-ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPMERGE_VERSION=\"$(PPMERGE_VERSION)\" -DPPMERGE_BRANCH=\"$(PPMERGE_BRANCH)\" -DPPMERGE_SOURCE=\"$(PPMERGE_SOURCE)\"
+ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPMERGE_VERSION=$(SVN_VERSION) -DPPMERGE_BRANCH=$(SVN_BRANCH) -DPPMERGE_SOURCE=$(SVN_SOURCE)
 ppMerge_LDFLAGS = $(PPMERGE_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
Index: branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeVersion.c	(revision 23239)
@@ -22,6 +22,4 @@
 #include "ppMergeVersion.h"
 
-psString ppMergeVersion(void)
-{
 #ifndef PPMERGE_VERSION
 #error "PPMERGE_VERSION is not set"
@@ -30,13 +28,21 @@
 #error "PPMERGE_BRANCH is not set"
 #endif
-    return psStringCopy(PPMERGE_BRANCH "@" PPMERGE_VERSION);
+#ifndef PPMERGE_SOURCE
+#error "PPMERGE_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString ppMergeVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PPMERGE_BRANCH), xstr(PPMERGE_VERSION));
+    return value;
 }
 
 psString ppMergeSource(void)
 {
-#ifndef PPMERGE_SOURCE
-#error "PPMERGE_SOURCE is not set"
-#endif
-    return psStringCopy(PPMERGE_SOURCE);
+    return psStringCopy(xstr(PPMERGE_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/ppSim/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSim/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSim/src/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 bin_PROGRAMS = ppSim ppSimSequence
 
-PPSIM_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PPSIM_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PPSIM_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PPSIM_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PPSIM_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PPSIM_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# 
+# # Force recompilation of ppSimVersion.c, since it gets the version information
+# ppSimVersion.c: FORCE
+# 	touch ppSimVersion.c
+# FORCE: ;
 
-# Force recompilation of ppSimVersion.c, since it gets the version information
-ppSimVersion.c: FORCE
-	touch ppSimVersion.c
-FORCE: ;
-
-ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -DPPSIM_VERSION=\"$(PPSIM_VERSION)\" -DPPSIM_BRANCH=\"$(PPSIM_BRANCH)\" -DPPSIM_SOURCE=\"$(PPSIM_SOURCE)\"
+ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -DPPSIM_VERSION=$(SVN_VERSION) -DPPSIM_BRANCH=$(SVN_BRANCH) -DPPSIM_SOURCE=$(SVN_SOURCE)
 ppSim_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PSASTRO_LIBS)
 ppSim_SOURCES = \
Index: branches/cnb_branches/cnb_branch_20090215/ppSim/src/ppSimVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSim/src/ppSimVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSim/src/ppSimVersion.c	(revision 23239)
@@ -1,7 +1,4 @@
 #include "ppSim.h"
 
-
-psString ppSimVersion(void)
-{
 #ifndef PPSIM_VERSION
 #error "PPSIM_VERSION is not set"
@@ -10,13 +7,21 @@
 #error "PPSIM_BRANCH is not set"
 #endif
-    return psStringCopy(PPSIM_BRANCH "@" PPSIM_VERSION);
+#ifndef PPSIM_SOURCE
+#error "PPSIM_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString ppSimVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PPSIM_BRANCH), xstr(PPSIM_VERSION));
+    return value;
 }
 
 psString ppSimSource(void)
 {
-#ifndef PPSIM_SOURCE
-#error "PPSIM_SOURCE is not set"
-#endif
-    return psStringCopy(PPSIM_SOURCE);
+    return psStringCopy(xstr(PPSIM_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/ppStack/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppStack/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppStack/src/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 bin_PROGRAMS = ppStack
 
-PPSTACK_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PPSTACK_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PPSTACK_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PPSTACK_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PPSTACK_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PPSTACK_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# 
+# # Force recompilation of ppStackVersion.c, since it gets the version information
+# ppStackVersion.c: FORCE
+# 	touch ppStackVersion.c
+# FORCE: ;
 
-# Force recompilation of ppStackVersion.c, since it gets the version information
-ppStackVersion.c: FORCE
-	touch ppStackVersion.c
-FORCE: ;
-
-ppStack_CFLAGS 	= $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) -DPPSTACK_VERSION=\"$(PPSTACK_VERSION)\" -DPPSTACK_BRANCH=\"$(PPSTACK_BRANCH)\" -DPPSTACK_SOURCE=\"$(PPSTACK_SOURCE)\"
+ppStack_CFLAGS 	= $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) -DPPSTACK_VERSION=$(SVN_VERSION) -DPPSTACK_BRANCH=$(SVN_BRANCH) -DPPSTACK_SOURCE=$(SVN_SOURCE)
 ppStack_LDFLAGS = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PSPHOT_LIBS)   $(PPSTATS_LIBS)   $(PPSTACK_LIBS)
 
Index: branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c	(revision 23239)
@@ -168,12 +168,15 @@
                       "Play safe with small numbers of pixels to combine?", false);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-radius", 0, "Radius (pixels) for matching sources", NAN);
-    psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter", 0, "Maximum iterations for zero point", 0);
+    psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter-1", 0, "Maximum iterations for zero point; pass 1", 0);
+    psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter-2", 0, "Maximum iterations for zero point; pass 2", 0);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-tol", 0, "Tolerance for zero point iterations", NAN);
     psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-trans-iter", 0, "Iterations for transparency determination", 0);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-trans-rej", 0, "Rejection threshold for transparency determination", NAN);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-trans-thresh", 0, "Threshold for transparency determination", NAN);
-    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej", 0, "Rejection threshold for stars", NAN);
+    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej-1", 0, "Rejection threshold for stars; pass 1", NAN);
+    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej-2", 0, "Rejection threshold for stars; pass 2", NAN);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-limit", 0, "Limit on star rejection fraction for successful iteration", NAN);
-    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys", 0, "Estimated systematic error", NAN);
+    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys-1", 0, "Estimated systematic error; pass 1", NAN);
+    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys-2", 0, "Estimated systematic error; pass 2", NAN);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-image", 0, "Suffix for temporary images", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-mask", 0, "Suffix for temporary masks", NULL);
@@ -242,12 +245,15 @@
 
     VALUE_ARG_RECIPE_FLOAT("-zp-radius",       "ZP.RADIUS",       F32);
-    VALUE_ARG_RECIPE_INT("-zp-iter",           "ZP.ITER",         S32, 0);
+    VALUE_ARG_RECIPE_INT("-zp-iter-1",         "ZP.ITER.1",       S32, 0);
+    VALUE_ARG_RECIPE_INT("-zp-iter-2",         "ZP.ITER.2",       S32, 0);
     VALUE_ARG_RECIPE_FLOAT("-zp-tol",          "ZP.TOL",          F32);
     VALUE_ARG_RECIPE_INT("-zp-trans-iter",     "ZP.TRANS.ITER",   S32, 0);
     VALUE_ARG_RECIPE_FLOAT("-zp-trans-rej",    "ZP.TRANS.REJ",    F32);
     VALUE_ARG_RECIPE_FLOAT("-zp-trans-thresh", "ZP.TRANS.THRESH", F32);
-    VALUE_ARG_RECIPE_FLOAT("-zp-star-rej",     "ZP.STAR.REJ",     F32);
+    VALUE_ARG_RECIPE_FLOAT("-zp-star-rej-1",   "ZP.STAR.REJ.1",   F32);
+    VALUE_ARG_RECIPE_FLOAT("-zp-star-rej-2",   "ZP.STAR.REJ.2",   F32);
     VALUE_ARG_RECIPE_FLOAT("-zp-star-limit",   "ZP.STAR.LIMIT",   F32);
-    VALUE_ARG_RECIPE_FLOAT("-zp-star-sys",     "ZP.STAR.SYS",     F32);
+    VALUE_ARG_RECIPE_FLOAT("-zp-star-sys-1",   "ZP.STAR.SYS.1",   F32);
+    VALUE_ARG_RECIPE_FLOAT("-zp-star-sys-2",   "ZP.STAR.SYS.2",   F32);
 
     VALUE_ARG_RECIPE_INT("-psf-instances", "PSF.INSTANCES", S32, 0);
Index: branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackSources.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackSources.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackSources.c	(revision 23239)
@@ -81,12 +81,19 @@
 
     float radius = psMetadataLookupF32(NULL, recipe, "ZP.RADIUS"); // Radius (pixels) for matching sources
-    int iter = psMetadataLookupS32(NULL, recipe, "ZP.ITER"); // Maximum iterations
+    int iter1 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.1"); // Maximum iterations for pass 1
+    int iter2 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.2"); // Maximum iterations for pass 2
     float tol = psMetadataLookupF32(NULL, recipe, "ZP.TOL"); // Tolerance for zero point iterations
     int transIter = psMetadataLookupS32(NULL, recipe, "ZP.TRANS.ITER"); // Iterations for transparency
     float transRej = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.REJ");// Rejection threshold for transparency
     float transThresh = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.THRESH"); // Threshold for transparency
-    float starRej = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ"); // Rejection threshold for stars
+
+    float starRej1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.1"); // Rejection threshold for stars
+    float starSys1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.1"); // Estimated systematic error
+    float starRej2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.2"); // Rejection threshold for stars
+    float starSys2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.2"); // Estimated systematic error
+
     float starLimit = psMetadataLookupF32(NULL, recipe, "ZP.STAR.LIMIT"); // Limit on star rejection fraction
-    float starSys = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS"); // Estimated systematic error
+
+    float fracMatch = psMetadataLookupF32(NULL, recipe, "ZP.MATCH"); // Fraction of images to match for star
 
     psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms
@@ -110,5 +117,6 @@
         pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout
         pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image
-        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], NULL, NULL, psf, 5, 0, false, true);
+        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i],
+                                 NULL, NULL, psf, 5, 0, false, true);
         psString name = NULL;
         psStringAppend(&name, "start_%03d.fits", i);
@@ -153,5 +161,5 @@
     }
 
-    psArray *matches = pmSourceMatchSources(sourceLists, radius); // List of matches
+    psArray *matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches
     if (!matches) {
         psError(PS_ERR_UNKNOWN, false, "Unable to match sources");
@@ -164,6 +172,7 @@
 #endif
 
-    psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,
-                                           transThresh, starRej, starSys); // Transparencies for each image
+    psVector *trans = pmSourceMatchRelphot(matches, zp, tol, iter1, starRej1, starSys1,
+                                           iter2, starRej2, starSys2, starLimit,
+                                           transIter, transRej, transThresh); // Transparencies for each image
     if (!trans) {
         psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
@@ -184,24 +193,26 @@
     // XXX this is a really poor output location; clean up the pmFPAfiles used in ppStack
     pmCell *sourcesCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT");
-    psArray *sourcesBest = psArrayAllocEmpty (100);
-
-    // XXX something of a hack: require at 2 detections or 1/2 of the max possible
-    int minMatches = PS_MAX (2, 0.5*num);
+    psArray *sourcesBest = psArrayAllocEmpty(matches->n);
+
+    // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible
+    int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required
     for (int i = 0; i < matches->n; i++) {
         pmSourceMatch *match = matches->data[i]; // Match of interest
-        if (match->num < minMatches) continue;
+        if (match->num < minMatches) {
+            continue;
+        }
 
         // We need to grab a single instance of this source: just take the first available
-        int nImage = match->image->data.S32[0];
-        int nIndex = match->index->data.S32[0];
-        psArray *sources = sourceLists->data[nImage];
-        pmSource *source = sources->data[nIndex];
-
-        // stick this sample source on sourcesBest
-        psArrayAdd (sourcesBest, 100, source);
-    }
-    psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest);
-    psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis\n", sourcesBest->n);
-    psFree (sourcesBest);
+        int image = match->image->data.S32[0]; // Index of image
+        int index = match->index->data.S32[0]; // Index of source within image
+        psArray *sources = sourceLists->data[image]; // Sources for image
+        pmSource *source = sources->data[index]; // Source of interest
+
+        psArrayAdd(sourcesBest, sourcesBest->n, source);
+    }
+    psMetadataAdd(sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE,
+                  "psphot sources", sourcesBest);
+    psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n);
+    psFree(sourcesBest);
 
     psFree(matches);
Index: branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackVersion.c	(revision 23239)
@@ -11,6 +11,4 @@
 #include "ppStack.h"
 
-psString ppStackVersion(void)
-{
 #ifndef PPSTACK_VERSION
 #error "PPSTACK_VERSION is not set"
@@ -19,13 +17,21 @@
 #error "PPSTACK_BRANCH is not set"
 #endif
-    return psStringCopy(PPSTACK_BRANCH "@" PPSTACK_VERSION);
+#ifndef PPSTACK_SOURCE
+#error "PPSTACK_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString ppStackVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PPSTACK_BRANCH), xstr(PPSTACK_VERSION));
+    return value;
 }
 
 psString ppStackSource(void)
 {
-#ifndef PPSTACK_SOURCE
-#error "PPSTACK_SOURCE is not set"
-#endif
-    return psStringCopy(PPSTACK_SOURCE);
+    return psStringCopy(xstr(PPSTACK_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/ppStats/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppStats/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppStats/src/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 lib_LTLIBRARIES = libppStats.la
 
-PPSTATS_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PPSTATS_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PPSTATS_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PPSTATS_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PPSTATS_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PPSTATS_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# 
+# # Force recompilation of ppStatsVersion.c, since it gets the version information
+# ppStatsVersion.c: FORCE
+# 	touch ppStatsVersion.c
+# FORCE: ;
 
-# Force recompilation of ppStatsVersion.c, since it gets the version information
-ppStatsVersion.c: FORCE
-	touch ppStatsVersion.c
-FORCE: ;
-
-libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPSTATS_VERSION=\"$(PPSTATS_VERSION)\" -DPPSTATS_BRANCH=\"$(PPSTATS_BRANCH)\" -DPPSTATS_SOURCE=\"$(PPSTATS_SOURCE)\"
+libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPSTATS_VERSION=$(SVN_VERSION) -DPPSTATS_BRANCH=$(SVN_BRANCH) -DPPSTATS_SOURCE=$(SVN_SOURCE)
 libppStats_la_LDFLAGS = $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
Index: branches/cnb_branches/cnb_branch_20090215/ppStats/src/ppStatsVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppStats/src/ppStatsVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppStats/src/ppStatsVersion.c	(revision 23239)
@@ -1,6 +1,4 @@
 #include "ppStatsInternal.h"
 
-psString ppStatsVersion(void)
-{
 #ifndef PPSTATS_VERSION
 #error "PPSTATS_VERSION is not set"
@@ -9,13 +7,21 @@
 #error "PPSTATS_BRANCH is not set"
 #endif
-    return psStringCopy(PPSTATS_BRANCH "@" PPSTATS_VERSION);
+#ifndef PPSTATS_SOURCE
+#error "PPSTATS_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString ppStatsVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PPSTATS_BRANCH), xstr(PPSTATS_VERSION));
+    return value;
 }
 
 psString ppStatsSource(void)
 {
-#ifndef PPSTATS_SOURCE
-#error "PPSTATS_SOURCE is not set"
-#endif
-    return psStringCopy(PPSTATS_SOURCE);
+    return psStringCopy(xstr(PPSTATS_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/ppSub/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSub/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSub/src/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 bin_PROGRAMS = ppSub ppSubKernel
 
-PPSUB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PPSUB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PPSUB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PPSUB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PPSUB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PPSUB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# 
+# # Force recompilation of ppSubVersion.c, since it gets the version information
+# ppSubVersion.c: FORCE
+# 	touch ppSubVersion.c
+# FORCE: ;
 
-# Force recompilation of ppSubVersion.c, since it gets the version information
-ppSubVersion.c: FORCE
-	touch ppSubVersion.c
-FORCE: ;
-
-ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) -DPPSUB_VERSION=\"$(PPSUB_VERSION)\" -DPPSUB_BRANCH=\"$(PPSUB_BRANCH)\" -DPPSUB_SOURCE=\"$(PPSUB_SOURCE)\"
+ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) -DPPSUB_VERSION=$(SVN_VERSION) -DPPSUB_BRANCH=$(SVN_BRANCH) -DPPSUB_SOURCE=$(SVN_SOURCE)
 ppSub_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPSUB_LIBS)
 
Index: branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubArguments.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubArguments.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubArguments.c	(revision 23239)
@@ -30,5 +30,5 @@
     fprintf(stderr, "\nPan-STARRS PSF-matched image subtraction\n\n");
     fprintf(stderr, "Usage: %s INPUT.fits REFERENCE.fits OUTPUT_ROOT \n"
-            "\t[-psf REFERENCE.psf.fits] [-sources REFERENCE.cmf]\n\n"
+            "\t[-psf REFERENCE.psf.fits]\n\n"
             "This subtracts the convolved REFERENCE from the INPUT, by default.\n",
             program);
@@ -201,11 +201,11 @@
 
 
-    pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL);
-
     psMetadata *arguments = config->arguments; // Command-line arguments
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-inmask", 0, "Input mask image", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-invariance", 0, "Input variance image", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-insources", 0, "Input source list", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-refmask", 0, "Reference mask image", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-refvariance", 0, "Reference variance image", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-refsources", 0, "Reference source list", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-region", 0, "Size of iso-kernel region", NAN);
@@ -224,4 +224,5 @@
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-spacing", 0, "Typical stamp spacing (pixels)", NAN);
     psMetadataAddS32(arguments, PS_LIST_TAIL, "-footprint", 0, "Stamp footprint half-size (pixels)", -1);
+    psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-radius", 0, "Source matching radius (pixels)", NAN);
     psMetadataAddS32(arguments, PS_LIST_TAIL, "-stride", 0, "Size of convolution patches (pixels)", -1);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-threshold", 0, "Minimum threshold for stamps (ADU)", NAN);
@@ -268,4 +269,8 @@
         fileList("INPUT.VARIANCE", inVariance, "Name of the input variance image", config);
     }
+    const char *inSources = psMetadataLookupStr(NULL, arguments, "-insources"); // Name of input source list
+    if (inSources && strlen(inSources) > 0) {
+        fileList("INPUT.SOURCES", inSources, "Name of the input source list", config);
+    }
 
     const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask
@@ -276,4 +281,8 @@
     if (refVariance && strlen(refVariance) > 0) {
         fileList("REF.VARIANCE", refVariance, "Name of the reference variance image", config);
+    }
+    const char *refSources = psMetadataLookupStr(NULL, arguments, "-refsources"); // Name of ref source list
+    if (refSources && strlen(refSources) > 0) {
+        fileList("REF.SOURCES", refSources, "Name of the reference source list", config);
     }
 
@@ -300,22 +309,23 @@
     }
 
-    VALUE_ARG_RECIPE_FLOAT("-region",     "REGION.SIZE",     F32);
-    VALUE_ARG_RECIPE_INT("-size",         "KERNEL.SIZE",     S32, 0);
-    VALUE_ARG_RECIPE_INT("-order",        "SPATIAL.ORDER",   S32, -1);
-    VALUE_ARG_RECIPE_FLOAT("-spacing",    "STAMP.SPACING",   F32);
-    VALUE_ARG_RECIPE_INT("-rings-order",  "RINGS.ORDER",     S32, -1);
-    VALUE_ARG_RECIPE_INT("-inner",        "INNER",           S32, -1);
-    VALUE_ARG_RECIPE_INT("-spam-binning", "SPAM.BINNING",    S32, 0);
-    VALUE_ARG_RECIPE_INT("-footprint",    "STAMP.FOOTPRINT", S32, -1);
-    VALUE_ARG_RECIPE_INT("-stride",       "STRIDE",          S32, -1);
-    VALUE_ARG_RECIPE_FLOAT("-threshold",  "STAMP.THRESHOLD", F32);
-    VALUE_ARG_RECIPE_INT("-iter",         "ITER",            S32, -1);
-    VALUE_ARG_RECIPE_FLOAT("-rej",        "REJ",             F32);
-    VALUE_ARG_RECIPE_FLOAT("-sys",        "SYS",             F32);
-    VALUE_ARG_RECIPE_FLOAT("-badfrac",    "BADFRAC",         F32);
-    VALUE_ARG_RECIPE_FLOAT("-penalty",    "PENALTY",         F32);
-    VALUE_ARG_RECIPE_FLOAT("-poor-frac",  "POOR.FRACTION",   F32);
-    VALUE_ARG_RECIPE_INT("-bin1",         "BIN1",            S32, 0);
-    VALUE_ARG_RECIPE_INT("-bin2",         "BIN2",            S32, 0);
+    VALUE_ARG_RECIPE_FLOAT("-region",        "REGION.SIZE",     F32);
+    VALUE_ARG_RECIPE_INT("-size",            "KERNEL.SIZE",     S32, 0);
+    VALUE_ARG_RECIPE_INT("-order",           "SPATIAL.ORDER",   S32, -1);
+    VALUE_ARG_RECIPE_FLOAT("-spacing",       "STAMP.SPACING",   F32);
+    VALUE_ARG_RECIPE_INT("-rings-order",     "RINGS.ORDER",     S32, -1);
+    VALUE_ARG_RECIPE_INT("-inner",           "INNER",           S32, -1);
+    VALUE_ARG_RECIPE_INT("-spam-binning",    "SPAM.BINNING",    S32, 0);
+    VALUE_ARG_RECIPE_INT("-footprint",       "STAMP.FOOTPRINT", S32, -1);
+    VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS",   F32);
+    VALUE_ARG_RECIPE_INT("-stride",          "STRIDE",          S32, -1);
+    VALUE_ARG_RECIPE_FLOAT("-threshold",     "STAMP.THRESHOLD", F32);
+    VALUE_ARG_RECIPE_INT("-iter",            "ITER",            S32, -1);
+    VALUE_ARG_RECIPE_FLOAT("-rej",           "REJ",             F32);
+    VALUE_ARG_RECIPE_FLOAT("-sys",           "SYS",             F32);
+    VALUE_ARG_RECIPE_FLOAT("-badfrac",       "BADFRAC",         F32);
+    VALUE_ARG_RECIPE_FLOAT("-penalty",       "PENALTY",         F32);
+    VALUE_ARG_RECIPE_FLOAT("-poor-frac",     "POOR.FRACTION",   F32);
+    VALUE_ARG_RECIPE_INT("-bin1",            "BIN1",            S32, 0);
+    VALUE_ARG_RECIPE_INT("-bin2",            "BIN2",            S32, 0);
 
     valueArgRecipeStr(arguments, recipe, "-mask-in",   "MASK.IN",  recipe);
Index: branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubCamera.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubCamera.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubCamera.c	(revision 23239)
@@ -40,5 +40,5 @@
     pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.MASK", "INPUT.MASK");
     if (!status) {
-        psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK");
+        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK");
         return NULL;
     }
@@ -51,9 +51,20 @@
     pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE");
     if (!status) {
-        psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE");
+        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE");
         return NULL;
     }
     if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) {
         psError(PS_ERR_IO, true, "PPSUB.INPUT.VARIANCE is not of type VARIANCE");
+        return false;
+    }
+
+    // Input source list
+    pmFPAfile *inputSources = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.SOURCES");
+        return NULL;
+    }
+    if (inputSources && inputSources->type != PM_FPA_FILE_CMF) {
+        psError(PS_ERR_IO, true, "PPSUB.INPUT.SOURCES is not of type CMF");
         return false;
     }
@@ -74,5 +85,5 @@
     pmFPAfile *refMask = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.MASK", "REF.MASK");
     if (!status) {
-        psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK");
+        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK");
         return NULL;
     }
@@ -85,9 +96,20 @@
     pmFPAfile *refVariance = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.VARIANCE", "REF.VARIANCE");
     if (!status) {
-        psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE");
+        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE");
         return NULL;
     }
     if (refVariance && refVariance->type != PM_FPA_FILE_VARIANCE) {
         psError(PS_ERR_IO, true, "PPSUB.REF.VARIANCE is not of type VARIANCE");
+        return false;
+    }
+
+    // Reference source list
+    pmFPAfile *refSources = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.SOURCES", "REF.SOURCES");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.SOURCES");
+        return NULL;
+    }
+    if (refSources && refSources->type != PM_FPA_FILE_CMF) {
+        psError(PS_ERR_IO, true, "PPSUB.REF.SOURCES is not of type CMF");
         return false;
     }
@@ -241,20 +263,4 @@
     outKernels->save = true;
 
-#if 0
-    if (!pmFPAAddSourceFromFormat(output->fpa, "Subtraction", output->format)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
-        return false;
-    }
-#endif
-
-    pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSUB.SOURCES", "PPSUB.SOURCES");
-    if (!status) {
-        psError(PS_ERR_IO, false, "Failed to load file definition PPSUB.SOURCES");
-        return false;
-    }
-    if (sources && sources->type != PM_FPA_FILE_CMF) {
-        psError(PS_ERR_IO, true, "PPSUB.SOURCES is not of type CMF");
-        return false;
-    }
 
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
Index: branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMakePSF.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMakePSF.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMakePSF.c	(revision 23239)
@@ -81,6 +81,5 @@
     // Extract the loaded sources from the associated readout, and generate PSF
     // Here, we assume the image is background-subtracted
-    pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES");
-    psArray *sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
+    psArray *sources = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.SOURCES");
     if (!psphotReadoutFindPSF(config, view, sources)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image.");
Index: branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMatchPSFs.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMatchPSFs.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMatchPSFs.c	(revision 23239)
@@ -50,9 +50,30 @@
 
     // Sources in image, used for stamps: these must be loaded from previous analysis stages
-    pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources
-    psArray *sources = NULL;            // Sources in image; used for stamps
-    if (sourcesRO) {
-        sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
+    psArray *inSources = psMetadataLookupPtr(&mdok, inRO->analysis, "PSPHOT.SOURCES"); // Input source list
+    psArray *refSources = psMetadataLookupPtr(&mdok, refRO->analysis, "PSPHOT.SOURCES"); // Ref source list
+
+    psArray *sources = NULL;            // Merged list of sources
+    if (inSources && refSources) {
+        float radius = psMetadataLookupF32(NULL, recipe, "SOURCE.RADIUS"); // Matching radius
+        psArray *lists = psArrayAlloc(2); // Source lists
+        lists->data[0] = psMemIncrRefCounter(inSources);
+        lists->data[1] = psMemIncrRefCounter(refSources);
+        sources = pmSourceMatchMerge(lists, radius);
+        psFree(lists);
+        if (!sources) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to merge source lists");
+            return false;
+        }
+    } else if (inSources) {
+        sources = psMemIncrRefCounter(inSources);
+    } else if (refSources) {
+        sources = psMemIncrRefCounter(refSources);
     }
+
+    psMetadataAddArray(inConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
+                       "Merged source list", sources);
+    psMetadataAddArray(refConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
+                       "Merged source list", sources);
+    psFree(sources);                    // Drop reference
 
     int footprint = psMetadataLookupS32(NULL, recipe, "STAMP.FOOTPRINT"); // Stamp half-size
@@ -129,9 +150,10 @@
 
     // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf)
-
+#ifdef TESTING
     psphotSaveImage (NULL, inRO->image, "inRO.fits");
     psphotSaveImage (NULL, refRO->image, "refRO.fits");
     psphotSaveImage (NULL, inConv->image, "inConv.fits");
     psphotSaveImage (NULL, refConv->image, "refConv.fits");
+#endif
 
     return true;
Index: branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubVersion.c	(revision 23239)
@@ -23,6 +23,4 @@
 #include "ppSub.h"
 
-psString ppSubVersion(void)
-{
 #ifndef PPSUB_VERSION
 #error "PPSUB_VERSION is not set"
@@ -31,13 +29,21 @@
 #error "PPSUB_BRANCH is not set"
 #endif
-    return psStringCopy(PPSUB_BRANCH "@" PPSUB_VERSION);
+#ifndef PPSUB_SOURCE
+#error "PPSUB_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString ppSubVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PPSUB_BRANCH), xstr(PPSUB_VERSION));
+    return value;
 }
 
 psString ppSubSource(void)
 {
-#ifndef PPSUB_SOURCE
-#error "PPSUB_SOURCE is not set"
-#endif
-    return psStringCopy(PPSUB_SOURCE);
+    return psStringCopy(xstr(PPSUB_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/psLib/src/imageops/psImageInterpolate.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psLib/src/imageops/psImageInterpolate.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psLib/src/imageops/psImageInterpolate.c	(revision 23239)
@@ -133,7 +133,7 @@
     }
 
-    float norm1 = 2.0 / PS_SQR(M_PI); // Normalisation for laczos
-    float norm2 = M_PI * 4.0 / (float)size; // Normalisation for sinc function 1
-    float norm3 = M_PI_2 * 4.0 / (float)size; // Normalisation for sinc function 2
+    float norm1 = size / 2.0 / PS_SQR(M_PI); // Normalisation for laczos
+    float norm2 = M_PI;                 // Normalisation for sinc function 1
+    float norm3 = M_PI * 2.0 / (float)size; // Normalisation for sinc function 2
     float pos = - (size - 1)/2 - frac;  // Position of interest
     for (int i = 0; i < size; i++, pos += 1.0) {
Index: branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/Makefile.am	(revision 23239)
@@ -3,7 +3,7 @@
 noinst_LTLIBRARIES = libpslibsys.la
 
-PSLIB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PSLIB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PSLIB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PSLIB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PSLIB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PSLIB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
 
 # Force recompilation of psConfigure.c, since it gets the version information
@@ -12,5 +12,5 @@
 FORCE: ;
 
-libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) -DPSLIB_VERSION=\"$(PSLIB_VERSION)\" -DPSLIB_BRANCH=\"$(PSLIB_BRANCH)\" -DPSLIB_SOURCE=\"$(PSLIB_SOURCE)\"
+libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) -DPSLIB_VERSION=$(SVN_VERSION) -DPSLIB_BRANCH=$(SVN_BRANCH) -DPSLIB_SOURCE=$(SVN_SOURCE)
 libpslibsys_la_SOURCES = \
 	psAbort.c \
Index: branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psConfigure.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psConfigure.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psConfigure.c	(revision 23239)
@@ -47,7 +47,4 @@
 static FILE *memCheckFile = NULL;       // File to which to write results of mem check
 
-
-psString psLibVersion(void)
-{
 #ifndef PSLIB_VERSION
 #error "PSLIB_VERSION is not set"
@@ -56,13 +53,21 @@
 #error "PSLIB_BRANCH is not set"
 #endif
-    return psStringCopy(PSLIB_BRANCH "@" PSLIB_VERSION);
+#ifndef PSLIB_SOURCE
+#error "PSLIB_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString psLibVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PSLIB_BRANCH), xstr(PSLIB_VERSION));
+    return value;
 }
 
 psString psLibSource(void)
 {
-#ifndef PSLIB_SOURCE
-#error "PSLIB_SOURCE is not set"
-#endif
-    return psStringCopy(PSLIB_SOURCE);
+    return psStringCopy(xstr(PSLIB_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psLogMsg.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psLogMsg.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psLogMsg.c	(revision 23239)
@@ -195,5 +195,5 @@
     }
 
-    int fileD = creat(dest, 0666);
+    int fileD = open(dest, O_WRONLY | O_CREAT, 0666);
     if (fileD == 0) {
         psError(PS_ERR_IO, true, _("Could not open file '%s' for output."), dest);
@@ -316,5 +316,5 @@
 
     if (write(logFD, head, strlen(head))) {;} // ignore return value
-    
+
     if (logMsg) {
         psString msg = NULL;            // Message to print
Index: branches/cnb_branches/cnb_branch_20090215/psModules/src/config/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psModules/src/config/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psModules/src/config/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 noinst_LTLIBRARIES = libpsmodulesconfig.la
 
-PSMODULES_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PSMODULES_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PSMODULES_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PSMODULES_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PSMODULES_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PSMODULES_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
 
 # Force recompilation of pmVersion.c, since it gets the version information
-pmVersion.c: FORCE
-	touch pmVersion.c
-FORCE: ;
+# pmVersion.c: FORCE
+# 	touch pmVersion.c
+# FORCE: ;
 
-libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) -DPSMODULES_VERSION=\"$(PSMODULES_VERSION)\" -DPSMODULES_BRANCH=\"$(PSMODULES_BRANCH)\" -DPSMODULES_SOURCE=\"$(PSMODULES_SOURCE)\"
+libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) -DPSMODULES_VERSION=$(SVN_VERSION) -DPSMODULES_BRANCH=$(SVN_BRANCH) -DPSMODULES_SOURCE=$(SVN_SOURCE)
 libpsmodulesconfig_la_LDFLAGS  = -release $(PACKAGE_VERSION)
 libpsmodulesconfig_la_SOURCES  = \
Index: branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmConfig.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmConfig.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmConfig.c	(revision 23239)
@@ -1110,6 +1110,6 @@
 // camera.  If we are discovering the camera (config->camera == NULL), then we also load the
 // recipe files for the camera.
-psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName, 
-					   pmConfig *config, const psMetadata *header, bool readRecipes)
+psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName,
+                                           pmConfig *config, const psMetadata *header, bool readRecipes)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -1672,5 +1672,5 @@
                 // if the object does not exist and create isn't set, then we
                 // should puke
-                psError(PM_ERR_SYS, true, "Unable to access file %s", filename);
+                psError(PM_ERR_SYS, true, "Unable to access file %s: %s", filename, nebErr(server));
                 nebServerFree(server);
                 return NULL;
@@ -1685,5 +1685,6 @@
         if (trunc) {
             if(truncate(path, 0) != 0) {
-                psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n", filename, path);
+                psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n",
+                        filename, path);
                 return NULL;
             }
Index: branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmVersion.c	(revision 23239)
@@ -8,6 +8,4 @@
 #include "pmVersion.h"
 
-psString psModulesVersion(void)
-{
 #ifndef PSMODULES_VERSION
 #error "PSMODULES_VERSION is not set"
@@ -16,13 +14,21 @@
 #error "PSMODULES_BRANCH is not set"
 #endif
-    return psStringCopy(PSMODULES_BRANCH "@" PSMODULES_VERSION);
+#ifndef PSMODULES_SOURCE
+#error "PSMODULES_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString psModulesVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PSMODULES_BRANCH), xstr(PSMODULES_VERSION));
+    return value;
 }
 
 psString psModulesSource(void)
 {
-#ifndef PSMODULES_SOURCE
-#error "PSMODULES_SOURCE is not set"
-#endif
-    return psStringCopy(PSMODULES_SOURCE);
+    return psStringCopy(xstr(PSMODULES_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.c	(revision 23239)
@@ -152,5 +152,5 @@
 
 
-psArray *pmSourceMatchSources(const psArray *sourceArrays, float radius)
+psArray *pmSourceMatchSources(const psArray *sourceArrays, float radius, bool cullSingles)
 {
     PS_ASSERT_ARRAY_NON_NULL(sourceArrays, NULL);
@@ -220,38 +220,38 @@
 
         // Match with the master list
-
-        psTree *tree = psTreePlant(2, SOURCES_MAX_LEAF, xMaster, yMaster); // kd Tree with sources
-        long numMatch = 0;              // Number of matches
-
-        long size = numMaster + numSources; // New size
-        xMaster = psVectorRealloc(xMaster, size);
-        yMaster = psVectorRealloc(yMaster, size);
-        matches = psArrayRealloc(matches, size);
-
-        psVector *coords = psVectorAlloc(2, PS_TYPE_F32); // Coordinates for tree lookup
-        for (int j = 0; j < numSources; j++) {
-            coords->data.F32[0] = xImage->data.F32[j];
-            coords->data.F32[1] = yImage->data.F32[j];
-            long index = psTreeNearestWithin(tree, coords, radius); // Match index
-            if (index >= 0) {
-                // Record the match
-                pmSourceMatch *match = matches->data[index]; // Match data
-                pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
-                numMatch++;
-            } else {
-                // Add to the master list
-                pmSourceMatch *match = pmSourceMatchAlloc(numImages); // Match data
-                pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
-                xMaster->data.F32[numMaster] = xImage->data.F32[j];
-                yMaster->data.F32[numMaster] = yImage->data.F32[j];
-                matches->data[numMaster] = match;
-                numMaster++;
-                xMaster->n = yMaster->n = matches->n = numMaster;
-            }
-
-        }
-        psFree(coords);
-        psFree(tree);
-
+        {
+            psTree *tree = psTreePlant(2, SOURCES_MAX_LEAF, xMaster, yMaster); // kd Tree with sources
+            long numMatch = 0;              // Number of matches
+
+            long size = numMaster + numSources; // New size
+            xMaster = psVectorRealloc(xMaster, size);
+            yMaster = psVectorRealloc(yMaster, size);
+            matches = psArrayRealloc(matches, size);
+
+            psVector *coords = psVectorAlloc(2, PS_TYPE_F32); // Coordinates for tree lookup
+            for (int j = 0; j < numSources; j++) {
+                coords->data.F32[0] = xImage->data.F32[j];
+                coords->data.F32[1] = yImage->data.F32[j];
+                long index = psTreeNearestWithin(tree, coords, radius); // Match index
+                if (index >= 0) {
+                    // Record the match
+                    pmSourceMatch *match = matches->data[index]; // Match data
+                    pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
+                    numMatch++;
+                } else {
+                    // Add to the master list
+                    pmSourceMatch *match = pmSourceMatchAlloc(numImages); // Match data
+                    pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
+                    xMaster->data.F32[numMaster] = xImage->data.F32[j];
+                    yMaster->data.F32[numMaster] = yImage->data.F32[j];
+                    matches->data[numMaster] = match;
+                    numMaster++;
+                    xMaster->n = yMaster->n = matches->n = numMaster;
+                }
+
+            }
+            psFree(coords);
+            psFree(tree);
+        }
 
     match_image_done:
@@ -263,26 +263,71 @@
     }
 
-    // Now cull the matches that contain only a single star
-    int numGood = 0;                    // Number of good matches
+    if (cullSingles) {
+        // Now cull the matches that contain only a single star
+        int numGood = 0;                    // Number of good matches
+        for (int i = 0; i < matches->n; i++) {
+            pmSourceMatch *match = matches->data[i]; // Match of interest
+            if (match->num > 1) {
+                if (i != numGood) {
+                    psFree(matches->data[numGood]);
+                    matches->data[numGood] = psMemIncrRefCounter(match);
+                }
+                numGood++;
+            }
+        }
+        matches->n = numGood;
+        for (int i = numGood; i < numMaster; i++) {
+            psFree(matches->data[i]);
+            matches->data[i] = NULL;
+        }
+    }
+
+    return matches;
+}
+
+
+psArray *pmSourceMatchMerge(psArray *sourceArrays, float radius)
+{
+    PS_ASSERT_ARRAY_NON_NULL(sourceArrays, NULL);
+    PS_ASSERT_FLOAT_LARGER_THAN(radius, 0.0, NULL);
+
+    psArray *matches = pmSourceMatchSources(sourceArrays, radius, false); // Source matches
+    if (!matches) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to match source lists.");
+        return NULL;
+    }
+
+    int index = 0;                      // Index to current position on list
     for (int i = 0; i < matches->n; i++) {
+        pmSource *source = NULL;        // Source to put in merged list
         pmSourceMatch *match = matches->data[i]; // Match of interest
-        if (match->num > 1) {
-            if (i != numGood) {
-                psFree(matches->data[numGood]);
-                matches->data[numGood] = psMemIncrRefCounter(match);
-                //                psFree(match);
-            }
-            numGood++;
-        }
-    }
-    matches->n = numGood;
-    for (int i = numGood; i < numMaster; i++) {
-        psFree(matches->data[i]);
-        matches->data[i] = NULL;
-    }
+        for (int j = 0; j < match->num && !source; j++) {
+            if (!isfinite(match->mag->data.F32[j]) || !isfinite(match->magErr->data.F32[j])) {
+                continue;
+            }
+            int image = match->image->data.S32[j]; // Index of image
+            int index = match->index->data.S32[j]; // Index of source for image
+            psArray *list = sourceArrays->data[image]; // List of interest
+            source = list->data[index];
+            break;
+        }
+
+        if (source) {
+            psFree(matches->data[index]);
+            matches->data[index] = psMemIncrRefCounter(source);
+            index++;
+        }
+    }
+
+    // Clear out the rest of the list
+    int num = index;                    // Number of good sources
+    for (; index < matches->n; index++) {
+        psFree(matches->data[index]);
+        matches->data[index] = NULL;
+    }
+    matches->n = num;
 
     return matches;
 }
-
 
 // Iterate on the star magnitudes and image transparencies
@@ -524,12 +569,15 @@
 psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches
                                const psVector *zp, // Zero points for each image (including airmass term)
-                               int maxIter, // Maximum number of iterations
                                float tol, // Relative tolerance for convergence
+                               int iter1, // Number of iterations for pass 1
+                               float rej1, // Limit on rejection between iterations for pass 1
+                               float sys1, // Systematic error in measurements for pass 1
+                               int iter2, // Number of iterations for pass 2
+                               float rej2, // Limit on rejection between iterations for pass 2
+                               float sys2, // Systematic error in measurements for pass 2
                                float rejLimit, // Limit on rejection between iterations
                                int transIter, // Clipping iterations for transparency
                                float transClip, // Clipping level for transparency
-                               float photoLevel, // Level at which we declare image is photometric
-                               float starClip, // Clipping for stars
-                               float sysErr // Systematic error in measurements
+                               float photoLevel // Level at which we declare image is photometric
                                )
 {
@@ -539,5 +587,6 @@
     PS_ASSERT_FLOAT_LARGER_THAN(transClip, 0.0, NULL);
 
-    sysErr *= sysErr;
+    sys1 *= sys1;
+    sys2 *= sys2;
 
     int numImages = zp->n;              // Number of images
@@ -552,11 +601,12 @@
 
     float chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp,
-                                           photo, sysErr); // chi^2 for solution
+                                           photo, sys1); // chi^2 for solution
     psTrace("psModules.objects", 1, "Initial: chi^2 = %f\n", chi2);
     float lastChi2 = INFINITY;          // chi^2 on last iteration
     float fracRej = INFINITY;        // Fraction of measurements rejected
 
-    // in the first passes, the transparencies are not well deteremined: use high systematic error and the rejection thresholds
-    for (int i = 0; i < 5; i++) {
+    // In the first passes, the transparencies are not well deteremined: use high systematic error and
+    // rejection thresholds
+    for (int i = 0; i < iter1; i++) {
 
         // Identify photometric nights
@@ -572,14 +622,12 @@
         psTrace("psModules.objects", 3, "Pass 1: Determined %d/%d are photometric", numPhoto, numImages);
 
-        // XXX use 20 sigma rejection and 0.1 mag systematic error (move these to the recipe)
-        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, 20.0, PS_SQR(0.1));
+        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej1, sys1);
         psTrace("psModules.objects", 3, "Pass 1: %f%% of measurements rejected", fracRej * 100);
 
-        // XXX use 0.05 mag systematic error (move these to the recipe)
-        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, PS_SQR(0.1));
+        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys1);
         psTrace("psModules.objects", 1, "Pass 1: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
     }
 
-    for (int i = 0; i < maxIter && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) {
+    for (int i = 0; i < iter2 && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) {
         lastChi2 = chi2;
 
@@ -594,11 +642,11 @@
             return NULL;
         }
-        psTrace("psModules.objects", 3, "Determined %d/%d are photometric", numPhoto, numImages);
-
-        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, starClip, sysErr);
-        psTrace("psModules.objects", 3, "%f%% of measurements rejected", fracRej * 100);
-
-        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sysErr);
-        psTrace("psModules.objects", 1, "iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
+        psTrace("psModules.objects", 3, "Pass 2: Determined %d/%d are photometric", numPhoto, numImages);
+
+        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej2, sys2);
+        psTrace("psModules.objects", 3, "Pass 2: %f%% of measurements rejected", fracRej * 100);
+
+        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys2);
+        psTrace("psModules.objects", 1, "Pass 2: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
     }
 
Index: branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.h
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.h	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.h	(revision 23239)
@@ -48,19 +48,30 @@
 ///
 /// Returns an array of psSourceMatch
-psArray *pmSourceMatchSources(const psArray *sourceArrays, // Array of arrays of sources on each image
-                              float radius // Correlation radius
+psArray *pmSourceMatchSources(const psArray *sourceArrays, ///< Array of arrays of sources on each image
+                              float radius, ///< Matching radius
+                              bool cullSingles ///< Cull "matches" with only a single source?
                               );
+
+/// Merge two source lists
+///
+/// Sources are pulled from the lists into a new list, with no effort made to adjust them.
+psArray *pmSourceMatchMerge(psArray *sourceArrays, ///< Array of arrays of sources on each image
+                            float radius ///< Matching radius
+    );
 
 /// Perform relative photometry to calibrate images
 psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches
                                const psVector *zp, // Zero points for each image (including airmass term)
-                               int maxIter, // Maximum number of iterations
                                float tol, // Relative tolerance for convergence
+                               int iter1, // Number of iterations for pass 1
+                               float rej1, // Limit on rejection between iterations for pass 1
+                               float sys1, // Systematic error in measurements for pass 1
+                               int iter2, // Number of iterations for pass 2
+                               float rej2, // Limit on rejection between iterations for pass 2
+                               float sys2, // Systematic error in measurements for pass 2
                                float rejLimit, // Limit on rejection between iterations
                                int transIter, // Clipping iterations for transparency
                                float transClip, // Clipping level for transparency
-                               float photoLevel, // Level at which we declare image is photometric
-                               float starClip, // Clipping for stars
-                               float sysErr // Systematic error in measurements
+                               float photoLevel // Level at which we declare image is photometric
     );
 
Index: branches/cnb_branches/cnb_branch_20090215/psastro/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psastro/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psastro/src/Makefile.am	(revision 23239)
@@ -1,15 +1,12 @@
 lib_LTLIBRARIES = libpsastro.la
 
-PSASTRO_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PSASTRO_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PSASTRO_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=$(SVN_VERSION) -DPSASTRO_BRANCH=$(SVN_BRANCH) -DPSASTRO_SOURCE=$(SVN_SOURCE)
+libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
 # Force recompilation of psastroVersion.c, since it gets the version information
-psastroVersion.c: FORCE
-	touch psastroVersion.c
-FORCE: ;
-
-libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=\"$(PSASTRO_VERSION)\" -DPSASTRO_BRANCH=\"$(PSASTRO_BRANCH)\" -DPSASTRO_SOURCE=\"$(PSASTRO_SOURCE)\"
-libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
+# can we do this with dependency info?
+# psastroVersion.c: FORCE
+# touch psastroVersion.c
+# FORCE: ;
 
 bin_PROGRAMS = psastro psastroModel psastroModelFit gpcModel
Index: branches/cnb_branches/cnb_branch_20090215/psastro/src/psastroVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psastro/src/psastroVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psastro/src/psastroVersion.c	(revision 23239)
@@ -10,6 +10,4 @@
 #include "psastroInternal.h"
 
-psString psastroVersion(void)
-{
 #ifndef PSASTRO_VERSION
 #error "PSASTRO_VERSION is not set"
@@ -18,13 +16,21 @@
 #error "PSASTRO_BRANCH is not set"
 #endif
-    return psStringCopy(PSASTRO_BRANCH "@" PSASTRO_VERSION);
+#ifndef PSASTRO_SOURCE
+#error "PSASTRO_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString psastroVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PSASTRO_BRANCH), xstr(PSASTRO_VERSION));
+    return value;
 }
 
 psString psastroSource(void)
 {
-#ifndef PSASTRO_SOURCE
-#error "PSASTRO_SOURCE is not set"
-#endif
-    return psStringCopy(PSASTRO_SOURCE);
+  return psStringCopy(xstr(PSASTRO_SOURCE));
 }
 
Index: branches/cnb_branches/cnb_branch_20090215/psconfig/psbuild
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psconfig/psbuild	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psconfig/psbuild	(revision 23239)
@@ -13,4 +13,5 @@
 $stop = "";
 $verbose = 0;
+$use_svn = 1;
 
 $extlibs = "none";
@@ -83,4 +84,8 @@
     if ($ARGV[0] eq "-bootstrap") {
         &bootstrap ();
+    }
+    if ($ARGV[0] eq "-skip-svn") {
+	$use_svn = 0;
+	shift; next;
     }
     if ($ARGV[0] eq "-env") {
@@ -157,6 +162,61 @@
 sub build_distribution {
 
+    # set environment variables used to supply SVN info to the compilation
+
+    if ($use_svn) {
+	# example dump from svn info:
+	# pikake: svn info
+	# Path: .
+	# URL: https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/branches/eam_branches/eam_branch_20090303/ppImage
+	# Repository Root: https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp
+	# Repository UUID: 60eb6cdc-a59c-4636-a4e0-dba66a9721fd
+	# Revision: 23158
+	# Node Kind: directory
+	# Schedule: normal
+	# Last Changed Author: price
+	# Last Changed Rev: 23125
+	# Last Changed Date: 2009-03-03 15:41:16 -1000 (Tue, 03 Mar 2009)
+	
+	$svn_version = `svnversion`; chomp $svn_version;
+	@svn_info = `svn info`;
+
+	# get the svn_root first:
+	foreach $line (@svn_info) {
+	    if ($line =~ m|^Repository Root:|) {
+		($svn_root) = $line =~ m|^Repository Root:\s*(\S*)|;
+		last;
+	    }
+	}
+
+	# now get the branch and UUID values
+	foreach $line (@svn_info) {
+	    if ($line =~ m|^URL:|) {
+		($svn_branch) = $line =~ m|^URL:\s*$svn_root/*(\S*)|;
+	    }
+	    if ($line =~ m|^Repository UUID:|) {
+		($svn_source) = $line =~ m|^Repository UUID:\s*(\S*)|;
+	    }
+	}
+	
+	$ENV{SVN_VERSION} = $svn_version;
+	$ENV{SVN_BRANCH}  = $svn_branch;
+	$ENV{SVN_SOURCE}  = $svn_source;
+    } else {
+	# alternatively, grab these from the following files:
+	if (! -e "SVNINFO") { 
+	    print "missing SVNINFO file for repository info, skipping\n";
+	} else {
+	    @svn_info = `cat SVNINFO`;
+	    foreach $line (@svn_info) {
+		($name, $value) = split (" ", $line);
+		$ENV{$name} = $value;
+	    }
+	}
+    }
+    print "SVN_VERSION $ENV{SVN_VERSION}\n";
+    print "SVN_BRANCH  $ENV{SVN_BRANCH}\n";
+    print "SVN_SOURCE  $ENV{SVN_SOURCE}\n";
+
     # use psconfig.csh to set needed build aliases
-
     if ($extlibs eq "check") {
         $status = vsystem ("pschecklibs");
Index: branches/cnb_branches/cnb_branch_20090215/psphot/src/Makefile.am
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psphot/src/Makefile.am	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psphot/src/Makefile.am	(revision 23239)
@@ -1,14 +1,14 @@
 lib_LTLIBRARIES = libpsphot.la
 
-PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
-PSPHOT_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
-PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+# PSPHOT_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+# PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+# 
+# # Force recompilation of psphotVersion.c, since it gets the version information
+# psphotVersion.c: FORCE
+# 	touch psphotVersion.c
+# FORCE: ;
 
-# Force recompilation of psphotVersion.c, since it gets the version information
-psphotVersion.c: FORCE
-	touch psphotVersion.c
-FORCE: ;
-
-libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=\"$(PSPHOT_VERSION)\" -DPSPHOT_BRANCH=\"$(PSPHOT_BRANCH)\" -DPSPHOT_SOURCE=\"$(PSPHOT_SOURCE)\"
+libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=$(PSPHOT_VERSION) -DPSPHOT_BRANCH=$(PSPHOT_BRANCH) -DPSPHOT_SOURCE=$(SVN_SOURCE)
 libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
Index: branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSetThreads.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSetThreads.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSetThreads.c	(revision 23239)
@@ -25,5 +25,5 @@
     psFree(task);
 
-    task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 4);
+    task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 5);
     task->function = &psphotSourceStats_Threaded;
     psThreadTaskAdd(task);
Index: branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSourceStats.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSourceStats.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSourceStats.c	(revision 23239)
@@ -15,5 +15,5 @@
     int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads
     if (!status) {
-	nThreads = 0;
+        nThreads = 0;
     }
 
@@ -41,8 +41,8 @@
         pmSource *source = pmSourceAlloc();
 
-	// add the peak
+        // add the peak
         source->peak = psMemIncrRefCounter(peak);
 
-	// allocate space for moments
+        // allocate space for moments
         source->moments = pmMomentsAlloc();
 
@@ -50,14 +50,14 @@
         pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
 
-	peak->assigned = true;
-	psArrayAdd (sources, 100, source);
-	psFree (source);
+        peak->assigned = true;
+        psArrayAdd (sources, 100, source);
+        psFree (source);
     }
 
     if (!strcasecmp (breakPt, "PEAKS")) {
-	psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));
-	psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
-	psphotVisualShowMoments (sources);
-	return sources;
+        psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));
+        psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
+        psphotVisualShowMoments (sources);
+        return sources;
     }
 
@@ -65,4 +65,5 @@
     int Nfail = 0;
     int Nmoments = 0;
+    int Nfaint = 0;
 
     // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts)
@@ -74,60 +75,63 @@
     for (int i = 0; i < cellGroups->n; i++) {
 
-	psArray *cells = cellGroups->data[i];
-
-	for (int j = 0; j < cells->n; j++) {
-
-	    // allocate a job -- if threads are not defined, this just runs the job
-	    psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS");
-
-	    psArrayAdd(job->args, 1, cells->data[j]); // sources
-	    psArrayAdd(job->args, 1, recipe);
-	    PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments
-	    PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
-
-	    if (!psThreadJobAddPending(job)) {
-		psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
-		psFree (job);
-		return NULL;
-	    }
-	    psFree(job);
+        psArray *cells = cellGroups->data[i];
+
+        for (int j = 0; j < cells->n; j++) {
+
+            // allocate a job -- if threads are not defined, this just runs the job
+            psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS");
+
+            psArrayAdd(job->args, 1, cells->data[j]); // sources
+            psArrayAdd(job->args, 1, recipe);
+            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments
+            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
+            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint
+
+            if (!psThreadJobAddPending(job)) {
+                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
+                psFree (job);
+                return NULL;
+            }
+            psFree(job);
 
 # if (0)
-		int nfail = 0;
-		int nmoments = 0;
-		if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {
-		    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
-		    return NULL;
-		}
-		Nfail += nfail;
-		Nmoments += nmoments;
+                int nfail = 0;
+                int nmoments = 0;
+                if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {
+                    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
+                    return NULL;
+                }
+                Nfail += nfail;
+                Nmoments += nmoments;
 # endif
-	}
-
-	// wait for the threads to finish and manage results
-	if (!psThreadPoolWait (false)) {
-	    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
-	    return NULL;
-	}
-
-	// we have only supplied one type of job, so we can assume the types here
-	psThreadJob *job = NULL;
-	while ((job = psThreadJobGetDone()) != NULL) {
-	    if (job->args->n < 1) {
-		fprintf (stderr, "error with job\n");
-	    } else {
-		psScalar *scalar = NULL;
-		scalar = job->args->data[2];
-		Nmoments += scalar->data.S32;
-		scalar = job->args->data[3];
-		Nfail += scalar->data.S32;
-	    }
-	    psFree(job);
-	}
+        }
+
+        // wait for the threads to finish and manage results
+        if (!psThreadPoolWait (false)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
+            return NULL;
+        }
+
+        // we have only supplied one type of job, so we can assume the types here
+        psThreadJob *job = NULL;
+        while ((job = psThreadJobGetDone()) != NULL) {
+            if (job->args->n < 1) {
+                fprintf (stderr, "error with job\n");
+            } else {
+                psScalar *scalar = NULL;
+                scalar = job->args->data[2];
+                Nmoments += scalar->data.S32;
+                scalar = job->args->data[3];
+                Nfail += scalar->data.S32;
+                scalar = job->args->data[4];
+                Nfaint += scalar->data.S32;
+            }
+            psFree(job);
+        }
     }
 
     psFree (cellGroups);
 
-    psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d failed: %f sec\n", sources->n, Nmoments, Nfail, psTimerMark ("psphot.stats"));
+    psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d faint, %d failed: %f sec\n", sources->n, Nmoments, Nfaint, Nfail, psTimerMark ("psphot.stats"));
 
     psphotVisualShowMoments (sources);
@@ -166,4 +170,5 @@
     int Nfail = 0;
     int Nmoments = 0;
+    int Nfaint = 0;
     for (int i = 0; i < sources->n; i++) {
         pmSource *source = sources->data[i];
@@ -171,5 +176,6 @@
         // skip faint sources for moments measurement
         if (source->peak->SN < MIN_SN) {
-	    source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN;
+            source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN;
+            Nfaint++;
             continue;
         }
@@ -179,8 +185,8 @@
         status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
         if (!status) {
-	    source->mode |= PM_SOURCE_MODE_SKY_FAILURE;
-	    psErrorClear(); // XXX re-consider the errors raised here
-	    Nfail ++;
-	    continue;
+            source->mode |= PM_SOURCE_MODE_SKY_FAILURE;
+            psErrorClear(); // XXX re-consider the errors raised here
+            Nfail ++;
+            continue;
         }
 
@@ -189,8 +195,8 @@
         status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
         if (!status) {
-	    source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;
-	    Nfail ++;
-	    psErrorClear();
-	    continue;
+            source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;
+            Nfail ++;
+            psErrorClear();
+            continue;
         }
 
@@ -208,10 +214,10 @@
         status = pmSourceMoments (source, BIG_RADIUS);
         if (status) {
-	    source->mode |= PM_SOURCE_MODE_BIG_RADIUS;
+            source->mode |= PM_SOURCE_MODE_BIG_RADIUS;
             Nmoments ++;
             continue;
         }
 
-	source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;
+        source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;
         Nfail ++;
         psErrorClear();
@@ -225,5 +231,8 @@
     scalar = job->args->data[3];
     scalar->data.S32 = Nfail;
-    
+
+    scalar = job->args->data[4];
+    scalar->data.S32 = Nfaint;
+
     return true;
 }
@@ -268,7 +277,7 @@
         status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
         if (!status) {
-	    psErrorClear(); // XXX re-consider the errors raised here
-	    Nfail ++;
-	    continue;
+            psErrorClear(); // XXX re-consider the errors raised here
+            Nfail ++;
+            continue;
         }
 
@@ -277,7 +286,7 @@
         status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
         if (!status) {
-	    Nfail ++;
-	    psErrorClear();
-	    continue;
+            Nfail ++;
+            psErrorClear();
+            continue;
         }
 
@@ -307,6 +316,6 @@
     *nmoments = Nmoments;
     *nfail = Nfail;
-    
+
     return true;
 }
-# endif 
+# endif
Index: branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotVersion.c
===================================================================
--- branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotVersion.c	(revision 23201)
+++ branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotVersion.c	(revision 23239)
@@ -5,6 +5,4 @@
 #endif
 
-psString psphotVersion(void)
-{
 #ifndef PSPHOT_VERSION
 #error "PSPHOT_VERSION is not set"
@@ -13,13 +11,21 @@
 #error "PSPHOT_BRANCH is not set"
 #endif
-    return psStringCopy(PSPHOT_BRANCH "@" PSPHOT_VERSION);
+#ifndef PSPHOT_SOURCE
+#error "PSPHOT_SOURCE is not set"
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+psString psphotVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", xstr(PSPHOT_BRANCH), xstr(PSPHOT_VERSION));
+    return value;
 }
 
 psString psphotSource(void)
 {
-#ifndef PSPHOT_SOURCE
-#error "PSPHOT_SOURCE is not set"
-#endif
-    return psStringCopy(PSPHOT_SOURCE);
+    return psStringCopy(xstr(PSPHOT_SOURCE));
 }
 
