Index: /trunk/Ohana/src/addstar/include/addstar.h
===================================================================
--- /trunk/Ohana/src/addstar/include/addstar.h	(revision 12731)
+++ /trunk/Ohana/src/addstar/include/addstar.h	(revision 12732)
@@ -104,4 +104,5 @@
 int    VERBOSE;
 int    PLOT;
+double MAX_CERROR;
 
 /* modify server behavior (make this an addstar cleanup mode?) */
Index: /trunk/Ohana/src/addstar/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ConfigInit.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/ConfigInit.c	(revision 12732)
@@ -38,4 +38,7 @@
   ScanConfig (config, "MIN_SN_FSTAT",           "%lf", 0, &SNLIMIT);
   ScanConfig (config, "ADDSTAR_SNLIMIT",        "%lf", 0, &SNLIMIT);
+
+  MAX_CERROR = 0.5; // arcseconds
+  ScanConfig (config, "ADDSTAR_MAX_CERROR",     "%lf", 0, &MAX_CERROR);
 
   /* used by parse_time to find time-related keywords */
Index: /trunk/Ohana/src/addstar/src/FilterStars.c
===================================================================
--- /trunk/Ohana/src/addstar/src/FilterStars.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/FilterStars.c	(revision 12732)
@@ -6,7 +6,13 @@
   float MTIME, dMs;
   Stars *stars;
+  float RMIN, RMAX, DMIN, DMAX;
 
   /* correct instrumental mags for exposure time */
   MTIME = (image[0].exptime > 0) ? 2.500*log10(image[0].exptime) : 0.0;
+
+  RMIN = 360.0;
+  RMAX =   0.0;
+  DMIN = +90.0;
+  DMAX = -90.0;
 
   /* modify resulting star list */
@@ -27,4 +33,8 @@
     stars[N].code = image[0].photcode;
 
+    RMIN = MIN (RMIN, stars[N].R);
+    RMAX = MAX (RMAX, stars[N].R);
+    DMIN = MIN (DMIN, stars[N].D);
+    DMAX = MAX (DMAX, stars[N].D);
     /** additional quantities to supply to Stars based on the image data **/
 
@@ -54,4 +64,5 @@
 
   if (VERBOSE) fprintf (stderr, "read %d stars from target file\n", image[0].nstar);
+  if (VERBOSE) fprintf (stderr, "stars cover region %f,%f - %f,%f\n", RMIN, DMIN, RMAX, DMAX);
   return (stars);
 }
Index: /trunk/Ohana/src/addstar/src/ReadImageHeader.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 12732)
@@ -6,5 +6,5 @@
 
   int Nastro, ccdnum, hour, min, Nx, Ny;
-  double tmp, sec;
+  double tmp, sec, Cerror;
   char *c, photname[64], line[80];
 
@@ -37,5 +37,7 @@
   Nastro = 0;
   gfits_scan (header, "NASTRO", "%d", 1, &Nastro);
-  if ((Nastro == 0) && !ACCEPT_ASTROM) {
+  Cerror = 0;
+  gfits_scan (header, "CERROR", "%lf", 1, &Cerror);
+  if (((Nastro == 0) || (Cerror > MAX_CERROR)) && !ACCEPT_ASTROM) {
     fprintf (stderr, "bad astrometric solution in header\n");
     return (FALSE);
@@ -51,4 +53,14 @@
     while (image[0].coords.crval1 < 0) image[0].coords.crval1 += 360.0;
     while (image[0].coords.crval1 > 360.0) image[0].coords.crval1 -= 360.0;
+  }
+
+  { 
+    double R, D;
+    /* sanity check on the image coordinates */
+    XY_to_RD (&R, &D, 0.5*Nx, 0.5*Ny, &image[0].coords);
+    if (!finite(R) || !finite(D)) {
+      fprintf (stderr, "corrupted header coordinates, skipping\n");
+      return (FALSE);
+    }
   }
     
Index: /trunk/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 12732)
@@ -77,4 +77,6 @@
 }
 
+// XXX I need to make the IPP I/O functions and these functions
+// consistent wrt ZERO_POINT....
 Stars *ConvertPS1_DEV_0 (FTable *table, int *nstars) {
 
@@ -91,5 +93,5 @@
     stars[i].dX      = ps1data[i].dX;
     stars[i].dY      = ps1data[i].dY;
-    stars[i].M       = ps1data[i].M;
+    stars[i].M       = ps1data[i].M + 25.0;
     stars[i].dM      = ps1data[i].dM;
     stars[i].Mpeak   = ps1data[i].Mpeak;
Index: /trunk/Ohana/src/addstar/src/addstar.c
===================================================================
--- /trunk/Ohana/src/addstar/src/addstar.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/addstar.c	(revision 12732)
@@ -79,9 +79,9 @@
 
     // set the parameters which guide catalog open/load/create
+    catalog.filename  = skylist[0].filename[i];
     catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
     catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
-    catalog.filename  = skylist[0].filename[i];
+    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
-    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     if (options.update) catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
 
Index: /trunk/Ohana/src/addstar/src/get2mass_ops.c
===================================================================
--- /trunk/Ohana/src/addstar/src/get2mass_ops.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/get2mass_ops.c	(revision 12732)
@@ -217,4 +217,9 @@
     Rs *= 15.0;
     Re *= 15.0;
+
+    // don't restrict by RA, but limit by DEC
+    if (De < UserPatch.Dmin) continue;
+    if (Ds > UserPatch.Dmax) continue;
+
     regions[Nregions].Rmin = Rs;
     regions[Nregions].Rmax = Re;
Index: /trunk/Ohana/src/addstar/src/gstars.c
===================================================================
--- /trunk/Ohana/src/addstar/src/gstars.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/gstars.c	(revision 12732)
@@ -229,5 +229,5 @@
 	snprintf (image[N].name, 32, "%s", name);
       } else {
-	snprintf (image[N].name, 32, "%s.%s", name, exthead[i]);
+	snprintf (image[N].name, 32, "%s[%s]", name, exthead[i]);
       }
 
Index: /trunk/Ohana/src/addstar/src/load2mass_as_rawdata.c
===================================================================
--- /trunk/Ohana/src/addstar/src/load2mass_as_rawdata.c	(revision 12731)
+++ /trunk/Ohana/src/addstar/src/load2mass_as_rawdata.c	(revision 12732)
@@ -120,4 +120,10 @@
 	if (tstars[j].D < region[0].Dmin) continue;
 	if (tstars[j].D > region[0].Dmax) continue;
+	  
+	// check if in UserPatch
+	if (tstars[j].R < UserPatch.Rmin) continue;
+	if (tstars[j].R > UserPatch.Rmax) continue;
+	if (tstars[j].D < UserPatch.Dmin) continue;
+	if (tstars[j].D > UserPatch.Dmax) continue;
 	  
 	offset = tstars[j].offset;
