Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c	(revision 36155)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c	(revision 36156)
@@ -200,4 +200,7 @@
     int psfSize             	   = PS_SCALAR_VALUE(job->args->data[5],S32);
 
+    float fitRadius;
+    float windowRadius;
+
     for (int i = 0; i < sources->n; i++) {
 
@@ -240,10 +243,9 @@
 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, int psfSize) {
 
-    // allocate the model
-    // XXX need to figure out how to get the model into the program
-    pmModelType modelType = pmModelClassGetType ("PS_MODEL_EXP");
-
+    // we use the 0th model to define the initial guess shape
     pmModel *model = source->modelFits->data[0];
     if (!model) return false;
+
+    pmModelType modelType = model->type;
 
     // we are using fitOptions->mode : be sure this makes sense
@@ -261,4 +263,8 @@
     // I am going to retain the value of e0, and grid search around e1,e2
     // I need to study a valid range (and distribution?) for e1,e2)
+
+    if (!source->galaxyFits) {
+      source->galaxyFits = pmSourceGalaxyFitsAlloc();
+    }
 
     for (float de1 = -0.2; de1 <= +0.2; de1 += 0.1) {
@@ -292,4 +298,5 @@
     pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);
 	
+    int nPix = 0;
     float YY = 0.0;
     float YM = 0.0;
@@ -307,4 +314,5 @@
 		continue;
 	    }
+
 	    // skip nan value points
 	    if (!isfinite(source->pixels->data.F32[iy][ix])) {
@@ -319,12 +327,19 @@
 	    YM += fm * fy * wt;
 	    MM += PS_SQR(fm) * wt;
+	    nPix ++;
 	}
     }
 
     float Io = YM / MM;
+    float dIo = sqrt (1.0 / MM);
     float Chisq = YY - 2 * Io * YM + Io * Io * MM;
 
     fprintf (stderr, "Io: %f, Chisq: %f\n", Io, Chisq);
 
-    return true;
-}
+    psVectorAppend (source->galaxyFits->Io, Io);
+    psVectorAppend (source->galaxyFits->dIo, dIo);
+    psVectorAppend (source->galaxyFits->chisq, Chisq);
+    source->galaxyFits->nPix = nPix;
+
+    return true;
+}
Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotMergeSources.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotMergeSources.c	(revision 36155)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotMergeSources.c	(revision 36156)
@@ -76,4 +76,5 @@
     bool status;
     pmDetections *extCMF = NULL;
+    pmDetections *extCFF = NULL;
     psArray *extSourcesTXT = NULL;
     int index = 0;
Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotPetroFlux.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotPetroFlux.c	(revision 36155)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotPetroFlux.c	(revision 36156)
@@ -1,3 +1,5 @@
 # include "psphotInternal.h"
+
+# define PETROSIAN_RADII 2.0
 
 bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule)
