Index: trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- trunk/Ohana/src/relphot/include/relphot.h	(revision 11880)
+++ trunk/Ohana/src/relphot/include/relphot.h	(revision 12332)
@@ -84,5 +84,4 @@
 
 PhotCode      *photcode;
-int            PhotPrimary;
 int            PhotNsec;
 int            PhotSec;
Index: trunk/Ohana/src/relphot/src/ConfigInit.c
===================================================================
--- trunk/Ohana/src/relphot/src/ConfigInit.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/ConfigInit.c	(revision 12332)
@@ -5,5 +5,6 @@
   double ZERO_POINT;
   char  *config, *file;
-  char   PhotCodeFile[256];
+  char CatdirPhotcodeFile[256];
+  char MasterPhotcodeFile[256];
 
   /*** load configuration info ***/
@@ -32,4 +33,6 @@
   ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
   ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
+  ScanConfig (config, "PHOTCODE_FILE",         	"%s",  0, MasterPhotcodeFile);
+
   sprintf (ImageCat, "%s/Images.dat", CATDIR);
 
@@ -41,5 +44,4 @@
   }
 
-  GetConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
   GetConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
 
@@ -52,6 +54,8 @@
   if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
 
-  if (!LoadPhotcodes (PhotCodeFile)) {
-    fprintf (stderr, "error loading photcodes\n");
+  /* XXX this does not yet write out the master photcode table */
+  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
   }
Index: trunk/Ohana/src/relphot/src/GridOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/GridOps.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/GridOps.c	(revision 12332)
@@ -282,5 +282,5 @@
       Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);
       list[N] = Msys - Mrel - Mcal - Mmos;
-      dlist[N] = MAX (catalog[c].measure[m].dM_PS, MIN_ERROR);
+      dlist[N] = MAX (catalog[c].measure[m].dM, MIN_ERROR);
       N++;
     }
@@ -447,5 +447,5 @@
   for (i = 0; i < Nimage; i++) {
     image = getimage (imlist[i]);
-    pname = GetPhotcodeNamebyCode (image[0].source);
+    pname = GetPhotcodeNamebyCode (image[0].photcode);
 
     /* this is kind of bogus... */
Index: trunk/Ohana/src/relphot/src/ImageOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/ImageOps.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/ImageOps.c	(revision 12332)
@@ -75,5 +75,5 @@
   for (i = 0; i < Ncatalog; i++) {
     for (j = 0; j < catalog[i].Nmeasure; j++) {
-      ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].source);
+      ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode);
       if (photcode[0].code != ecode) continue;
       matchImage (catalog, j, i);
@@ -82,4 +82,6 @@
 }
 
+/* XXX convert this to use the values of measure->Xccd,Yccd */
+/* XXX need to apply the conversion for ELIXIR and LONEOS formats */
 void matchImage (Catalog *catalog, int meas, int cat) {
 
@@ -91,6 +93,6 @@
   measure = &catalog[cat].measure[meas];
   for (i = 0; i < Nimage; i++) {
-    if (image[0].source == -1) continue;
-    if (measure[0].source != image[i].source) continue;
+    if (image[0].photcode == -1) continue;
+    if (measure[0].photcode != image[i].photcode) continue;
     if (measure[0].t < start[i]) continue;
     if (measure[0].t > stop[i]) continue;
@@ -100,5 +102,5 @@
 
       /* identify the ccd on the basis of the photcode name */
-      pname = GetPhotcodeNamebyCode (image[i].source);
+      pname = GetPhotcodeNamebyCode (image[i].photcode);
       filter = photcode[0].name;
       sprintf (base, "%s.%s.", MOSAICNAME, filter);
@@ -111,6 +113,6 @@
       /* add this measurement to the grid cell for this chip */
       ave = measure[0].averef;
-      ra  = catalog[cat].average[ave].R - measure[0].dR_PS / 3600.0;
-      dec = catalog[cat].average[ave].D - measure[0].dD_PS / 3600.0;
+      ra  = catalog[cat].average[ave].R - measure[0].dR / 3600.0;
+      dec = catalog[cat].average[ave].D - measure[0].dD / 3600.0;
        
       /* X,Y always positive-definite in range 0,0 - dX, dY */
@@ -133,5 +135,5 @@
     return;
   }
-  /*  fprintf (stderr, "can't find source image for this measurement: %d (%d)\n", measure[0].t, measure[0].source); */
+  /*  fprintf (stderr, "can't find source image for this measurement: %d (%d)\n", measure[0].t, measure[0].photcode); */
 }
 
@@ -145,5 +147,5 @@
 
   if (image[i].code & IMAGE_BAD)  return (NO_MAG);  
-  value = image[i].Mcal_PS;
+  value = image[i].Mcal;
   return (value);
 }
@@ -203,5 +205,5 @@
       Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);
       list[N] = Msys - Mrel - Mmos - Mgrid;
-      dlist[N] = MAX (catalog[c].measure[m].dM_PS, MIN_ERROR);
+      dlist[N] = MAX (catalog[c].measure[m].dM, MIN_ERROR);
       N++;
     }
@@ -219,6 +221,6 @@
     
     liststats (list, dlist, N, &stats);
-    image[i].Mcal_PS  = stats.mean;
-    image[i].dMcal_PS = stats.sigma;
+    image[i].Mcal  = stats.mean;
+    image[i].dMcal = stats.sigma;
     image[i].Xm    = 100.0*log10(stats.chisq);
   }
@@ -251,6 +253,6 @@
   for (i = N = 0; i < Nimage; i++) {
     if (image[i].code & IMAGE_BAD) continue;
-    mlist[N] = fabs (image[i].Mcal_PS);
-    slist[N] = image[i].dMcal_PS;
+    mlist[N] = fabs (image[i].Mcal);
+    slist[N] = image[i].dMcal;
     dlist[N] = 1;
     N++;
@@ -268,5 +270,5 @@
     mark = FALSE;
     image[i].code &= ~ID_IMAGE_POOR;
-    mark = (image[i].dMcal_PS > MaxScatter) || (fabs(image[i].Mcal_PS - MedOffset) > MaxOffset);
+    mark = (image[i].dMcal > MaxScatter) || (fabs(image[i].Mcal - MedOffset) > MaxOffset);
     if (mark) { 
       Nmark ++;
@@ -298,7 +300,7 @@
   /**** dMcal vs airmass ****/
   for (i = 0; i < Nimage; i++) {
-    Mlist[i] = image[i].Mcal_PS;
-    dlist[i] = image[i].dMcal_PS;
-    xlist[i] = image[i].secz_PS;
+    Mlist[i] = image[i].Mcal;
+    dlist[i] = image[i].dMcal;
+    xlist[i] = image[i].secz;
   }
 
@@ -318,5 +320,5 @@
   bzero (Mlist, NBIN*sizeof(double));
   for (i = 0; i < Nimage; i++) {
-    bin = image[i].dMcal_PS / 0.00025;
+    bin = image[i].dMcal / 0.00025;
     bin = MAX (0, MIN (NBIN - 1, bin));
     Mlist[bin] += 1.0;
@@ -420,5 +422,5 @@
     if (image[i].code & IMAGE_BAD)  continue;
 
-    list[n] = image[i].Mcal_PS;
+    list[n] = image[i].Mcal;
     dlist[n] = 1;
     n++;
@@ -448,5 +450,5 @@
     if (image[i].code & IMAGE_BAD)  continue;
 
-    list[n] = image[i].dMcal_PS;
+    list[n] = image[i].dMcal;
     dlist[n] = 1;
     n++;
Index: trunk/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 12332)
@@ -36,5 +36,5 @@
 
     /* select valid mosaic images by photcode */
-    pname = GetPhotcodeNamebyCode (image[i].source);
+    pname = GetPhotcodeNamebyCode (image[i].photcode);
     status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME));
     if (status) continue;
@@ -69,5 +69,5 @@
     mosaic[Nmosaic].Xm    = 0.0;
     mosaic[Nmosaic].code  = image[i].code;
-    mosaic[Nmosaic].secz  = image[i].secz_PS;
+    mosaic[Nmosaic].secz  = image[i].secz;
 
     /* add image to mosaic image list */
@@ -134,10 +134,10 @@
       Dmin = MIN (Dmin, D);
       Dmax = MAX (Dmax, D);
-      Mcal += image[m].Mcal_PS;
-      dMcal += image[m].dMcal_PS;
+      Mcal += image[m].Mcal;
+      dMcal += image[m].dMcal;
       Xm += image[m].Xm;
       /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */
-      image[m].Mcal_PS = 0.0;
-      image[m].dMcal_PS = image[m].Xm = NO_MAG;
+      image[m].Mcal = 0.0;
+      image[m].dMcal = image[m].Xm = NO_MAG;
     }
     dS /= Nimlist[i];
@@ -179,6 +179,6 @@
     for (j = 0; j < Nimlist[i]; j++) {
       im = imlist[i][j];
-      image[im].Mcal_PS = mosaic[i].Mcal;
-      image[im].dMcal_PS = mosaic[i].dMcal;
+      image[im].Mcal = mosaic[i].Mcal;
+      image[im].dMcal = mosaic[i].dMcal;
       image[im].Xm = mosaic[i].Xm;
       image[im].code |= (mosaic[i].code & ID_IMAGE_FEW);
@@ -247,5 +247,5 @@
 	if (catalog[i].measure[j].t > TSTOP) continue;
       }
-      ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].source);
+      ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode);
       if (photcode[0].code != ecode) continue;
       matchMosaics (catalog, j, i);
@@ -266,6 +266,6 @@
     if (USE_GRID) {
       ave = catalog[cat].measure[meas].averef;
-      ra  = catalog[cat].average[ave].R_PS - catalog[cat].measure[meas].dR_PS / 3600.0;
-      dec = catalog[cat].average[ave].D_PS - catalog[cat].measure[meas].dD_PS / 3600.0;
+      ra  = catalog[cat].average[ave].R - catalog[cat].measure[meas].dR / 3600.0;
+      dec = catalog[cat].average[ave].D - catalog[cat].measure[meas].dD / 3600.0;
 
       /* X,Y always positive-definite in range 0,0 - dX, dY */
@@ -355,5 +355,5 @@
       Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);
       list[N]  = Msys - Mrel - Mcal - Mgrid;
-      dlist[N] = MAX (catalog[c].measure[m].dM_PS, MIN_ERROR);
+      dlist[N] = MAX (catalog[c].measure[m].dM, MIN_ERROR);
       Mlist[N] = Msys;
       dMlist[N] = list[N];
@@ -596,6 +596,6 @@
 
       ave = catalog[c].measure[m].averef;
-      xlist[N] = catalog[c].average[ave].R - catalog[c].measure[m].dR_PS / 3600.0;
-      ylist[N] = catalog[c].average[ave].D - catalog[c].measure[m].dD_PS / 3600.0;
+      xlist[N] = catalog[c].average[ave].R - catalog[c].measure[m].dR / 3600.0;
+      ylist[N] = catalog[c].average[ave].D - catalog[c].measure[m].dD / 3600.0;
       N++;
     }
Index: trunk/Ohana/src/relphot/src/StarOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/StarOps.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/StarOps.c	(revision 12332)
@@ -28,5 +28,5 @@
   if (catalog[cat].average[ave].code & STAR_BAD) return (NO_MAG);  
  
-  value = PhotPrimary ? catalog[cat].average[ave].M : catalog[cat].secfilt[PhotNsec*ave+PhotSec].M_PS;
+  value = catalog[cat].secfilt[PhotNsec*ave+PhotSec].M;
   return (value);
 }
@@ -65,5 +65,5 @@
 	Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
 	list[N] = Msys - Mcal - Mmos - Mgrid;
-	dlist[N] = MAX (catalog[i].measure[m].dM_PS, MIN_ERROR);
+	dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
 	N++;
       }
@@ -76,13 +76,7 @@
       liststats (list, dlist, N, &stats);
 
-      if (PhotPrimary) {
-	catalog[i].average[j].M = stats.mean;
-	catalog[i].average[j].dM = stats.sigma;
-	catalog[i].average[j].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
-      } else {
-	catalog[i].secfilt[PhotNsec*j+PhotSec].M_PS  = stats.mean;
-	catalog[i].secfilt[PhotNsec*j+PhotSec].dM_PS = stats.sigma;
-	catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
-      }      
+      catalog[i].secfilt[PhotNsec*j+PhotSec].M  = stats.mean;
+      catalog[i].secfilt[PhotNsec*j+PhotSec].dM = stats.sigma;
+      catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
     }
   }
@@ -130,5 +124,5 @@
 	Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
 	list[N] = Msys - Mcal - Mmos - Mgrid;
-	dlist[N] = MAX (catalog[i].measure[m].dM_PS, MIN_ERROR);
+	dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
 	N++;
       }
@@ -139,13 +133,7 @@
 
       /* use sigma or error in dM for output? */
-      if (PhotPrimary) {
-	catalog[i].average[j].M = stats.mean;
-	catalog[i].average[j].dM = MAX (stats.sigma, stats.error);
-	catalog[i].average[j].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
-      } else {
-	catalog[i].secfilt[PhotNsec*j+PhotSec].M_PS  = stats.mean;
-	catalog[i].secfilt[PhotNsec*j+PhotSec].dM_PS = MAX (stats.error, stats.sigma);
-	catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
-      }      
+      catalog[i].secfilt[PhotNsec*j+PhotSec].M  = stats.mean;
+      catalog[i].secfilt[PhotNsec*j+PhotSec].dM = MAX (stats.error, stats.sigma);
+      catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
     }
   }
@@ -178,5 +166,5 @@
 	if (Mmos == NO_IMAGE) continue;
 	if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
-	catalog[i].measure[m].Mcal_PS = Mcal + Mmos + Mgrid;
+	catalog[i].measure[m].Mcal = Mcal + Mmos + Mgrid;
       }
     }
@@ -205,9 +193,9 @@
     for (j = 0; j < catalog[i].Naverage; j++) {
       if (catalog[i].average[j].code & STAR_BAD) continue;
-      Xm = PhotPrimary ? catalog[i].average[j].Xm : catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
+      Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
       if (Xm == -1) continue;
       Chisq = pow (10.0, 0.01*Xm);
       xlist[Ntot] = Chisq;
-      slist[Ntot] = PhotPrimary ? catalog[i].average[j].dM : catalog[i].secfilt[PhotNsec*j+PhotSec].dM_PS;
+      slist[Ntot] = catalog[i].secfilt[PhotNsec*j+PhotSec].dM;
       dlist[Ntot] = 1;
       Ntot ++;
@@ -225,6 +213,6 @@
   for (i = 0; i < Ncatalog; i++) {
     for (j = 0; j < catalog[i].Naverage; j++) {
-      dM = PhotPrimary ? catalog[i].average[j].dM : catalog[i].secfilt[PhotNsec*j+PhotSec].dM_PS;
-      Xm = PhotPrimary ? catalog[i].average[j].Xm    : catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
+      dM = catalog[i].secfilt[PhotNsec*j+PhotSec].dM;
+      Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
       Chisq = pow (10.0, 0.01*Xm);
       mark = (dM > MaxScatter) || (Xm == NO_MAG) || (Chisq > MaxChisq);
@@ -295,5 +283,5 @@
 	Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
 	list[N] = Msys - Mcal - Mmos - Mgrid;
-	dlist[N] = MAX (catalog[i].measure[m].dM_PS, MIN_ERROR);
+	dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
 	N++;
       }
@@ -331,5 +319,5 @@
 	Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
 	list[N] = Msys - Mcal - Mmos - Mgrid;
-	dlist[N] = MAX (catalog[i].measure[m].dM_PS, MIN_ERROR);
+	dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
 	ilist[N] = m;
 	N++;
@@ -422,5 +410,5 @@
       if (catalog[i].average[j].code & STAR_BAD) continue;  
 
-      Xm = PhotPrimary ? catalog[i].average[j].Xm : catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
+      Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
       if (Xm == NO_MAG) continue;
       list[n] = pow (10.0, 0.01*Xm);
@@ -458,5 +446,5 @@
       if (catalog[i].average[j].code & STAR_BAD) continue;  
 
-      dM = PhotPrimary ? catalog[i].average[j].dM : catalog[i].secfilt[PhotNsec*j+PhotSec].dM_PS;
+      dM = catalog[i].secfilt[PhotNsec*j+PhotSec].dM;
       list[n] = dM;
       dlist[n] = 1;
@@ -487,5 +475,5 @@
     for (j = 0; j < catalog[i].Naverage; j++) {
       if (catalog[i].average[j].code & STAR_BAD) continue;  
-      dMrel = PhotPrimary ? catalog[i].average[j].dM : catalog[i].secfilt[PhotNsec*j+PhotSec].dM_PS;
+      dMrel = catalog[i].secfilt[PhotNsec*j+PhotSec].dM;
       bin = dMrel / 0.00025;
       bin = MAX (0, MIN (NBIN-1, bin));
@@ -518,6 +506,6 @@
     for (j = 0; j < catalog[i].Naverage; j++) {
       if (catalog[i].average[j].code & STAR_BAD) continue;
-      xlist[N] = PhotPrimary ? catalog[i].average[j].M : catalog[i].secfilt[PhotNsec*j+PhotSec].M_PS;
-      value    = PhotPrimary ? catalog[i].average[j].Xm   : catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
+      xlist[N] = catalog[i].secfilt[PhotNsec*j+PhotSec].M;
+      value    = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
       if (value == NO_MAG) continue;
       ylist[N] = 0.01*value;
Index: trunk/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- trunk/Ohana/src/relphot/src/bcatalog.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/bcatalog.c	(revision 12332)
@@ -27,9 +27,6 @@
 
     if (RESET) {
-      float *p;
-      p = (PhotPrimary) ? &subcatalog[0].average[Naverage].M : &subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M_PS;
-      *p = NO_MAG;
-      p = (PhotPrimary) ? &subcatalog[0].average[Naverage].dM : &subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM_PS;
-      *p = NO_MAG;
+      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M  = NO_MAG;
+      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NO_MAG;
       subcatalog[0].average[Naverage].code &= ~ID_STAR_FEW;
       subcatalog[0].average[Naverage].code &= ~ID_STAR_POOR;
@@ -42,5 +39,5 @@
 
       /* select measurements by photcode */
-      ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[offset].source);
+      ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[offset].photcode);
       if (ecode != photcode[0].code) continue;
 
@@ -60,5 +57,5 @@
 
       /* select measurements by measurement error */
-      if ((SIGMA_LIM > 0) && (catalog[0].measure[offset].dM_PS > SIGMA_LIM)) continue;
+      if ((SIGMA_LIM > 0) && (catalog[0].measure[offset].dM > SIGMA_LIM)) continue;
 
       /* select measurements by mag limit */
@@ -73,5 +70,5 @@
       subcatalog[0].measure[Nmeasure].averef = Naverage;
       if (RESET) { 
-	subcatalog[0].measure[Nmeasure].Mcal_PS = 0;
+	subcatalog[0].measure[Nmeasure].Mcal = 0;
 	subcatalog[0].measure[Nmeasure].flags &= 0xff00;
 	subcatalog[0].measure[Nmeasure].flags &= ~ID_MEAS_POOR;
Index: trunk/Ohana/src/relphot/src/initialize.c
===================================================================
--- trunk/Ohana/src/relphot/src/initialize.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/initialize.c	(revision 12332)
@@ -13,10 +13,9 @@
     exit (1);
   }
-  if ((photcode[0].type != PHOT_PRI) && (photcode[0].type != PHOT_SEC)) {
+  if (photcode[0].type != PHOT_SEC) {
     fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[N]);
     exit (1);
   }
 
-  PhotPrimary = (photcode[0].type == PHOT_PRI);
   PhotNsec = GetPhotcodeNsecfilt ();
   PhotSec = GetPhotcodeNsec (photcode[0].code);
Index: trunk/Ohana/src/relphot/src/plot_scatter.c
===================================================================
--- trunk/Ohana/src/relphot/src/plot_scatter.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/plot_scatter.c	(revision 12332)
@@ -36,5 +36,5 @@
 	if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
 
-	Mrel = PhotPrimary ? catalog[i].average[j].M : catalog[i].secfilt[PhotNsec*j+PhotSec].M_PS;
+	Mrel = catalog[i].secfilt[PhotNsec*j+PhotSec].M;
 	xlist[N] = Mrel;
 	ylist[N] = PhotSys  (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]) - Mcal - Mmos - Mgrid - Mrel;
Index: trunk/Ohana/src/relphot/src/relphot.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/relphot.c	(revision 12332)
@@ -44,4 +44,6 @@
   /* load catalog data from region files */
   catalog = load_catalogs (skylist, &Ncatalog);
+  
+  /* add in a loop over the catalogs calling dvo_catalog_chipcoords */
 
   /* match measurements with images, mosaics */
Index: trunk/Ohana/src/relphot/src/select_images.c
===================================================================
--- trunk/Ohana/src/relphot/src/select_images.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/select_images.c	(revision 12332)
@@ -76,5 +76,5 @@
       
     /* exclude images by photcode */
-    ecode = GetPhotcodeEquivCodebyCode (timage[i].source);
+    ecode = GetPhotcodeEquivCodebyCode (timage[i].photcode);
     if (ecode != photcode[0].code) continue;
 
@@ -135,5 +135,5 @@
       if (RESET) {
 	assignMcal (&image[nimage], (double *) NULL, -1);
-	image[nimage].dMcal_PS = NO_MAG;
+	image[nimage].dMcal = NO_MAG;
 	image[nimage].code &= ~ID_IMAGE_POOR;
       }
Index: trunk/Ohana/src/relphot/src/setExclusions.c
===================================================================
--- trunk/Ohana/src/relphot/src/setExclusions.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/setExclusions.c	(revision 12332)
@@ -3,9 +3,9 @@
 int setExclusions (Catalog *catalog, int Ncatalog) {
 
-  int i, j, k, m, Narea, Nnocal, ecode;
+  int i, j, k, m, Narea, Nnocal, Ngood, ecode;
   Coords *coords;
   double r, d, x, y;
 
-  Nnocal = Narea = 0;
+  Ngood = Nnocal = Narea = 0;
   for (i = 0; i < Ncatalog; i++) {
     for (j = 0; j < catalog[i].Naverage; j++) {
@@ -14,5 +14,5 @@
 
 	/* select measurements by photcode */
-	ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].source);
+	ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode);
 	if (ecode != photcode[0].code) goto mark_nocal;
 	
@@ -25,6 +25,6 @@
 	/* select measurements by mag limit */
 	if (AreaSelect) {
-	  r = catalog[i].average[j].R + catalog[i].measure[m].dR_PS / 3600.0;
-	  d = catalog[i].average[j].D + catalog[i].measure[m].dD_PS / 3600.0;
+	  r = catalog[i].average[j].R + catalog[i].measure[m].dR / 3600.0;
+	  d = catalog[i].average[j].D + catalog[i].measure[m].dD / 3600.0;
 	  if ((coords = getCoords (m, i)) == NULL) goto markbad;
 	  RD_to_XY (&x, &y, r, d, coords);
@@ -34,4 +34,5 @@
 	  if (y > AreaYmax) goto markbad;
 	}
+	Ngood ++;
 	continue;
 
@@ -50,4 +51,5 @@
   if (VERBOSE) fprintf (stderr, "%d measurements marked by area\n", Narea);
   if (VERBOSE) fprintf (stderr, "%d measurements marked nocal\n", Nnocal);
+  if (VERBOSE) fprintf (stderr, "%d measurements kept for analysis\n", Ngood);
   return (TRUE);
 }
Index: trunk/Ohana/src/relphot/src/setMrelFinal.c
===================================================================
--- trunk/Ohana/src/relphot/src/setMrelFinal.c	(revision 11880)
+++ trunk/Ohana/src/relphot/src/setMrelFinal.c	(revision 12332)
@@ -4,6 +4,4 @@
 
   int i, j, m, ecode;
-  float *p;
-  short *q;
 
   /* if we reset the catalog, reset all the current measurements */
@@ -11,10 +9,7 @@
 
     for (i = 0; i < catalog[0].Naverage; i++) {
-      p = (PhotPrimary) ? &catalog[0].average[i].M  : &catalog[0].secfilt[PhotNsec*i+PhotSec].M_PS;
-      *p = NO_MAG;
-      p = (PhotPrimary) ? &catalog[0].average[i].dM : &catalog[0].secfilt[PhotNsec*i+PhotSec].dM_PS;
-      *p = NO_MAG;
-      q = (PhotPrimary) ? &catalog[0].average[i].Xm : &catalog[0].secfilt[PhotNsec*i+PhotSec].Xm;
-      *q = NO_MAG;
+      catalog[0].secfilt[PhotNsec*i+PhotSec].M = NO_MAG;
+      catalog[0].secfilt[PhotNsec*i+PhotSec].dM = NO_MAG;
+      catalog[0].secfilt[PhotNsec*i+PhotSec].Xm = NO_MAG;
 
       m = catalog[0].average[i].offset;
@@ -22,5 +17,5 @@
 	
 	/* select measurements by photcode */
-	ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].source);
+	ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode);
 	if (ecode != photcode[0].code) continue;
 	
@@ -31,5 +26,5 @@
 	}
 	
-	catalog[0].measure[m].Mcal_PS = 0;
+	catalog[0].measure[m].Mcal = 0;
 	catalog[0].measure[m].flags &= 0xff00;
 	catalog[0].measure[m].flags &= ~ID_MEAS_POOR;
@@ -97,5 +92,5 @@
       /** never use these measurements (wrong photcode, bad time range) */
       /* skipped via NOCAL, don't mark as skipped */
-      ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].source);
+      ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode);
       if (ecode != photcode[0].code) continue;
 
