Index: trunk/psastro/src/psastroExtractStars.c
===================================================================
--- trunk/psastro/src/psastroExtractStars.c	(revision 23591)
+++ trunk/psastro/src/psastroExtractStars.c	(revision 23592)
@@ -83,7 +83,7 @@
 	return false;
     }
+
     char *filename = NULL;
     psStringAppend (&filename, "%s.st.fits", fileroot);
-
     psFits *outStars = psFitsOpen (filename, "w");
     if (!outStars) {
@@ -91,4 +91,14 @@
 	return false;
     }
+    psFree (filename);
+
+    filename = NULL;
+    psStringAppend (&filename, "%s.gh.fits", fileroot);
+    psFits *outGhosts = psFitsOpen (filename, "w");
+    if (!outGhosts) {
+	psError(PS_ERR_IO, false, "error opening file %s\n", filename);
+	return false;
+    }
+    psFree (filename);
 
     pmFPAview *view = pmFPAviewAlloc (0);
@@ -103,5 +113,7 @@
     psMetadataAddF32 (phu, PS_LIST_TAIL, "EXPTIME", 0, "exptime", exptime);
     psMetadataAddF32 (phu, PS_LIST_TAIL, "ZEROPT",  0, "zeropt", zeropt);
+
     psFitsWriteBlank (outStars, phu, NULL);
+    psFitsWriteBlank (outGhosts, phu, NULL);
     psFree (phu);
 
@@ -145,4 +157,34 @@
                     psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y",   0, "focal-plane coordinate", ref->FP->y);
                     psMetadataAddF32 (header, PS_LIST_TAIL, "MAG",     0, "magnitude",              ref->Mag);
+
+		    snprintf (extname, 80, "extname.%05d", nExt);
+		    psFitsWriteImage (outStars, header, subraster, 0, extname);
+		    nExt ++;
+		    
+		    psFree (header);
+		    psFree (subraster);
+                }
+
+                // select the raw objects for this readout (loaded in psastroExtract.c)
+                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++) {
+                    pmAstromObj *ghost = ghosts->data[i];
+
+		    pmReadout *inReadout = pmFPAviewThisReadout (view, input->fpa);
+		    psImage *subraster = psastroExtractStar (inReadout->image, ghost->chip->x, ghost->chip->y, 200.0, 200.0);
+		    if (!subraster) continue;
+		    
+                    // generate a (very) basic header:
+                    psMetadata *header = psMetadataAlloc ();
+                    psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_X",  0, "chip coordinate",        ghost->chip->x);
+                    psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_Y",  0, "chip coordinate",        ghost->chip->y);
+                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X",   0, "focal-plane coordinate", ghost->FP->x);
+                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y",   0, "focal-plane coordinate", ghost->FP->y);
+                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X0",  0, "star focal-plane coordinate", ghost->TP->x); // note : over-loaded value 
+                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y0",  0, "star focal-plane coordinate", ghost->TP->y); // note : over-loaded value 
+                    psMetadataAddF32 (header, PS_LIST_TAIL, "MAG",     0, "magnitude",              ghost->Mag);
 
 		    snprintf (extname, 80, "extname.%05d", nExt);
