Index: /trunk/Ohana/src/opihi/cmd.astro/imfit.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit.c	(revision 3104)
+++ /trunk/Ohana/src/opihi/cmd.astro/imfit.c	(revision 3105)
@@ -246,9 +246,11 @@
   dchisq = ochisq;
 
-  for (i = 0; (i < 50) && ((dchisq <= 0.0) || (dchisq > 0.001*(Npts - Npar))); i++) {
+  for (i = 0; (i < 25) && ((dchisq <= 0.0) || (dchisq > 0.01*(Npts - Npar))); i++) {
     chisq = mrq2dmin (x, y, z, dz, Npts, par, Npar, fitfunc, VERBOSE);
     dchisq = ochisq - chisq;
     ochisq = chisq;
   }  
+  set_int_variable ("Niter",  i);
+  
 
   if (ShapeVariation) {
@@ -407,8 +409,10 @@
   set_variable ("ChiSq", chisq/(Npts - Npar));
 
-  for (i = 0; i < Npar; i++) {
-    fprintf (stderr, "%g ", par[i]);
-  }
-  fprintf (stderr, "\n");
+  if (VERBOSE) {
+    for (i = 0; i < Npar; i++) {
+      fprintf (stderr, "%g ", par[i]);
+    }
+    fprintf (stderr, "\n");
+  }
 
   free (x);
Index: /trunk/Ohana/src/opihi/cmd.data/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 3104)
+++ /trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 3105)
@@ -72,4 +72,5 @@
 $(SDIR)/peak.$(ARCH).o		\
 $(SDIR)/plot.$(ARCH).o		\
+$(SDIR)/dot.$(ARCH).o		\
 $(SDIR)/point.$(ARCH).o		\
 $(SDIR)/ps.$(ARCH).o		\
Index: /trunk/Ohana/src/opihi/cmd.data/dot.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/dot.c	(revision 3105)
+++ /trunk/Ohana/src/opihi/cmd.data/dot.c	(revision 3105)
@@ -0,0 +1,81 @@
+# include "data.h"
+
+int dot (int argc, char **argv) {
+  
+  int N, Npts, Ngraph;
+  Graphdata graphmode;
+  float x, y;
+
+  /* choose the appropriate graphing window */
+  Ngraph = -1;
+  if ((N = get_argument (argc, argv, "-n"))) {
+    remove_argument (N, &argc, argv);
+    Ngraph = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE);
+
+  /* evaluate various plotting options */
+  if ((N = get_argument (argc, argv, "-lt"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.ltype = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-lw"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.lweight = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-pt"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.ptype = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "+eb"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.ebar = TRUE;
+  }
+  if ((N = get_argument (argc, argv, "-eb"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.ebar = FALSE;
+  }
+  if ((N = get_argument (argc, argv, "-sz"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.size = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-c"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.color = GetColor (argv[N]);
+    if (graphmode.color == -1) return (FALSE);
+    remove_argument (N, &argc, argv);
+  }
+  /* only -x 2 makes sense here
+  if ((N = get_argument (argc, argv, "-x"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.style = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  */
+  graphmode.style = 2;
+
+  if (argc != 3) {
+    fprintf (stderr, "USAGE: plot <x> <y>\n");
+    return (FALSE);
+  }
+  x = atof(argv[1]);
+  y = atof(argv[2]);
+
+  /* set plotting options (these are sticky) */
+  SetGraph (graphmode);
+
+  /* set errorbar mode (these are NOT sticky) */
+  graphmode.etype = 0;
+
+  if (!PrepPlotting (1, &graphmode)) return (FALSE);
+  
+  PlotVector (1, &x);
+  PlotVector (1, &y);
+  
+  return (TRUE);
+}
Index: /trunk/Ohana/src/opihi/cmd.data/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/init.c	(revision 3104)
+++ /trunk/Ohana/src/opihi/cmd.data/init.c	(revision 3105)
@@ -53,4 +53,5 @@
 int peak             PROTO((int, char **));
 int plot             PROTO((int, char **));
+int dot              PROTO((int, char **));
 int point            PROTO((int, char **));
 int pop              PROTO((int, char **));
@@ -152,4 +153,5 @@
   {"peak",	   peak,	     "find vector peak in range"},
   {"plot",    	   plot,	     "plot a pair of vectors"},
+  {"dot",    	   dot,	             "plot a single point"},
   {"point",	   point,	     "load overlay with single point"},
   {"ps",      	   ps,		     "define labels for plot"},
Index: /trunk/Ohana/src/opihi/cmd.data/plot.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/plot.c	(revision 3104)
+++ /trunk/Ohana/src/opihi/cmd.data/plot.c	(revision 3105)
@@ -123,4 +123,2 @@
 
 }
-
-
Index: /trunk/Ohana/src/opihi/mana/fitcontour.c
===================================================================
--- /trunk/Ohana/src/opihi/mana/fitcontour.c	(revision 3104)
+++ /trunk/Ohana/src/opihi/mana/fitcontour.c	(revision 3105)
@@ -36,9 +36,5 @@
     r = hypot (x, y);
 
-    /* 
-    t = 2*atan2(y,x);
-    sn = sin(t);
-    cs = cos(t);
-    */
+    /* calculate sin(2t), cos(2t) using 1/2 angle tri relationship above */
     sn1 = y / r;
     cs1 = x / r;
@@ -63,4 +59,5 @@
   gaussj (C, NTERM, B, 1);
   
+  /** this is somewhat weak: if the object is too elongated, Rmin can be < 0 **/
   dR = hypot (B[1][0], B[2][0]);
   Rmaj = B[0][0] + dR;
@@ -101,2 +98,42 @@
 }
 
+
+/* this routine fits a single sine and cosine to the value of dr as a function of the angle around the central
+ * point, theta.  this is NOT an exact fit, an is increasingly in error for more eccentric ellipses.  however,
+ * it does a reasonable job of approximating the value of the major and minor axes, and it gets the angle of
+ * orientation right at well.  We then assume the values of major and minor axis and angle are correct to get
+ * the parameters for the elliptical gaussian fit:
+ 
+ z = (x^2) / (2 Rx^2) + (y^2) / (2 Ry^2) + Rxy x y
+
+ the functions above give the correct relationship between these:
+
+   R1 = SQ(Rmaj) + SQ(Rmin);
+   R2 = SQ(Rmaj) - SQ(Rmin);
+   R3 = Rmaj*Rmin;
+
+   Rx = R3 / sqrt (R1 - R2*cs);
+   Ry = R3 / sqrt (R1 + R2*cs);
+   Rxy = -sn*R2 / SQ(R3);
+
+ to derive these relationships, write the equation for an ellipse with major axis in the x-dir and minor in
+ the y-dir:
+
+ z = (x^2) / (2 Rmaj^2) + (y^2) / (2 Rmin^2)
+
+ apply the rotation matrix:
+
+ (x)' = (cos, -sin)(x,y)
+ (y)' = (sin, +cos)(x,y)  (modulo the sign on the sine)
+
+ then group the x^2 terms, the y^2 terms, and the xy terms to find the three coeffs.
+
+ NOTE: I spent a while having trouble deriving this from the polar form of an ellipse:
+
+ x = Rmaj*cos(theta)
+ y = Rmin*sin(theta)
+
+ it turns out that 'theta' above is NOT the angle (0,1)-(0,0)-(x,y). rather, it should be viewed as a
+ paraterization of the ellipse.  
+
+*/
