Index: trunk/psastro/src/psastroAstromGuess.c
===================================================================
--- trunk/psastro/src/psastroAstromGuess.c	(revision 15200)
+++ trunk/psastro/src/psastroAstromGuess.c	(revision 15891)
@@ -32,4 +32,10 @@
     }
 
+    // have we already supplied the astrometry from the model?
+    bool useModel = psMetadataLookupBool (&status, config->arguments, "PSASTRO.USE.MODEL");
+    if (!status) {
+	useModel = psMetadataLookupBool (&status, recipe, "PSASTRO.USE.MODEL");
+    }
+
     // select the input data sources
     pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
@@ -46,36 +52,19 @@
     } 
 
-    pmFPAview *view = pmFPAviewAlloc (0);
     pmFPA *fpa = input->fpa;
 
     // load mosaic-level astrometry?
     bool bilevelAstrometry = false;
-    pmHDU *phu = pmFPAviewThisPHU (view, fpa);
-    if (phu) {
-      char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
-      if (ctype) {
-	bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
-      }
+    if (!useModel) {
+	psastroAstromGuessSetFPA (fpa, &bilevelAstrometry);
     }
-    if (bilevelAstrometry) {
-      pmAstromReadBilevelMosaic (fpa, phu->header);
-    } 
 
+    pmFPAview *view = pmFPAviewAlloc (0);
     while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
         psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
         if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; }
 
-        // read WCS data from the corresponding header
-        pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
-	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 (fpa, chip, hdu->header, pixelScale)) {
-		psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 
-		continue;
-	    } 
+	if (!useModel) {
+	    if (!psastroAstromGuessSetChip (fpa, chip, view, pixelScale, bilevelAstrometry)) continue;
 	}
 
@@ -160,2 +149,41 @@
    sky (ra, dec)
 */
+
+bool psastroAstromGuessSetChip (pmFPA *fpa, pmChip *chip, pmFPAview *view, double pixelScale, bool bilevelAstrometry) {
+
+    // read WCS data from the corresponding header
+    pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
+    if (bilevelAstrometry) {
+	if (!pmAstromReadBilevelChip (chip, hdu->header)) {
+	    psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 
+	    return false;
+	} 
+    } else {
+	if (!pmAstromReadWCS (fpa, chip, hdu->header, pixelScale)) {
+	    psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 
+	    return false;
+	} 
+    }
+    return true;
+}
+
+bool psastroAstromGuessSetFPA (pmFPA *fpa, bool *bilevelAstrometry) {
+
+    pmFPAview *view = pmFPAviewAlloc (0);
+    pmHDU *phu = pmFPAviewThisPHU (view, fpa);
+
+    *bilevelAstrometry = false;
+
+    // load mosaic-level astrometry?
+    if (phu) {
+	char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
+	if (ctype) {
+	    *bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
+	}
+    }
+    if (*bilevelAstrometry) {
+	pmAstromReadBilevelMosaic (fpa, phu->header);
+    } 
+    psFree (view);
+    return true;
+}
