Index: trunk/pswarp/src/pswarpTransformTile.c
===================================================================
--- trunk/pswarp/src/pswarpTransformTile.c	(revision 21323)
+++ trunk/pswarp/src/pswarpTransformTile.c	(revision 21368)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-05 20:44:04 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 03:10:36 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -20,4 +20,5 @@
     psFree(args->interp);
     psFree(args->region);
+    psFree(args->covariance);
     return;
 }
@@ -42,4 +43,5 @@
     args->yMin = PS_MAX_S32;
     args->yMax = PS_MIN_S32;
+    args->covariance = NULL;
 
     return args;
@@ -60,5 +62,5 @@
     // Dereference images for convenience
     psF32 **outImageData     = args->output->image->data.F32;
-    psF32 **outVarData       = (args->output->weight) ? args->output->weight->data.F32 : NULL;
+    psF32 **outVarData       = (args->output->variance) ? args->output->variance->data.F32 : NULL;
     psImageMaskType **outMaskData = (args->output->mask)   ? args->output->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
     psImageMaskType **inMaskData  = (args->input->mask)    ? args->input->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
@@ -92,9 +94,7 @@
             }
 
-	    double imageValue, varValue; // Value of image and variance map
-
             // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates
+            double imageValue, varValue; // Value of image and variance map
             psImageMaskType maskValue = inMaskData ? inMaskData[(int)yIn][(int)xIn] : 0; // Value of mask
-
             if (!psImageInterpolate(&imageValue, &varValue, &maskValue, xIn, yIn, args->interp)) {
                 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
@@ -118,4 +118,17 @@
     }
 
+    if (goodPixels > 0) {
+        float xOut = 0.5 * (xMin + xMax), yOut = 0.5 * (yMin + yMax); // Position of interest on output
+        double xIn, yIn;                // Position of interest on input
+        pswarpMapApply(&xIn, &yIn, map, xOut + 0.5, yOut + 0.5);
+        // XXX Why are we subtracting the *output* col0,row0 from the *input* coordinates?
+        // I expect these are zero, so that it makes no difference, but it's distracting.
+        xIn -= outCol0;
+        yIn -= outRow0;
+        psKernel *kernel = psImageInterpolationKernel(xIn, yIn, args->interp->mode); // Interpolation kernel
+        args->covariance = psImageCovarianceCalculate(kernel, args->input->covariance);
+        psFree(kernel);
+    }
+
     args->goodPixels = goodPixels;
     args->xMin = xMin;
