Index: /trunk/magic/censorObjects/src/censorLoop.c
===================================================================
--- /trunk/magic/censorObjects/src/censorLoop.c	(revision 25079)
+++ /trunk/magic/censorObjects/src/censorLoop.c	(revision 25080)
@@ -22,5 +22,5 @@
  */
 bool censorLoop (pmConfig *config) {
-
+  //bool status;
     pmChip *chip;
     pmCell *cell;
@@ -28,4 +28,7 @@
 
     psTimerStart ("censor");
+
+
+
 
     // select the current recipe
@@ -35,4 +38,12 @@
 	return false;
     }
+
+    // physical pixel scale in microns per pixel
+    //double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE");
+    //if (!status) {
+    //    psError(PS_ERR_IO, true, "Failed to lookup pixel scale"); 
+    //    return false; 
+    //} 
+
 
     // select the input data sources
@@ -50,5 +61,16 @@
     }
 
+    
+#if 0    
+    pmFPAfileActivate(config->files, false, NULL);
+    pmFPAfileActivate(config->files, true, "CENSOR.INPUT");
+#endif
+
     pmFPAview *view = pmFPAviewAlloc (0);
+
+
+
+
+
     bool badMaskFile = false;
 
@@ -59,12 +81,50 @@
     if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
 
+
+// check PHU header to see if we are using mosaic-level or per-chip astrometry
+    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);
+    } 
+
+
+
     while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
 	psTrace ("censor", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
 	if (!chip->process || !chip->file_exists) { continue; }
-
+	
 	// check on the mask file at this level if possible
 	badMaskFile = censorBadFileByView(badMaskFile, inMask, config, view);
 
 	if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
+
+	// read WCS data from the corresponding header
+
+	pmHDU *hdu = pmFPAviewThisHDU (view, input->fpa);
+	
+	//	int nAstro = psMetadataLookupS32 (&status, hdu->header, "NASTRO");
+	//	if (!nAstro) {psLogMsg ("censor", 3, "nothing %f sec\n", psTimerMark ("censor"));}
+	
+	//continue;
+	if (bilevelAstrometry) {
+	  if (!pmAstromReadBilevelChip (chip, hdu->header)) {
+	    psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 
+	    continue;
+	  }
+	} else {
+	  if (!pmAstromReadWCS(input->fpa, chip, hdu->header, 1.0)) {
+	    psWarning( "Unable to read WCS astrometry from chip %d, skipping", view->chip);
+	    continue;
+	  }
+	}
+
+
+	
+
 
 	while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
