Index: trunk/pswarp/src/pswarpDataLoad.c
===================================================================
--- trunk/pswarp/src/pswarpDataLoad.c	(revision 10952)
+++ trunk/pswarp/src/pswarpDataLoad.c	(revision 10954)
@@ -32,9 +32,24 @@
 
     // de-activate PSWARP.SKYCELL and PSWARP.OUTPUT
-    // 
+    pmFPAfileActivate (config->files, false, "PSWARP.SKYCELL");
     pmFPAfileActivate (config->files, false, "PSWARP.OUTPUT");
-    pmFPAfileActivate (config->files, false, "PSWARP.SKYCELL");
 
     pmFPAview *view = pmFPAviewAlloc (0);
+
+    // find the FPA phu
+    // XXX wrap the test below into a function
+    // XXX need to read only the headers for the skycell
+    // XXX need to optionally load the astrometry datafile
+    bool bilevelAstrometry = false;
+    pmHDU *phu = pmFPAviewThisPHU (view, input->fpa);
+    if (phu) {
+      char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
+      if (ctype) {
+	bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
+      }
+    }
+    if (bilevelAstrometry) {
+      pmAstromReadBilevelMosaic (input->fpa, phu->header);
+    } 
 
     // files associated with the science image
@@ -45,4 +60,14 @@
         if (!chip->process || !chip->file_exists) { continue; }
 	pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
+
+        // read WCS data from the corresponding header
+	pmHDU *hdu = pmFPAviewThisHDU (view, input->fpa);
+	if (bilevelAstrometry) {
+	  pmAstromReadBilevelChip (chip, hdu->header); 
+	} else {
+	  // XXX get pixelScale from recipes.  does it matter?
+	  float pixelScale = 13.5;
+	  pmAstromReadWCS (input->fpa, chip, hdu->header, pixelScale);
+	}
 
 	while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
@@ -56,5 +81,5 @@
 		if (! readout->data_exists) { continue; }
 
-		pswarpConvertReadout (output, readout, config);
+		pswarpTransformReadout (output, readout, config);
 
 		pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
