Index: trunk/psastro/src/psastroLoadReferences.c
===================================================================
--- trunk/psastro/src/psastroLoadReferences.c	(revision 8780)
+++ trunk/psastro/src/psastroLoadReferences.c	(revision 9368)
@@ -1,9 +1,4 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 # include "psastro.h"
-int mkstemp(char *template);
-
+// int mkstemp(char *template);
 # define ELIXIR_MODE 1
 # define PIPE_MODE 0
@@ -26,33 +21,12 @@
     float DECmax = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MAX");
 
+    char *CATDIR = psMetadataLookupStr(NULL, recipe, "DVO.CATDIR");
+    if (CATDIR == NULL) {
+	psLogMsg ("psastro", 2, "warning: missing DVO.CATDIR, using HOME/.ptolemyrc definition\n");
+    }
+
     // XXX need to add a padding area
     // issue the following command:
     // getstar -region RAmin RAmax DECmin DECmax
-
-# if PIPE_MODE
-    // use fork to add timeout capability
-    // use cfitsio |filename format to avoid tempFile
-    # if ELIXIR_MODE
-    sprintf (tempLine, "getstar -D CATFORMAT elixir -D CATMODE mef -region %f %f %f %f |", RAmin, DECmin, RAmax, DECmax, tempFile);
-    # else
-    sprintf (tempLine, "getstar -D CATFORMAT panstarrs -D CATMODE mef -region %f %f %f %f |", RAmin, DECmin, RAmax, DECmax, tempFile);
-    # endif
-
-    psTrace (__func__, 3, "%s\n", tempLine);
-
-    // the output from getstar is a file with the Average table
-    psFits *fits = psFitsOpen (tempLine, "r");
-
-    # if ELIXIR_MODE
-    psFitsMoveExtName (fits, "DVO_AVERAGE_ELIXIR");
-    # else
-    psFitsMoveExtName (fits, "DVO_AVERAGE_PANSTARRS");
-    # endif
-
-    psMetadata *header = psFitsReadHeader (NULL, fits);
-    psArray *table = psFitsReadTable (fits);
-    psFitsClose (fits);
-
-# else /***** use a temp file instead ****/
 
     char tempFile[64];
@@ -67,7 +41,15 @@
     // use cfitsio |filename format to avoid tempFile
     # if ELIXIR_MODE
-    sprintf (tempLine, "getstar -D CATFORMAT elixir -D CATMODE mef -region %f %f %f %f > %s", RAmin, DECmin, RAmax, DECmax, tempFile);
+    if (CATDIR) {
+	sprintf (tempLine, "getstar -D CATDIR %s -D CATFORMAT elixir -D CATMODE mef -region %f %f %f %f > %s", CATDIR, RAmin, DECmin, RAmax, DECmax, tempFile);
+    } else {
+	sprintf (tempLine, "getstar -D CATFORMAT elixir -D CATMODE mef -region %f %f %f %f > %s", RAmin, DECmin, RAmax, DECmax, tempFile);
+    }
     # else
-    sprintf (tempLine, "getstar -D CATFORMAT panstarrs -D CATMODE mef -region %f %f %f %f > %s", RAmin, DECmin, RAmax, DECmax, tempFile);
+    if (CATDIR) {
+	sprintf (tempLine, "getstar -D CATDIR %s -D CATFORMAT panstarrs -D CATMODE mef -region %f %f %f %f > %s", CATDIR, RAmin, DECmin, RAmax, DECmax, tempFile);
+    } else {
+	sprintf (tempLine, "getstar -D CATFORMAT panstarrs -D CATMODE mef -region %f %f %f %f > %s", RAmin, DECmin, RAmax, DECmax, tempFile);
+    }
     # endif
 
@@ -92,6 +74,4 @@
     psFitsClose (fits);
     unlink (tempFile);
-
-# endif
 
     // convert the Average table to the pmAstromObj entries
