Index: trunk/Ohana/src/relastro/include/relastro.h
===================================================================
--- trunk/Ohana/src/relastro/include/relastro.h	(revision 39603)
+++ trunk/Ohana/src/relastro/include/relastro.h	(revision 39610)
@@ -163,5 +163,7 @@
   double D, dD;
   double T, dT;
-  double Wx, Wy;
+  double Qx, Qy; // unmodified error-based weight (1/dX^2)
+  double qx, qy; // IRLS-modified error-based weight (1/dX^2)
+  double Wx, Wy; // IRLS weight factor
   double rx, ry;
   double u;
Index: trunk/Ohana/src/relastro/src/FitAstromOps.c
===================================================================
--- trunk/Ohana/src/relastro/src/FitAstromOps.c	(revision 39603)
+++ trunk/Ohana/src/relastro/src/FitAstromOps.c	(revision 39610)
@@ -227,4 +227,9 @@
   object->Wy     = 1.0;
 
+  object->Qx     = 0.0;
+  object->Qy     = 0.0;
+  object->qx     = 0.0;
+  object->qy     = 0.0;
+
   object->rx     = 0.0;
   object->ry     = 0.0;
Index: trunk/Ohana/src/relastro/src/FitPMandPar.c
===================================================================
--- trunk/Ohana/src/relastro/src/FitPMandPar.c	(revision 39603)
+++ trunk/Ohana/src/relastro/src/FitPMandPar.c	(revision 39610)
@@ -1,3 +1,5 @@
 # include "relastro.h"
+# define OLD_METHOD 0
+
 int FitPMandPar_MinChisq (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints);
 int FitPMandPar_SetChisq (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints);
@@ -16,6 +18,15 @@
   // Convert the measurement errors into initial weights.
   for (i = 0; i < Npoints; i++) {
+# if (OLD_METHOD)
     points[i].Wx = 1.0 / SQ(points[i].dX);
     points[i].Wy = 1.0 / SQ(points[i].dY);
+# else
+    points[i].Wx = 1.0;
+    points[i].Wy = 1.0;
+    points[i].Qx = 1.0 / SQ(points[i].dX);
+    points[i].Qy = 1.0 / SQ(points[i].dY);
+    points[i].qx = points[i].Wx * points[i].Qx; // Wx, Wy start out at 1.0
+    points[i].qy = points[i].Wy * points[i].Qy; // Wx, Wy start out at 1.0
+# endif
   }
 
@@ -34,6 +45,15 @@
   // Convert the measurement errors into initial weights.
   for (i = 0; i < Npoints; i++) {
+# if (OLD_METHOD)
     points[i].Wx = 1.0 / SQ(points[i].dX);
     points[i].Wy = 1.0 / SQ(points[i].dY);
+    points[i].qx = points[i].Wx; // Wx, Wy start out at 1.0
+    points[i].qy = points[i].Wy; // Wx, Wy start out at 1.0
+# else
+    points[i].Qx = 1.0 / SQ(points[i].dX);
+    points[i].Qy = 1.0 / SQ(points[i].dY);
+    points[i].qx = points[i].Wx * points[i].Qx; // Wx, Wy start out at 1.0
+    points[i].qy = points[i].Wy * points[i].Qy; // Wx, Wy start out at 1.0
+# endif
   }
   
@@ -77,4 +97,6 @@
       points[i].Wx = weight_cauchy(points[i].rx / points[i].dX);
       points[i].Wy = weight_cauchy(points[i].ry / points[i].dY);
+      points[i].qx = points[i].Wx * points[i].Qx;
+      points[i].qy = points[i].Wy * points[i].Qy;
     }    
 
@@ -209,6 +231,11 @@
     Nfit ++;
 
+# if (OLD_METHOD)    
     wx = points[i].Wx;
     wy = points[i].Wy;
+# else
+    wx = points[i].qx;
+    wy = points[i].qy;
+# endif
 
     Wx += wx;
Index: trunk/Ohana/src/relastro/src/FitPMandPar_IRLS.c
===================================================================
--- trunk/Ohana/src/relastro/src/FitPMandPar_IRLS.c	(revision 39603)
+++ trunk/Ohana/src/relastro/src/FitPMandPar_IRLS.c	(revision 39610)
@@ -1,3 +1,4 @@
 # include "relastro.h"
+# define OLD_METHOD 1
 
 // These should probably be tunable:
@@ -15,6 +16,13 @@
   // Convert the measurement errors into initial weights.
   for (i = 0; i < Npoints; i++) {
+# if (OLD_METHOD)
     points[i].Wx = (fabs(points[i].dX) < 0.0001) ? 1.0 : 1 / SQ(points[i].dX);
     points[i].Wy = (fabs(points[i].dY) < 0.0001) ? 1.0 : 1 / SQ(points[i].dY);
+# else
+    points[i].Qx = (fabs(points[i].dX) < 0.0001) ? 1.0 : 1 / SQ(points[i].dX);
+    points[i].Qy = (fabs(points[i].dY) < 0.0001) ? 1.0 : 1 / SQ(points[i].dY);
+# endif
+    points[i].qx = points[i].Wx * points[i].Qx; // Wx, Wy start out at 1.0
+    points[i].qy = points[i].Wy * points[i].Qy; // Wx, Wy start out at 1.0
   }
   
@@ -58,4 +66,6 @@
       points[i].Wx = weight_cauchy(points[i].rx / points[i].dX);
       points[i].Wy = weight_cauchy(points[i].ry / points[i].dY);
+      points[i].qx = points[i].Wx * points[i].Qx;
+      points[i].qy = points[i].Wy * points[i].Qy;
     }    
 
@@ -138,6 +148,6 @@
       ay += dpsi_cauchy(points[i].ry / points[i].dY);
 
-      bx += SQ(points[i].Wx);
-      by += SQ(points[i].Wy);
+      bx += SQ(points[i].qx);
+      by += SQ(points[i].qy);
     }
     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
@@ -207,6 +217,11 @@
     // if (VERBOSE == 2) fprintf (stderr, "%f %f : %f %f : %f : %f %f\n", X[i], WX[i], Y[i], WY[i], T[i], pR[i], pD[i]);
 
+# if (OLD_METHOD)
     wx = points[i].Wx;
     wy = points[i].Wy;
+# else 
+    wx = points[i].Wx;
+    wy = points[i].Wy;
+# endif
 
     Wx += wx;
Index: trunk/Ohana/src/relastro/src/fitobj.c
===================================================================
--- trunk/Ohana/src/relastro/src/fitobj.c	(revision 39603)
+++ trunk/Ohana/src/relastro/src/fitobj.c	(revision 39610)
@@ -121,5 +121,5 @@
   for (i = 0; i < Nstars; i++) {
 
-    double Ro  = 360.0*(drand48() - 0.5);
+    double Ro  = 360.0*drand48();
     double Phi = 2.0*(drand48() - 0.5);
     double Do  = DEG_RAD * asin(Phi);
Index: trunk/Ohana/src/relastro/src/fitpm.c
===================================================================
--- trunk/Ohana/src/relastro/src/fitpm.c	(revision 39603)
+++ trunk/Ohana/src/relastro/src/fitpm.c	(revision 39610)
@@ -155,5 +155,5 @@
   for (i = 0; i < Nstars; i++) {
 
-    double Ro  = 360.0*(drand48_cnt() - 0.5);
+    double Ro  = 360.0*drand48_cnt();
     double Phi = 2.0*(drand48_cnt() - 0.5);
     double Do  = DEG_RAD * asin(Phi);
@@ -181,7 +181,10 @@
     }
 
-    int Npoints = N_POINTS*drand48_cnt(); // minimum of 0 points
-    int Noutliers_max = Npoints * F_OUTLIERS;
-    int Noutliers = Noutliers_max*drand48_cnt(); // minimum of 0 points
+    // int Npoints = N_POINTS*drand48_cnt(); // minimum of 0 points
+    // int Noutliers_max = Npoints * F_OUTLIERS;
+    // int Noutliers = Noutliers_max*drand48_cnt(); // minimum of 0 points
+
+    int Npoints = N_POINTS; // minimum of 0 points
+    int Noutliers = Npoints * F_OUTLIERS;
 
     // generate a single fake star with N_POINTS real points and N_OUTLIERS bad points
@@ -287,5 +290,6 @@
   escape:
     fprintf (stdout, "%12.8f %12.8f %8.6f %8.6f %8.6f | %12.8f %12.8f %8.6f %8.6f %8.6f | %12.8f |  %8.6f %8.6f %8.6f %8.6f %8.6f  %d | %f\n",
-	     NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, 0.0, NAN, NAN, NAN, NAN, NAN, 0, 0.0);
+	     Ro, Do, uR, uD, plx, 
+	     NAN, NAN, NAN, NAN, NAN, 0.0, NAN, NAN, NAN, NAN, NAN, 0, 0.0);
   }
   // return exit_status();
Index: trunk/Ohana/src/relastro/test/mana.sh
===================================================================
--- trunk/Ohana/src/relastro/test/mana.sh	(revision 39603)
+++ trunk/Ohana/src/relastro/test/mana.sh	(revision 39610)
@@ -91,6 +91,7 @@
   # foreach outliers 0 3 10 30 100 
 
-  foreach outliers 10
-    exec ../bin/fitpm.lin64 -Nstars 3000 -Noutliers $outliers -Npoints 100 -Nbootstrap 100 $1 > test.$1.dat
+  foreach outliers 0
+    echo ../bin/fitpm.lin64 -Nstars 3000 -Npoints 100 -Nbootstrap 100 $1 
+    exec ../bin/fitpm.lin64 -Nstars 3000 -Npoints 100 -Nbootstrap 100 $1 > test.$1.dat
     reload test.$1.dat 0
 
@@ -107,6 +108,6 @@
   data $1
   if ($2)
-    read Npts 1 Nout 2 Ro 3 Do 4 uRo 5 uDo 6 Po 7 Rx 9 Dx 10 uRx 11 uDx 12 Px 13 Tx 15 dRo 17 dDo 18 duRo 19 duDo 20 dPo 21 Nfit 22 chisq 26
-    # read Ro 1 Do 2 uRo 3 uDo 4 Po 5 Rx 7 Dx 8 uRx 9 uDx 10 Px 11 Tx 13 dRo 15 dDo 16 duRo 17 duDo 18 dPo 19 Nfit 20 chisq 24
+    # read Npts 1 Nout 2 Ro 3 Do 4 uRo 5 uDo 6 Po 7 Rx 9 Dx 10 uRx 11 uDx 12 Px 13 Tx 15 dRo 17 dDo 18 duRo 19 duDo 20 dPo 21 Nfit 22 chisq 26
+    read Ro 1 Do 2 uRo 3 uDo 4 Po 5 Rx 7 Dx 8 uRx 9 uDx 10 Px 11 Tx 13 dRo 15 dDo 16 duRo 17 duDo 18 dPo 19 Nfit 20 chisq 24
   else
     read Ro 1 Do 2 uRo 3 uDo 4 Po 5 Rx 7 Dx 8 uRx 9 uDx 10 Px 11 Tx 13 dRo 15 dDo 16 duRo 17 duDo 18 dPo 19 Nfit 20 chisq 22
