Index: trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 8815)
+++ trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 9527)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA; GLG, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-15 09:49:01 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-13 02:24:34 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -95,6 +95,6 @@
     }
 
-    if (model->dparams->data.F32[1] > 0) {
-        SN = model->params->data.F32[1] / model->dparams->data.F32[1];
+    if (model->dparams->data.F32[PM_PAR_FLUX] > 0) {
+        SN = model->params->data.F32[PM_PAR_FLUX] / model->dparams->data.F32[PM_PAR_FLUX];
         source->errMag = 1.0 / SN;
     } else {
@@ -102,6 +102,6 @@
         source->errMag = 0.0;
     }
-    x = model->params->data.F32[2];
-    y = model->params->data.F32[3];
+    x = model->params->data.F32[PM_PAR_XPOS];
+    y = model->params->data.F32[PM_PAR_YPOS];
 
     // measure object model photometry
@@ -194,5 +194,5 @@
 
     if (DO_SKY) {
-        sky = model->params->data.F32[0];
+        sky = model->params->data.F32[PM_PAR_SKY];
     } else {
         sky = 0;
@@ -233,5 +233,5 @@
     // we only care about the value of the object model, not the local sky
     if (DO_SKY) {
-        sky = model->params->data.F32[0];
+        sky = model->params->data.F32[PM_PAR_SKY];
     } else {
         sky = 0;
@@ -245,6 +245,6 @@
     psVector *params = model->params;
 
-    Xo = params->data.F32[2];
-    Yo = params->data.F32[3];
+    Xo = params->data.F32[PM_PAR_XPOS];
+    Yo = params->data.F32[PM_PAR_YPOS];
 
     dX = Xo - image->col0;
@@ -297,5 +297,7 @@
 }
 
-float pmSourceCrossProduct (pmSource *Mi, pmSource *Mj)
+double pmSourceCrossProduct (const pmSource *Mi,
+                             const pmSource *Mj,
+                             const bool unweighted_sum) // should the cross product be weighted?
 {
 
@@ -304,13 +306,13 @@
     int xIs, xJs, yIs, yJs;
     int xIe, yIe;
-    float flux, wt;
-
-    psImage *Pi = Mi->pixels;
-    psImage *Pj = Mj->pixels;
-
-    psImage *Wi = Mi->weight;
-
-    psImage *Ti = Mi->mask;
-    psImage *Tj = Mj->mask;
+    double flux, wt;
+
+    const psImage *Pi = Mi->pixels;
+    const psImage *Pj = Mj->pixels;
+
+    const psImage *Wi = Mi->weight;
+
+    const psImage *Ti = Mi->mask;
+    const psImage *Tj = Mj->mask;
 
     Xs = PS_MAX (Pi->col0, Pj->col0);
@@ -337,14 +339,21 @@
             if (Tj->data.U8[yj][xj])
                 continue;
-            wt = Wi->data.F32[yi][xi];
-            if (wt > 0) {
-                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
+
+            if (unweighted_sum) {
+                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
+            } else {
+                wt = Wi->data.F32[yi][xi];
+                if (wt > 0) {
+                    flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
+                }
             }
         }
     }
-    return (flux);
-}
-
-float pmSourceCrossWeight (pmSource *Mi, pmSource *Mj)
+    return flux;
+}
+
+double pmSourceCrossWeight(const pmSource *Mi,
+                           const pmSource *Mj,
+                           const bool unweighted_sum) // should the cross product be weighted?
 {
 
@@ -353,13 +362,13 @@
     int xIs, xJs, yIs, yJs;
     int xIe, yIe;
-    float flux, wt;
-
-    psImage *Pi = Mi->pixels;
-    psImage *Pj = Mj->pixels;
-
-    psImage *Wi = Mi->weight;
-
-    psImage *Ti = Mi->mask;
-    psImage *Tj = Mj->mask;
+    double flux, wt;
+
+    const psImage *Pi = Mi->pixels;
+    const psImage *Pj = Mj->pixels;
+
+    const psImage *Wi = Mi->weight;
+
+    const psImage *Ti = Mi->mask;
+    const psImage *Tj = Mj->mask;
 
     Xs = PS_MAX (Pi->col0, Pj->col0);
@@ -386,11 +395,16 @@
             if (Tj->data.U8[yj][xj])
                 continue;
-            wt = Wi->data.F32[yi][xi];
-            if (wt > 0) {
-                flux += 1.0 / wt;
+
+            if (unweighted_sum) {
+                flux++;
+            } else {
+                wt = Wi->data.F32[yi][xi];
+                if (wt > 0) {
+                    flux += 1.0 / wt;
+                }
             }
         }
     }
-    return (flux);
-}
-
+    return flux;
+}
+
