Index: /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.c
===================================================================
--- /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.c	(revision 28675)
+++ /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.c	(revision 28676)
@@ -105,5 +105,6 @@
     static int id = 1;
     pmSource *source = (pmSource *) psAlloc(sizeof(pmSource));
-    *(int *)&source->id = id++;
+    P_PM_SOURCE_SET_ID(source, id++);
+
     source->seq = -1;
     source->peak = NULL;
@@ -149,8 +150,56 @@
 
 /******************************************************************************
-pmSourceCopy(): copy the pmSource structure and contents
-XXX : are we OK with incrementing the ID?
+pmSourceCopy(): copy the pmSource, yielding a copy of the source that can be used without
+affecting the original.  This Copy can be used to allow multiple fit attempts on the same
+object.  The pixels, variance, and mask arrays all point to the same original subarrays.  The
+peak and moments point at the original values.
 *****************************************************************************/
 pmSource *pmSourceCopy(pmSource *in)
+{
+    if (in == NULL) {
+        return(NULL);
+    }
+    pmSource *source = pmSourceAlloc ();
+
+    // keep the original ID so we can find map back to the original
+    P_PM_SOURCE_SET_ID(source, in->id);
+
+    // peak has the same values as the original
+    if (in->peak != NULL) {
+        source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
+        source->peak->xf = in->peak->xf;
+        source->peak->yf = in->peak->yf;
+        source->peak->flux = in->peak->flux;
+        source->peak->SN = in->peak->SN;
+    }
+
+    // copy the values in the moments structure
+    if (in->moments != NULL) {
+        source->moments  =  pmMomentsAlloc();
+        *source->moments = *in->moments;
+    }
+
+    // These images are all views to the parent.  We want a new view, but pointing at the same
+    // pixels.  Modifying these pixels (ie, subtracting the model) will affect the pixels seen
+    // by all copies.
+    source->pixels   = psImageCopyView(NULL, in->pixels);
+    source->variance   = psImageCopyView(NULL, in->variance);
+    source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
+
+    // the maskObj is a unique mask array; create a new mask image
+    source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
+
+    source->type = in->type;
+    source->mode = in->mode;
+    source->imageID = in->imageID;
+
+    return(source);
+}
+
+/******************************************************************************
+pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the
+original (but is actually a new source at the same location)
+*****************************************************************************/
+pmSource *pmSourceCopyData(pmSource *in)
 {
     if (in == NULL) {
Index: /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.h
===================================================================
--- /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.h	(revision 28675)
+++ /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.h	(revision 28676)
@@ -104,4 +104,6 @@
 pmPSFClump;
 
+// private macro to set the source ID (a const)
+#define P_PM_SOURCE_SET_ID(S,V) { *(int *)&(S)->id = (V); }
 
 /** pmSourceAlloc()
@@ -117,4 +119,5 @@
 
 pmSource  *pmSourceCopy(pmSource *source);
+pmSource *pmSourceCopyData(pmSource *in);
 
 // free just the pixels for a source, keeping derived data
Index: /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c
===================================================================
--- /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c	(revision 28675)
+++ /branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c	(revision 28676)
@@ -86,4 +86,9 @@
     psVector *yErr = psVectorAllocEmpty(nPix, PS_TYPE_F32);
 
+    // XXX for a test, skip the central pixel in the sersic fit
+    bool skipCenter = false && (model->type == pmModelClassGetType("PS_MODEL_SERSIC"));
+    float Xo = model->params->data.F32[PM_PAR_XPOS];
+    float Yo = model->params->data.F32[PM_PAR_YPOS];
+
     // fill in the coordinate and value entries
     nPix = 0;
@@ -109,10 +114,20 @@
             }
 
-            psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
-
             // Convert i/j to image space:
 	    // 0.5 PIX: the coordinate values must be in pixel coords, not index	    
-            coord->data.F32[0] = (psF32) (j + 0.5 + source->pixels->col0);
-            coord->data.F32[1] = (psF32) (i + 0.5 + source->pixels->row0);
+            float Xv = (psF32) (j + 0.5 + source->pixels->col0);
+            float Yv = (psF32) (i + 0.5 + source->pixels->row0);
+
+	    // XXX possible skip of center pixel:
+	    if (skipCenter) {
+		float r = hypot(Xv - Xo, Yv - Yo);
+		if (r < 0.75) {
+		    continue;
+		}
+	    }
+
+            psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
+            coord->data.F32[0] = Xv;
+            coord->data.F32[1] = Yv;
             x->data[nPix] = (psPtr *) coord;
             y->data.F32[nPix] = source->pixels->data.F32[i][j];
