Index: /branches/eam_branches/ipp-20100621/ppSim/src/ppSimMakeGalaxies.c
===================================================================
--- /branches/eam_branches/ipp-20100621/ppSim/src/ppSimMakeGalaxies.c	(revision 28674)
+++ /branches/eam_branches/ipp-20100621/ppSim/src/ppSimMakeGalaxies.c	(revision 28675)
@@ -18,4 +18,5 @@
     int galaxyGridDX 	  = psMetadataLookupS32(&mdok, recipe, "GALAXY.GRID.DX"); // Density of fakes
     int galaxyGridDY 	  = psMetadataLookupS32(&mdok, recipe, "GALAXY.GRID.DY"); // Density of fakes
+    bool galaxyGridRandom = psMetadataLookupBool(&mdok, recipe, "GALAXY.GRID.RANDOM"); // Density of fakes
     
     float galaxyRmajorMax = psMetadataLookupF32(&mdok, recipe, "GALAXY.RMAJOR.MAX"); // Density of fakes
@@ -43,4 +44,11 @@
 
     if (galaxyDensity <= 0) return true;
+
+    if (galaxyGridRandom) {
+	long A, B;
+	A = time(NULL);
+	for (B = 0; A == time(NULL); B++);
+	srand48(B);
+    }
 
     // Size of FPA
@@ -81,8 +89,8 @@
 	psLogMsg("ppSim", PS_LOG_INFO, "Adding grid of %ld galaxies\n", num);
 
-	float galaxyIndexSlope = (galaxyIndexMax - galaxyIndexMin) / num;
-	float galaxyThetaSlope = (galaxyThetaMax - galaxyThetaMin) / num;
-	float galaxyARatioSlope = (galaxyARatioMax - galaxyARatioMin) / num;
-	float galaxyRmajorSlope = (galaxyRmajorMax - galaxyRmajorMin) / num;
+	float galaxyIndexSlope = (galaxyIndexMax - galaxyIndexMin);
+	float galaxyThetaSlope = (galaxyThetaMax - galaxyThetaMin);
+	float galaxyARatioSlope = (galaxyARatioMax - galaxyARatioMin);
+	float galaxyRmajorSlope = (galaxyRmajorMax - galaxyRmajorMin);
 
 	int i = 0;
@@ -101,8 +109,10 @@
 		// galaxy->index = (1/2n)
 
-		float index = (galaxyIndexMin  + i * galaxyIndexSlope); // factor of 0.5 because the Sersic model creates exp(-z^n), not exp(-r^n)
+		float factor = galaxyGridRandom ? drand48() : i / num;
+		float index = (galaxyIndexMin  + factor * galaxyIndexSlope); // factor of 0.5 because the Sersic model creates exp(-z^n), not exp(-r^n)
 		galaxy->index = 0.5/index;
 
-		float scale = (galaxyRmajorMin + i * galaxyRmajorSlope);
+		factor = galaxyGridRandom ? drand48() : i / num;
+		float scale = (galaxyRmajorMin + factor * galaxyRmajorSlope);
 
 		// for a sersic model, 
@@ -114,11 +124,16 @@
 
 		galaxy->Rmaj  = scale;
-		galaxy->Rmin  = (galaxyARatioMin + i * galaxyARatioSlope) * galaxy->Rmaj;
-		galaxy->theta = (galaxyThetaMin  + i * galaxyThetaSlope);
+
+		factor = galaxyGridRandom ? drand48() : i / num;
+		galaxy->Rmin  = (galaxyARatioMin + factor * galaxyARatioSlope) * galaxy->Rmaj;
+
+		factor = galaxyGridRandom ? drand48() : i / num;
+		galaxy->theta = (galaxyThetaMin  + factor * galaxyThetaSlope);
 
 		// galaxy->peak *= Io;
 
-		fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f\n",
-			 galaxy->Rmaj, scale, index, bn, fR, Io);
+		if (0) {
+		    fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f\n", galaxy->Rmaj, scale, index, bn, fR, Io);
+		}
 
 		psArrayAdd (galaxies, 100, galaxy);
Index: /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadout.c
===================================================================
--- /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadout.c	(revision 28674)
+++ /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadout.c	(revision 28675)
@@ -69,5 +69,5 @@
     psArray *fakeSources = psArrayAlloc (injectedSources->n);
     for (int i = 0; i < injectedSources->n; i++) {
-      fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]);
+      fakeSources->data[i] = pmSourceCopyData (injectedSources->data[i]);
     }
 
Index: /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadoutFake.c
===================================================================
--- /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadoutFake.c	(revision 28674)
+++ /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadoutFake.c	(revision 28675)
@@ -40,5 +40,5 @@
     psArray *fakeSources = psArrayAlloc (injectedSources->n);
     for (int i = 0; i < injectedSources->n; i++) {
-      fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]);
+      fakeSources->data[i] = pmSourceCopyData (injectedSources->data[i]);
     }
 
@@ -47,5 +47,5 @@
     psArray *realSources = psArrayAlloc (realMeasuredSources->n);
     for (int i = 0; i < realMeasuredSources->n; i++) {
-        realSources->data[i] = pmSourceCopy (realMeasuredSources->data[i]);
+        realSources->data[i] = pmSourceCopyData (realMeasuredSources->data[i]);
     }
 
Index: /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadoutForce.c
===================================================================
--- /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadoutForce.c	(revision 28674)
+++ /branches/eam_branches/ipp-20100621/ppSim/src/ppSimPhotomReadoutForce.c	(revision 28675)
@@ -46,5 +46,5 @@
     psArray *realSources = psArrayAlloc (realMeasuredSources->n);
     for (int i = 0; i < realMeasuredSources->n; i++) {
-        realSources->data[i] = pmSourceCopy (realMeasuredSources->data[i]);
+        realSources->data[i] = pmSourceCopyData (realMeasuredSources->data[i]);
     }
 
