Index: /branches/czw_branch/20170908/Ohana/src/uniphot/src/cam_zpt_correction.c
===================================================================
--- /branches/czw_branch/20170908/Ohana/src/uniphot/src/cam_zpt_correction.c	(revision 40368)
+++ /branches/czw_branch/20170908/Ohana/src/uniphot/src/cam_zpt_correction.c	(revision 40369)
@@ -286,4 +286,15 @@
   // table->offset[seq][ix][iy] with dM values for image[seq] 
 
+  // Set up HSC/GPC1 distinguishing limits
+
+  int minCodeGPC1 = 10000;
+  int maxCodeGPC1 = 10576;
+
+  int minCodeHSC  = 20000;
+  int maxCodeHSC  = 26111;
+
+  int isGPC1 = FALSE;
+  int isHSC  = FALSE;
+    
   // loop over the flatcorr images and match from image[seq] to newcorr:
   for (i = 0; i < flatcorr->Nimage; i++) {
@@ -302,8 +313,28 @@
     int photcode = flatcorr->image[i].photcode;
 
+    if ((photcode >= minCodeGPC1)&&(photcode <= maxCodeGPC1)) {
+      isGPC1 = TRUE;
+      isHSC  = FALSE;
+    }
+    else if ((photcode >= minCodeHSC)&&(photcode <= maxCodeHSC)) {
+      isGPC1 = FALSE;
+      isHSC  = TRUE;
+    }
+    if (!(isGPC1) && !(isHSC)) { continue; }
+
+    int iy, ix, filter;
+
+    
     // find the chip and filter from photcode:
-    int iy = photcode % 10;
-    int ix = (int)(photcode / 10) % 10;
-    int filter = (int)(photcode / 100) % 10;
+    if (isGPC1) {
+      iy = photcode % 10;
+      ix = (int)(photcode / 10) % 10;
+      filter = (int)(photcode / 100) % 10;
+    }
+    else if (isHSC) {
+      iy = 0;
+      ix = (int) photcode % 112;
+      filter = (int)(photcode / 1000) % 10;
+    }
 	      
     myAssert (ix     < newcorr->Nx, "oops");
Index: /branches/czw_branch/20170908/Ohana/src/uniphot/src/match_camcorr_to_images.c
===================================================================
--- /branches/czw_branch/20170908/Ohana/src/uniphot/src/match_camcorr_to_images.c	(revision 40368)
+++ /branches/czw_branch/20170908/Ohana/src/uniphot/src/match_camcorr_to_images.c	(revision 40369)
@@ -55,7 +55,7 @@
       }
       else if (isHSC) {
-	int ix = photcode % 112;
 	int filter = (int)(photcode / 1000) % 10;
-
+	int ix = photcode - 20000 - filter * 1000;
+	
 	seq = ix + filter * camcorr->Nchips + j * camcorr->Nflats;
       }
Index: /branches/czw_branch/20170908/Ohana/src/uniphot/src/setphot.c
===================================================================
--- /branches/czw_branch/20170908/Ohana/src/uniphot/src/setphot.c	(revision 40368)
+++ /branches/czw_branch/20170908/Ohana/src/uniphot/src/setphot.c	(revision 40369)
@@ -73,5 +73,5 @@
     // we are going to deprecate the flatcorr imaage lookup
     // match_flatcorr_to_images (image, Nimage, &flatcorrTable);
-    match_camcorr_to_images (image, Nimage, camcorr);
+  match_camcorr_to_images (image, Nimage, camcorr);
     //  } 
 
