Index: trunk/stac/src/stacTransform.c
===================================================================
--- trunk/stac/src/stacTransform.c	(revision 2783)
+++ trunk/stac/src/stacTransform.c	(revision 3375)
@@ -1,3 +1,4 @@
 #include <stdio.h>
+#include <assert.h>
 #include "pslib.h"
 #include "stac.h"
@@ -120,16 +121,9 @@
 
     // Check input sizes
-    if (images->n != maps->n) {
-	psError("stac.transform", "Number of maps (%d) does not match number of images (%d).\n",
-		maps->n, images->n);
-	return false;
-    }
-    if (errors && (images->n != errors->n)) {
-	psError("stac.transform", "Number of error images (%d) does not match number of images (%d).\n",
-		errors->n, images->n);
-	return false;
-    }
+    assert(images->n == maps->n);
+    assert(!errors || (images->n == errors->n));
 
     // Allocate the output images if required, otherwise check the number
+    assert(!*outputs || (*outputs)->n == nImages);
     if (*outputs == NULL) {
 	*outputs = psArrayAlloc(nImages);
@@ -138,11 +132,8 @@
 	    (*outputs)->data[i] = psImageAlloc(nx, ny, PS_TYPE_F32);
 	}
-    } else if ((*outputs)->n != nImages) {
-	psError("stac.transform", "Number of output images (%d) does not match number of input images "
-		"(%d).\n", (*outputs)->n, nImages);
-	return false;
     }
 
     // Allocate the output error images, if required, otherwise check the number
+    assert(!errors || ! *outErrors || errors->n == (*outErrors)->n);
     if (errors && (*outErrors == NULL)) {
 	*outErrors = psArrayAlloc(errors->n);
@@ -151,26 +142,13 @@
 	    (*outErrors)->data[i] = psImageAlloc(nx, ny, PS_TYPE_F32);
 	}
-    } else if (errors->n != (*outErrors)->n) {
-	psError("stac.transform", "Number of error output images (%d) does not match number of input"
-		"images (%d).\n", (*outErrors)->n, errors->n);
-	return false;
     }
 
     // Check the masks, if specified
+    assert(!masks || masks->n == nImages);
     if (masks != NULL) {
-	if (masks->n != nImages) {
-	    psError("stac.transform", "Number of masks (%d) does not match number of input images (%d).\n",
-		    masks->n, nImages);
-	    return false;
-	}
 	for (int i = 0; i < nImages; i++) {
 	    psImage *image = images->data[i];
 	    psImage *mask = masks->data[i];
-	    if ((mask->numRows != image->numRows) || (mask->numCols != image->numCols)) {
-		psError ("stac.transform",
-			 "Size of input mask (%dx%d) does not match that of input image (%dx%d).\n",
-			 mask->numCols, mask->numRows, image->numCols, image->numRows);
-		return false;
-	    }
+	    assert(mask->numRows == image->numRows && mask->numCols == image->numCols);
 	}
     }
@@ -236,12 +214,23 @@
 #ifdef TESTING
 	// Write error image out to check
-	char shiftfile[MAXCHAR];	// Filename of shift image
-	char errfile[MAXCHAR];		// Filename of error image
-	sprintf(shiftfile,"%s.shift.%d",config->inputs->data[n],numTransforms);
-	sprintf(errfile,"%s.shifterr.%d",config->inputs->data[n],numTransforms);
+	char shiftName[MAXCHAR];	// Filename of shift image
+	char errName[MAXCHAR];		// Filename of error image
+	sprintf(shiftName,"%s.shift.%d",config->inputs->data[n],numTransforms);
+	sprintf(errName,"%s.shifterr.%d",config->inputs->data[n],numTransforms);
 	psTrace("stac.transform.test", 6,
 		"Output files have size: %dx%d\n",outImage->numCols,outImage->numRows);
-	psImageWriteSection(outImage,0,0,0,NULL,0,shiftfile);
-	psImageWriteSection(outError,0,0,0,NULL,0,errfile);
+
+	psFits *shiftFile = psFitsAlloc(shiftName);
+	psFits *errFile = psFitsAlloc(errName);
+	if (!psFitsWriteImage(shiftFile, NULL, outImage, 0, NULL)) {
+	    psErrorStackPrint(stderr, "Unable to write image: %s\n", shiftName);
+	}
+	psTrace("stac", 1, "Shifted image written to %s\n", shiftName);
+	if (!psFitsWriteImage(errFile, NULL, outError, 0, NULL)) {
+	    psErrorStackPrint(stderr, "Unable to write image: %s\n", errName);
+	}
+	psTrace("stac", 1, "Shifted error image written to %s\n", errName);
+	psFree(shiftFile);
+	psFree(errFile);
 #endif
 
