Index: /trunk/Ohana/src/getstar/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/getstar/src/ConfigInit.c	(revision 15542)
+++ /trunk/Ohana/src/getstar/src/ConfigInit.c	(revision 15543)
@@ -38,4 +38,5 @@
     exit (1);
   }
+  SetZeroPoint (25.0);
 
   free (config);
Index: /trunk/Ohana/src/getstar/src/args.c
===================================================================
--- /trunk/Ohana/src/getstar/src/args.c	(revision 15542)
+++ /trunk/Ohana/src/getstar/src/args.c	(revision 15543)
@@ -72,5 +72,4 @@
       exit (1);
     }
-    // XXX check that photcode is SEC type
     remove_argument (N, &argc, argv);
   }
Index: /trunk/Ohana/src/getstar/src/select_by_region.c
===================================================================
--- /trunk/Ohana/src/getstar/src/select_by_region.c	(revision 15542)
+++ /trunk/Ohana/src/getstar/src/select_by_region.c	(revision 15543)
@@ -4,7 +4,8 @@
 int select_by_region (Catalog *output, Catalog *catalog, SkyRegion *region, int start, int end) {
 
-  int i, j, n, Nm, offset, Nsecfilt;
+  int i, j, n, Nm, offset, m, Nsecfilt, code, Nsec;
   int Nave, NAVE, Nmeas, NMEAS;
   double R, D;
+  float mag;
 
   Nsecfilt = output[0].Nsecfilt;
@@ -23,4 +24,7 @@
     gfits_modify (&output[0].header, "DEC1", "%lf", 1, region[0].Dmax);
   }
+
+  code = photcode[0].code;
+  Nsec = GetPhotcodeNsec (code);
 
   /* select the average objects in this region */
@@ -45,6 +49,19 @@
     if (D > region[0].Dmax) continue;
 
-    /* XXX add photcode as argument to MagLimitUse */
-    if (MagLimitUse && (catalog[0].secfilt[Nsecfilt*i].M > MagLimitValue)) continue;
+    if (MagLimitUse) {
+      mag = NAN;
+      if (Nsec != -1) {
+	mag = catalog[0].secfilt[i*Nsecfilt + Nsec].M;
+      } else {
+	offset = catalog[0].average[i].offset;
+	for (m = 0; m < catalog[0].average[i].Nm; m++) {
+	  if (catalog[0].measure[offset + m].photcode == code) {
+	    mag = PhotRel (&catalog[0].measure[offset + m], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]);
+	    break;
+	  }
+	}
+      }
+      if (isnan(mag) || (mag > MagLimitValue)) continue;
+    }
 
     output[0].average[Nave] = catalog[0].average[i];
Index: /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c
===================================================================
--- /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c	(revision 15542)
+++ /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c	(revision 15543)
@@ -40,9 +40,4 @@
   secfilt = catalog[0].secfilt;
 
-  if (Nsec_c0 == -1) {
-    fprintf (stderr, "invalid photcode %s\n", photcode[0].name);
-    exit (2);
-  }
-
   // do we skip any of catalog entries? (probably not)
   for (i = 0; i < catalog[0].Naverage; i++) {
@@ -50,12 +45,25 @@
     output[i].R        = average[i].R;
     output[i].D        = average[i].D;
-    output[i].mag      = secfilt[i*Nsecfilt + Nsec_c0].M;
 
     output[i].code     = average[i].code;
     output[i].photcode = code_c0;
 
-    // It is not necessary for the output color terms to be average values.  If they are,
-    // we grab them quickly & easily from the secfilt table.  If not, then we need to scan
-    // the list of measures to find the value of interest
+    // It is not necessary for the output magnitude or color terms to be average values.
+    // If they are, we grab them quickly & easily from the secfilt table.  If not, then we
+    // need to scan the list of measures to find the value of interest
+
+    // find primary magnitude
+    if (Nsec_c0 != -1) {
+      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].M;
+    } else {
+      output[i].mag = NAN;
+      offset = average[i].offset;
+      for (m = 0; m < average[i].Nm; m++) {
+        if (measure[offset + m].photcode == code_c0) {
+          output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt]);
+	  break;
+        }
+      }
+    }
 
     // find color term 1
Index: /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c
===================================================================
--- /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c	(revision 15542)
+++ /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c	(revision 15543)
@@ -40,9 +40,4 @@
   secfilt = catalog[0].secfilt;
 
-  if (Nsec_c0 == -1) {
-    fprintf (stderr, "invalid photcode %s\n", photcode[0].name);
-    exit (2);
-  }
-
   // do we skip any of catalog entries? (probably not)
   for (i = 0; i < catalog[0].Naverage; i++) {
@@ -57,9 +52,21 @@
     output[i].photcode = code_c0;
 
-    output[i].mag      = secfilt[i*Nsecfilt + Nsec_c0].M;
-
     // It is not necessary for the output color terms to be average values.  If they are,
     // we grab them quickly & easily from the secfilt table.  If not, then we need to scan
     // the list of measures to find the value of interest
+
+    // find primary magnitude
+    if (Nsec_c0 != -1) {
+      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].M;
+    } else {
+      output[i].mag = NAN;
+      offset = average[i].offset;
+      for (m = 0; m < average[i].Nm; m++) {
+        if (measure[offset + m].photcode == code_c0) {
+          output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt]);
+	  break;
+        }
+      }
+    }
 
     // find color term 1
Index: /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c
===================================================================
--- /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c	(revision 15542)
+++ /trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c	(revision 15543)
@@ -39,9 +39,4 @@
   secfilt = catalog[0].secfilt;
 
-  if (Nsec_c0 == -1) {
-    fprintf (stderr, "invalid photcode %s\n", photcode[0].name);
-    exit (2);
-  }
-
   // do we skip any of catalog entries? (probably not)
   for (i = 0; i < catalog[0].Naverage; i++) {
@@ -63,9 +58,21 @@
     output[i].photcode = code_c0;
 
-    output[i].mag      = secfilt[i*Nsecfilt + Nsec_c0].M;
-
     // It is not necessary for the output color terms to be average values.  If they are,
     // we grab them quickly & easily from the secfilt table.  If not, then we need to scan
     // the list of measures to find the value of interest
+
+    // find primary magnitude
+    if (Nsec_c0 != -1) {
+      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].M;
+    } else {
+      output[i].mag = NAN;
+      offset = average[i].offset;
+      for (m = 0; m < average[i].Nm; m++) {
+        if (measure[offset + m].photcode == code_c0) {
+          output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt]);
+	  break;
+        }
+      }
+    }
 
     // find color term 1
