Index: trunk/ppSub/src/ppSubReadoutPhotometry.c
===================================================================
--- trunk/ppSub/src/ppSubReadoutPhotometry.c	(revision 21360)
+++ trunk/ppSub/src/ppSubReadoutPhotometry.c	(revision 21374)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-06 01:37:17 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 03:20:02 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -25,7 +25,7 @@
 
     if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
-	pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
-	pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
-	return true;
+        pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
+        pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
+        return true;
     }
 
@@ -40,6 +40,6 @@
     pmPSF *psf = psMetadataLookupPtr(NULL, psfInputChip->analysis, "PSPHOT.PSF");
     if (!psf) {
-	psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF from psphot");
-	return false;
+        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF from psphot");
+        return false;
     }
     psMetadataAddPtr(psfLoadChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "PSF from matched addition", psf);
@@ -55,19 +55,19 @@
     pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
     if (!photRO) {
-	pmCell *cell = pmFPAfileThisCell(config->files, view, "PSPHOT.RESID"); // Output cell
-	photRO = pmReadoutAlloc(cell); // Output readout: subtraction
+        pmCell *cell = pmFPAfileThisCell(config->files, view, "PSPHOT.RESID"); // Output cell
+        photRO = pmReadoutAlloc(cell); // Output readout: subtraction
     }
     photRO->image = psImageCopy(photRO->image, outRO->image, PS_TYPE_F32);
-    if (outRO->weight) {
-	photRO->weight = psImageCopy(photRO->weight, outRO->weight, PS_TYPE_F32);
+    if (outRO->variance) {
+        photRO->variance = psImageCopy(photRO->variance, outRO->variance, PS_TYPE_F32);
     } else {
-	psFree (photRO->weight);
-	photRO->weight = NULL;
+        psFree (photRO->variance);
+        photRO->variance = NULL;
     }
     if (outRO->mask) {
-	photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK);
+        photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK);
     } else {
-	psFree (photRO->mask);
-	photRO->mask = NULL;
+        psFree (photRO->mask);
+        photRO->mask = NULL;
     }
 
@@ -77,20 +77,20 @@
     // old-style variance renormalization
     if (!ppSubReadoutRenormPhot (config, recipe, photRO)) {
-	psError(PS_ERR_UNKNOWN, false, "failure in renormalization");
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "failure in renormalization");
+        return false;
     }
 
     if (!psphotReadoutMinimal(config, view)) {
-	psWarning("Unable to perform photometry on subtracted image.");
-	psErrorStackPrint(stderr, "Error stack from photometry:");
-	psErrorClear();
+        psWarning("Unable to perform photometry on subtracted image.");
+        psErrorStackPrint(stderr, "Error stack from photometry:");
+        psErrorClear();
     }
 
     if (stats) {
-	psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
-	psMetadataAddS32(stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected",
-			 sources ? sources->n : 0);
-	psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry",
-			 psTimerClear("PPSUB_PHOT"));
+        psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
+        psMetadataAddS32(stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected",
+                         sources ? sources->n : 0);
+        psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry",
+                         psTimerClear("PPSUB_PHOT"));
     }
 
@@ -103,8 +103,8 @@
     // XXX not sure that this is still needed (only if psphotReadoutMinimal measures the background)
     // if (!pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL") ||
-    // 	!pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||
-    // 	!pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {
-    // 	psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");
-    // 	return false;
+    //  !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||
+    //  !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {
+    //  psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");
+    //  return false;
     // }
 
@@ -116,44 +116,44 @@
     // Record data about sources: not everything gets into the output CMF files
     {
-	pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
-	psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
-	FILE *sourceFile = fopen("sources.dat", "w"); // File for sources
-	fprintf(sourceFile,
-		"# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n");
-	for (int i = 0; i < sources->n; i++) {
-	    pmSource *source = sources->data[i];
-	    if (!source) {
-		continue;
-	    }
+        pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
+        psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
+        FILE *sourceFile = fopen("sources.dat", "w"); // File for sources
+        fprintf(sourceFile,
+                "# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n");
+        for (int i = 0; i < sources->n; i++) {
+            pmSource *source = sources->data[i];
+            if (!source) {
+                continue;
+            }
 
-	    float x, y;             // Position of source
-	    float chi2;             // chi^2 for source
-	    if (source->modelPSF) {
-		x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
-		y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
-		chi2 = source->modelPSF->chisq;
-	    } else if (source->peak) {
-		x = source->peak->xf;
-		y = source->peak->yf;
-		chi2 = NAN;
-	    } else {
-		psWarning("No position available for source.");
-		continue;
-	    }
+            float x, y;             // Position of source
+            float chi2;             // chi^2 for source
+            if (source->modelPSF) {
+                x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
+                y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
+                chi2 = source->modelPSF->chisq;
+            } else if (source->peak) {
+                x = source->peak->xf;
+                y = source->peak->yf;
+                chi2 = NAN;
+            } else {
+                psWarning("No position available for source.");
+                continue;
+            }
 
-	    float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN;
-	    if (source->moments) {
-		xMoment = source->moments->Mx;
-		yMoment = source->moments->My;
-		xxMoment = source->moments->Mxx;
-		xyMoment = source->moments->Mxy;
-		yyMoment = source->moments->Myy;
-	    }
+            float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN;
+            if (source->moments) {
+                xMoment = source->moments->Mx;
+                yMoment = source->moments->My;
+                xxMoment = source->moments->Mxx;
+                xyMoment = source->moments->Mxy;
+                yyMoment = source->moments->Myy;
+            }
 
-	    fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f\n",
-		    x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma,
-		    source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment);
-	}
-	fclose(sourceFile);
+            fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f\n",
+                    x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma,
+                    source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment);
+        }
+        fclose(sourceFile);
     }
 #endif
