Index: /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fit_fake_stars.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fit_fake_stars.c	(revision 37526)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fit_fake_stars.c	(revision 37527)
@@ -1,3 +1,19 @@
 # include "fakeastro.h"
+
+int dump_fit_stars (Stars *stars, double *L, double *M, int Nstars, char *filename) {
+
+  FILE *f = fopen (filename, "w");
+  if (!f) {
+    fprintf (stderr, "failed to open %s\n", filename);
+    return FALSE;
+  }
+
+  int i;
+  for (i = 0; i < Nstars; i++) {
+    fprintf (f, "%d  %f %f : %f %f\n", i, stars[i].measure.Xccd, stars[i].measure.Yccd, L[i], M[i]);
+  }
+  fclose (f);
+  return TRUE;
+}
 
 int fit_fake_stars (Stars *stars, int Nstars, Image *image) {
@@ -59,4 +75,18 @@
   }
 
+  // measure chip corners and find dX,dY
+  {
+    double Lo, Mo;
+    XY_to_LM (&Lo, &Mo, 0.0, 0.0, &image[0].coords);
+    
+    double Ls, Ms;
+    XY_to_LM (&Ls, &Ms, 4850.0, 0.0, &image[0].coords);
+
+    double Le, Me;
+    XY_to_LM (&Le, &Me, 0.0, 4850.0, &image[0].coords);
+
+    fprintf (stderr, "%s : (dL,dM)_1 : %f : (dL,dM)_2 : %f\n", image->name, hypot(Le-Lo, Me-Mo), hypot(Ls-Lo, Ms-Mo));
+  }
+
   if (CHIPMAP) {
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fitpoly.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fitpoly.c	(revision 37526)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fitpoly.c	(revision 37527)
@@ -141,5 +141,6 @@
   }
 
-  for (i = 0; FALSE && (i < fit[0].Nelems); i++) {
+# define DEBUG FALSE
+  for (i = 0; DEBUG && (i < fit[0].Nelems); i++) {
     ix = i % fit[0].Nterms;
     iy = i / fit[0].Nterms;
@@ -154,5 +155,5 @@
   }
 
-  for (i = 0; FALSE && i < fit[0].Nelems; i++) {
+  for (i = 0; DEBUG && i < fit[0].Nelems; i++) {
     ix = i % fit[0].Nterms;
     iy = i / fit[0].Nterms;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_images.c	(revision 37526)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_images.c	(revision 37527)
@@ -39,11 +39,11 @@
 
       if (ix < 4) {
-	fakeImage[N].coords.crpix1 = (ix - 3)*4900;
-	fakeImage[N].coords.crpix2 = (iy - 3)*4900;
+	fakeImage[N].coords.crpix1 = (ix - 3)*5000;
+	fakeImage[N].coords.crpix2 = (iy - 3)*5100;
 	fakeImage[N].coords.pc1_1 = 1.0;
 	fakeImage[N].coords.pc2_2 = 1.0;
       } else {
-	fakeImage[N].coords.crpix1 = (3 - ix)*4900;
-	fakeImage[N].coords.crpix2 = (4 - iy)*4900;
+	fakeImage[N].coords.crpix1 = (4 - ix)*5000;
+	fakeImage[N].coords.crpix2 = (4 - iy)*5100;
 	fakeImage[N].coords.pc1_1 = -1.0;
 	fakeImage[N].coords.pc2_2 = -1.0;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fakeqsos.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fakeqsos.c	(revision 37526)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fakeqsos.c	(revision 37527)
@@ -7,4 +7,9 @@
 
   // do I want to add in a galaxy obscuration (P(b) ?)
+
+  float dR = UserPatch.Rmax - UserPatch.Rmin;
+  float dPmin = sin(RAD_DEG*UserPatch.Dmin);
+  float dPmax = sin(RAD_DEG*UserPatch.Dmax);
+  float dP = dPmax - dPmin;
 
   int i;
@@ -18,7 +23,7 @@
     int inPatch = FALSE;
     while (!inPatch) {
-      double phi = 2.0 * drand48() - 1.0;
-      D = DEG_RAD * asin(phi);
-      R = drand48() * 2 * M_PI;
+      double phi = dP * drand48() + dPmin;
+      D = DEG_RAD * asin(phi); // random in degrees
+      R = drand48() * dR + UserPatch.Rmin;   // random in degrees
       if (R < UserPatch.Rmin) continue;
       if (R > UserPatch.Rmax) continue;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/match_fake_stars.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/match_fake_stars.c	(revision 37526)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/match_fake_stars.c	(revision 37527)
@@ -1,3 +1,6 @@
 # include "fakeastro.h"
+
+// Image *image is only used to set the equiv photcode, which in turn is used to set Nsec, which 
+// is only used to set the average photometry, but is not really needed.
 
 int match_fake_stars (Stars *stars, unsigned int NstarsIn, SkyRegion *region, Catalog *catalog, Image *image) {
