Index: /branches/eam_branch_20080223/Ohana/src/relastro/src/UpdateObjects.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/relastro/src/UpdateObjects.c	(revision 16786)
+++ /branches/eam_branch_20080223/Ohana/src/relastro/src/UpdateObjects.c	(revision 16787)
@@ -38,4 +38,37 @@
 }  
 
+enum {ERROR_MODE_RA, ERROR_MODE_DEC};
+
+float GetAstromError (Measure *measure, int mode) {
+
+  PhotCode *code;
+  float dPobs, dPsys, dPtotal, dM, AS, MS;
+
+  switch (mode) {
+    case ERROR_MODE_RA:
+      dPobs = measure[0].dXccd;  // need to redefine this as RAerr
+      break;
+    case ERROR_MODE_DEC:
+      dPobs = measure[0].dYccd;  // need to redefine this as RAerr
+      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);
+  AS   	= code[0].astromErrScale;
+  MS   	= code[0].astromErrMagScale;
+  dPsys = code[0].astromErrSys;
+  dM    = measure[0].dM;
+  
+  dPtotal = sqrt(SQ(dPsys) + AS*SQ(dPobs) + MS*SQ(dM));
+  dPtotal = MAX (dPtotal, MIN_ERROR);
+
+  return (dPtotal);
+}
+
 int UpdateObjects (Catalog *catalog, int Ncatalog) {
 
@@ -48,5 +81,4 @@
   double Tmin, Tmax;
   float errorScale;
-  PhotCode *code;
 
   initObjectData (catalog, Ncatalog);
@@ -96,11 +128,6 @@
 	Tmax = MAX(Tmax, T[N]);
 
-	/* the astrometric errors are not being carried yet (but should be!) */
-	/* we use the photometric mag error as a weighting term */
-
-	code = GetPhotcodebyCode (catalog[0].measure[m].photcode);
-	errorScale = code[0].astromScale;
-	dR[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR) * errorScale;
-	dD[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR) * errorScale;
+	dR[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_RA);
+	dD[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_DEC);
 	dT[N] = catalog[i].measure[m].dt;
 
