Index: trunk/psModules/src/astrom/pmAstrometryObjects.c
===================================================================
--- trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 15102)
+++ trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 15665)
@@ -8,6 +8,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-09-29 02:28:04 $
+*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-11-21 07:02:55 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -269,5 +269,5 @@
 
 /******************************************************************************
-pmAstromRotateObj(old, center, angle): rotate the focal-plane coordinates
+pmAstromRotateObj(old, center, angle, angle): rotate & scale the focal-plane coordinates
 about the center coordinate angle specified in radians
  ******************************************************************************/
@@ -275,5 +275,6 @@
     const psArray *old,
     psPlane center,
-    double angle)
+    double angle,
+    double scale)
 {
     PS_ASSERT_PTR_NON_NULL(old, NULL);
@@ -284,6 +285,6 @@
 
     psArray *new = psArrayAlloc (old->n);
-    double cs = cos(angle);
-    double sn = sin(angle);
+    double cs = scale*cos(angle);
+    double sn = scale*sin(angle);
     double xCenter = center.x;
     double yCenter = center.y;
@@ -326,4 +327,5 @@
     //    stats->offset = {0, 0, 0, 0};
     stats->angle     = 0.0;
+    stats->scale     = 1.0;
     stats->minMetric = 0.0;
     stats->minVar    = 0.0;
@@ -703,4 +705,8 @@
     center.y = 0.5*(yMin + yMax);
 
+    double minScale = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.MIN.SCALE");
+    double maxScale = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.MAX.SCALE");
+    double delScale = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.DEL.SCALE");
+
     double minAngle = RAD_DEG*psMetadataLookupF32 (&status, config, "PSASTRO.GRID.MIN.ANGLE");
     double maxAngle = RAD_DEG*psMetadataLookupF32 (&status, config, "PSASTRO.GRID.MAX.ANGLE");
@@ -709,24 +715,27 @@
 
     minStat->minMetric = 1e10;
-    for (double angle = minAngle; angle <= maxAngle; angle += delAngle) {
-        rot = pmAstromRotateObj (raw, center, angle);
-        newStat = pmAstromGridAngle (rot, ref, config);
-        newStat->angle  = angle;
-        newStat->center = center;
-
-        if (newStat->minMetric < minStat->minMetric) {
-            *minStat = *newStat;
-            psLogMsg ("psModule.astrom", 4, "grid test - offset: %7.2f,%7.2f @ %6.1f deg (%4d pts, %5.1f sig, %5.1f var, %6.3f log metric) *",
-                      minStat->offset.x, minStat->offset.y, DEG_RAD*minStat->angle, minStat->nMatch, minStat->nSigma, minStat->minVar, log10(minStat->minMetric));
-        } else {
-            psLogMsg ("psModule.astrom", 4, "grid test - offset: %7.2f,%7.2f @ %6.1f deg (%4d pts, %5.1f sig, %5.1f var, %6.3f log metric)",
-                      newStat->offset.x, newStat->offset.y, DEG_RAD*newStat->angle, newStat->nMatch, newStat->nSigma, newStat->minVar, log10(newStat->minMetric));
-
-        }
-        psFree (newStat);
-        psFree (rot);
-    }
-    psLogMsg ("psModule.astrom.grid.match", 4, "grid best - offset: %7.2f,%7.2f @ %6.1f deg (%4d pts, %5.1f sig, %5.1f var, %6.3f log metric)",
-              minStat->offset.x, minStat->offset.y, DEG_RAD*minStat->angle, minStat->nMatch, minStat->nSigma, minStat->minVar, log10(minStat->minMetric));
+    for (double scale = minScale; scale <= maxScale; scale += delScale) {
+	for (double angle = minAngle; angle <= maxAngle; angle += delAngle) {
+	    rot = pmAstromRotateObj (raw, center, angle, scale);
+	    newStat = pmAstromGridAngle (rot, ref, config);
+	    newStat->angle  = angle;
+	    newStat->scale  = scale;
+	    newStat->center = center;
+
+	    if (newStat->minMetric < minStat->minMetric) {
+		*minStat = *newStat;
+		psLogMsg ("psModule.astrom", 4, "grid test - offset: %7.2f,%7.2f @ %6.1f deg x %7.3f (%4d pts, %5.1f sig, %5.1f var, %6.3f log metric) *",
+			  minStat->offset.x, minStat->offset.y, DEG_RAD*minStat->angle, minStat->scale, minStat->nMatch, minStat->nSigma, minStat->minVar, log10(minStat->minMetric));
+	    } else {
+		psLogMsg ("psModule.astrom", 4, "grid test - offset: %7.2f,%7.2f @ %6.1f deg x %7.3f (%4d pts, %5.1f sig, %5.1f var, %6.3f log metric)",
+			  newStat->offset.x, newStat->offset.y, DEG_RAD*newStat->angle, newStat->scale, newStat->nMatch, newStat->nSigma, newStat->minVar, log10(newStat->minMetric));
+
+	    }
+	    psFree (newStat);
+	    psFree (rot);
+	}
+    }
+    psLogMsg ("psModule.astrom.grid.match", 4, "grid best - offset: %7.2f,%7.2f @ %6.1f deg x %7.3f (%4d pts, %5.1f sig, %5.1f var, %6.3f log metric)",
+              minStat->offset.x, minStat->offset.y, DEG_RAD*minStat->angle, minStat->scale, minStat->nMatch, minStat->nSigma, minStat->minVar, log10(minStat->minMetric));
 
     // I need to decide if a solution is likely to be a good solution or just a mis-match
@@ -756,5 +765,5 @@
     int nBin, xBin, yBin;
 
-    rot = pmAstromRotateObj (raw, stats->center, stats->angle);
+    rot = pmAstromRotateObj (raw, stats->center, stats->angle, stats->scale);
 
     // sampling scale of the grid
@@ -846,6 +855,6 @@
     PS_ASSERT_POLY_NON_NULL(map->y, NULL);
 
-    double cs = cos (stat->angle);
-    double sn = sin (stat->angle);
+    double cs = stat->scale * cos (stat->angle);
+    double sn = stat->scale * sin (stat->angle);
 
     double dx = (map->x->coeff[0][0] - stat->center.x);
