Index: branches/eam_branches/ipp-20101205/Ohana/src/relastro/src/GetAstromError.c
===================================================================
--- branches/eam_branches/ipp-20101205/Ohana/src/relastro/src/GetAstromError.c	(revision 30476)
+++ branches/eam_branches/ipp-20101205/Ohana/src/relastro/src/GetAstromError.c	(revision 30477)
@@ -1,24 +1,31 @@
 # include "relastro.h"
+# define WEIGHTED_ERRORS 0
 
 float GetAstromError (Measure *measure, int mode) {
-  //BIG HACKXXXXXXXX
-  return 0.1;
+
   PhotCode *code;
-  float dPobs, dPsys, dPtotal, dM, AS, MS;
+  float dPobs, dPsys, dPtotal, dM, AS, MS, dX, dY;
+
+  if (!WEIGHTED_ERRORS) {
+    // if we don't understand the errors at all, this at least lets us get things roughly
+    // right:
+    return 0.1;
+  }
+
   switch (mode) {
     case ERROR_MODE_RA:
-      dPobs = measure[0].dXccd / 100.0;  // need to redefine this as RAerr
+      dPobs = FromShortPixels(measure[0].dXccd);  // dXccd is a value in pixels
       break;
     case ERROR_MODE_DEC:
-      dPobs = measure[0].dYccd / 100.0;  // need to redefine this as RAerr
+      dPobs = FromShortPixels(measure[0].dYccd);  // dYccd is a value in pixels
       break;
     case ERROR_MODE_POS:
-      dPobs = hypot (measure[0].dXccd, measure[0].dYccd) / 100.0;  // need to redefine this as RAerr
+      dX = FromShortPixels(measure[0].dXccd);  // dXccd is a value in pixels
+      dY = FromShortPixels(measure[0].dYccd);  // dYccd is a value in pixels
+      dPobs = hypot (dX, dY);
       break;
     default:
       abort();
   }
-  /* the astrometric errors are not being carried yet (but should be!) */
-  /* we use the photometric mag error as a weighting term */
 
   code 	= GetPhotcodebyCode (measure[0].photcode);
@@ -27,8 +34,5 @@
   dPsys = code[0].astromErrSys;
   dM    = measure[0].dM;
-  dPtotal = sqrt(SQ(dPsys) + AS*SQ(dPobs) + MS*SQ(dM));
-
-  //XXX dXccd, dYccd are now working correctly
-  //dPtotal = AS * dPobs;
+  dPtotal = sqrt(SQ(dPsys) + SQ(AS*dPobs) + SQ(MS*dM));
 
   dPtotal = MAX (dPtotal, MIN_ERROR);
@@ -36,2 +40,17 @@
 }
 
+/* for a long time, psphot was either not reported position errors, or was reporting
+ * completely wrong astrometry errors.  This function lets us handle, in the
+ * configuration, different strategies to generating a position error 
+ *
+ * astrometry systematic error : this is the minimum expected per-position error.  You
+ * should probably measure this from you data.  watch out for the chicken and egg problem!
+ *
+ * astrometry error scale : this field lets you accept position errors in (say) pixels and
+ * convert them with this term to arcsec.  AS : pixel scale in arcsec
+ *
+ * astrometry mag scale : this field lets you define position errors based on the
+ * photometry error.  the scale factor should be something like a typical seeing number
+ * (in arcsec) for the given instrument
+ *
+ */
