Index: /branches/eam_branches/ipp-20130509/Ohana/src/relphot/include/relphot.h
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/relphot/include/relphot.h	(revision 35733)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/relphot/include/relphot.h	(revision 35734)
@@ -17,4 +17,6 @@
 # define GRID_V2
 # define NO_IMAGE -100
+
+# define ID_SECF_STACK_PRIMARY 0x00004000
 
 // choose off_t or int depending on full-scale relphot analysis resources
@@ -114,4 +116,7 @@
   unsigned int photom_map_id;
   unsigned int flags;
+  int projID;
+  int skycellID;
+  unsigned int tzero;
   unsigned int tzero;
   unsigned char trate;
@@ -149,4 +154,5 @@
 char        *IMAGES;
 char        *BCATALOG;
+char        *BOUNDARY_TREE;
 ModeType     MODE;
 
Index: /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/ImageSubset.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/ImageSubset.c	(revision 35733)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/ImageSubset.c	(revision 35734)
@@ -63,4 +63,6 @@
   GET_COLUMN (map,     "PHOTOM_MAP", int);
   GET_COLUMN (flags,   "FLAGS",      int);
+  GET_COLUMN (projID,  "PROJ_ID",    int);
+  GET_COLUMN (skycellID, "SKYCELL_ID", int);
   GET_COLUMN (tzero,   "TZERO",      int);
   GET_COLUMN (trate,   "TRATE",      short);
@@ -76,4 +78,6 @@
     image[i].photom_map_id = map[i];
     image[i].flags         = flags[i];
+    image[i].projID        = projID[i];
+    image[i].skycellID     = skycellID[i];
     image[i].tzero         = tzero[i];
     image[i].trate         = trate[i];
@@ -87,4 +91,6 @@
   free (map);
   free (flags);
+  free (projID);
+  free (skycellID);
   free (tzero);
   free (trate);
@@ -124,4 +130,7 @@
   gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000);
 
+  gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0);
+
   gfits_define_bintable_column (&theader, "J", "TZERO", "exposure start", NULL, 1.0, 1.0*0x8000);
   gfits_define_bintable_column (&theader, "I", "TRATE", "tti rate", NULL, 1.0, 0.0);
@@ -134,16 +143,19 @@
   float *Mcal, *dMcal;
   unsigned int *imageID, *map, *flags, *tzero;
+  int *projID, *skycellID;
   unsigned short *trate;
   short *ucdist;
 
   // create intermediate storage arrays
-  ALLOCATE (Mcal,    float, 	     Nimage);
-  ALLOCATE (dMcal,   float, 	     Nimage);
-  ALLOCATE (imageID, unsigned int,   Nimage);
-  ALLOCATE (map,     unsigned int,   Nimage);
-  ALLOCATE (flags,   unsigned int,   Nimage);
-  ALLOCATE (tzero,   unsigned int,   Nimage);
-  ALLOCATE (trate,   unsigned short, Nimage);
-  ALLOCATE (ucdist,  short,          Nimage);
+  ALLOCATE (Mcal,      float, 	     Nimage);
+  ALLOCATE (dMcal,     float, 	     Nimage);
+  ALLOCATE (imageID,   unsigned int,   Nimage);
+  ALLOCATE (map,       unsigned int,   Nimage);
+  ALLOCATE (flags,     unsigned int,   Nimage);
+  ALLOCATE (projID,    int,            Nimage);
+  ALLOCATE (skycellID, int,            Nimage);
+  ALLOCATE (tzero,     unsigned int,   Nimage);
+  ALLOCATE (trate,     unsigned short, Nimage);
+  ALLOCATE (ucdist,    short,          Nimage);
 
   // assign the storage arrays
@@ -157,15 +169,24 @@
     trate[i]   = image[i].trate;
     ucdist[i]  = image[i].ubercalDist;
+
+    projID[i] = -1;
+    skycellID[i] = -1;
+    if (!strncmp (image[i].name, "RINGS.V3.skycell", strlen("RINGS.V3.skycell"))) {
+      projID[i] = atoi(&image[i].name[18]);
+      skycellID[i] = atoi(&image[i].name[23]);
+    }
   }
 
   // add the columns to the output array
-  gfits_set_bintable_column (&theader, &ftable, "MCAL",         Mcal,    Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "MCAL_ERR",     dMcal,   Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "IMAGE_ID",     imageID, Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP",   map,     Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "FLAGS",        flags,   Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "TZERO",        tzero,   Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "TRATE",        trate,   Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "UBERCAL_DIST", ucdist,  Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "MCAL",         Mcal,      Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "MCAL_ERR",     dMcal,     Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "IMAGE_ID",     imageID,   Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP",   map,       Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "FLAGS",        flags,     Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "PROJ_ID",      projID,    Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "SKYCELL_ID",   skycellID, Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "TZERO",        tzero,     Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "TRATE",        trate,     Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "UBERCAL_DIST", ucdist,    Nimage);
 
   free (Mcal);
@@ -174,4 +195,6 @@
   free (map);
   free (flags);
+  free (projID);
+  free (skycellID);
   free (tzero);
   free (trate);
Index: /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/args.c	(revision 35733)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/args.c	(revision 35734)
@@ -211,7 +211,9 @@
   }
 
+  BOUNDARY_TREE = NULL;
   if ((N = get_argument (argc, argv, "-boundary-tree"))) {
     remove_argument (N, &argc, argv);
-    load_tree (argv[N]);
+    BOUNDARY_TREE = strcreate(argv[N]);
+    load_tree (BOUNDARY_TREE);
     remove_argument (N, &argc, argv);
   }
@@ -409,4 +411,12 @@
     remove_argument (N, &argc, argv);
     strcpy (STATMODE, argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  BOUNDARY_TREE = NULL;
+  if ((N = get_argument (argc, argv, "-boundary-tree"))) {
+    remove_argument (N, &argc, argv);
+    BOUNDARY_TREE = strcreate(argv[N]);
+    load_tree (BOUNDARY_TREE);
     remove_argument (N, &argc, argv);
   }
Index: /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/reload_catalogs.c	(revision 35733)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/reload_catalogs.c	(revision 35734)
@@ -187,4 +187,5 @@
     if (!KEEP_UBERCAL)    { snprintf (tmpline, 1024, "%s -reset-ubercal",	command); 		                          strcpy (command, tmpline); }
     if (UPDATE_CATFORMAT) { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); 		          strcpy (command, tmpline); }
+    if (BOUNDARY_TREE)    { snprintf (tmpline, 1024, "%s -boundary-tree %s",    command, BOUNDARY_TREE); 		          strcpy (command, tmpline); }
     if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", command, SET_MREL_VERSION);                  strcpy (command, tmpline); }
     if (AreaSelect)       { snprintf (tmpline, 1024, "%s -area %f %f %f %f",    command, AreaXmin, AreaXmax, AreaYmin, AreaYmax); strcpy (command, tmpline); }
Index: /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/setMrelFinal.c
===================================================================
--- /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/setMrelFinal.c	(revision 35733)
+++ /branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/setMrelFinal.c	(revision 35734)
@@ -16,9 +16,15 @@
     // flags used by the photometry analysis (excluding UBERCAL)
     unsigned int PHOTOM_FLAGS = 
-      ID_MEAS_NOCAL |       // detection ignored for this analysis (photcode, time range)
-      ID_MEAS_POOR_PHOTOM | // detection is photometry outlier 
-      ID_MEAS_SKIP_PHOTOM | // detection was ignored for photometry measurement 
-      ID_MEAS_AREA;	  // detetion was outside acceptable area of device
-    
+      ID_MEAS_NOCAL |          // detection ignored for this analysis (photcode, time range)
+      ID_MEAS_POOR_PHOTOM |    // detection is photometry outlier 
+      ID_MEAS_SKIP_PHOTOM |    // detection was ignored for photometry measurement 
+      ID_MEAS_AREA |	       // detetion was outside acceptable area of device
+      ID_MEAS_SYNTH_MAG |      // magnitude is synthetic
+      ID_MEAS_STACK_PRIMARY |  // this stack measurement is in the primary skycell
+      ID_MEAS_STACK_PHOT_SRC;  // this measurement supplied the stack photometry
+
+    // ID_MEAS_PHOTOM_UBERCAL -- externally-supplied zero point from ubercal analysis
+    // this is set by 'setphot', do not reset here
+
     // flags used by the photometry analysis (excluding UBERCAL)
     // unsigned int secfiltFlags = 
