Index: /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h	(revision 33564)
@@ -172,12 +172,14 @@
 /* Secfilt.flags values -- these values are 32 bit (as of PS1_V1) */
 typedef enum {
-  ID_SECF_STAR_FEW  = 0x00000001, // used within relphot: skip star
-  ID_SECF_STAR_POOR = 0x00000002, // used within relphot: skip star
-  ID_PHOTOM_PASS_0  = 0x00000100, // average magnitude calculated in 0th pass
-  ID_PHOTOM_PASS_1  = 0x00000200, // average magnitude calculated in 1th pass
-  ID_PHOTOM_PASS_2  = 0x00000400, // average magnitude calculated in 2th pass
-  ID_PHOTOM_PASS_3  = 0x00000800, // average magnitude calculated in 3th pass
-  ID_PHOTOM_PASS_4  = 0x00001000, // average magnitude calculated in 4th pass
-  ID_SECF_OBJ_EXT   = 0x01000000, // extended in this band
+  ID_SECF_STAR_FEW    = 0x00000001, // used within relphot: skip star
+  ID_SECF_STAR_POOR   = 0x00000002, // used within relphot: skip star
+  ID_SECF_USE_SYNTH   = 0x00000004, // synthetic photometry used in average measurement
+  ID_SECF_USE_UBERCAL = 0x00000008, // synthetic photometry used in average measurement
+  ID_PHOTOM_PASS_0    = 0x00000100, // average magnitude calculated in 0th pass
+  ID_PHOTOM_PASS_1    = 0x00000200, // average magnitude calculated in 1th pass
+  ID_PHOTOM_PASS_2    = 0x00000400, // average magnitude calculated in 2th pass
+  ID_PHOTOM_PASS_3    = 0x00000800, // average magnitude calculated in 3th pass
+  ID_PHOTOM_PASS_4    = 0x00001000, // average magnitude calculated in 4th pass
+  ID_SECF_OBJ_EXT     = 0x01000000, // extended in this band
 } DVOSecfiltFlags;
 
@@ -254,4 +256,5 @@
   char *hostname;	      // name of remote machine
   char *pathname;	      // name of directory for this machine's data
+  char *results;	      // name of file machine's result data
   int hostID;		      // remove machine ID in SkyTable
   int stdio[3]; 	      // fd's for communication with the remote host
Index: /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c	(revision 33564)
@@ -9,4 +9,5 @@
     hosts[i].hostname = NULL;
     hosts[i].pathname = NULL;
+    hosts[i].results = NULL;
     hosts[i].stdio[HOST_STDIN] = -1;
     hosts[i].stdio[HOST_STDOUT] = -1;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_host_utils.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_host_utils.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_host_utils.c	(revision 33564)
@@ -8,4 +8,9 @@
 int HostTableLaunchJobs (HostTable *table, char *basecmd, char *options) {
 
+  char uniquer[12];
+  int TIME = time(NULL);
+  int PID = getpid();
+  snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
+
   int i;
   for (i = 0; i < table->Nhosts; i++) {
@@ -16,8 +21,13 @@
     table->hosts[i].pathname = tmppath;
 
-    char resultFile[MAX_PATH_LENGTH];
-    snprintf (resultFile, MAX_PATH_LENGTH, "%s/dvo.results.fits", table->hosts[i].pathname);
+    // need to save the results filename with the uniquer
+    // XXX a bit of a waste (but only 1024 * 60 bytes or so
+    ALLOCATE (table->hosts[i].results, char, MAX_PATH_LENGTH);
+    snprintf (table->hosts[i].results, MAX_PATH_LENGTH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer);
 
-    char *commandFile = abspath("dvo_client.command.txt", MAX_PATH_LENGTH);
+    char commandBase[MAX_PATH_LENGTH];
+    snprintf (commandBase, MAX_PATH_LENGTH, "dvo.command.%s.txt", uniquer);
+    char *commandFile = abspath(commandBase, MAX_PATH_LENGTH);
+
     FILE *f = fopen (commandFile, "w");
     fprintf (f, "%s\n", basecmd);
@@ -25,5 +35,5 @@
 
     char command[1024];
-    snprintf (command, 1024, "dvo_client %s -result %s %s -hostID %d -hostdir %s", commandFile, resultFile, options, table->hosts[i].hostID, table->hosts[i].pathname);
+    snprintf (command, 1024, "dvo_client %s -result %s %s -hostID %d -hostdir %s", commandFile, table->hosts[i].results, options, table->hosts[i].hostID, table->hosts[i].pathname);
     free (commandFile);
 
@@ -134,9 +144,8 @@
     if (table->hosts[i].status) continue; 
 
-    char resultFile[MAX_PATH_LENGTH];
-    snprintf (resultFile, MAX_PATH_LENGTH, "%s/dvo.results.fits", table->hosts[i].pathname);
-	
     int    Ninvec = 0;
-    Vector **invec = ReadVectorTableFITS (resultFile, "RESULT", &Ninvec);
+    Vector **invec = ReadVectorTableFITS (table->hosts[i].results, "RESULT", &Ninvec);
+    free (table->hosts[i].results);
+    table->hosts[i].results = NULL;
 
     if (Nelements == 0) {
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/load_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/load_catalogs.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/load_catalogs.c	(revision 33564)
@@ -127,6 +127,6 @@
     table->hosts[i].pathname = tmppath;
 
-    char catalogFile[512];
-    snprintf (catalogFile, 512, "%s/relastro.catalog.subset.dat", table->hosts[i].pathname);
+    ALLOCATE (table->hosts[i].results, char, 1024);
+    snprintf (table->hosts[i].results, 1024, "%s/relastro.catalog.subset.dat", table->hosts[i].pathname);
 
     // options / arguments that can affect relastro_client -load:
@@ -211,9 +211,5 @@
   for (i = 0; i < table->Nhosts; i++) {
 
-    // XXX save this name in table->hosts[]?  it is created above as well...
-    char catalogFile[512];
-    snprintf (catalogFile, 512, "%s/relastro.catalog.subset.dat", table->hosts[i].pathname);
-
-    BrightCatalog *bcatalog = BrightCatalogLoad (catalogFile);
+    BrightCatalog *bcatalog = BrightCatalogLoad (table->hosts[i].results);
     assert (bcatalog);
     
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/StarOps.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/StarOps.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/StarOps.c	(revision 33564)
@@ -200,4 +200,6 @@
 	int Ncode = 0;
 	int Next = 0;
+	int haveSynth = FALSE;
+	int haveUbercal = FALSE;
 
 	N = 0;
@@ -250,4 +252,9 @@
 	    }
 	  }
+	  // ignore SYNTH photocdes until PASS == 4 (where we also accept saturated stars)
+	  if ((catalog[i].measure[m].photcode >= 3001) && (catalog[i].measure[m].photcode <= 3005)) {
+	    if (pass < 4) continue;
+	    haveSynth = TRUE;
+	  }
 
 	  // dlist gives the error, which is used as the weight in WT_MEAN.
@@ -262,4 +269,5 @@
 	  if (catalog[i].measureT[m].dbFlags & ID_MEAS_PHOTOM_UBERCAL) {
 	    dlist[N] = MAX (0.1*catalog[i].measureT[m].dM, MIN_ERROR);
+	    haveUbercal = TRUE;
 	  }
 
@@ -299,4 +307,11 @@
 	}
 
+	if (haveSynth) {
+	  catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_SECF_USE_SYNTH;
+	}	
+	if (haveUbercal) {
+	  catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_SECF_USE_UBERCAL;
+	}	
+
 	/* use sigma or error in dM for output? */
 	catalog[i].secfilt[Nsecfilt*j+Nsec].M  = stats.mean;
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c	(revision 33564)
@@ -60,5 +60,8 @@
 	ID_PHOTOM_PASS_2 | 
 	ID_PHOTOM_PASS_3 | 
-	ID_PHOTOM_PASS_4;
+	ID_PHOTOM_PASS_4 |
+	ID_SECF_USE_SYNTH |
+	ID_SECF_USE_UBERCAL |
+	ID_SECF_OBJ_EXT;
       for (Ns = 0; Ns < Nphotcodes; Ns++) {
 
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c	(revision 33564)
@@ -127,6 +127,6 @@
     table->hosts[i].pathname = tmppath;
 
-    char catalogFile[512];
-    snprintf (catalogFile, 512, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname);
+    ALLOCATE (table->hosts[i].results, char, 1024);
+    snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname);
 
     // options / arguments that can affect relphot_client -load:
@@ -144,5 +144,5 @@
     char command[1024];
     snprintf (command, 1024, "relphot_client %s -load %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D CAMERA %s -D MAG_LIM %f -D SIGMA_LIM %f", 
-	      PhotcodeList, catalogFile, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, CAMERA, MAG_LIM, SIGMA_LIM);
+	      PhotcodeList, table->hosts[i].results, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, CAMERA, MAG_LIM, SIGMA_LIM);
 
     char tmpline[1024];
@@ -202,9 +202,6 @@
   for (i = 0; i < table->Nhosts; i++) {
 
-    char catalogFile[512];
-    snprintf (catalogFile, 512, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname);
-
     BrightCatalog *bcatalog = NULL;
-    while ((bcatalog = BrightCatalogLoad (catalogFile)) == NULL) {
+    while ((bcatalog = BrightCatalogLoad (table->hosts[i].results)) == NULL) {
       // failed to get the data from this host.  This can happen for various reasons.  Give the user a chance to try again...
       fprintf (stderr, "failed to read data from %s, stopping operations until this can be fixed\n", table->hosts[i].hostname);
@@ -212,6 +209,8 @@
       int pid = getpid();
       kill (pid, SIGSTOP);
-      fprintf (stderr, "retrying %s\n", catalogFile);
-    }
+      fprintf (stderr, "retrying %s\n", table->hosts[i].results);
+    }
+    free (table->hosts[i].results);
+    table->hosts[i].results = NULL;
     
     BrightCatalogSplit (catalogs, bcatalog);
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot_objects.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot_objects.c	(revision 33564)
@@ -67,6 +67,9 @@
 	ID_PHOTOM_PASS_2 | 
 	ID_PHOTOM_PASS_3 | 
-	ID_PHOTOM_PASS_4;
-
+	ID_PHOTOM_PASS_4 |
+	ID_SECF_USE_SYNTH |
+	ID_SECF_USE_UBERCAL |
+	ID_SECF_OBJ_EXT;
+      
       for (j = 0; j < catalog.Naverage; j++) {
 	catalog.average[j].flags = 0;
@@ -128,7 +131,4 @@
     table->hosts[i].pathname = tmppath;
 
-    char catalogFile[512];
-    snprintf (catalogFile, 512, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname);
-
     // options / arguments that can affect relphot_client -update-objects:
     // VERBOSE, VERBOSE2
Index: /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/setMrelFinal.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/setMrelFinal.c	(revision 33563)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/setMrelFinal.c	(revision 33564)
@@ -22,10 +22,13 @@
     
     // flags used by the photometry analysis (excluding UBERCAL)
-    unsigned int PHOTOM_PASSES = 
+    unsigned int secfiltFlags = 
       ID_PHOTOM_PASS_0 | // average measured at pass 0
       ID_PHOTOM_PASS_1 | // average measured at pass 1
       ID_PHOTOM_PASS_2 | // average measured at pass 2
       ID_PHOTOM_PASS_3 | // average measured at pass 3
-      ID_PHOTOM_PASS_4;  // average measured at pass 4
+      ID_PHOTOM_PASS_4 | // average measured at pass 3
+      ID_SECF_USE_SYNTH | // average measured at pass 3
+      ID_SECF_USE_UBERCAL | // average measured at pass 3
+      ID_SECF_OBJ_EXT; // average measured at pass 3
     
     int Ns;
@@ -45,5 +48,5 @@
 	catalog[0].secfilt[N].Ncode  = 0;
 	catalog[0].secfilt[N].Nused  = 0;
-	catalog[0].secfilt[N].flags &= ~PHOTOM_PASSES;
+	catalog[0].secfilt[N].flags &= ~secfiltFlags;
 	catalog[0].secfilt[N].ubercalDist = 1000;
 
