Index: /trunk/psastro/src/Makefile.am
===================================================================
--- /trunk/psastro/src/Makefile.am	(revision 12805)
+++ /trunk/psastro/src/Makefile.am	(revision 12806)
@@ -9,36 +9,44 @@
 
 psastro_SOURCES = \
-	psastro.c		
+	psastro.c		    \
+        psastroArguments.c	    \
+	psastroParseCamera.c   	    \
+	psastroDataLoad.c           \
+	psastroCleanup.c
+
+## move DataSave to psastro_SOURCES?
 
 libpsastro_la_SOURCES = \
-psastroArguments.c	    \
-psastroErrorCodes.c         \
-psastroVersion.c            \
-psastroCleanup.c            \
-psastroParseCamera.c   	    \
-psastroDataLoad.c           \
-psastroDataSave.c           \
-psastroAstromGuess.c        \
-psastroLoadRefstars.c       \
-psastroChooseRefstars.c     \
-psastroConvert.c	    \
-psastroChipAstrom.c         \
-psastroOneChip.c	    \
-psastroUtils.c	       	    \
-psastroTestFuncs.c          \
-psastroLuminosityFunction.c \
-psastroRefstarSubset.c      \
-psastroMosaicAstrom.c       \
-psastroMosaicGradients.c    \
-psastroMosaicChipAstrom.c   \
-psastroMosaicOneChip.c      \
-psastroMosaicSetAstrom.c    \
-psastroMosaicSetMatch.c     \
-psastroDemoDump.c           \
-psastroDemoPlot.c
+	psastroErrorCodes.c         \
+	psastroVersion.c            \
+	psastroDataSave.c           \
+	psastroDefineFiles.c        \
+	psastroAnalysis.c           \
+	psastroAstromGuess.c        \
+	psastroLoadRefstars.c       \
+	psastroChooseRefstars.c     \
+	psastroConvert.c	    \
+	psastroChipAstrom.c         \
+	psastroOneChip.c	    \
+	psastroUtils.c	       	    \
+	psastroTestFuncs.c          \
+	psastroLuminosityFunction.c \
+	psastroRefstarSubset.c      \
+	psastroMosaicAstrom.c       \
+	psastroMosaicGradients.c    \
+	psastroMosaicChipAstrom.c   \
+	psastroMosaicOneChip.c      \
+	psastroMosaicSetAstrom.c    \
+	psastroMosaicSetMatch.c     \
+	psastroDemoDump.c           \
+	psastroDemoPlot.c
 
 include_HEADERS = \
 	psastro.h \
 	psastroErrorCodes.h
+
+noinst_HEADERS = \
+	psastroInternal.h \
+	psastroStandAlone.h
 
 clean-local:
Index: /trunk/psastro/src/psastro.c
===================================================================
--- /trunk/psastro/src/psastro.c	(revision 12805)
+++ /trunk/psastro/src/psastro.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroStandAlone.h"
 
 static void usage (void) {
@@ -9,5 +9,4 @@
 
     pmConfig *config = NULL;
-    psArray *refs = NULL;
 
     psTimerStart ("complete");
@@ -36,49 +35,9 @@
     }
 
-    // interpret the available initial astrometric information
-    // apply the initial guess
-    if (!psastroAstromGuess (config)) {
-	psErrorStackPrint(stderr, "failed to determine initial astrometry guess\n");
+    if (!psastroAnalysis (config)) {
+	psErrorStackPrint(stderr, "failure in psastro analysis\n");
 	exit (1);
     }
-
-    // load the reference stars overlapping the data stars
-    refs = psastroLoadRefstars (config);
-    if (!refs) {
-	psErrorStackPrint(stderr, "failed to load reference data\n");
-	exit (1);
-    }
-
-    // choose reference stars corresponding to the selected chips
-    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 how do we specify stack astrometry?
-    // psastroStackAstrom (config, refs);
-
+    
     // write out the results
     if (!psastroDataSave (config)) {
@@ -89,5 +48,5 @@
     psLogMsg ("psastro", 3, "complete psastro run: %f sec\n", psTimerMark ("complete"));
 
-    psastroCleanup (config, refs);
+    psastroCleanup (config);
     exit (EXIT_SUCCESS);
 }
Index: /trunk/psastro/src/psastro.h
===================================================================
--- /trunk/psastro/src/psastro.h	(revision 12805)
+++ /trunk/psastro/src/psastro.h	(revision 12806)
@@ -1,15 +1,11 @@
-# ifdef HAVE_CONFIG_H
-# include <config.h>
-# endif
+/* This file defines the library functions available to external programs.  It must be included
+ * by programs which are compiled against psphot functions.
+ */
 
-# include <stdio.h>
-# include <string.h>
-# include <strings.h>  // for strcasecmp
-# include <unistd.h>   // for unlink
-# include <pslib.h>
-# include <psmodules.h>
+# ifndef PSASTRO_H
+# define PSASTRO_H
 
 # include "psastroErrorCodes.h"
-#define PSASTRO_RECIPE "PSASTRO" // Name of the recipe to use
+# define PSASTRO_RECIPE "PSASTRO" // Name of the recipe to use
 
 # define psMemCopy(A)(psMemIncrRefCounter((A)))
@@ -27,9 +23,7 @@
 } pmLumFunc;
 
-pmConfig         *psastroArguments (int argc, char **argv);
-void              psastroCleanup (pmConfig *config, psArray *refs);
-bool              psastroParseCamera (pmConfig *config);
-bool              psastroDataLoad (pmConfig *config);
 bool              psastroDataSave (pmConfig *config);
+bool              psastroDefineFiles (pmConfig *config, pmFPAfile *input);
+bool              psastroAnalysis (pmConfig *config);
 
 bool              psastroConvertFPA (pmFPA *fpa, psMetadata *recipe);
@@ -38,11 +32,9 @@
 bool              psastroAstromGuess (pmConfig *config);
 
-// bool              pmAstromReadWCS (pmFPA *fpa, pmChip *chip, psMetadata *header, double plateScale, bool isMosaic);
-// bool              pmAstromWriteWCS (psPlaneTransform *toFPA, psPlaneDistort *toTPA, psProjection *toSky, psMetadata *header, double plateScale);
 psPlaneDistort   *psPlaneDistortIdentity ();
-bool psPlaneDistortIsIdentity (psPlaneDistort *distort);
+bool              psPlaneDistortIsIdentity (psPlaneDistort *distort);
 
 psArray          *psastroLoadRefstars (pmConfig *config);
-bool              psastroChipAstrom (pmConfig *config, psArray *refs);
+bool              psastroChipAstrom (pmConfig *config);
 bool              psastroOneChip (pmFPA *fpa, pmChip *chip, psArray *refset, psArray *rawset, psMetadata *recipe, psMetadata *updates);
 bool              psastroChooseRefstars (pmConfig *config, psArray *refs);
@@ -56,28 +48,30 @@
 
 // mosaic fitting functions
-bool psastroMosaicGradients (pmFPA *fpa, psMetadata *recipe);
-bool psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe);
-bool psastroMosaicAstrom (pmConfig *config, psArray *refs);
-bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration);
-bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration);
-bool psastroMosaicSetAstrom (pmFPA *fpa);
-bool psastroMosaicHeaders (pmConfig *config);
-bool psastroMosaicRescaleChips (pmFPA *fpa);
-bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration);
+bool 		  psastroMosaicGradients (pmFPA *fpa, psMetadata *recipe);
+bool 		  psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe);
+bool 		  psastroMosaicAstrom (pmConfig *config);
+bool 		  psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration);
+bool 		  psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration);
+bool 		  psastroMosaicSetAstrom (pmFPA *fpa);
+bool 		  psastroMosaicHeaders (pmConfig *config);
+bool 		  psastroMosaicRescaleChips (pmFPA *fpa);
+bool 		  psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration);
 
 // Return version strings.
-psString psastroVersion(void);
-psString psastroVersionLong(void);
+psString 	  psastroVersion(void);
+psString 	  psastroVersionLong(void);
 
 // demo plots
-bool psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
-bool psastroPlotRefstars (psArray *refstars);
-bool psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, pmAstromFitResults *results);
+bool 		  psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
+bool 		  psastroPlotRefstars (psArray *refstars);
+bool 		  psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, pmAstromFitResults *results);
 
-bool psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
-bool psastroDumpRefstars (psArray *refstars, char *filename);
-bool psastroDumpMatches (pmFPA *fpa, char *filename);
-bool psastroDumpStars (psArray *stars, char *filename);
+bool 		  psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
+bool 		  psastroDumpRefstars (psArray *refstars, char *filename);
+bool 		  psastroDumpMatches (pmFPA *fpa, char *filename);
+bool 		  psastroDumpStars (psArray *stars, char *filename);
 
-bool psastroMosaicSetAstrom_tmp (pmFPA *fpa);
-int psastroSortByMag (const void **a, const void **b);
+bool		  psastroMosaicSetAstrom_tmp (pmFPA *fpa);
+int 		  psastroSortByMag (const void **a, const void **b);
+
+# endif /* PSASTRO_H */
Index: /trunk/psastro/src/psastroAnalysis.c
===================================================================
--- /trunk/psastro/src/psastroAnalysis.c	(revision 12806)
+++ /trunk/psastro/src/psastroAnalysis.c	(revision 12806)
@@ -0,0 +1,50 @@
+# include "psastroInternal.h"
+
+bool psastroAnalysis (pmConfig *config) {
+
+    // interpret the available initial astrometric information
+    // apply the initial guess
+    if (!psastroAstromGuess (config)) {
+	psError (PSASTRO_ERR_UNKNOWN, false, "failed to determine initial astrometry guess\n");
+	return false;
+    }
+
+    // load the reference stars overlapping the data stars
+    psArray *refs = psastroLoadRefstars(config);
+    if (!refs) {
+	psError (PSASTRO_ERR_UNKNOWN, false, "failed to load reference data\n");
+	return false;
+    }
+
+    if (!psastroChooseRefstars (config, refs)) {
+	psError (PSASTRO_ERR_UNKNOWN, false, "failed to select reference data for chips\n");
+	return false;
+    }
+
+    // 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)) {
+	    psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform single chip astrometry\n");
+	    return false;
+	}
+    } 
+    if (mosastro) {
+	if (!psastroMosaicAstrom (config)) {
+	    psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform mosaic camera astrometry\n");
+	    return false;
+	}
+    }
+
+    // XXX how do we specify stack astrometry?
+    // psastroStackAstrom (config, refs);
+
+    psFree (refs);
+    return true;
+}
Index: /trunk/psastro/src/psastroArguments.c
===================================================================
--- /trunk/psastro/src/psastroArguments.c	(revision 12805)
+++ /trunk/psastro/src/psastroArguments.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroStandAlone.h"
 
 pmConfig *psastroArguments (int argc, char **argv) {
Index: /trunk/psastro/src/psastroAstromGuess.c
===================================================================
--- /trunk/psastro/src/psastroAstromGuess.c	(revision 12805)
+++ /trunk/psastro/src/psastroAstromGuess.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 // this function loads the header WCS astrometry terms into the fpa terms and applies the
Index: /trunk/psastro/src/psastroChipAstrom.c
===================================================================
--- /trunk/psastro/src/psastroChipAstrom.c	(revision 12805)
+++ /trunk/psastro/src/psastroChipAstrom.c	(revision 12806)
@@ -1,6 +1,6 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 # define NONLIN_TOL 0.001 /* tolerance in pixels */
 
-bool psastroChipAstrom (pmConfig *config, psArray *refs) {
+bool psastroChipAstrom (pmConfig *config) {
 
     pmChip *chip = NULL;
Index: /trunk/psastro/src/psastroChooseRefstars.c
===================================================================
--- /trunk/psastro/src/psastroChooseRefstars.c	(revision 12805)
+++ /trunk/psastro/src/psastroChooseRefstars.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 bool psastroChooseRefstars (pmConfig *config, psArray *refs) {
Index: /trunk/psastro/src/psastroCleanup.c
===================================================================
--- /trunk/psastro/src/psastroCleanup.c	(revision 12805)
+++ /trunk/psastro/src/psastroCleanup.c	(revision 12806)
@@ -1,7 +1,6 @@
-# include "psastro.h"
+# include "psastroStandAlone.h"
 
-void psastroCleanup (pmConfig *config, psArray *refs) {
+void psastroCleanup (pmConfig *config) {
 
-    psFree (refs);
     psFree (config);
 
Index: /trunk/psastro/src/psastroConvert.c
===================================================================
--- /trunk/psastro/src/psastroConvert.c	(revision 12805)
+++ /trunk/psastro/src/psastroConvert.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 // leak free 2006.04.27
 
Index: /trunk/psastro/src/psastroDataLoad.c
===================================================================
--- /trunk/psastro/src/psastroDataLoad.c	(revision 12805)
+++ /trunk/psastro/src/psastroDataLoad.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroStandAlone.h"
 // this loop loads the data from the input files and selects the
 // brighter stars for astrometry
Index: /trunk/psastro/src/psastroDataSave.c
===================================================================
--- /trunk/psastro/src/psastroDataSave.c	(revision 12805)
+++ /trunk/psastro/src/psastroDataSave.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 // XXX leak free 2006.04.27
 
Index: /trunk/psastro/src/psastroDefineFiles.c
===================================================================
--- /trunk/psastro/src/psastroDefineFiles.c	(revision 12806)
+++ /trunk/psastro/src/psastroDefineFiles.c	(revision 12806)
@@ -0,0 +1,22 @@
+# include "psastroInternal.h"
+
+bool psastroDefineFiles (pmConfig *config, pmFPAfile *input) {
+
+    // these calls bind the I/O handle to the specified fpa
+    if (!pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT")) {
+	psError(PSASTRO_ERR_CONFIG, false, "Failed to build FPA from PSASTRO.INPUT");
+	return false;
+    }
+
+# if (0)
+    // optionally save output plots
+    if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.MOMENTS")) {
+	psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.MOMENTS");
+    }
+    if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.PSFMODEL")) {
+	psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.PSFMODEL");
+    }
+# endif
+
+    return true;
+}
Index: /trunk/psastro/src/psastroDemoDump.c
===================================================================
--- /trunk/psastro/src/psastroDemoDump.c	(revision 12805)
+++ /trunk/psastro/src/psastroDemoDump.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 // this function is used for test purposes (-trace psastro.dump.psastroAstromGuess 1)
Index: /trunk/psastro/src/psastroDemoPlot.c
===================================================================
--- /trunk/psastro/src/psastroDemoPlot.c	(revision 12805)
+++ /trunk/psastro/src/psastroDemoPlot.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 # if (HAVE_KAPA)
Index: /trunk/psastro/src/psastroInternal.h
===================================================================
--- /trunk/psastro/src/psastroInternal.h	(revision 12806)
+++ /trunk/psastro/src/psastroInternal.h	(revision 12806)
@@ -0,0 +1,16 @@
+# ifdef HAVE_CONFIG_H
+# include <config.h>
+# endif
+
+# ifndef PSASTRO_INTERNAL_H
+# define PSASTRO_INTERNAL_H
+
+# include <stdio.h>
+# include <string.h>
+# include <strings.h>  // for strcasecmp
+# include <unistd.h>   // for unlink
+# include <pslib.h>
+# include <psmodules.h>
+# include "psastro.h"
+
+#endif
Index: /trunk/psastro/src/psastroLoadRefstars.c
===================================================================
--- /trunk/psastro/src/psastroLoadRefstars.c	(revision 12805)
+++ /trunk/psastro/src/psastroLoadRefstars.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 # define ELIXIR_MODE 1
 
@@ -22,5 +22,5 @@
     PS_ASSERT (CATDIR, NULL);
 
-    char *getstarCommand = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR");
+    char *getstarCommand = psMemIncrRefCounter(psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR"));
     PS_ASSERT (getstarCommand, NULL);
 
@@ -44,8 +44,8 @@
     }
 
-    // XXX check for a default name (use .ptolemyrc)?
-    if (CATDIR) {
+    // check for default name (use .ptolemyrc), or use specified CATDIR
+    if (strcasecmp(CATDIR, "NONE")) {
         psStringAppend (&getstarCommand, " -D CATDIR %s", CATDIR);
-    }
+    } 
 
     // psStringAppend (&getstarCommand, " -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile);
@@ -89,4 +89,5 @@
     // convert the Average table to the pmAstromObj entries
     psTimerStart ("psastro");
+
     psArray *refstars = psArrayAllocEmpty (table->n);
     for (int i = 0; i < table->n; i++) {
Index: /trunk/psastro/src/psastroLuminosityFunction.c
===================================================================
--- /trunk/psastro/src/psastroLuminosityFunction.c	(revision 12805)
+++ /trunk/psastro/src/psastroLuminosityFunction.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 # define dMag 0.1
 // XXX put this in config?
Index: /trunk/psastro/src/psastroMosaicAstrom.c
===================================================================
--- /trunk/psastro/src/psastroMosaicAstrom.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicAstrom.c	(revision 12806)
@@ -1,7 +1,7 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 # define NONLIN_TOL 0.001 /* tolerance in pixels */
 
 // XXX require this fpa to have multiple chip extensions and a PHU?
-bool psastroMosaicAstrom (pmConfig *config, psArray *refs) {
+bool psastroMosaicAstrom (pmConfig *config) {
 
     // select the current recipe
Index: /trunk/psastro/src/psastroMosaicChipAstrom.c
===================================================================
--- /trunk/psastro/src/psastroMosaicChipAstrom.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicChipAstrom.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 # define NONLIN_TOL 0.001 /* tolerance in pixels */
 
Index: /trunk/psastro/src/psastroMosaicGetGrads.c
===================================================================
--- /trunk/psastro/src/psastroMosaicGetGrads.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicGetGrads.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 psArray *psastroMosaicGetGrads (pmFPA *fpa, psMetadata *recipe) {
Index: /trunk/psastro/src/psastroMosaicGradients.c
===================================================================
--- /trunk/psastro/src/psastroMosaicGradients.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicGradients.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 bool psastroMosaicGradients (pmFPA *fpa, psMetadata *recipe) {
Index: /trunk/psastro/src/psastroMosaicHeaders.c
===================================================================
--- /trunk/psastro/src/psastroMosaicHeaders.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicHeaders.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 bool psastroMosaicHeaders (pmConfig *config) {
Index: /trunk/psastro/src/psastroMosaicOneChip.c
===================================================================
--- /trunk/psastro/src/psastroMosaicOneChip.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicOneChip.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 # define REQUIRED_RECIPE_VALUE(VALUE, NAME, TYPE, MESSAGE)\
Index: /trunk/psastro/src/psastroMosaicSetAstrom.c
===================================================================
--- /trunk/psastro/src/psastroMosaicSetAstrom.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicSetAstrom.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 bool psastroMosaicSetAstrom (pmFPA *fpa) {
Index: /trunk/psastro/src/psastroMosaicSetMatch.c
===================================================================
--- /trunk/psastro/src/psastroMosaicSetMatch.c	(revision 12805)
+++ /trunk/psastro/src/psastroMosaicSetMatch.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration) {
Index: /trunk/psastro/src/psastroOneChip.c
===================================================================
--- /trunk/psastro/src/psastroOneChip.c	(revision 12805)
+++ /trunk/psastro/src/psastroOneChip.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 # define REQUIRED_RECIPE_VALUE(VALUE, NAME, TYPE, MESSAGE)\
Index: /trunk/psastro/src/psastroParseCamera.c
===================================================================
--- /trunk/psastro/src/psastroParseCamera.c	(revision 12805)
+++ /trunk/psastro/src/psastroParseCamera.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 bool psastroParseCamera (pmConfig *config) {
@@ -12,13 +12,9 @@
     }
 
-    // select recipe options supplied on command line
-    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
-
-    // set default recipe values here
-    psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE",    PS_META_NO_REPLACE, "", "NONE");
-    psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "", "NONE");
-
-    // these calls bind the I/O handle to the specified fpa
-    pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT");
+    // define the additional input/output files associated with psphot 
+    if (!psastroDefineFiles (config, input)) {
+	psError(PSASTRO_ERR_CONFIG, false, "Trouble defining the additional input/output files");
+	return false;
+    }
 
     // Chip selection: turn on only the chips specified (option is not required)
Index: /trunk/psastro/src/psastroRefstarSubset.c
===================================================================
--- /trunk/psastro/src/psastroRefstarSubset.c	(revision 12805)
+++ /trunk/psastro/src/psastroRefstarSubset.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 bool psastroRefstarSubset (pmReadout *readout) {
Index: /trunk/psastro/src/psastroStandAlone.h
===================================================================
--- /trunk/psastro/src/psastroStandAlone.h	(revision 12806)
+++ /trunk/psastro/src/psastroStandAlone.h	(revision 12806)
@@ -0,0 +1,19 @@
+# ifdef HAVE_CONFIG_H
+# include <config.h>
+# endif
+
+#ifndef PSASTRO_STAND_ALONE_H
+#define PSASTRO_STAND_ALONE_H
+
+#include <stdio.h>
+#include <pslib.h>
+#include <psmodules.h>
+#include "psastro.h"
+
+// Top level functions
+pmConfig         *psastroArguments (int argc, char **argv);
+void              psastroCleanup (pmConfig *config);
+bool              psastroParseCamera (pmConfig *config);
+bool              psastroDataLoad (pmConfig *config);
+
+#endif
Index: /trunk/psastro/src/psastroTestFuncs.c
===================================================================
--- /trunk/psastro/src/psastroTestFuncs.c	(revision 12805)
+++ /trunk/psastro/src/psastroTestFuncs.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 
 // write out objects
Index: /trunk/psastro/src/psastroUtils.c
===================================================================
--- /trunk/psastro/src/psastroUtils.c	(revision 12805)
+++ /trunk/psastro/src/psastroUtils.c	(revision 12806)
@@ -1,3 +1,3 @@
-# include "psastro.h"
+# include "psastroInternal.h"
 # define RENORM 0
 
Index: /trunk/psastro/src/psastroVersion.c
===================================================================
--- /trunk/psastro/src/psastroVersion.c	(revision 12805)
+++ /trunk/psastro/src/psastroVersion.c	(revision 12806)
@@ -1,10 +1,3 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <pslib.h>
-#include <psmodules.h>
-#include "psastro.h"
+#include "psastroInternal.h"
 
 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
