Index: /trunk/psModules/src/astrom/pmAstrometryObjects.c
===================================================================
--- /trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 10851)
+++ /trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 10852)
@@ -8,6 +8,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-12-25 01:49:49 $
+*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-12-29 18:30:36 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -569,5 +569,6 @@
 
         // only check bins with at least 1/2 of max bin
-        int minNpts = 0.5*imStats->max;
+        // XXX requiring at least 3 matches in bin
+        int minNpts = PS_MAX (0.5*imStats->max, 3);
         psTrace("psModule.astrom.grid.angle", 5, "minNpts: %d, max: %d", minNpts, (int)(imStats->max));
 
@@ -596,9 +597,20 @@
 
         // convert the bin to delta-delta
-        stats->offset.x  = DX[minY][minX] / NP[minY][minX];
-        stats->offset.y  = DY[minY][minX] / NP[minY][minX];
-        stats->minMetric = minMetric;
-        stats->minVar    = minVar;
-        stats->nMatch    = NP[minY][minX];
+        if ((minX < 0) || (minY < 0))
+        {
+            // no valid matches found
+            stats->offset.x   = 0;
+            stats->offset.y   = 0;
+            stats->minMetric  = minMetric;
+            stats->minVar     = minVar;
+            stats->nMatch     = 0;
+        } else
+        {
+            stats->offset.x  = DX[minY][minX] / NP[minY][minX];
+            stats->offset.y  = DY[minY][minX] / NP[minY][minX];
+            stats->minMetric = minMetric;
+            stats->minVar    = minVar;
+            stats->nMatch    = NP[minY][minX];
+        }
 
         psFree (imStats);
