Index: branches/eam_branches/ipp-20120601/psphot/src/psphotReadout.c
===================================================================
--- branches/eam_branches/ipp-20120601/psphot/src/psphotReadout.c	(revision 34071)
+++ branches/eam_branches/ipp-20120601/psphot/src/psphotReadout.c	(revision 34072)
@@ -9,4 +9,49 @@
 }
 
+# if (0)
+// TEST CODE, can be removed
+bool psphotDumpFlux (pmConfig *config, const pmFPAview *view, const char *filerule) {
+
+    bool status = false;
+
+    // find the currently selected readout
+    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest
+    psAssert (file, "missing file?");
+
+    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
+    psAssert (readout, "missing readout?");
+
+    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
+    psAssert (detections, "missing detections?");
+
+    psArray *sources = detections->allSources;
+    psAssert (sources, "missing sources?");
+
+    static int npass;
+    char filename[64];
+    snprintf (filename, 64, "mags.%d.dat", npass);
+    FILE *ftest = fopen (filename, "w");
+    for (int j = 0; j < sources->n; j++) {
+	pmSource *source = sources->data[j];
+
+	float psfMag;
+	status = pmSourcePhotometryModel (&psfMag, NULL, source->modelPSF);
+
+	float psfMagNorm;
+	float Io = source->modelPSF->params->data.F32[PM_PAR_I0];
+	source->modelPSF->params->data.F32[PM_PAR_I0] = 1.0;
+	status = pmSourcePhotometryModel (&psfMagNorm, NULL, source->modelPSF);
+	source->modelPSF->params->data.F32[PM_PAR_I0] = Io;
+
+	// double apTrend = pmTrend2DEval (psf->ApTrend, (float)source->peak->x, (float)source->peak->y);
+	fprintf (ftest, "%d %d %d  %f %f %f %f  %f %f\n", j, source->peak->x, source->peak->y, source->modelPSF->params->data.F32[PM_PAR_I0], source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SYY], source->modelPSF->params->data.F32[PM_PAR_SXY], psfMag, psfMagNorm);
+    }
+    fclose (ftest);
+    npass++;
+
+    return true;
+}
+# endif
+
 bool psphotReadout(pmConfig *config, const pmFPAview *view, const char *filerule) {
 
Index: branches/eam_branches/ipp-20120601/psphot/test/tap_psphot_varmodel.pro
===================================================================
--- branches/eam_branches/ipp-20120601/psphot/test/tap_psphot_varmodel.pro	(revision 34071)
+++ branches/eam_branches/ipp-20120601/psphot/test/tap_psphot_varmodel.pro	(revision 34072)
@@ -89,4 +89,8 @@
         sprintf name "test/test.%02d.%02d.%s" $sky {10*$fwhm} $psf_in
         # mkexp $name $sky $fwhm $psf_in
+	data $name.dat
+	read fluxIn 3 MagPredIn 5
+	set MagRealIn = -2.5*log(fluxIn)
+	set dMagIn = MagRealIn - MagPredIn
         
         foreach psf_out GAUSS PS1_V1
@@ -270,5 +274,5 @@
   section a1 0.0 0.50 1.0 0.25
   lim rv -0.025 0.075; label -fn courier 14; box; 
-  plot -c black -pt 0 -sz 0.3 MagPredIn dMagIn
+  # plot -c black -pt 0 -sz 0.3 MagPredIn dMagIn
   plot -c red   -pt 7 -sz 2.0 imag_V dmag_V
   plot -c darkgreen -pt 3 -sz 2.0 imag_V Dmag_V
@@ -279,4 +283,9 @@
   sprintf line "OFFSET: %6.3f" $offset
   textline -frac 0.1 0.8 -fn courier 24 "$line"
+
+  subset dmsub = delta if (rv < -13) && (rv > -16)
+  vstat -q dmsub
+  sprintf line "STDEV: %6.3f" $SIGMA
+  textline -frac 0.1 0.7 -fn courier 24 "$line"
 
 
