Index: trunk/ppImage/src/ppImageAstrom.c
===================================================================
--- trunk/ppImage/src/ppImageAstrom.c	(revision 11352)
+++ trunk/ppImage/src/ppImageAstrom.c	(revision 12807)
@@ -17,65 +17,17 @@
     // find or define a pmFPAfile PSPHOT.INPUT
     pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSASTRO.INPUT");
-    if (!status) {
-	// psphotReadout requires a pmFPAfile supplied with the name PSASTRO.INPUT
-	// create a pmFPAfile which points at PSPHOT.OUTPUT
-	// mode is 'REFERENCE' to prevent double frees of the fpa
-	pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
-	input = pmFPAfileDefineInput (config, output->fpa, "PSASTRO.INPUT");
-	input->mode = PM_FPA_MODE_REFERENCE;
-
-	pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT");
-    }
+    PS_ASSERT (input, false);
 
     // convert the output sources created by psphot into astrometry objects
     if (!psastroConvertFPA (input->fpa, recipe)) {
-	psErrorStackPrint(stderr, "error loading input data\n");
-	exit (1);
+	psError (PSASTRO_ERR_UNKNOWN, false, "error reading input data\n");
+	return false;
     }
 
-    // interpret the available initial astrometric information
-    // apply the initial guess
-    if (!psastroAstromGuess (config)) {
-	psErrorStackPrint(stderr, "failed to determine initial astrometry guess\n");
-	exit (1);
+    if (!psastroAnalysis (config)) {
+	psError (PSASTRO_ERR_UNKNOWN, false, "failure in psastro analysis\n");
+	return false;
     }
 
-    // load the reference stars overlapping the data stars
-    psArray *refs = psastroLoadRefstars(config);
-    if (!refs) {
-	psErrorStackPrint(stderr, "failed to load reference data\n");
-	exit (1);
-    }
-
-    if (!psastroChooseRefstars (config, refs)) {
-	psErrorStackPrint(stderr, "failed to select reference data for chips\n");
-	exit (1);
-    }
-
-    // XXX does this check the recipe??
-    bool chipastro = psMetadataLookupBool (NULL, config->arguments, "PSASTRO.CHIP.MODE");
-    bool mosastro  = psMetadataLookupBool (NULL, config->arguments, "PSASTRO.MOSAIC.MODE");
-    if (!chipastro && !mosastro) {
-	psLogMsg ("psastro", 3, "no astrometry mode selected, assuming chip mode\n");
-	chipastro= true;
-    }
-
-    if (chipastro) {
-      if (!psastroChipAstrom (config, refs)) {
-	    psErrorStackPrint(stderr, "failed to perform single chip astrometry\n");
-	    exit (1);
-	}
-    } 
-    if (mosastro) {
-	if (!psastroMosaicAstrom (config, refs)) {
-	    psErrorStackPrint(stderr, "failed to perform mosaic camera astrometry\n");
-	    exit (1);
-	}
-    }
-
-    // XXX should this be left to the ppImageLoop?
-    psastroDataSave (config);
-
-    psFree (refs);
     return true;
 }
