Index: /trunk/pswarp/src/pswarp.h
===================================================================
--- /trunk/pswarp/src/pswarp.h	(revision 18178)
+++ /trunk/pswarp/src/pswarp.h	(revision 18179)
@@ -14,4 +14,7 @@
 #define PSWARP_RECIPE  "PSWARP" // Name of the recipe to use
 #define PSASTRO_RECIPE "PSASTRO" // Name of the recipe to use
+
+#define PSWARP_ANALYSIS_VARFACTOR "PSWARP.VARFACTOR" // Name for variance factor in analysis metadata
+#define PSWARP_ANALYSIS_GOODPIX   "PSWARP.GOODPIX" // Name for number of good pixels in analysis metadata
 
 // a single pswarpMap converts coordinates from one image to a second image
Index: /trunk/pswarp/src/pswarpLoop.c
===================================================================
--- /trunk/pswarp/src/pswarpLoop.c	(revision 18178)
+++ /trunk/pswarp/src/pswarpLoop.c	(revision 18179)
@@ -253,4 +253,21 @@
     }
 
+    // Set variance factor
+    {
+        float varFactor = psMetadataLookupF32(NULL, output->analysis, PSWARP_ANALYSIS_VARFACTOR);
+        psAssert(isfinite(varFactor), "Should be something here.");
+        long goodPix = psMetadataLookupS64(NULL, output->analysis, PSWARP_ANALYSIS_GOODPIX);
+        psAssert(goodPix > 0, "Should be something here.");
+        varFactor /= goodPix;
+
+        psMetadataItem *vfItem = psMetadataLookup(outCell->concepts, "CELL.VARFACTOR"); // Item to update
+        psAssert(vfItem && vfItem->type == PS_TYPE_F64, "Concept should be as specified.");
+        if (!isfinite(vfItem->data.F64)) {
+            vfItem->data.F64 = varFactor;
+        } else {
+            vfItem->data.F64 *= varFactor;
+        }
+    }
+
     if (!pmConceptsAverageCells(outCell, cells, NULL, NULL, false)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts.");
Index: /trunk/pswarp/src/pswarpTransformReadout_Opt.c
===================================================================
--- /trunk/pswarp/src/pswarpTransformReadout_Opt.c	(revision 18178)
+++ /trunk/pswarp/src/pswarpTransformReadout_Opt.c	(revision 18179)
@@ -86,5 +86,5 @@
 
     // Iterate over the output image pixels (parent frame)
-    bool goodPixels = false;            // Any input pixels landing on the output image?
+    long goodPixels = 0;                // Number of input pixels landing on the output image
     for (int y = minY; y < maxY; y++) {
         if (y >= nextGridY) {
@@ -117,5 +117,5 @@
             if (inPix->y - inRow0 >= inImage->numRows) continue;
 
-            goodPixels = true;
+            goodPixels++;
 
             // XXX include mask
@@ -146,7 +146,28 @@
     psFree(grid);
 
+    // Store the variance factor and number of good pixels
+    if (goodPixels > 0) {
+        float varFactor = psImageInterpolateVarianceFactor(output->image->numCols, output->image->numRows,
+                                                           interp); // Variance factor: large --> small scale
+        psMetadataItem *vfItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_VARFACTOR);
+        if (vfItem) {
+            psMetadataItem *goodpixItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_GOODPIX);
+            psAssert(goodpixItem, "It should be where we left it!");
+            psAssert(vfItem->type == PS_TYPE_F32 && goodpixItem->type == PS_TYPE_S64,
+                     "Should be the type we said.");
+
+            vfItem->data.F32 += varFactor * goodPixels;
+            goodpixItem->data.S64 += goodPixels;
+        } else {
+            psMetadataAddF32(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_VARFACTOR, 0,
+                             "Variance factor weighted by the good pixels", varFactor * goodPixels);
+            psMetadataAddS64(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_GOODPIX, 0,
+                             "Number of good pixels", goodPixels);
+        }
+    }
+
     // Transform sources
     psArray *inSources = psMetadataLookupPtr(&mdok, input->analysis, "PSPHOT.SOURCES"); // Sources in source
-    if (goodPixels && mdok && inSources) {
+    if (goodPixels > 0 && mdok && inSources) {
         pswarpMapGrid *sourceGrid = pswarpMapGridFromImage(output, input, nGridX, nGridY); // Grid for sources
 
