Index: /trunk/psastro/src/psastroAstromGuess.c
===================================================================
--- /trunk/psastro/src/psastroAstromGuess.c	(revision 10860)
+++ /trunk/psastro/src/psastroAstromGuess.c	(revision 10861)
@@ -75,5 +75,12 @@
                 if (rawstars == NULL) { continue; }
 
-		FILE *f = fopen ("rawstars.dat", "w");
+		if (psTraceGetLevel("psastro.dump.rawstars") > 2) {
+		  dump_stars (rawstars, fpa, chip);
+		}
+
+		if (psTraceGetLevel("psastro.plot.rawstars") > 2) {
+		  plot_stars (rawstars, fpa, chip);
+		}
+
                 for (int i = 0; i < rawstars->n; i++) {
                     pmAstromObj *raw = rawstars->data[i];
@@ -82,36 +89,4 @@
                     psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP);
                     psDeproject (raw->sky, raw->TP, fpa->toSky);
-
-		    fprintf (f, "%d  %f %f  %f %f  %f %f  %f %f\n", i,
-			     raw->sky->r, raw->sky->d, 
-			     raw->TP->x, raw->TP->y, 
-			     raw->FP->x, raw->FP->y, 
-			     raw->chip->x, raw->chip->y);
-
-		    if (i < 10) {
-			psTrace ("psastro", 8, "up: %f,%f -> %f,%f -> %f,%f -> %f,%f\n",
-                                 raw->chip->x, raw->chip->y,
-                                 raw->FP->x, raw->FP->y,
-                                 raw->TP->x, raw->TP->y,
-                                 raw->sky->r, raw->sky->d);
-			
-                        psPlane *fp = psPlaneAlloc();
-                        psPlane *tp = psPlaneAlloc();
-                        psPlane *ch = psPlaneAlloc();
-			
-                        psProject (tp, raw->sky, fpa->toSky);
-                        psPlaneTransformApply (fp, fpa->fromTPA, tp);
-                        psPlaneTransformApply (ch, chip->fromFPA, fp);
-			
-                        psTrace ("psastro", 8, "dn: %f,%f <- %f,%f <- %f,%f <- %f,%f\n",
-                                 ch->x, ch->y,
-                                 fp->x, fp->y,
-                                 tp->x, tp->y,
-                                 raw->sky->r, raw->sky->d);
-
-			psFree (fp);
-			psFree (tp);
-			psFree (ch);
-                    }
 
                     // rationalize ra to sky range centered on boresite
@@ -125,5 +100,4 @@
                     DECmax = PS_MAX (raw->sky->d, DECmax);
                 }
-		fclose (f);
             }
         }
@@ -151,2 +125,42 @@
    sky (ra, dec)
 */
+
+dump_stars (psArray *rawstars, pmFPA *fpa, pmChip *chip) {
+
+  FILE *f1 = fopen ("rawstars.up.dat", "w");
+  FILE *f2 = fopen ("rawstars.dn.dat", "w");
+  for (int i = 0; i < rawstars->n; i++) {
+    pmAstromObj *raw = rawstars->data[i];
+
+    psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip);
+    psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP);
+    psDeproject (raw->sky, raw->TP, fpa->toSky);
+
+    fprintf (f1, "%d  %f %f  %f %f  %f %f  %f %f\n", i,
+	     raw->sky->r, raw->sky->d, 
+	     raw->TP->x, raw->TP->y, 
+	     raw->FP->x, raw->FP->y, 
+	     raw->chip->x, raw->chip->y);
+		
+    psPlane *fp = psPlaneAlloc();
+    psPlane *tp = psPlaneAlloc();
+    psPlane *ch = psPlaneAlloc();
+			
+    psProject (tp, raw->sky, fpa->toSky);
+    psPlaneTransformApply (fp, fpa->fromTPA, tp);
+    psPlaneTransformApply (ch, chip->fromFPA, fp);
+			
+    fprintf (f2, "%d  %f %f  %f %f  %f %f  %f %f\n", i,
+	     raw->sky->r, raw->sky->d, 
+	     tp->x, tp->y, 
+	     fp->x, fp->y, 
+	     ch->x, ch->y);
+		
+    psFree (fp);
+    psFree (tp);
+    psFree (ch);
+  }
+
+  fclose (f1);
+  fclose (f2);
+}
