Index: trunk/ppSim/src/ppSimMakeStars.c
===================================================================
--- trunk/ppSim/src/ppSimMakeStars.c	(revision 25760)
+++ trunk/ppSim/src/ppSimMakeStars.c	(revision 41173)
@@ -27,5 +27,9 @@
     float zp           = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); // Photometric zero point
     float seeing       = psMetadataLookupF32(&status, recipe, "SEEING"); // Seeing SIGMA (pixels)
-    float scale        = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
+    float scale        = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel)
+    // there has been some confusion over pixel scale: PIXEL.SCALE is supplied in arcsec / pixel.
+    // In some other places (ppSimLoadStars.c, ppSimUtils.c) it is needed in radius for WCS conversion.
+    // in the past, it was converted to radians on load (but applied inconsisently elsewhere)
+    // Now the radian version is carried as scaleRad to be more explicit
 
     if (isnan(darkRate)) darkRate = 0.0;
@@ -42,4 +46,5 @@
 	float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS");  assert (status);
 	skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
+	// skyMags is in mags / square arcsec, so scale must be in arcsec / pixel
     }
 
@@ -61,9 +66,9 @@
 	if (!status) {
 	    refMag = brightMag;
-	    refSum = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);
+	    refSum = starsDensity * xSize * ySize * PS_SQR(scale / 3600.0);
 	}
     } else {
 	refMag = brightMag;
-	refSum = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);
+	refSum = starsDensity * xSize * ySize * PS_SQR(scale / 3600.0);
     }
     psTrace("ppSim", 6, "refMag: %f, refSum: %f\n", refMag, refSum);
@@ -120,4 +125,9 @@
     psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld stars between %f and %f mag\n", nTotal, brightMag, faintMag);
 
+    if (nTotal > 1e7) {
+      psLogMsg("ppSim", PS_LOG_INFO, "Trying to add %d stars (far more than 10M stars!), giving up\n", (int) nTotal);
+      exit (2);
+    }
+
     long oldSize = stars->n;
     psArrayRealloc (stars, stars->n + nTotal);
