Index: /branches/czw_branch/20160809/Ohana/src/relphot/include/relphot.h
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/relphot/include/relphot.h	(revision 39720)
+++ /branches/czw_branch/20160809/Ohana/src/relphot/include/relphot.h	(revision 39721)
@@ -309,4 +309,5 @@
 int    RESET_ZEROPTS;
 int    REPAIR_WARPS;
+int    PRESERVE_PS1;
 int    UPDATE;
 int    SAVE_IMAGE_UPDATES;
@@ -616,4 +617,7 @@
 int isTYCHO (int photcode);
 
+int isHSCchip  (int photcode);
+int isCFHchip  (int photcode);
+
 int magStatsByRanking (StatDataSet *dataset, StatType *stats);
 
Index: /branches/czw_branch/20160809/Ohana/src/relphot/src/args.c
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/relphot/src/args.c	(revision 39720)
+++ /branches/czw_branch/20160809/Ohana/src/relphot/src/args.c	(revision 39721)
@@ -226,4 +226,10 @@
     remove_argument (N, &argc, argv);
     REPAIR_WARPS = TRUE;
+  }
+
+  PRESERVE_PS1 = FALSE;
+  if ((N = get_argument (argc, argv, "-preserve-ps1"))) {
+    remove_argument (N, &argc, argv);
+    PRESERVE_PS1 = TRUE;
   }
 
@@ -672,4 +678,10 @@
   }
 
+  PRESERVE_PS1 = FALSE;
+  if ((N = get_argument (argc, argv, "-preserve-ps1"))) {
+    remove_argument (N, &argc, argv);
+    PRESERVE_PS1 = TRUE;
+  }
+
   REPAIR_WARPS = FALSE;
   if ((N = get_argument (argc, argv, "-repair-warps"))) {
Index: /branches/czw_branch/20160809/Ohana/src/relphot/src/extra.c
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/relphot/src/extra.c	(revision 39720)
+++ /branches/czw_branch/20160809/Ohana/src/relphot/src/extra.c	(revision 39721)
@@ -2,7 +2,8 @@
 
 // for now (20140710) I need to identify gpc1 chips explicitly.  generalize in the future
+// note that the 4000, 14000, 15000 sets are SIMTEST (*not* synthetic) 
 int whichGPC1filter (int photcode) {
 
-  if (((photcode > 10000) && (photcode < 10077)) || (photcode == 4100)) return PS1_g; // g-band
+  if (((photcode > 10000) && (photcode < 10077)) || (photcode == 4100)) return PS1_g; // g-band 
   if (((photcode > 10100) && (photcode < 10177)) || (photcode == 4200)) return PS1_r; // r-band
   if (((photcode > 10200) && (photcode < 10277)) || (photcode == 4300)) return PS1_i; // i-band
@@ -83,2 +84,26 @@
 }
 
+// for now (20160925) I need to identify HSC chips explicitly.  generalize in the future
+int isHSCchip (int photcode) {
+
+  if ((photcode >= 20000) && (photcode <= 20111)) return TRUE; // g-band
+  if ((photcode >= 21000) && (photcode <= 21111)) return TRUE; // r-band
+  if ((photcode >= 22000) && (photcode <= 22111)) return TRUE; // i-band
+  if ((photcode >= 23000) && (photcode <= 23111)) return TRUE; // z-band
+  if ((photcode >= 24000) && (photcode <= 24111)) return TRUE; // y-band
+
+  return FALSE;
+}
+
+// for now (20160925) I need to identify CFH chips explicitly.  generalize in the future
+int isCFHchip (int photcode) {
+
+  if ((photcode >= 100) && (photcode <= 152)) return TRUE; // g-band
+  if ((photcode >= 200) && (photcode <= 252)) return TRUE; // r-band
+  if ((photcode >= 300) && (photcode <= 352)) return TRUE; // i-band
+  if ((photcode >= 400) && (photcode <= 452)) return TRUE; // z-band
+  if ((photcode >= 500) && (photcode <= 552)) return TRUE; // y-band
+
+  return FALSE;
+}
+
Index: /branches/czw_branch/20160809/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/relphot/src/reload_catalogs.c	(revision 39720)
+++ /branches/czw_branch/20160809/Ohana/src/relphot/src/reload_catalogs.c	(revision 39721)
@@ -239,4 +239,5 @@
     if (RESET)             { strextend (&command, "-reset"); }
     if (RESET_ZEROPTS)     { strextend (&command, "-reset-zpts"); }
+    if (PRESERVE_PS1)      { strextend (&command, "-preserve-ps1"); }
     if (UPDATE)            { strextend (&command, "-update"); }
     if (IS_DIFF_DB)        { strextend (&command, "-is-diff-db"); }
Index: /branches/czw_branch/20160809/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/relphot/src/relphot_objects.c	(revision 39720)
+++ /branches/czw_branch/20160809/Ohana/src/relphot/src/relphot_objects.c	(revision 39721)
@@ -243,4 +243,5 @@
     if (RESET_ZEROPTS) 	   { strextend (&command, "-reset-zpts"); }
     if (REPAIR_WARPS)      { strextend (&command, "-repair-warps"); }
+    if (PRESERVE_PS1)      { strextend (&command, "-preserve-ps1"); }
     if (IS_DIFF_DB)        { strextend (&command, "-is-diff-db"); }
     if (UPDATE)        	   { strextend (&command, "-update"); }
Index: /branches/czw_branch/20160809/Ohana/src/relphot/src/setMrelCatalog.c
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/relphot/src/setMrelCatalog.c	(revision 39720)
+++ /branches/czw_branch/20160809/Ohana/src/relphot/src/setMrelCatalog.c	(revision 39721)
@@ -142,4 +142,6 @@
   int Galaxy2MASS = FALSE;
   int haveTYCHO = FALSE;
+  int haveHSC = FALSE;
+  int haveCFH = FALSE;
 
   float stargalmax = 0.0;
@@ -163,4 +165,6 @@
     
     if (isTYCHO(measureT[k].photcode)) { haveTYCHO = TRUE; }
+    if (isHSCchip(measureT[k].photcode)) { haveHSC = TRUE; }
+    if (isCFHchip(measureT[k].photcode)) { haveCFH = TRUE; }
 
     if (is2MASS(measureT[k].photcode)) {
@@ -317,4 +321,10 @@
   // now calculate the mean stats for the Nsec bands.
   for (Nsec = 0; Nsec < Nsecfilt; Nsec++) {
+
+    // if we detected this object in PS1, keep the mean photometry
+    if (PRESERVE_PS1) {
+      if (secfilt[Nsec].flags & ID_SECF_HAS_PS1) continue;
+    }
+
     dvo_secfilt_init (&secfilt[Nsec], SECFILT_RESET_CHIP); // this does not reset astrometry or STACK bits
 
@@ -328,4 +338,10 @@
     if (haveTYCHO) {
       secfilt[Nsec].flags |= ID_SECF_HAS_TYCHO;
+    }
+    if (haveHSC) {
+      secfilt[Nsec].flags |= ID_SECF_HAS_HSC;
+    }
+    if (haveCFH) {
+      secfilt[Nsec].flags |= ID_SECF_HAS_CFH;
     }
 
