Index: /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_setphot.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_setphot.c	(revision 33226)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_setphot.c	(revision 33226)
@@ -0,0 +1,54 @@
+# include "uniphot.h"
+# include <glob.h>
+
+// for parallel operation, we need to have a threaded client / server model here:
+// save the zero point information to a temporary file
+// launch remote jobs on each of the remote hosts
+// monitor the results
+// harvest the children
+
+int update_setphot_parallel () {
+
+   return (TRUE);
+}      
+
+void update_catalog_setphot (Catalog *catalog, Image *image, off_t *index, off_t Nimage, FlatCorrectionTable *flatcorr) {
+
+  off_t i, j, found;
+
+  found = 0;    
+  for (i = 0; i < catalog[0].Naverage; i++) {
+
+    off_t m = catalog[0].average[i].measureOffset;
+    for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) {
+      off_t idx = catalog[0].measure[m].imageID;
+      if (idx <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode)
+
+      off_t id = index[idx];
+      float Mcal = image[id].Mcal;
+      float dMcal = image[id].dMcal;
+      float Mcal_offset = 0.0;
+
+      // if we know about a flat-field correction, then we need to apply the sub-chip correction
+      int flat_id = image[id].photom_map_id;
+      if (flat_id > 0) {
+	  Mcal_offset = FlatCorrectionOffset (flatcorr, flat_id, catalog[0].measure[m].Xccd, catalog[0].measure[m].Yccd);
+      }
+
+      catalog[0].measure[m].Mcal = Mcal - Mcal_offset;
+      catalog[0].measure[m].dMcal = dMcal;
+
+      // if we are setting the zero points from an UBERCAL database, and this detection is from one of those images,
+      // then tag the measurement as well
+      if (UBERCAL && (image[id].flags & ID_IMAGE_PHOTOM_UBERCAL)) {
+	catalog[0].measure[m].dbFlags |=  ID_MEAS_PHOTOM_UBERCAL;
+      }
+
+      found ++;
+    }
+  }
+
+  if (found) {
+    fprintf (stderr, "found "OFF_T_FMT" matches\n", found);
+  }
+}
