Index: trunk/Ohana/src/opihi/lib.data/starfuncs.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/starfuncs.c	(revision 2598)
+++ trunk/Ohana/src/opihi/lib.data/starfuncs.c	(revision 2826)
@@ -6,5 +6,5 @@
   double x, y, x2, y2, I, sky, FWHMx, FWHMy, value, mag;
   int i, j, n, Npix2, Nring, Nmax;
-  double Npts, gain, dsky2, dmag;
+  double Npts, gain, dsky2, dmag, peak, offset;
   char *string;
   
@@ -45,4 +45,5 @@
   free (ring);
 
+  peak = 0;
   Npts = Nmax = 0;
   x = y = x2 = y2 = I = 0;
@@ -50,13 +51,15 @@
     for (j = Y - Npix2; j < Y + Npix2 + 1; j++) {
       value = fits_get_matrix_value (matrix, i, j);
-      x  += i*(value - sky);
-      y  += j*(value - sky);
-      x2 += i*i*(value - sky);
-      y2 += j*j*(value - sky);
-      I  += (value - sky);
+      offset = value - sky;
+      x  += i*offset;
+      y  += j*offset;
+      x2 += i*i*offset;
+      y2 += j*j*offset;
+      I  += offset;
       Npts ++;
       if (value > max) {
 	Nmax ++;
       }
+      if (value > peak) peak = value;
     }
   }
@@ -80,4 +83,5 @@
   set_variable ("dZg", dmag);
   set_variable ("Zcg", I);
+  set_variable ("Zpk", peak);
   set_int_variable ("Nsat", Nmax);
   
