Index: /trunk/Ohana/src/addstar/src/FilterStars.c
===================================================================
--- /trunk/Ohana/src/addstar/src/FilterStars.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/FilterStars.c	(revision 15509)
@@ -49,26 +49,27 @@
     }
 
-    if (stars[N].M >= 0.001*NO_MAG) {
-      stars[N].M       = 0.001*NO_MAG;
-    } else {
-      stars[N].M       = stars[N].M + MTIME;
+    // stars->M is either NAN or a valid inst magnitude
+    // stars->dM is either NAN or a valid error
+
+    dMs  = 0.0;
+    dMx = 0.0;
+    if (SUBPIX) {
+      dMs = get_subpix (stars[N].X, stars[N].Y);
+      dMx = scat_subpix (stars[N].X, stars[N].Y);
+      if (!isnan(stars[N].dM)) {
+	stars[N].dM = hypot (stars[N].dM, dMx);
+      }
     }
 
-    if (stars[N].M > 32.77) {
-      fprintf (stderr, "*");
+    if (!isnan(stars[N].M)) {
+      stars[N].M += MTIME - dMs;
     }
-
-    stars[N].dM      = MIN (stars[N].dM, NO_ERR);
-
-    stars[N].Mgal    = MIN (stars[N].Mgal + MTIME, 0.001*NO_MAG);
+    if (!isnan(stars[N].Mgal)) {
+      stars[N].Mgal += MTIME - dMs;
+    }
+    if (!isnan(stars[N].Map)) {
+      stars[N].Map += MTIME - dMs;
+    }
     
-    if (SUBPIX) {
-      dMs = get_subpix (stars[N].X, stars[N].Y);
-      stars[N].M    -= dMs;
-      stars[N].Mgal -= dMs;
-      stars[N].Map  -= dMs;
-      dMs = scat_subpix (stars[N].X, stars[N].Y);
-      stars[N].dM = hypot (stars[N].dM, dMs);
-    }
     N ++;
   }
Index: /trunk/Ohana/src/addstar/src/ReadImageHeader.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 15509)
@@ -135,7 +135,8 @@
   image[0].trate = 10000 * tmp;
 
-  tmp = 0;
-  gfits_scan (header, AirmassKeyword, "%lf", 1, &tmp);
-  image[0].secz = MIN (NO_MAG, tmp);
+  image[0].secz = NAN;
+  if (gfits_scan (header, AirmassKeyword, "%lf", 1, &tmp)) {
+    image[0].secz = tmp;
+  } 
 
   if (!gfits_scan (header, CCDNumKeyword, "%d", 1, &ccdnum)) {
Index: /trunk/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 15509)
@@ -54,4 +54,5 @@
 
   int i, Nstars, swapped;
+  double ZeroPt;
   Stars *stars = NULL;
   SMPData *smpdata = NULL;
@@ -59,17 +60,27 @@
   swapped = FALSE;
   smpdata = gfits_table_get_SMPData (table, &Nstars, &swapped);
+  ZeroPt = GetZeroPoint();
+
   /* XXX we need to check at least the size of the loaded table */
-
   // XXX use memset to zero-out the elements before setting
+
   ALLOCATE (stars, Stars, Nstars);
   for (i = 0; i < Nstars; i++) {
     stars[i].X      = smpdata[i].X;
     stars[i].Y      = smpdata[i].Y;
-    stars[i].M      = smpdata[i].M;
+
+    if ((smpdata[i].M >= ZeroPt) || isnan(smpdata[i].M)) {
+      stars[i].M    = NAN;
+      stars[i].Mgal = NAN;
+      stars[i].Map  = NAN;
+    } else {
+      stars[i].M    = smpdata[i].M;
+      stars[i].Mgal = smpdata[i].M;
+      stars[i].Map  = smpdata[i].M;
+    }
+
     stars[i].dM     = smpdata[i].dM*0.001;
     stars[i].dophot = smpdata[i].dophot;
 
-    stars[i].Mgal   = smpdata[i].M;
-    stars[i].Map    = smpdata[i].dM;
     stars[i].fx     = smpdata[i].fx;
     stars[i].fy     = smpdata[i].fy;
@@ -88,4 +99,72 @@
 
   ps1data = gfits_table_get_PS1_DEV_0 (table, &Nstars, NULL);
+  ZeroPt = GetZeroPoint();
+
+  ALLOCATE (stars, Stars, Nstars);
+  for (i = 0; i < Nstars; i++) {
+    stars[i].X       = ps1data[i].X;
+    stars[i].Y       = ps1data[i].Y;
+    stars[i].dX      = ps1data[i].dX;
+    stars[i].dY      = ps1data[i].dY;
+    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
+      stars[i].M     = NAN;
+    } else {
+      stars[i].M     = ps1data[i].M + ZeroPt;
+    }
+    stars[i].dM      = ps1data[i].dM;
+    stars[i].Mpeak   = ps1data[i].Mpeak;
+
+    stars[i].sky     = ps1data[i].sky;
+    stars[i].dsky    = ps1data[i].dSky;
+
+    stars[i].fx      = ps1data[i].fx;
+    stars[i].fy      = ps1data[i].fy;
+    stars[i].df      = ps1data[i].df;
+
+    stars[i].psfProb = ps1data[i].psfProb;
+    stars[i].psfQual = ps1data[i].psfQual;
+
+    stars[i].detID   = ps1data[i].detID;
+
+    /* these are set elsewhere */
+    stars[i].R       = 0.0;
+    stars[i].D       = 0.0;
+    stars[i].dR      = 0.0;
+    stars[i].dD      = 0.0;
+
+    stars[i].uR      = 0.0;
+    stars[i].uD      = 0.0;
+    stars[i].duR     = 0.0;
+    stars[i].duD     = 0.0;
+
+    stars[i].P       = 0.0;
+    stars[i].dP      = 0.0;
+
+    stars[i].Mcal    = 0;
+    stars[i].t       = 0;
+    stars[i].dt      = 0;
+    stars[i].airmass = 0;
+    stars[i].code    = 0;
+    stars[i].found   = 0;
+
+    /* these are not used */
+    stars[i].Map     = NAN;
+    stars[i].Mgal    = NAN;
+    stars[i].dophot  = 0;
+  }    
+  *nstars = Nstars;
+  return (stars);
+}
+
+// XXX I need to make the IPP I/O functions and these functions
+// consistent wrt ZERO_POINT....
+Stars *Convert_PS1_DEV_1 (FTable *table, int *nstars) {
+
+  int i, Nstars;
+  double ZeroPt;
+  Stars *stars;
+  PS1_DEV_1 *ps1data;
+
+  ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL);
   ZeroPt = GetZeroPoint();
 
@@ -111,72 +190,4 @@
     stars[i].df      = ps1data[i].df;
 
-    stars[i].psfProb = ps1data[i].psfProb;
-    stars[i].psfQual = ps1data[i].psfQual;
-
-    stars[i].detID   = ps1data[i].detID;
-
-    /* these are set elsewhere */
-    stars[i].R       = 0.0;
-    stars[i].D       = 0.0;
-    stars[i].dR      = 0.0;
-    stars[i].dD      = 0.0;
-
-    stars[i].uR      = 0.0;
-    stars[i].uD      = 0.0;
-    stars[i].duR     = 0.0;
-    stars[i].duD     = 0.0;
-
-    stars[i].P       = 0.0;
-    stars[i].dP      = 0.0;
-
-    stars[i].Mcal    = 0;
-    stars[i].t       = 0;
-    stars[i].dt      = 0;
-    stars[i].airmass = 0;
-    stars[i].code    = 0;
-    stars[i].found   = 0;
-
-    /* these are not used */
-    stars[i].Map     = 0.001*NO_MAG;
-    stars[i].Mgal    = 0.001*NO_MAG;
-    stars[i].dophot  = 0;
-  }    
-  *nstars = Nstars;
-  return (stars);
-}
-
-// XXX I need to make the IPP I/O functions and these functions
-// consistent wrt ZERO_POINT....
-Stars *Convert_PS1_DEV_1 (FTable *table, int *nstars) {
-
-  int i, Nstars;
-  double ZeroPt;
-  Stars *stars;
-  PS1_DEV_1 *ps1data;
-
-  ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL);
-  ZeroPt = GetZeroPoint();
-
-  ALLOCATE (stars, Stars, Nstars);
-  for (i = 0; i < Nstars; i++) {
-    stars[i].X       = ps1data[i].X;
-    stars[i].Y       = ps1data[i].Y;
-    stars[i].dX      = ps1data[i].dX;
-    stars[i].dY      = ps1data[i].dY;
-    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
-	stars[i].M   = 0.001*NO_MAG;
-    } else {
-	stars[i].M   = ps1data[i].M + ZeroPt;
-    }
-    stars[i].dM      = ps1data[i].dM;
-    stars[i].Mpeak   = ps1data[i].Mpeak;
-
-    stars[i].sky     = ps1data[i].sky;
-    stars[i].dsky    = ps1data[i].dSky;
-
-    stars[i].fx      = ps1data[i].fx;
-    stars[i].fy      = ps1data[i].fy;
-    stars[i].df      = ps1data[i].df;
-
     stars[i].psfProb   = ps1data[i].psfProb;
     stars[i].psfQual   = ps1data[i].psfQual;
@@ -213,6 +224,6 @@
 
     /* these are not used */
-    stars[i].Map     = 0.001*NO_MAG;
-    stars[i].Mgal    = 0.001*NO_MAG;
+    stars[i].Map     = NAN;
+    stars[i].Mgal    = NAN;
     stars[i].dophot  = 0;
   }    
Index: /trunk/Ohana/src/addstar/src/ReadStarsTEXT.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadStarsTEXT.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/ReadStarsTEXT.c	(revision 15509)
@@ -10,6 +10,9 @@
   char *buffer, *c, *c2;
   double tmp;
+  double ZeroPt;
   Stars *stars;
   
+  ZeroPt = GetZeroPoint();
+
   /* load in stars by blocks of 1000 */
   N = 0;
@@ -66,4 +69,7 @@
       dparse (&stars[N].Y,  2, &buffer[j*BYTES_STAR]);
       dparse (&stars[N].M,  3, &buffer[j*BYTES_STAR]);
+      if ((stars[N].M > ZeroPt) || isnan(stars[N].M)) {
+	stars[N].M = NAN;
+      }
 
       /* cmp files carry dM in millimags */
Index: /trunk/Ohana/src/addstar/src/SEDfit.c
===================================================================
--- /trunk/Ohana/src/addstar/src/SEDfit.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/SEDfit.c	(revision 15509)
@@ -161,5 +161,5 @@
     outcat[0].average[Nave].Nm        = 0;
     outcat[0].average[Nave].Nn        = 0;
-    outcat[0].average[Nave].Xp        = NO_MAG;
+    outcat[0].average[Nave].Xp        = NAN_S_SHORT;
     outcat[0].average[Nave].offset    = Nmeas;
     outcat[0].average[Nave].missing   = -1;
@@ -167,7 +167,7 @@
 
     for (j = 0; j < Nsec; j++) {
-      outcat[0].secfilt[Nave*Nsec+j].M  = NO_MAG;
-      outcat[0].secfilt[Nave*Nsec+j].dM = NO_MAG;
-      outcat[0].secfilt[Nave*Nsec+j].Xm    = NO_MAG;
+      outcat[0].secfilt[Nave*Nsec+j].M  = NAN;
+      outcat[0].secfilt[Nave*Nsec+j].dM = NAN;
+      outcat[0].secfilt[Nave*Nsec+j].Xm = NAN_S_SHORT;
     }
 
@@ -183,5 +183,5 @@
       outcat[0].measure[Nmeas].dR       = 0.0;
       outcat[0].measure[Nmeas].dD       = 0.0;
-      outcat[0].measure[Nmeas].M        = MIN (table[0].row[minFit.row][0].mags[n] + minFit.Md,  NO_MAG);
+      outcat[0].measure[Nmeas].M        = table[0].row[minFit.row][0].mags[n] + minFit.Md;
       outcat[0].measure[Nmeas].dM       = 0.0;
       outcat[0].measure[Nmeas].Mcal     = 0;
@@ -193,9 +193,9 @@
       outcat[0].measure[Nmeas].dt       = 0xffff;
 
-      outcat[0].measure[Nmeas].Mgal     = NO_MAG;
+      outcat[0].measure[Nmeas].Mgal     = NAN;
       outcat[0].measure[Nmeas].airmass  = 0;
-      outcat[0].measure[Nmeas].FWx         = NO_MAG;
-      outcat[0].measure[Nmeas].FWy         = NO_ERR;
-      outcat[0].measure[Nmeas].theta       = NO_ERR;
+      outcat[0].measure[Nmeas].FWx      = NAN_S_SHORT;
+      outcat[0].measure[Nmeas].FWy      = NAN_S_SHORT;
+      outcat[0].measure[Nmeas].theta    = NAN_S_SHORT;
 
       outcat[0].average[Nave].Nm++;
Index: /trunk/Ohana/src/addstar/src/calibrate.c
===================================================================
--- /trunk/Ohana/src/addstar/src/calibrate.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/calibrate.c	(revision 15509)
@@ -54,5 +54,5 @@
 
   found0 = found1 = found2 = FALSE;
-  CalM0 = CalM1 = CalM2 = dCalM = NO_MAG;
+  CalM0 = CalM1 = CalM2 = dCalM = NAN;
 
   // we have two options here: 
Index: /trunk/Ohana/src/addstar/src/fakeimage.c
===================================================================
--- /trunk/Ohana/src/addstar/src/fakeimage.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/fakeimage.c	(revision 15509)
@@ -128,5 +128,5 @@
 
     image[i+1].Mcal = 0.0;
-    image[i+1].Xm   = NO_MAG;
+    image[i+1].Xm   = NAN_S_SHORT;
     image[i+1].code = 0;
     memset (image[i+1].dummy, 0, sizeof(image[i+1].dummy));
@@ -187,5 +187,5 @@
   image[0].ccdnum = 0xff;
   image[0].Mcal = 0.0;
-  image[0].Xm   = NO_MAG;
+  image[0].Xm   = NAN_S_SHORT;
   image[0].code = 0;
   memset (image[0].dummy, 0, sizeof(image[0].dummy));
Index: /trunk/Ohana/src/addstar/src/find_matches.c
===================================================================
--- /trunk/Ohana/src/addstar/src/find_matches.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/find_matches.c	(revision 15509)
@@ -194,7 +194,7 @@
 
       catalog[0].measure[Nmeas].Mgal     = stars[N].Mgal;
-      catalog[0].measure[Nmeas].FWx      = MIN (100*stars[N].fx, NO_MAG);
-      catalog[0].measure[Nmeas].FWy      = MIN (100*stars[N].fy, NO_MAG);
-      catalog[0].measure[Nmeas].theta    = MIN ((0xffff/360.0)*stars[N].df, NO_MAG);
+      catalog[0].measure[Nmeas].FWx      = 100*stars[N].fx;
+      catalog[0].measure[Nmeas].FWy      = 100*stars[N].fy;
+      catalog[0].measure[Nmeas].theta    = (0xffff/360.0)*stars[N].df;
 	
       /* adds the measurement to the calibration if appropriate color terms are found */
@@ -207,7 +207,7 @@
       /* in UPDATE mode, this value is not saved; use relphot to recalculate */
       if (Nsec > -1) { 
-	  if (catalog[0].secfilt[n*Nsecfilt+Nsec].M != NO_MAG) {
-	      catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
-	  }
+	if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) {
+	  catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
+	}
       }
 
@@ -282,7 +282,7 @@
 
     for (j = 0; j < Nsecfilt; j++) {
-      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NO_MAG;
-      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NO_MAG;
-      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NO_MAG;
+      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NAN;
+      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN;
+      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT;
     }
 
@@ -320,7 +320,7 @@
 
     catalog[0].measure[Nmeas].Mgal  	= stars[N].Mgal;
-    catalog[0].measure[Nmeas].FWx      	= MIN (100*stars[N].fx, NO_MAG);
-    catalog[0].measure[Nmeas].FWy      	= MIN (100*stars[N].fy, NO_MAG);
-    catalog[0].measure[Nmeas].theta    	= MIN ((0xffff/360.0)*stars[N].df, NO_MAG);
+    catalog[0].measure[Nmeas].FWx      	= 100*stars[N].fx;
+    catalog[0].measure[Nmeas].FWy      	= 100*stars[N].fy;
+    catalog[0].measure[Nmeas].theta    	= (0xffff/360.0)*stars[N].df;
     /* XXX replace df here with theta, right? */
 
Index: /trunk/Ohana/src/addstar/src/find_matches_closest.c
===================================================================
--- /trunk/Ohana/src/addstar/src/find_matches_closest.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/find_matches_closest.c	(revision 15509)
@@ -214,14 +214,17 @@
 
     catalog[0].measure[Nmeas].Mgal     = stars[N].Mgal;
-    catalog[0].measure[Nmeas].FWx      = MIN (100*stars[N].fx, NO_MAG);
-    catalog[0].measure[Nmeas].FWy      = MIN (100*stars[N].fy, NO_MAG);
-    catalog[0].measure[Nmeas].theta    = MIN ((0xffff/360.0)*stars[N].df, NO_MAG);
+
+    // XXX saturate range for FWx, FWy, theta
+    // XXX convert to unsigned int for these...
+    catalog[0].measure[Nmeas].FWx      = 100*stars[N].fx;
+    catalog[0].measure[Nmeas].FWy      = 100*stars[N].fy;
+    catalog[0].measure[Nmeas].theta    = (0xffff/360.0)*stars[N].df;
 	
     /* set the average magnitude if not already set and the photcode.equiv is not 0 */
     /* in UPDATE mode, this value is not saved; use relphot to recalculate */
     if (Nsec > -1) { 
-	if (catalog[0].secfilt[n*Nsecfilt+Nsec].M != NO_MAG) {
-	    catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
-	}
+      if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) {
+	catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
+      }
     }
 
@@ -281,7 +284,7 @@
 
     for (j = 0; j < Nsecfilt; j++) {
-      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NO_MAG;
-      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NO_MAG;
-      catalog[0].secfilt[Nave*Nsecfilt+j].Xm    = NO_MAG;
+      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NAN;
+      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN;
+      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT;
     }
 
@@ -319,7 +322,7 @@
 
     catalog[0].measure[Nmeas].Mgal     = stars[N].Mgal;
-    catalog[0].measure[Nmeas].FWx      = MIN (100*stars[N].fx, NO_MAG);
-    catalog[0].measure[Nmeas].FWy      = MIN (100*stars[N].fy, NO_MAG);
-    catalog[0].measure[Nmeas].theta    = MIN ((0xffff/360.0)*stars[N].df, NO_ERR);
+    catalog[0].measure[Nmeas].FWx      = 100*stars[N].fx;
+    catalog[0].measure[Nmeas].FWy      = 100*stars[N].fy;
+    catalog[0].measure[Nmeas].theta    = (0xffff/360.0)*stars[N].df;
 
     /* set the average magnitude if not already set and the photcode.equiv is not 0 */
Index: /trunk/Ohana/src/addstar/src/find_matches_refstars.c
===================================================================
--- /trunk/Ohana/src/addstar/src/find_matches_refstars.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/find_matches_refstars.c	(revision 15509)
@@ -133,6 +133,6 @@
       catalog[0].measure[Nmeas].dR       = 3600.0*(catalog[0].average[n].R - stars[N][0].R);
       catalog[0].measure[Nmeas].dD       = 3600.0*(catalog[0].average[n].D - stars[N][0].D);
-      catalog[0].measure[Nmeas].M        = MIN (stars[N][0].M,  NO_MAG);
-      catalog[0].measure[Nmeas].dM       = MIN (stars[N][0].dM, NO_ERR);
+      catalog[0].measure[Nmeas].M        = stars[N][0].M;
+      catalog[0].measure[Nmeas].dM       = stars[N][0].dM;
       catalog[0].measure[Nmeas].Mcal     = 0;
       catalog[0].measure[Nmeas].t        = (TIMEREF == 0) ? stars[N][0].t : TIMEREF; /** careful : time_t vs e_time **/
@@ -143,9 +143,9 @@
       catalog[0].measure[Nmeas].dt       = 0xffff;
 
-      catalog[0].measure[Nmeas].Mgal     = NO_MAG;
+      catalog[0].measure[Nmeas].Mgal     = NAN;
       catalog[0].measure[Nmeas].airmass  = 0;
-      catalog[0].measure[Nmeas].FWx      = NO_MAG;
-      catalog[0].measure[Nmeas].FWy      = NO_MAG;
-      catalog[0].measure[Nmeas].theta    = NO_MAG;
+      catalog[0].measure[Nmeas].FWx      = NAN_S_SHORT;
+      catalog[0].measure[Nmeas].FWy      = NAN_S_SHORT;
+      catalog[0].measure[Nmeas].theta    = NAN_S_SHORT;
 	
       catalog[0].measure[Nmeas].photFlags = 0;
@@ -254,13 +254,13 @@
 
     for (j = 0; j < Nsecfilt; j++) {
-      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NO_MAG;
-      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NO_MAG;
-      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NO_MAG;
+      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NAN;
+      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN;
+      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT;
     }
 
     catalog[0].measure[Nmeas].dR       = 0.0;
     catalog[0].measure[Nmeas].dD       = 0.0;
-    catalog[0].measure[Nmeas].M        = MIN (stars[N][0].M,  NO_MAG);
-    catalog[0].measure[Nmeas].dM       = MIN (stars[N][0].dM, NO_ERR);
+    catalog[0].measure[Nmeas].M        = stars[N][0].M;
+    catalog[0].measure[Nmeas].dM       = stars[N][0].dM;
     catalog[0].measure[Nmeas].Mcal     = 0;
     catalog[0].measure[Nmeas].t        = (stars[N][0].t == 0) ? TIMEREF : stars[N][0].t; /** careful : time_t vs e_time **/
@@ -291,8 +291,8 @@
 
     catalog[0].measure[Nmeas].airmass  = 0;
-    catalog[0].measure[Nmeas].Mgal     = NO_MAG;
-    catalog[0].measure[Nmeas].FWx      = NO_MAG;
-    catalog[0].measure[Nmeas].FWy      = NO_MAG;
-    catalog[0].measure[Nmeas].theta    = NO_MAG;
+    catalog[0].measure[Nmeas].Mgal     = NAN;
+    catalog[0].measure[Nmeas].FWx      = NAN_S_SHORT;
+    catalog[0].measure[Nmeas].FWy      = NAN_S_SHORT;
+    catalog[0].measure[Nmeas].theta    = NAN_S_SHORT;
 
     catalog[0].measure[Nmeas].Xccd     = 0.0;
Index: /trunk/Ohana/src/addstar/src/load2mass_catalog.c
===================================================================
--- /trunk/Ohana/src/addstar/src/load2mass_catalog.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/load2mass_catalog.c	(revision 15509)
@@ -34,5 +34,5 @@
     catalog[0].average[Nave].Nm        = 0;
     catalog[0].average[Nave].Nn        = 0;
-    catalog[0].average[Nave].Xp        = NO_MAG;
+    catalog[0].average[Nave].Xp        = NAN_S_SHORT;
     catalog[0].average[Nave].offset    = Nmeas;
     catalog[0].average[Nave].missing   = -1;
@@ -40,7 +40,7 @@
 
     for (j = 0; j < Nsec; j++) {
-      catalog[0].secfilt[Nave*Nsec+j].M  = NO_MAG;
-      catalog[0].secfilt[Nave*Nsec+j].dM = NO_MAG;
-      catalog[0].secfilt[Nave*Nsec+j].Xm    = NO_MAG;
+      catalog[0].secfilt[Nave*Nsec+j].M  = NAN;
+      catalog[0].secfilt[Nave*Nsec+j].dM = NAN;
+      catalog[0].secfilt[Nave*Nsec+j].Xm = NAN_S_SHORT;
     }
 
@@ -49,6 +49,6 @@
       catalog[0].measure[Nmeas].dR       = 0.0;
       catalog[0].measure[Nmeas].dD       = 0.0;
-      catalog[0].measure[Nmeas].M        = MIN (stars[i+j].M,  NO_MAG);
-      catalog[0].measure[Nmeas].dM       = MIN (stars[i+j].dM,  NO_ERR);
+      catalog[0].measure[Nmeas].M        = stars[i+j].M;
+      catalog[0].measure[Nmeas].dM       = stars[i+j].dM;
       catalog[0].measure[Nmeas].Mcal     = 0;
       catalog[0].measure[Nmeas].t        = stars[i+j].t;
@@ -59,9 +59,9 @@
       catalog[0].measure[Nmeas].dt       = 0xffff;
 
-      catalog[0].measure[Nmeas].Mgal     = NO_MAG;
+      catalog[0].measure[Nmeas].Mgal     = NAN;
       catalog[0].measure[Nmeas].airmass  = 0;
-      catalog[0].measure[Nmeas].FWx         = NO_MAG;
-      catalog[0].measure[Nmeas].FWy         = NO_ERR;
-      catalog[0].measure[Nmeas].theta       = NO_ERR;
+      catalog[0].measure[Nmeas].FWx      = NAN_S_SHORT;
+      catalog[0].measure[Nmeas].FWy      = NAN_S_SHORT;
+      catalog[0].measure[Nmeas].theta    = NAN_S_SHORT;
 
       catalog[0].average[Nave].Nm++;
Index: /trunk/Ohana/src/addstar/src/replace_match.c
===================================================================
--- /trunk/Ohana/src/addstar/src/replace_match.c	(revision 15508)
+++ /trunk/Ohana/src/addstar/src/replace_match.c	(revision 15509)
@@ -8,9 +8,9 @@
   for (i = 0; i < average[0].Nm; i++) {
     if (measure[i].photcode != star[0].code) continue;
-    measure[i].dR       = 3600.0*(average[0].R - star[0].R);
-    measure[i].dD       = 3600.0*(average[0].D - star[0].D);
-    measure[i].M        = MIN (star[0].M,  NO_MAG);
-    measure[i].dM       = MIN (star[0].dM, NO_ERR);
-    star[0].found          = average[0].offset + i;
+    measure[i].dR = 3600.0*(average[0].R - star[0].R);
+    measure[i].dD = 3600.0*(average[0].D - star[0].D);
+    measure[i].M  = star[0].M;
+    measure[i].dM = star[0].dM;
+    star[0].found = average[0].offset + i;
     return (TRUE);
   }
Index: /trunk/Ohana/src/delstar/src/gimages.c
===================================================================
--- /trunk/Ohana/src/delstar/src/gimages.c	(revision 15508)
+++ /trunk/Ohana/src/delstar/src/gimages.c	(revision 15509)
@@ -79,6 +79,6 @@
 
   /* secz is in units milli-airmass */
-  image[0].Mcal =  ALPHA*(image[0].secz - 1.000);
-  image[0].Xm   = NO_MAG;
+  image[0].Mcal = ALPHA*(image[0].secz - 1.000);
+  image[0].Xm   = NAN_S_SHORT;
 
   free (header.buffer);
Index: /trunk/Ohana/src/getstar/src/ReadImageHeader.c
===================================================================
--- /trunk/Ohana/src/getstar/src/ReadImageHeader.c	(revision 15508)
+++ /trunk/Ohana/src/getstar/src/ReadImageHeader.c	(revision 15509)
@@ -90,11 +90,11 @@
   image[0].fwhm_y = tmp * 25.0 * image[0].coords.cdelt1 * 3600.0;
 
-  image[0].trate = 0.0;
-  image[0].secz = NO_MAG;
+  image[0].trate  = 0.0;
+  image[0].secz   = NAN;
   image[0].ccdnum = 0;
 
   /* secz is in units milli-airmass */
   image[0].Mcal = 0.0;
-  image[0].Xm   = NO_MAG;
+  image[0].Xm   = NAN_S_SHORT;
   image[0].code = 0;
   bzero (image[0].dummy, sizeof(image[0].dummy));
Index: /trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /trunk/Ohana/src/libdvo/include/dvo.h	(revision 15508)
+++ /trunk/Ohana/src/libdvo/include/dvo.h	(revision 15509)
@@ -5,12 +5,4 @@
 # ifndef DVO_H
 # define DVO_H
-
-/*
-  # define ELIXIR 1
-  # define PANSTARRS 0
-  # define LONEOS 0
-*/
-
-/*** named data values (convert all to enums?) ***/
 
 /* DVO table modes */
@@ -55,4 +47,25 @@
 } OhanaProjectionMode;
 
+// these are used as NAN for types of int values
+typedef enum {
+    NAN_S_CHAR  = 0x7f,
+    NAN_U_CHAR  = 0xff,   // was NO_ERR
+    NAN_S_SHORT = 0x7fff, // was NO_MAG
+    NAN_U_SHORT = 0xffff, 
+    NAN_S_INT   = 0x7fffffff,
+    NAN_U_INT   = 0xffffffff,
+} DVO_INT_NAN;
+
+# ifndef (NAN)
+# ifndef (BYTE_SWAP)
+#  define __nan_bytes           { 0x7f, 0xc0, 0, 0 }
+# else
+#  define __nan_bytes           { 0, 0, 0xc0, 0x7f }
+# endif
+static union { unsigned char __c[4]; float __d; } __nan_union
+    __attribute_used__ = { __nan_bytes };
+# define NAN    (__nan_union.__d)
+# endif
+
 /* RegImage.flag values */
 # define IMREG_DIST  0x01 /* image distributed, only imregister-3.0 */
@@ -64,8 +77,4 @@
 # define LOAD_SECF 	0x08 
 # define LOAD_MEAS_META 0x10
-
-/* invalid mag value */
-# define NO_MAG    0x7fff
-# define NO_ERR    0xff
 
 /* photometry code types */
Index: /trunk/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 15508)
+++ /trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 15509)
@@ -352,7 +352,7 @@
       }
       for (j = 0; j < Nextra; j++, out++) {
-	outsec[out].M  = NO_MAG;
-	outsec[out].dM = NO_MAG;
-	outsec[out].Xm    = NO_MAG;
+	outsec[out].M  = NAN;
+	outsec[out].dM = NAN;
+	outsec[out].Xm = NAN_S_SHORT;
       }
     }
Index: /trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 15508)
+++ /trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 15509)
@@ -221,5 +221,5 @@
 
   Np = photcodes[0].hashcode[measure[0].photcode];
-  if (Np == -1) return (NO_MAG);
+  if (Np == -1) return (NAN);
 
   if (photcodes[0].code[Np].type == PHOT_REF) {
@@ -241,5 +241,5 @@
 
   Np = photcodes[0].hashcode[measure[0].photcode];
-  if (Np == -1) return (NO_MAG);
+  if (Np == -1) return (NAN);
 
   if (photcodes[0].code[Np].type == PHOT_REF) {
@@ -260,5 +260,5 @@
 
   Np = photcodes[0].hashcode[measure[0].photcode];
-  if (Np == -1) return (NO_MAG);
+  if (Np == -1) return (NAN);
 
   if (photcodes[0].code[Np].type == PHOT_REF) {
@@ -271,5 +271,5 @@
   /* for DEP, color must be made of PRI/SEC */
   mc = PhotColorForCode (average, secfilt, NULL, code);
-  if (mc == NO_MAG) return (Mcat);
+  if (isnan(mc)) return (Mcat);
   mc = mc - SCALE*code[0].dX;
 
@@ -291,5 +291,5 @@
 
   Np = photcodes[0].hashcode[measure[0].photcode];
-  if (Np == -1) return (NO_MAG);
+  if (Np == -1) return (NAN);
 
   if (photcodes[0].code[Np].type == PHOT_REF) {
@@ -302,5 +302,5 @@
   /* for DEP, color must be made of PRI/SEC */
   mc = PhotColorForCode (average, secfilt, NULL, code);
-  if (mc == NO_MAG) return (Mrel);
+  if (isnan(mc)) return (Mrel);
   mc = mc - SCALE*code[0].dX;
 
@@ -323,7 +323,5 @@
   /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */
   Np = photcodes[0].hashcode[thisone[0].photcode];
-  if (Np == -1) {
-    return (NO_MAG);
-  }
+  if (Np == -1) return (NAN);
 
   if (photcodes[0].code[Np].type == PHOT_REF) {
@@ -331,12 +329,10 @@
     return (Mrel);
   }
-  if (code[0].code != photcodes[0].code[Np].equiv) {
-    return (NO_MAG);
-  }
+  if (code[0].code != photcodes[0].code[Np].equiv) return (NAN);
 
   Mcal = PhotRel (thisone, average, secfilt) + SCALE*code[0].C;
 
   mc = PhotColorForCode (average, secfilt, measure, code);
-  if (mc == NO_MAG) return (Mcal);
+  if (isnan(mc)) return (Mcal);
   mc = mc - SCALE*code[0].dX;
 
@@ -358,5 +354,5 @@
   PhotCode *color;
 
-  m1 = m2 = NO_MAG;
+  m1 = m2 = NAN;
 
   if (measure == NULL) {
@@ -364,7 +360,7 @@
     Ns2 = photcodes[0].hashNsec[code[0].c2];
   
-    m1 = (Ns1 == -1) ? NO_MAG : secfilt[Ns1].M;
-    m2 = (Ns2 == -1) ? NO_MAG : secfilt[Ns2].M;
-    mc = ((m1 == NO_MAG) || (m2 == NO_MAG)) ? NO_MAG : (m1 - m2);
+    m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].M;
+    m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].M;
+    mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2);
     return (mc);
   }
@@ -372,7 +368,7 @@
   /* find magnitude matching first color term */
   color = GetPhotcodebyCode (code[0].c1);
-  if (color == NULL) return (NO_MAG);
+  if (color == NULL) return (NAN);
   if (color[0].type == PHOT_REF) {
-    for (i = 0; (i < average[0].Nm) && (m1 == NO_MAG); i++) {
+    for (i = 0; (i < average[0].Nm) && (isnan(m1)); i++) {
       if (measure[i].photcode == color[0].code) {
 	m1 = measure[i].M;
@@ -381,12 +377,12 @@
   } else {
     Ns = photcodes[0].hashNsec[color[0].code];
-    m1 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
+    m1 = (Ns == -1) ? NAN : secfilt[Ns].M;
   }	
 
   /* find magnitude matching second color term */
   color = GetPhotcodebyCode (code[0].c2);
-  if (color == NULL) return (NO_MAG);
+  if (color == NULL) return (NAN);
   if (color[0].type == PHOT_REF) {
-    for (i = 0; (i < average[0].Nm) && (m2 == NO_MAG); i++) {
+    for (i = 0; (i < average[0].Nm) && (isnan(m2)); i++) {
       if (measure[i].photcode == color[0].code) {
 	m2 = measure[i].M;
@@ -395,7 +391,7 @@
   } else {
     Ns = photcodes[0].hashNsec[color[0].code];
-    m2 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
+    m2 = (Ns == -1) ? NAN : secfilt[Ns].M;
   }	
-  mc = ((m1 == NO_MAG) || (m2 == NO_MAG)) ? NO_MAG : (m1 - m2);
+  mc = (isnan(m1)) || isnan(m2))) ? NAN : (m1 - m2);
   return (mc);
 }
@@ -409,9 +405,9 @@
 
   Ns = photcodes[0].hashNsec[code[0].code];
-  Mave = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
+  Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
   Mref = Mave + SCALE*code[0].C;
 
   mc = PhotColorForCode (average, secfilt, measure, code);
-  if (mc == NO_MAG) return (Mref);
+  if (isnan(mc)) return (Mref);
   mc = mc - SCALE*code[0].dX;
 
@@ -433,5 +429,5 @@
 
   Ns = photcodes[0].hashNsec[code[0].code];
-  Mave = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
+  Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
   return (Mave);
 }
@@ -443,8 +439,9 @@
 
   Ns = photcodes[0].hashNsec[code[0].code];
-  dM  = (Ns == -1) ? NO_MAG : secfilt[Ns].dM;
+  dM  = (Ns == -1) ? NAN : secfilt[Ns].dM;
   return (dM);
 }
 
+// XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short)
 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) {
 
@@ -454,6 +451,6 @@
 
   Ns = photcodes[0].hashNsec[code[0].code];
-  Mi = (Ns == -1) ? NO_MAG : secfilt[Ns].Xm;
-  Xm = (Mi == NO_MAG) ? -1.0 : pow (10.0, 0.01*Mi);
+  Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm;
+  Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi);
   return (Xm);
 }
@@ -478,5 +475,5 @@
   } else {
     Ns = photcodes[0].hashNsec[code[0].code];
-    M1 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
+    M1 = (Ns == -1) ? NAN : secfilt[Ns].M;
   }	
 
@@ -494,5 +491,5 @@
   } else {
     Ns = photcodes[0].hashNsec[code[0].code];
-    M2 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
+    M2 = (Ns == -1) ? NAN : secfilt[Ns].M;
   }	
   
Index: /trunk/Ohana/src/libdvo/src/photfits.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/photfits.c	(revision 15508)
+++ /trunk/Ohana/src/libdvo/src/photfits.c	(revision 15509)
@@ -31,5 +31,5 @@
     return (0);
   }
-  return (NO_MAG);
+  return (NAN_S_SHORT);
 }
 
Index: /trunk/Ohana/src/opihi/dvo/calextract.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/calextract.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/calextract.c	(revision 15509)
@@ -82,6 +82,6 @@
 
       /* find data for filter 2 (PHOT_REF) */
-      M2 = NO_MAG;
-      dM2 = NO_MAG;
+      M2 = NAN;
+      dM2 = NAN;
       for (j = 0; j < catalog.average[i].Nm; j++) {
 	if (catalog.measure[m+j].photcode != code[1][0].code) continue;
@@ -89,9 +89,9 @@
 	dM2 = catalog.measure[m+j].dM;
       }	
-      if (M2 == NO_MAG) continue;
+      if (isnan(M2)) continue;
 
       /* find data for filter 1 */
       M1 = ExtractAverages (code[0], mode[0], &catalog.average[i], &catalog.secfilt[i*Nsecfilt], &catalog.measure[m], AVE_MAG);
-      if (M1 == NO_MAG) continue;
+      if (isnan(M1)) continue;
 
       vec[Nd ][0].elements[N] = M1 - M2;
Index: /trunk/Ohana/src/opihi/dvo/calmextract.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/calmextract.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/calmextract.c	(revision 15509)
@@ -93,6 +93,6 @@
 
       /* find data for filter 2 (REF) */
-      M2 = NO_MAG;
-      dM2 = NO_MAG;
+      M2 = NAN;
+      dM2 = NAN;
       for (j = 0; j < catalog.average[i].Nm; j++) {
 	if (catalog.measure[m+j].photcode != code[1][0].code) continue;
@@ -100,5 +100,5 @@
 	dM2 = catalog.measure[m+j].dM;
       }	
-      if (M2 == NO_MAG) continue;
+      if (isnan(M2)) continue;
       
       /* find data for filter 1 */
Index: /trunk/Ohana/src/opihi/dvo/ccd.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/ccd.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/ccd.c	(revision 15509)
@@ -84,5 +84,5 @@
 	  ALLOCATE (M2, double, 1);
 	  N2 = 1;
-	  M2[0] = NO_MAG;
+	  M2[0] = NAN;
 	} else {
 	  goto skip;
Index: /trunk/Ohana/src/opihi/dvo/cmd.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/cmd.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/cmd.c	(revision 15509)
@@ -82,5 +82,5 @@
 	  ALLOCATE (M3, double, 1);
 	  N3 = 1;
-	  M3[0] = NO_MAG;
+	  M3[0] = NAN;
 	} else {
 	  goto skip;
Index: /trunk/Ohana/src/opihi/dvo/dbExtractAverages.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/dbExtractAverages.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/dbExtractAverages.c	(revision 15509)
@@ -7,5 +7,5 @@
   double value;
 
-  value = NO_MAG;
+  value = NAN;
 
   /* assign vector values */
@@ -71,5 +71,5 @@
 	case MAG_CAL:
 	  // XXX need to code this correctly: this returns just the first matching value
-	  value = NO_MAG;
+	  value = NAN;
 	  for (i = 0; i < average[0].Nm; i++) {
 	    if (field->photcode->code != measure[i].photcode) continue;
Index: /trunk/Ohana/src/opihi/dvo/dbExtractMeasures.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/dbExtractMeasures.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/dbExtractMeasures.c	(revision 15509)
@@ -19,5 +19,5 @@
   Coords *mosaic;
 
-  value = NO_MAG;
+  value = NAN;
 
   switch (field->ID) {
@@ -128,8 +128,8 @@
       break;
     case MEAS_RA_OFFSET_ERR: /* OK */
-      value = NO_MAG;
+      value = NAN;
       break;
     case MEAS_DEC_OFFSET_ERR: /* OK */
-      value = NO_MAG;
+      value = NAN;
       break;
     case MEAS_AIRMASS: /* OK */
Index: /trunk/Ohana/src/opihi/dvo/ddmags.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/ddmags.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/ddmags.c	(revision 15509)
@@ -94,5 +94,5 @@
 	  ALLOCATE (M2, double, 1);
 	  N2 = 1;
-	  M2[0] = NO_MAG;
+	  M2[0] = NAN;
 	} else {
 	  goto skip;
Index: /trunk/Ohana/src/opihi/dvo/dmagmeas.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/dmagmeas.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/dmagmeas.c	(revision 15509)
@@ -91,5 +91,5 @@
 	  ALLOCATE (M3, double, 1);
 	  N3 = 1;
-	  M3[0] = NO_MAG;
+	  M3[0] = NAN;
 	} else {
 	  goto skip;
Index: /trunk/Ohana/src/opihi/dvo/dmags.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/dmags.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/dmags.c	(revision 15509)
@@ -89,5 +89,5 @@
 	  ALLOCATE (M3, double, 1);
 	  N3 = 1;
-	  M3[0] = NO_MAG;
+	  M3[0] = NAN;
 	} else {
 	  goto skip;
Index: /trunk/Ohana/src/opihi/dvo/gstar.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/gstar.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/gstar.c	(revision 15509)
@@ -274,6 +274,13 @@
 }
 
-void print_value (double value, short int ival) {
-  if (ival == NO_MAG) 
+void print_double (double value) {
+  if (isnan(value)) 
+    gprint (GP_LOG, "NaN    ");
+  else 
+    gprint (GP_LOG, "%6.3f ", value);
+}
+
+void print_short (double value, short int ival) {
+  if (ival == NAN_S_SHORT) 
     gprint (GP_LOG, "NaN    ");
   else 
@@ -320,7 +327,7 @@
     case 0: /* average mags */
       if (seq == -1) {
-	print_value (NO_MAG, NO_MAG);
+	print_double (NAN);
       } else {
-	print_value (secfilt[seq].M, secfilt[seq].M);
+	print_double (secfilt[seq].M);
       }
       break;
@@ -328,7 +335,7 @@
     case 1: /* average mags errors */
       if (seq == -1) {
-	print_value (NO_MAG, NO_MAG);
+	print_double (NAN);
       } else {
-	print_value (secfilt[seq].dM, secfilt[seq].dM);
+	print_double (secfilt[seq].dM);
       }
       break;
@@ -336,7 +343,7 @@
     case 2: /* average mag chisq */
       if (seq == -1) {
-	print_value (NO_MAG, NO_MAG);
+	print_short (NAN_S_SHORT, NAN_S_SHORT);
       } else {
-	print_value (pow (10.0, 0.01*secfilt[seq].Xm), secfilt[seq].Xm);
+	print_short (pow (10.0, 0.01*secfilt[seq].Xm), secfilt[seq].Xm);
       }
       break;
Index: /trunk/Ohana/src/opihi/dvo/photometry.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/photometry.c	(revision 15508)
+++ /trunk/Ohana/src/opihi/dvo/photometry.c	(revision 15509)
@@ -28,5 +28,5 @@
 
 # define SETMAG(MOUT,MEAS,MODE) \
-  MOUT = NO_MAG; \
+  MOUT = NAN; \
   if (MODE == MAG_INST) MOUT = PhotInst (&MEAS);  \
   if (MODE == MAG_CAT)  MOUT = PhotCat  (&MEAS); \
@@ -588,5 +588,5 @@
   double value;
 
-  value = NO_MAG;
+  value = NAN;
 
   /* this function requires code set for certain value of param.  
@@ -594,5 +594,5 @@
 
   /* filter by average quantities (eg, chisq, Nphot, etc) */
-  if (!TestAverage (code, average, secfilt, measure)) return (NO_MAG);
+  if (!TestAverage (code, average, secfilt, measure)) return (NAN);
 
   /* assign vector values */
@@ -657,5 +657,5 @@
 	case MAG_REL:
 	case MAG_CAL:
-	  value = NO_MAG;
+	  value = NAN;
 	  for (i = 0; i < average[0].Nm; i++) {
 	      if (code[0].code != measure[i].photcode) continue;
@@ -866,5 +866,5 @@
   if (ErrSelect) {
     dM = PhotdM (code, average, secfilt);
-    if (dM > ErrValue) return (NO_MAG);
+    if (dM > ErrValue) return (NAN);
   }
   
@@ -944,5 +944,5 @@
     ALLOCATE (M, double, 1);
     mag = ExtractAverages (code, mode, average, secfilt, measure, AVE_MAG);
-    if (mag == NO_MAG) {
+    if (isnan(mag)) {
       N = 0;
     } else {
@@ -962,5 +962,5 @@
 
   int i, j, A1, A2, N1, N2, Np, Nlist, NLIST;
-  double *M1, *M2, *list, NoMag;
+  double *M1, *M2, *list;
 
   /* check for special case of measure-measure - this is needed to drop self-matches */
@@ -977,5 +977,4 @@
   ALLOCATE (list, double, NLIST);
   M1 = M2 = NULL;
-  NoMag = NO_MAG * 0.001;
 
   /* one of the two is an average, must do independently */
@@ -988,9 +987,9 @@
   if (N2 == 0) goto skip;
 
-  /* magnitudes may be NO_MAG : set delta to NO_MAG */
+  /* magnitudes may be NAN : set delta to NAN */
   for (i = 0; i < N1; i++) {
     for (j = 0; j < N2; j++) {
-      if ((M1[i] == NoMag) || (M2[j] == NoMag)) {
-	list[Nlist] = NoMag;
+      if (isnan(M1[i]) || isnan(M2[j])) {
+	list[Nlist] = NAN;
       } else {
 	list[Nlist] = M1[i] - M2[j];
@@ -1012,5 +1011,5 @@
 
   int i, j, Np0, Np1, Nlist, NLIST;
-  double *list, M1, M2, NoMag;
+  double *list, M1, M2;
   
   *nlist = 0; 
@@ -1018,5 +1017,4 @@
   NLIST = MAX (1, average[0].Nm*average[0].Nm);
   ALLOCATE (list, double, NLIST);
-  NoMag = NO_MAG * 0.001;
 
   /* must have two code values - drop this test? this is programming case, not a user case */
@@ -1044,6 +1042,6 @@
       TESTMEASURE (measure[j]);
       SETMAG(M2, measure[j], mode[1]);
-      if ((M1 == NoMag) || (M2 == NoMag)) {
-	list[Nlist] = NoMag;
+      if (isnan(M1) || isnan(M2)) {
+	list[Nlist] = NAN;
       } else {
 	list[Nlist] = M1 - M2;
Index: /trunk/Ohana/src/photdbc/src/get_mags.c
===================================================================
--- /trunk/Ohana/src/photdbc/src/get_mags.c	(revision 15508)
+++ /trunk/Ohana/src/photdbc/src/get_mags.c	(revision 15509)
@@ -19,11 +19,8 @@
   for (i = 0; i < catalog[0].Naverage; i++) {
     Nlist = MAX (Nlist, catalog[0].average[i].Nm);
-    catalog[0].average[i].M  = NO_MAG;
-    catalog[0].average[i].dM = NO_MAG;
-    catalog[0].average[i].Xm = NO_MAG;
     for (j = 0; j < Nsecfilt; j++) {
-      catalog[0].secfilt[i*Nsecfilt+j].M  = NO_MAG;
-      catalog[0].secfilt[i*Nsecfilt+j].dM = NO_MAG;
-      catalog[0].secfilt[i*Nsecfilt+j].Xm = NO_MAG;
+      catalog[0].secfilt[i*Nsecfilt+j].M  = NAN;
+      catalog[0].secfilt[i*Nsecfilt+j].dM = NAN;
+      catalog[0].secfilt[i*Nsecfilt+j].Xm = NAN_S_SHORT;
     }
   }
Index: /trunk/Ohana/src/relastro/Makefile
===================================================================
--- /trunk/Ohana/src/relastro/Makefile	(revision 15508)
+++ /trunk/Ohana/src/relastro/Makefile	(revision 15509)
@@ -55,9 +55,4 @@
 $(SRC)/write_coords.$(ARCH).o
 
-DROP = \
-$(SRC)/setMrelFinal.$(ARCH).o 	 \
-$(SRC)/StarOps.$(ARCH).o	 
-
-
 $(RELASTRO): $(INC)/relastro.h
 $(BIN)/relastro.$(ARCH): $(RELASTRO)
Index: /trunk/Ohana/src/relastro/src/UpdateObjects.c
===================================================================
--- /trunk/Ohana/src/relastro/src/UpdateObjects.c	(revision 15508)
+++ /trunk/Ohana/src/relastro/src/UpdateObjects.c	(revision 15509)
@@ -196,5 +196,5 @@
       catalog[i].average[j].dP  = fit.dp; // parallax error in arcsec
 
-      catalog[i].average[j].Xp  = (fit.Nfit > 1) ? 100.0*log10(fit.chisq) : NO_MAG;
+      catalog[i].average[j].Xp  = (fit.Nfit > 1) ? 100.0*log10(fit.chisq) : NAN_S_SHORT;
     }
 
Index: /trunk/Ohana/src/relastro/src/select_images.c
===================================================================
--- /trunk/Ohana/src/relastro/src/select_images.c	(revision 15508)
+++ /trunk/Ohana/src/relastro/src/select_images.c	(revision 15509)
@@ -142,6 +142,7 @@
       }
       if (RESET) {
+	// XXX do we need this in relastro?
 	assignMcal (&image[nimage], (double *) NULL, -1);
-	image[nimage].dMcal = NO_MAG;
+	image[nimage].dMcal = NAN;
 	image[nimage].code &= ~ID_IMAGE_POOR;
       }
Index: /trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- /trunk/Ohana/src/relphot/include/relphot.h	(revision 15508)
+++ /trunk/Ohana/src/relphot/include/relphot.h	(revision 15509)
@@ -142,4 +142,5 @@
 int           gcatalog            PROTO((Catalog *catalog, int FINAL));
 Coords       *getCoords           PROTO((int meas, int cat));
+int           getImageEntry       PROTO((int meas, int cat));
 float         getMcal             PROTO((int meas, int cat));
 float         getMgrid            PROTO((int meas, int cat));
Index: /trunk/Ohana/src/relphot/src/GridOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/GridOps.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/GridOps.c	(revision 15509)
@@ -239,5 +239,5 @@
   if (!USE_GRID) return (0);
   i = bin[cat][meas];
-  if (i == -1) return (NO_MAG);
+  if (i == -1) return (NAN);
 
   value = gridM[i];
@@ -272,10 +272,9 @@
       if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
       Mcal = getMcal  (m, c);
-      if (Mcal == NO_MAG) continue;
-      if (Mcal == NO_IMAGE) continue;
+      if (isnan(Mcal)) continue;
       Mmos = getMmos  (m, c);
-      if (Mmos == NO_MAG) continue;
-      if (Mmos == NO_IMAGE) continue;
-      if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
+      if (isnan(Mmos)) continue;
+      Mrel  = getMrel  (catalog, m, c);
+      if (isnan(Mrel)) continue;
       
       n = catalog[c].measure[m].averef;
@@ -326,10 +325,9 @@
       }
       Mcal  = getMcal  (m, c);
-      if (Mcal == NO_MAG) continue;
-      if (Mcal == NO_IMAGE) continue;
+      if (isnan(Mcal)) continue;
       Mmos  = getMmos  (m, c);
-      if (Mmos == NO_MAG) continue;
-      if (Mmos == NO_IMAGE) continue;
-      if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
+      if (isnan(Mmos)) continue;
+      Mrel  = getMrel  (catalog, m, c);
+      if (isnan(Mrel)) continue;
 
       n = catalog[c].measure[m].averef;
Index: /trunk/Ohana/src/relphot/src/ImageOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/ImageOps.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/ImageOps.c	(revision 15509)
@@ -138,4 +138,12 @@
 }
 
+int getImageEntry (int meas, int cat) {
+
+  int i;
+
+  i = bin[cat][meas];
+  return (i);
+}
+
 float getMcal (int meas, int cat) {
 
@@ -144,7 +152,7 @@
 
   i = bin[cat][meas];
-  if (i == -1) return (NO_IMAGE);
-
-  if (image[i].code & IMAGE_BAD)  return (NO_MAG);  
+  if (i == -1) return (NAN);
+
+  if (image[i].code & IMAGE_BAD) return (NAN);  
   value = image[i].Mcal;
   return (value);
@@ -197,8 +205,9 @@
       if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
       Mmos  = getMmos  (m, c);
-      if (Mmos == NO_MAG) continue;
-      if (Mmos == NO_IMAGE) continue;
-      if ((Mgrid = getMgrid (m, c)) == NO_MAG) continue;
-      if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
+      if (isnan(Mmos)) continue;
+      Mgrid = getMgrid (m, c);
+      if (isnan(Mgrid)) continue;
+      Mrel  = getMrel  (catalog, m, c);
+      if (isnan(Mrel)) continue;
       
       n = catalog[c].measure[m].averef;
@@ -338,5 +347,5 @@
   int i, j, m, c, n, N;
   double *list, *dlist;
-  float Mcal, Mmos;
+  float Mcal, Mmos, Mgrid;
   StatType stats;
 
@@ -357,11 +366,10 @@
       c = clist[i][j];
 
-      Mcal = getMcal  (m, c);
-      if (Mcal == NO_MAG) continue;
-      if (Mcal == NO_IMAGE) continue;
-      Mmos = getMmos  (m, c);
-      if (Mmos == NO_MAG) continue;
-      if (Mmos == NO_IMAGE) continue;
-      if (getMgrid (m, c) == NO_MAG) continue;
+      Mcal  = getMcal  (m, c);
+      if (isnan(Mcal)) continue;
+      Mmos  = getMmos  (m, c);
+      if (isnan(Mmos)) continue;
+      Mgrid = getMgrid (m, c);
+      if (isnan(Mgrid)) continue;
       N++;
     }
Index: /trunk/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 15509)
@@ -134,10 +134,11 @@
       Dmin = MIN (Dmin, D);
       Dmax = MAX (Dmax, D);
-      Mcal += image[m].Mcal;
+      Mcal  += image[m].Mcal;
       dMcal += image[m].dMcal;
-      Xm += image[m].Xm;
+      Xm    += image[m].Xm;
       /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */
-      image[m].Mcal = 0.0;
-      image[m].dMcal = image[m].Xm = NO_MAG;
+      image[m].Mcal  = 0.0;
+      image[m].dMcal = NAN;
+      image[m].Xm    = NAN_S_SHORT;
     }
     dS /= Nimlist[i];
@@ -299,7 +300,7 @@
   if (!MOSAICNAME[0]) return (0);
   i = bin[cat][meas];
-  if (i == -1) return (NO_IMAGE);
-
-  if (mosaic[i].code & IMAGE_BAD) return (NO_MAG);  
+  if (i == -1) return (NAN);
+
+  if (mosaic[i].code & IMAGE_BAD) return (NAN);  
   value = mosaic[i].Mcal;
   return (value);
@@ -345,10 +346,11 @@
       c = clist[i][j];
       
+      if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
       Mcal  = getMcal  (m, c);
-      if (Mcal == NO_MAG) continue;
-      if (Mcal == NO_IMAGE) continue;
-      if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
-      if ((Mgrid = getMgrid (m, c)) == NO_MAG) continue;
-      if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
+      if (isnan(Mcal)) continue;
+      Mgrid = getMgrid (m, c);
+      if (isnan(Mgrid)) continue;
+      Mrel  = getMrel  (catalog, m, c);
+      if (isnan(Mrel)) continue;
       
       n = catalog[c].measure[m].averef;
@@ -469,8 +471,9 @@
 
       Mcal = getMcal  (m, c);
-      if (Mcal == NO_MAG) continue;
-      if (Mcal == NO_IMAGE) continue;
-      if (getMgrid (m, c) == NO_MAG) continue;
-      if (getMrel  (catalog, m, c) == NO_MAG) continue;
+      if (isnan(Mcal)) continue;
+      Mgrid = getMgrid (m, c);
+      if (isnan(Mgrid)) continue;
+      Mrel = getMrel  (catalog, m, c);
+      if (isnan(Mrel)) continue;
       N++;
     }
Index: /trunk/Ohana/src/relphot/src/StarOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/StarOps.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/StarOps.c	(revision 15509)
@@ -26,5 +26,5 @@
 
   ave = catalog[cat].measure[meas].averef;
-  if (catalog[cat].average[ave].code & STAR_BAD) return (NO_MAG);  
+  if (catalog[cat].average[ave].code & STAR_BAD) return (NAN);  
  
   value = catalog[cat].secfilt[PhotNsec*ave+PhotSec].M;
@@ -45,20 +45,19 @@
       m = catalog[i].average[j].offset;
 
-      // XXX allow REF stars to be included in the calculation
-      // this should be optionally set, and should allow for 
-      // REF stars to be downweighted by more than their reported
-      // errors.  how such info is carried is unclear...
       N = 0;
       for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
 	if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
-	Mcal  = getMcal  (m, i);
-	if (Mcal == NO_MAG) continue;
-	if (Mcal == NO_IMAGE) {
+	// XXX allow REF stars (no Image Entry) to be included in the calculation this
+	// should be optionally set, and should allow for REF stars to be downweighted by
+	// more than their reported errors.  how such info is carried is unclear...
+	if (getImageEntry (m, i) < 0) {
 	  Mcal = Mmos = Mgrid = 0;
 	} else {
+	  Mcal  = getMcal  (m, i);
+	  if (isnan(Mcal)) continue;
 	  Mmos  = getMmos  (m, i);
-	  if (Mmos == NO_MAG) continue;
-	  if (Mmos == NO_IMAGE) continue;
-	  if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
+	  if (isnan(Mmos)) continue;
+	  Mgrid = getMgrid (m, i);
+	  if (isnan(Mgrid)) continue;
 	}
 
@@ -78,5 +77,5 @@
       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;
+      catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT;
     }
   }
@@ -111,13 +110,16 @@
       for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
 	if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
-	Mcal  = getMcal  (m, i);
-	if (Mcal == NO_MAG) continue;
-	if (Mcal == NO_IMAGE) {
+	// XXX allow REF stars (no Image Entry) to be included in the calculation this
+	// should be optionally set, and should allow for REF stars to be downweighted by
+	// more than their reported errors.  how such info is carried is unclear...
+	if (getImageEntry (m, i) < 0) {
 	  Mcal = Mmos = Mgrid = 0;
 	} else {
+	  Mcal  = getMcal  (m, i);
+	  if (isnan(Mcal)) continue;
 	  Mmos  = getMmos  (m, i);
-	  if (Mmos == NO_MAG) continue;
-	  if (Mmos == NO_IMAGE) continue;
-	  if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
+	  if (isnan(Mmos)) continue;
+	  Mgrid = getMgrid (m, i);
+	  if (isnan(Mgrid)) continue;
 	}
 
@@ -135,5 +137,5 @@
       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;
+      catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT;
     }
   }
@@ -160,10 +162,9 @@
 	if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
 	Mcal  = getMcal  (m, i);
-	if (Mcal == NO_MAG) continue;
-	if (Mcal == NO_IMAGE) continue;
+	if (isnan(Mcal)) continue;
 	Mmos  = getMmos  (m, i);
-	if (Mmos == NO_MAG) continue;
-	if (Mmos == NO_IMAGE) continue;
-	if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
+	if (isnan(Mmos)) continue;
+	Mgrid = getMgrid (m, i);
+	if (isnan(Mgrid)) continue;
 	catalog[i].measure[m].Mcal = Mcal + Mmos + Mgrid;
       }
@@ -216,5 +217,5 @@
       Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
       Chisq = pow (10.0, 0.01*Xm);
-      mark = (dM > MaxScatter) || (Xm == NO_MAG) || (Chisq > MaxChisq);
+      mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq);
       if (mark) {
 	catalog[i].average[j].code |= ID_STAR_POOR;
@@ -274,10 +275,9 @@
 	/* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */
 	Mcal  = getMcal  (m, i);
-	if (Mcal == NO_MAG) continue;
-	if (Mcal == NO_IMAGE) continue;
+	if (isnan(Mcal)) continue;
 	Mmos  = getMmos  (m, i);
-	if (Mmos == NO_MAG) continue;
-	if (Mmos == NO_IMAGE) continue;
-	if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
+	if (isnan(Mmos)) continue;
+	Mgrid = getMgrid (m, i);
+	if (isnan(Mgrid)) continue;
 
 	Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
@@ -310,10 +310,9 @@
 	/* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */
 	Mcal  = getMcal  (m, i);
-	if (Mcal == NO_MAG) continue;
-	if (Mcal == NO_IMAGE) continue;
+	if (isnan(Mcal)) continue;
 	Mmos  = getMmos  (m, i);
-	if (Mmos == NO_MAG) continue;
-	if (Mmos == NO_IMAGE) continue;
-	if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
+	if (isnan(Mmos)) continue;
+	Mgrid = getMgrid (m, i);
+	if (isnan(Mgrid)) continue;
 
 	Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
@@ -368,10 +367,9 @@
       for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
 	Mcal = getMcal  (m, i);
-	if (Mcal == NO_MAG) continue;
-	if (Mcal == NO_IMAGE) continue;
+	if (isnan(Mcal)) continue;
 	Mmos = getMmos  (m, i);
-	if (Mmos == NO_MAG) continue;
-	if (Mmos == NO_IMAGE) continue;
-	if (getMgrid (m, i) == NO_MAG) continue;
+	if (isnan(Mmos)) continue;
+	Mgrid = getMgrid (m, i);
+	if (isnan(Mgrid)) continue;
 	N++;
       }
@@ -411,5 +409,5 @@
 
       Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
-      if (Xm == NO_MAG) continue;
+      if (Xm == NAN_S_SHORT) continue;
       list[n] = pow (10.0, 0.01*Xm);
       dlist[n] = 1;
@@ -508,5 +506,5 @@
       xlist[N] = catalog[i].secfilt[PhotNsec*j+PhotSec].M;
       value    = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
-      if (value == NO_MAG) continue;
+      if (value == NAN_S_SHORT) continue;
       ylist[N] = 0.01*value;
       N++;
Index: /trunk/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- /trunk/Ohana/src/relphot/src/bcatalog.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/bcatalog.c	(revision 15509)
@@ -27,6 +27,6 @@
 
     if (RESET) {
-      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M  = NO_MAG;
-      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NO_MAG;
+      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M  = NAN;
+      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NAN;
       subcatalog[0].average[Naverage].code &= ~ID_STAR_FEW;
       subcatalog[0].average[Naverage].code &= ~ID_STAR_POOR;
Index: /trunk/Ohana/src/relphot/src/plot_scatter.c
===================================================================
--- /trunk/Ohana/src/relphot/src/plot_scatter.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/plot_scatter.c	(revision 15509)
@@ -28,11 +28,10 @@
       for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
 	if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
-	Mcal  = getMcal  (m, i);
-	if (Mcal == NO_MAG) continue;
-	if (Mcal == NO_IMAGE) continue;
-	Mmos  = getMmos  (m, i);
-	if (Mmos == NO_MAG) continue;
-	if (Mmos == NO_IMAGE) continue;
-	if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
+	Mcal = getMcal  (m, i);
+	if (isnan(Mcal)) continue;
+	Mmos = getMmos  (m, i);
+	if (isnan(Mmos)) continue;
+	Mgrid = getMgrid (m, i);
+	if (isnan(Mgrid)) continue;
 
 	Mrel = catalog[i].secfilt[PhotNsec*j+PhotSec].M;
Index: /trunk/Ohana/src/relphot/src/select_images.c
===================================================================
--- /trunk/Ohana/src/relphot/src/select_images.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/select_images.c	(revision 15509)
@@ -138,5 +138,5 @@
       if (RESET) {
 	assignMcal (&image[nimage], (double *) NULL, -1);
-	image[nimage].dMcal = NO_MAG;
+	image[nimage].dMcal = NAN;
 	image[nimage].code &= ~ID_IMAGE_POOR;
       }
Index: /trunk/Ohana/src/relphot/src/setMrelFinal.c
===================================================================
--- /trunk/Ohana/src/relphot/src/setMrelFinal.c	(revision 15508)
+++ /trunk/Ohana/src/relphot/src/setMrelFinal.c	(revision 15509)
@@ -9,7 +9,7 @@
 
     for (i = 0; i < catalog[0].Naverage; i++) {
-      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;
+      catalog[0].secfilt[PhotNsec*i+PhotSec].M  = NAN;
+      catalog[0].secfilt[PhotNsec*i+PhotSec].dM = NAN;
+      catalog[0].secfilt[PhotNsec*i+PhotSec].Xm = NAN_S_SHORT;
 
       m = catalog[0].average[i].offset;
@@ -106,6 +106,6 @@
       /* skip measurements from BAD images and mosaics */
       /* do NOT skip measurements without a matching image */
-      if ((getMcal  (m, 0)) == NO_MAG) goto skip;
-      if ((getMmos  (m, 0)) == NO_MAG) goto skip;
+      if (isnan(getMcal (m, 0))) goto skip;
+      if (isnan(getMmos (m, 0))) goto skip;
 
       /* skip measurements by inst mag limit */
Index: /trunk/Ohana/src/uniphot/src/update_catalog.c
===================================================================
--- /trunk/Ohana/src/uniphot/src/update_catalog.c	(revision 15508)
+++ /trunk/Ohana/src/uniphot/src/update_catalog.c	(revision 15509)
@@ -13,5 +13,5 @@
   for (i = 0; i < catalog[0].Naverage; i++) {
     
-    if (catalog[0].secfilt[i*Nsecfilt+Nsec].M != NO_MAG) {
+    if (!isnan(catalog[0].secfilt[i*Nsecfilt+Nsec].M)) {
       catalog[0].secfilt[i*Nsecfilt+Nsec].M += sgroup[0].M;
     }
