Index: trunk/psastro/src/psastroMaskUpdates.c
===================================================================
--- trunk/psastro/src/psastroMaskUpdates.c	(revision 24651)
+++ trunk/psastro/src/psastroMaskUpdates.c	(revision 24652)
@@ -28,7 +28,8 @@
     pmCell *cell = NULL;
     pmReadout *readout = NULL;
-    float zeropt, exptime;
+    float zeropt, exptime, GHOST_MAX_MAG;
 
     psImageMaskType ghostMaskValue = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
+    psImageMaskType glintMaskValue = pmConfigMaskGet("GHOST", config); // Mask value for glint pixels (overload ghost)
     psImageMaskType spikeMaskValue = pmConfigMaskGet("SPIKE", config); // Mask value for ghost pixels
     psImageMaskType starMaskValue  = pmConfigMaskGet("STARCORE", config); // Mask value for ghost pixels
@@ -53,6 +54,11 @@
     }
     bool COUNT_GHOSTS = psMetadataLookupF32 (&status, recipe, "REFSTAR_COUNT_GHOSTS");
-    double GHOST_MAX_MAG = psMetadataLookupF32 (&status, recipe, "GHOST_MAX_MAG");
     int nGhosts = 0;
+
+    // convert star positions to glint positions and add to the fpa->analysis data
+    if (!psastroLoadGlints (config)) {
+        psError(PSASTRO_ERR_CONFIG, false, "Error loading glints");
+        return false;
+    }
 
     psLogMsg ("psastro", PS_LOG_INFO, "generating a bright-star mask");
@@ -79,5 +85,5 @@
 
     // really error-out here?  or just skip?
-    if (!psastroZeroPointFromRecipe (&zeropt, &exptime, fpa, recipe)) {
+    if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &GHOST_MAX_MAG, fpa, recipe)) {
         psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
         return false;
@@ -221,6 +227,8 @@
                     }
 
+		    // This masking option was needed for persistent charge trails in GPC1; it
+		    // has since been replaced with 'burntool', which is applied upon readout
+		    // by the camera software, and therefore is aware of the image sequence.
 		    if (REFSTAR_MASK_BLEED) {
-
 			// convert x,y chip coordinates to cells in maskChip
 			pmCell *refCell = pmCellInChip (refChip, ref->chip->x, ref->chip->y);
@@ -245,14 +253,32 @@
                 }
 
-                // select the raw objects for this readout (loaded in psastroExtract.c)
+                // select the ghost object for this readout (loaded in psastroExtractGhosts.c).
+                // These differ from the reference stars since the star position is not
+                // contained by the readout; instead, the ghost position is predicted based on
+                // the ghost model, and the ghost positions associated with a given readout are
+                // supplied here.
                 psArray *ghosts = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.GHOSTS");
-                if (ghosts == NULL) { continue; }
-
-                // identify the bright stars of interest
-                for (int i = 0; i < ghosts->n; i++) {
-                    psastroGhost *ghost = ghosts->data[i];
-		    // XXX bright vs faint ghost bits? (OR with SUSPECT) 
-		    psastroMaskEllipticalAnnulus (readoutMask->mask, ghostMaskValue, ghost->chip->x, ghost->chip->y, ghost->inner, ghost->outer);
-                }
+                if (ghosts) { 
+		    // mask the ghosts on this readout
+		    for (int i = 0; i < ghosts->n; i++) {
+			psastroGhost *ghost = ghosts->data[i];
+			// XXX bright vs faint ghost bits? (OR with SUSPECT) 
+			psastroMaskEllipticalAnnulus (readoutMask->mask, ghostMaskValue, ghost->chip->x, ghost->chip->y, ghost->inner, ghost->outer);
+		    }
+		}
+
+                // Select the glint mask regions for this readout (loaded in
+                // psastroExtractGlints.c).  These glint regions are defined as rectangular
+                // boxes and are generated for each chip based on the position of the bright
+                // stars beyond the edge of the focal plane.  This masking is currently very
+                // GPC1-specific
+                psArray *glints = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.GLINTS");
+                if (glints) {
+		    // mask the glints on this readout
+		    for (int i = 0; i < glints->n; i++) {
+			psRegion *glint = glints->data[i];
+			psastroMaskRectangle (readoutMask->mask, glintMaskValue, glint->x0, glint->y0, glint->x1, glint->y1);
+		    }
+		}
 
 		// select the raw objects for this readout, flag is they fall in a mask
@@ -260,6 +286,7 @@
 		if (rawstars == NULL) return false;
 		
-		// XXX finish this:
-		for (int i = 0; i < rawstars->n; i++) {
+		// XXX finish this: raise a bit for stars that land on certain types of masks;
+		// others (eg, bright star core) should be ignored.
+		for (int i = 0; false && (i < rawstars->n); i++) {
 		    pmAstromObj *raw = rawstars->data[i];
 		    psImageMaskType value = readoutMask->mask->data.PS_TYPE_IMAGE_MASK_DATA[(int)(raw->chip->x)][(int)(raw->chip->y)];
