Index: /trunk/pswarp/src/pswarpLoop.c
===================================================================
--- /trunk/pswarp/src/pswarpLoop.c	(revision 14209)
+++ /trunk/pswarp/src/pswarpLoop.c	(revision 14210)
@@ -1,4 +1,6 @@
 # include "pswarp.h"
 #include <ppStats.h>
+
+#define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
 
 // Loop over the inputs, warp them to the output skycell and then write out the output.
@@ -20,4 +22,9 @@
     if (!astrom) {
         astrom = input;
+    }
+
+    if (astrom->camera != input->camera) {
+        psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match.");
+        return false;
     }
 
@@ -89,7 +96,7 @@
     // find the FPA phu
     bool bilevelAstrometry = false;
-    pmHDU *phu = pmFPAviewThisPHU (view, astrom->fpa);
+    pmHDU *phu = pmFPAviewThisPHU(view, astrom->fpa);
     if (phu) {
-        char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
+        char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1");
         if (ctype) {
             bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
@@ -208,5 +215,4 @@
 #endif
 
-
     // Perform statistics on the output image
     if (stats) {
@@ -216,7 +222,13 @@
     }
 
-    pmHDU *hdu = output->parent->parent->parent->hdu; // HDU for the output warped image
+    pmHDU *hdu = outFPA->hdu;           // HDU for the output warped image
     if (!hdu->header) {
         hdu->header = psMetadataAlloc();
+    }
+
+    if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to generate WCS header.");
+        psFree(stats);
+        return false;
     }
 
Index: /trunk/pswarp/src/pswarpParseCamera.c
===================================================================
--- /trunk/pswarp/src/pswarpParseCamera.c	(revision 14209)
+++ /trunk/pswarp/src/pswarpParseCamera.c	(revision 14210)
@@ -17,5 +17,5 @@
     // the input image(s) are required arguments; they define the camera
     status = false;
-    pmFPAfile *astrom = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.ASTROM", "ASTROM");
+    pmFPAfile *astrom = pmFPAfileDefineFromArgs(&status, config, "PSWARP.ASTROM", "ASTROM");
     if (!status) {
         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
