Index: trunk/psastro/src/psastroChooseRefstars.c
===================================================================
--- trunk/psastro/src/psastroChooseRefstars.c	(revision 24646)
+++ trunk/psastro/src/psastroChooseRefstars.c	(revision 24806)
@@ -49,4 +49,12 @@
     pmFPAview *view = pmFPAviewAlloc (0);
     pmFPA *fpa = input->fpa;
+
+    // XXX kind of a hack -- think this through a bit more clearly:
+    if (psMetadataLookupPtr (&status, fpa->analysis, "MATCHED_REFS")) {
+	// we loaded a set of matched references from an earlier astrometry
+	// analysis.  however, we are re-doing the astrometry here, so remove
+	// that prior set of matched references
+	psMetadataRemoveKey (fpa->analysis, "MATCHED_REFS");
+    }
 
     // sort by mag
@@ -114,4 +122,15 @@
                 psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n);
 
+# if (0)
+		// XXX test
+		FILE *outfile = fopen ("refstars.dat", "w");
+		assert (outfile);
+		for (int nn = 0; nn < refstars->n; nn++) {
+			  pmAstromObj *ref = refstars->data[nn];
+			  fprintf (outfile, "%lf %lf\n", ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD);
+		}
+		fclose (outfile);
+# endif
+
 		psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars);
 		psFree (refstars);
