Index: trunk/Ohana/src/getstar/src/ConfigInit.c
===================================================================
--- trunk/Ohana/src/getstar/src/ConfigInit.c	(revision 11955)
+++ trunk/Ohana/src/getstar/src/ConfigInit.c	(revision 12332)
@@ -4,5 +4,6 @@
 
   char *config, *file;
-  char PhotCodeFile[256];
+  char CatdirPhotcodeFile[256];
+  char MasterPhotcodeFile[256];
 
   /*** load configuration info ***/
@@ -20,5 +21,5 @@
   ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
   ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
-  ScanConfig (config, "PHOTCODE_FILE",          "%s", 0, PhotCodeFile);
+  ScanConfig (config, "PHOTCODE_FILE",         	"%s",  0, MasterPhotcodeFile);
   if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
     SKY_DEPTH = 2;
@@ -31,6 +32,8 @@
   if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
 
-  if (!LoadPhotcodes (PhotCodeFile)) {
-    fprintf (stderr, "error loading photcodes\n");
+  /* XXX this does not yet write out the master photcode table */
+  sprintf (MasterPhotcodeFile, "%s/Photcodes.dat", CATDIR);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
   }
Index: trunk/Ohana/src/getstar/src/select_by_image.c
===================================================================
--- trunk/Ohana/src/getstar/src/select_by_image.c	(revision 11955)
+++ trunk/Ohana/src/getstar/src/select_by_image.c	(revision 12332)
@@ -21,5 +21,5 @@
     start = image[0].tzero;
     end   = image[0].tzero + 1e-4*image[0].NY*image[0].trate;  /* trate is in 0.1 msec / row */
-    photcode = image[0].source;
+    photcode = image[0].photcode;
   }
   if (VERBOSE) fprintf (stderr, "extracting for range %d to %d (photcode %s)\n", start, end, photcode);
@@ -27,5 +27,5 @@
   for (i = 0; (i < catalog[0].Nmeasure); i++) {
     if ((i % 10000) == 0) fprintf (stderr, ". ");
-    if ((catalog[0].measure[i].t >= start) && (catalog[0].measure[i].t <= end) && (photcode == catalog[0].measure[i].source)) { 
+    if ((catalog[0].measure[i].t >= start) && (catalog[0].measure[i].t <= end) && (photcode == catalog[0].measure[i].photcode)) { 
       n = catalog[0].measure[i].averef;
       stars[N].R      = catalog[0].average[n].R - catalog[0].measure[i].dR / 360000.0;
Index: trunk/Ohana/src/getstar/src/select_by_region.c
===================================================================
--- trunk/Ohana/src/getstar/src/select_by_region.c	(revision 11955)
+++ trunk/Ohana/src/getstar/src/select_by_region.c	(revision 12332)
@@ -38,5 +38,6 @@
     if (D > region[0].Dmax) continue;
 
-    if (MagLimitUse && (catalog[0].average[i].M > MagLimitValue)) continue;
+    /* XXX add photcode as argument to MagLimitUse */
+    if (MagLimitUse && (catalog[0].secfilt[Nsecfilt*i].M > MagLimitValue)) continue;
 
     output[0].average[Nave] = catalog[0].average[i];
