Index: /trunk/Ohana/src/libautocode/def/average-panstarrs-dev-0.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/average-panstarrs-dev-0.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/average-panstarrs-dev-0.d	(revision 15511)
@@ -19,10 +19,4 @@
 FIELD dP,             PAR_ERR,    float,            parallax error,               arcsec
 
-# XXX drop the old primary magnitude concept
-# FIELD M,            MAG,        float,            primary mag,       	       	  mag
-# FIELD dM,           MAG_ERR,    float,            error on primary mag,         mag
-# FIELD Xm,           CHISQ_MAG,  short, 	    chisq for primary mag,        [100*log(value)]
-# FIELD Xg,           CHISQ_GAL,  short,            chisq for galaxy mags,        [100*log(value)]
-
 FIELD Xp,             SIGMA_POS,  short, 	    position scatter,   	  1/100 arcsec
 FIELD Nm,             NMEAS,      unsigned short,   number of measures
@@ -41,7 +35,4 @@
 # the index for the secfilt table is just Nsecfilt times the index for the average table.
 
-# XXX after the rest of the DVO re-org work, remove the magnitude based values from this table
-# and move them to the secfilt table.
-
 # the DVO object IDs are generated internally and are not equivalent to the PSPS object IDs
 # probably need to add position chisq
Index: /trunk/Ohana/src/libautocode/def/average-panstarrs-dev-1.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/average-panstarrs-dev-1.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/average-panstarrs-dev-1.d	(revision 15511)
@@ -35,7 +35,4 @@
 # the index for the secfilt table is just Nsecfilt times the index for the average table.
 
-# XXX after the rest of the DVO re-org work, remove the magnitude based values from this table
-# and move them to the secfilt table.
-
 # the DVO object IDs are generated internally and are not equivalent to the PSPS object IDs
 # probably need to add position chisq
Index: /trunk/Ohana/src/libautocode/def/average-ps1-dev-1.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/average-ps1-dev-1.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/average-ps1-dev-1.d	(revision 15511)
@@ -19,10 +19,4 @@
 FIELD dP,             PAR_ERR,    float,            parallax error,               arcsec
 
-# XXX drop the old primary magnitude concept
-# FIELD M,            MAG,        float,            primary mag,       	       	  mag
-# FIELD dM,           MAG_ERR,    float,            error on primary mag,         mag
-# FIELD Xm,           CHISQ_MAG,  short, 	    chisq for primary mag,        [100*log(value)]
-# FIELD Xg,           CHISQ_GAL,  short,            chisq for galaxy mags,        [100*log(value)]
-
 FIELD Xp,             SIGMA_POS,  short, 	    position scatter,   	  1/100 arcsec
 FIELD Nm,             NMEAS,      unsigned short,   number of measures
@@ -41,7 +35,4 @@
 # the index for the secfilt table is just Nsecfilt times the index for the average table.
 
-# XXX after the rest of the DVO re-org work, remove the magnitude based values from this table
-# and move them to the secfilt table.
-
 # the DVO object IDs are generated internally and are not equivalent to the PSPS object IDs
 # probably need to add position chisq
Index: /trunk/Ohana/src/libautocode/def/average.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/average.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/average.d	(revision 15511)
@@ -30,6 +30,4 @@
 FIELD objID_lo,       OBJ_ID_LO,    unsigned int,   ID lower bytes
 
-# XXX record the number of detections used for average astrometry
-
 # this structure should only be used for internal representations
 # the average-FORMAT structures should be used for external representations
@@ -37,7 +35,4 @@
 # the index for the secfilt table is just Nsecfilt times the index for the average table.
 
-# XXX after the rest of the DVO re-org work, remove the magnitude based values from this table
-# and move them to the secfilt table.
-
 # the DVO object IDs are generated internally and are not equivalent to the PSPS object IDs
 # probably need to add position chisq
Index: /trunk/Ohana/src/libautocode/def/measure-panstarrs-dev-0.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/measure-panstarrs-dev-0.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/measure-panstarrs-dev-0.d	(revision 15511)
@@ -8,11 +8,11 @@
 FIELD dD,             D_DEC,        float,          DEC offset,               	  arcsec
 FIELD M,              MAG,          float,          catalog mag,       	       	  mag
-FIELD Mcal,           Mcal,         float,          image cal mag,	          mag
-FIELD Mgal,           Mgal,         float,          galaxy mag,			  mag
-FIELD dM,             dM,           float,          mag error,                    mag
-FIELD dt,             dt,           float,          exposure time,                2.5*log(exptime)
+FIELD Mcal,           M_CAL,        float,          image cal mag,	          mag
+FIELD Mgal,           M_GAL,        float,          galaxy mag,			  mag
+FIELD dM,             MAG_ERR,      float,          mag error,                    mag
+FIELD dt,             M_TIME,       float,          exposure time,                2.5*log(exptime)
 
 # note that with airmass = 1.0 / cos(90 - alt), we have full alt/az representation
-FIELD airmass,        airmass,      float,          (airmass - 1),		  airmass
+FIELD airmass,        AIRMASS,      float,          (airmass - 1),		  airmass
 FIELD az,             AZ,           float,          telescope azimuth
 
@@ -25,6 +25,6 @@
 FIELD dSky,           SKY_FLUX_ERR, float,          local estimate of sky flux,    counts/sec
 
-FIELD t,              t,            unsigned int,   time in seconds (UNIX)
-FIELD averef,         averef,       unsigned int,   reference to average entry      
+FIELD t,              TIME,         unsigned int,   time in seconds (UNIX)
+FIELD averef,         AVE_REF,      unsigned int,   reference to average entry      
 
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
@@ -35,10 +35,10 @@
 FIELD imageID_lo,     IMAGE_ID_LO,  unsigned int,   reference to image
 
-FIELD FWx,            FWx,          short,          object fwhm major axis,       1/100 of arcsec 
-FIELD FWy,            FWy,          short,          object fwhm minor axis,       1/100 of arcsec 
-FIELD theta,          theta,        short,          angle wrt ccd X dir,          (0xffff/360) deg
-FIELD photcode,       photcode,     unsigned short, photcode
+FIELD FWx,            FWHM_MAJOR,   short,          object fwhm major axis,       1/100 of arcsec 
+FIELD FWy,            FWHM_MINOR,   short,          object fwhm minor axis,       1/100 of arcsec 
+FIELD theta,          PSF_THETA,    short,          angle wrt ccd X dir,          (0xffff/360) deg
+FIELD photcode,       PHOTCODE,     unsigned short, photcode
 
-FIELD flags,          flags,        unsigned short, flags for various uses  
+FIELD flags,          FLAGS,        unsigned short, flags for various uses  
 
 FIELD dXccd,          X_CCD_ERR,    short,          X coord error on chip,         pixels
@@ -48,12 +48,7 @@
 FIELD qPSF,           PSF_QF,       short,          psf coverage/quality factor
 
-FIELD dophot,         dophot,       char,           dophot type
-FIELD stargal,        stargal,      char,           star-galaxy separator
+FIELD dophot,         DOPHOT,       char,           dophot type
+FIELD stargal,        STAR_GAL,     char,           star-galaxy separator
 
 # we need extra bytes for padding purposes...
-FIELD dummy,          dummy,        char[2],        padding
-
-# float : 13 x 4 = 52
-# int:     6 x 4 = 24
-# short:   8 x 2 = 16
-# char :   2     =  2
+FIELD dummy,          DUMMY,        char[2],        padding
Index: /trunk/Ohana/src/libautocode/def/measure-panstarrs-dev-1.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/measure-panstarrs-dev-1.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/measure-panstarrs-dev-1.d	(revision 15511)
@@ -8,11 +8,11 @@
 FIELD dD,             D_DEC,        float,          DEC offset,               	  arcsec
 FIELD M,              MAG,          float,          catalog mag,       	       	  mag
-FIELD Mcal,           Mcal,         float,          image cal mag,	          mag
-FIELD Mgal,           Mgal,         float,          galaxy mag,			  mag
-FIELD dM,             dM,           float,          mag error,                    mag
-FIELD dt,             dt,           float,          exposure time,                2.5*log(exptime)
+FIELD Mcal,           M_CAL,        float,          image cal mag,	          mag
+FIELD Mgal,           M_GAL,        float,          galaxy mag,			  mag
+FIELD dM,             MAG_ERR,      float,          mag error,                    mag
+FIELD dt,             M_TIME,       float,          exposure time,                2.5*log(exptime)
 
 # note that with airmass = 1.0 / cos(90 - alt), we have full alt/az representation
-FIELD airmass,        airmass,      float,          (airmass - 1),		  airmass
+FIELD airmass,        AIRMASS,      float,          (airmass - 1),		  airmass
 FIELD az,             AZ,           float,          telescope azimuth
 
@@ -25,6 +25,6 @@
 FIELD dSky,           SKY_FLUX_ERR, float,          local estimate of sky flux,    counts/sec
 
-FIELD t,              t,            unsigned int,   time in seconds (UNIX)
-FIELD averef,         averef,       unsigned int,   reference to average entry      
+FIELD t,              TIME,         unsigned int,   time in seconds (UNIX)
+FIELD averef,         AVE_REF,      unsigned int,   reference to average entry      
 
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
@@ -35,10 +35,10 @@
 FIELD imageID_lo,     IMAGE_ID_LO,  unsigned int,   reference to image
 
-FIELD FWx,            FWx,          short,          object fwhm major axis,       1/100 of arcsec 
-FIELD FWy,            FWy,          short,          object fwhm minor axis,       1/100 of arcsec 
-FIELD theta,          theta,        short,          angle wrt ccd X dir,          (0xffff/360) deg
-FIELD photcode,       photcode,     unsigned short, photcode
+FIELD FWx,            FWHM_MAJOR,   short,          object fwhm major axis,       1/100 of arcsec 
+FIELD FWy,            FWHM_MINOR,   short,          object fwhm minor axis,       1/100 of arcsec 
+FIELD theta,          PSF_THETA,    short,          angle wrt ccd X dir,          (0xffff/360) deg
+FIELD photcode,       PHOTCODE,     unsigned short, photcode
 
-FIELD flags,          flags,        unsigned short, flags for various uses  
+FIELD flags,          FLAGS,        unsigned short, flags for various uses  
 
 FIELD dXccd,          X_CCD_ERR,    short,          X coord error on chip,         pixels
@@ -48,12 +48,7 @@
 FIELD qPSF,           PSF_QF,       short,          psf coverage/quality factor
 
-FIELD dophot,         dophot,       char,           dophot type
-FIELD stargal,        stargal,      char,           star-galaxy separator
+FIELD dophot,         DOPHOT,       char,           dophot type
+FIELD stargal,        STAR_GAL,     char,           star-galaxy separator
 
 # we need extra bytes for padding purposes...
-FIELD dummy,          dummy,        char[2],        padding
-
-# float : 13 x 4 = 52
-# int:     6 x 4 = 24
-# short:   8 x 2 = 16
-# char :   2     =  2
+FIELD dummy,          DUMMY,        char[2],        padding
Index: /trunk/Ohana/src/libautocode/def/measure-ps1-dev-1.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/measure-ps1-dev-1.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/measure-ps1-dev-1.d	(revision 15511)
@@ -29,5 +29,5 @@
 
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
-FIELD detID,          DET_ID,       unsigned int,   ID upper bytes
+FIELD detID,          DET_ID,       unsigned int,   detection ID
 FIELD imageID,        IMAGE_ID,     unsigned int,   reference to image
 
@@ -55,7 +55,2 @@
 
 FIELD dummy,          DUMMY,        char[2],        padding
-
-# float : 17 x 4 = 68
-# int:     6 x 4 = 24
-# short:   8 x 2 = 16
-# char :   2     =  2
Index: /trunk/Ohana/src/libautocode/def/measure.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/measure.d	(revision 15510)
+++ /trunk/Ohana/src/libautocode/def/measure.d	(revision 15511)
@@ -8,11 +8,11 @@
 FIELD dD,             D_DEC,        float,          DEC offset,               	  arcsec
 FIELD M,              MAG,          float,          catalog mag,       	       	  mag
-FIELD Mcal,           Mcal,         float,          image cal mag,	          mag
-FIELD Mgal,           Mgal,         float,          galaxy mag,			  mag
-FIELD dM,             dM,           float,          mag error,                    mag
-FIELD dt,             dt,           float,          exposure time,                2.5*log(exptime)
+FIELD Mcal,           M_CAL,        float,          image cal mag,	          mag
+FIELD Mgal,           M_GAL,        float,          galaxy mag,			  mag
+FIELD dM,             MAG_ERR,      float,          mag error,                    mag
+FIELD dt,             M_TIME,       float,          exposure time,                2.5*log(exptime)
 
 # note that with airmass = 1.0 / cos(90 - alt), we have full alt/az representation
-FIELD airmass,        airmass,      float,          (airmass - 1),		  airmass
+FIELD airmass,        AIRMASS,      float,          (airmass - 1),		  airmass
 FIELD az,             AZ,           float,          telescope azimuth
 
@@ -25,6 +25,6 @@
 FIELD dSky,           SKY_FLUX_ERR, float,          local estimate of sky flux,    counts/sec
 
-FIELD t,              t,            unsigned int,   time in seconds (UNIX)
-FIELD averef,         averef,       unsigned int,   reference to average entry      
+FIELD t,              TIME,         unsigned int,   time in seconds (UNIX)
+FIELD averef,         AVE_REF,      unsigned int,   reference to average entry      
 
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
@@ -38,8 +38,8 @@
 FIELD extNsigma,      EXT_NSIGMA,   float,          psf coverage/quality factor
 
-FIELD FWx,            FWx,          short,          object fwhm major axis,       1/100 of arcsec 
-FIELD FWy,            FWy,          short,          object fwhm minor axis,       1/100 of arcsec 
-FIELD theta,          theta,        short,          angle wrt ccd X dir,          (0xffff/360) deg
-FIELD photcode,       photcode,     unsigned short, photcode
+FIELD FWx,            FWHM_MAJOR,   short,          object fwhm major axis,       1/100 of arcsec 
+FIELD FWy,            FWHM_MINOR,   short,          object fwhm minor axis,       1/100 of arcsec 
+FIELD theta,          PSF_THETA,    short,          angle wrt ccd X dir,          (0xffff/360) deg
+FIELD photcode,       PHOTCODE,     unsigned short, photcode
 
 FIELD dXccd,          X_CCD_ERR,    short,          X coord error on chip,         pixels
@@ -49,8 +49,8 @@
 FIELD photFlags,      PHOT_FLAGS,   unsigned short, flags supplied by photometry program
 
-FIELD stargal,        stargal,      char,           star-galaxy separator
+FIELD stargal,        STAR_GAL,     char,           star-galaxy separator
 
 # absorb these into photFlags?
-FIELD dophot,         dophot,       char,           dophot type
+FIELD dophot,         DOPHOT,       char,           dophot type
 
 FIELD dummy,          DUMMY,        char[2],        padding
Index: /trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c	(revision 15510)
+++ /trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c	(revision 15511)
@@ -10,12 +10,12 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].dR       = in[i].dR * 0.01;
-    out[i].dD       = in[i].dD * 0.01;
-    out[i].M        = in[i].M  * 0.001;
-    out[i].dM       = in[i].dM * 0.001;
-    out[i].dt       = in[i].dt * 0.001;
-    out[i].Mcal     = in[i].Mcal * 0.001;
-    out[i].Mgal     = in[i].Mgal * 0.001;
-    out[i].airmass  = in[i].airmass * 0.001;
+    out[i].dR       = (in[i].dR      == NAN_S_SHORT) ? NAN : in[i].dR     * 0.01;
+    out[i].dD       = (in[i].dD      == NAN_S_SHORT) ? NAN : in[i].dD     * 0.01;
+    out[i].M        = (in[i].M       == NAN_S_SHORT) ? NAN : in[i].M      * 0.001;
+    out[i].dM       = (in[i].dM      == NAN_U_CHAR)  ? NAN : in[i].dM     * 0.001;
+    out[i].dt       = (in[i].dt      == NAN_S_SHORT) ? NAN : in[i].dt     * 0.001;
+    out[i].Mcal     = (in[i].Mcal    == NAN_S_SHORT) ? NAN : in[i].Mcal   * 0.001;
+    out[i].Mgal     = (in[i].Mgal    == NAN_S_SHORT) ? NAN : in[i].Mgal   * 0.001;
+    out[i].airmass  = (in[i].airmass == NAN_S_SHORT) ? NAN : in[i].airmass* 0.001;
     out[i].FWx 	    = in[i].FWx;
     out[i].FWy 	    = in[i].fwy * in[i].FWx * 0.01;
@@ -60,15 +60,17 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].dR      = in[i].dR * 100.0;
-    out[i].dD 	   = in[i].dD * 100.0;
-    out[i].M       = in[i].M  * 1000.0;
+    out[i].dR       = isnan(in[i].dR     ) ? NAN_S_SHORT : in[i].dR      *  100.0;
+    out[i].dD       = isnan(in[i].dD     ) ? NAN_S_SHORT : in[i].dD      *  100.0;
+    out[i].M        = isnan(in[i].M      ) ? NAN_S_SHORT : in[i].M       * 1000.0;
+    out[i].dM       = isnan(in[i].dM     ) ? NAN_U_CHAR  : in[i].dM      * 1000.0;
+    out[i].dt       = isnan(in[i].dt     ) ? NAN_S_SHORT : in[i].dt      * 1000.0;
+    out[i].Mcal     = isnan(in[i].Mcal   ) ? NAN_S_SHORT : in[i].Mcal    * 1000.0;
+    out[i].Mgal     = isnan(in[i].Mgal   ) ? NAN_S_SHORT : in[i].Mgal    * 1000.0;
+    out[i].airmass  = isnan(in[i].airmass) ? NAN_S_SHORT : in[i].airmass * 1000.0;
+
     if (out[i].M < 0) {
 	fprintf (stderr, ".");
     }
-    out[i].dM      = in[i].dM * 1000.0;
-    out[i].dt      = in[i].dt * 1000.0;
-    out[i].Mcal    = in[i].Mcal * 1000.0;
-    out[i].Mgal    = in[i].Mgal * 1000.0;
-    out[i].airmass = in[i].airmass * 1000.0;
+
     out[i].FWx 	   = in[i].FWx;
     out[i].fwy 	   = in[i].FWy * 100.0 / in[i].FWx;
@@ -116,12 +118,9 @@
     out[i].objID_lo = 0;
 
-    primary[0][i].M  = in[i].M  * 0.001;      
-    primary[0][i].dM = in[i].dM * 0.001;      
-    primary[0][i].Xm = in[i].Xm;     
+    primary[0][i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
+    primary[0][i].dM    = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001;      
+    primary[0][i].Xm    = in[i].Xm;     
     primary[0][i].Ncode = 0;     
     primary[0][i].Nused = 0;
-
-    // XXX drop this or keep this?
-    // primary[0][i].Xg = in[i].Xg;
   }
   return (out);
@@ -146,8 +145,7 @@
     out[i].missing = in[i].missing;
 
-    out[i].M       = primary[i].M  * 1000.0;      
-    out[i].dM      = primary[i].dM * 1000.0;
+    out[i].M       = isnan(primary[i].M)  ? NAN_S_SHORT : primary[i].M   * 1000.0;
+    out[i].dM      = isnan(primary[i].dM) ? NAN_S_SHORT : primary[i].dM  * 1000.0;
     out[i].Xm      = primary[i].Xm;     
-    // out[i].Xg      = in[i].Xg;
   }
   return (out);
@@ -163,6 +161,6 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M  * 0.001;      
-    out[i].dM    = in[i].dM * 0.001;      
+    out[i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M   * 0.001;
+    out[i].dM    = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM  * 0.001;
     out[i].Xm    = in[i].Xm;     
     out[i].Ncode = 0;
@@ -181,7 +179,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M       = in[i].M  * 1000.0;      
-    out[i].dM      = in[i].dM * 1000.0;
-    out[i].Xm      = in[i].Xm;     
+    out[i].M     = isnan(in[i].M)  ? NAN_S_SHORT : in[i].M   * 1000.0;
+    out[i].dM    = isnan(in[i].dM) ? NAN_S_SHORT : in[i].dM  * 1000.0;
+    out[i].Xm    = in[i].Xm;     
   }
   return (out);
@@ -198,16 +196,15 @@
   for (i = 0; i < Nvalues; i++) {
     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
-    memcpy (out[i].dummy, in[i].dummy, 20);
-    strcpy (out[i].name, in[i].name);
+    strcpy (out[i].name, in[i].name); // out[64], in[32]
 
     out[i].tzero    	    = in[i].tzero;
     out[i].nstar    	    = in[i].nstar;
-    out[i].secz    	    = in[i].secz * 0.001;
     out[i].NX	    	    = in[i].NX;
     out[i].NY	    	    = in[i].NY;
-    out[i].apmifit  	    = in[i].apmifit * 0.001;
-    out[i].dapmifit 	    = in[i].dapmifit * 0.001;
-    out[i].Mcal   	    = in[i].Mcal * 0.001;
-    out[i].dMcal   	    = in[i].dMcal * 0.001;
+    out[i].secz    	    = (in[i].secz     == NAN_S_SHORT) ? NAN : in[i].secz     * 0.001;
+    out[i].apmifit  	    = (in[i].apmifit  == NAN_S_SHORT) ? NAN : in[i].apmifit  * 0.001;
+    out[i].dapmifit  	    = (in[i].dapmifit == NAN_S_SHORT) ? NAN : in[i].dapmifit * 0.001;
+    out[i].Mcal   	    = (in[i].Mcal     == NAN_S_SHORT) ? NAN : in[i].Mcal     * 0.001;
+    out[i].dMcal   	    = (in[i].dMcal    == NAN_S_SHORT) ? NAN : in[i].dMcal    * 0.001;
     out[i].Xm	    	    = in[i].Xm;
     out[i].photcode   	    = in[i].source;
@@ -221,4 +218,5 @@
     out[i].code		    = in[i].code;
     out[i].ccdnum	    = in[i].ccdnum;
+
     out[i].order	    = in[i].order;
     out[i].Mx		    = in[i].Mx;
@@ -239,4 +237,8 @@
     /* XXX add these later */
     out[i].imageID = 0;
+
+    // not available in ELIXIR
+    out[i].sidtime  	    = NAN;
+    out[i].latitude  	    = NAN;
   }
   return (out);
@@ -253,16 +255,16 @@
   for (i = 0; i < Nvalues; i++) {
     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
-    memcpy (out[i].dummy, in[i].dummy, 20);
-    strcpy (out[i].name, in[i].name);
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[64]
+    out[i].name[31] = 0; // force termination
 
     out[i].tzero    	    = in[i].tzero;
     out[i].nstar    	    = in[i].nstar;
-    out[i].secz	    	    = in[i].secz * 1000.0;
     out[i].NX	    	    = in[i].NX;
     out[i].NY	    	    = in[i].NY;
-    out[i].apmifit  	    = in[i].apmifit * 1000.0;
-    out[i].dapmifit 	    = in[i].dapmifit * 1000.0;
-    out[i].Mcal	    	    = in[i].Mcal * 1000.0;
-    out[i].dMcal    	    = in[i].dMcal * 1000.0;
+    out[i].secz    	    = isnan(in[i].secz    ) ? NAN_S_SHORT : in[i].secz     * 1000.0;
+    out[i].apmifit    	    = isnan(in[i].apmifit ) ? NAN_S_SHORT : in[i].apmifit  * 1000.0;
+    out[i].dapmifit    	    = isnan(in[i].dapmifit) ? NAN_S_SHORT : in[i].dapmifit * 1000.0;
+    out[i].Mcal    	    = isnan(in[i].Mcal    ) ? NAN_S_SHORT : in[i].Mcal     * 1000.0;
+    out[i].dMcal    	    = isnan(in[i].dMcal   ) ? NAN_S_SHORT : in[i].dMcal    * 1000.0;
     out[i].Xm	    	    = in[i].Xm;
     out[i].source   	    = in[i].photcode;
@@ -276,4 +278,5 @@
     out[i].code		    = in[i].code;
     out[i].ccdnum	    = in[i].ccdnum;
+
     out[i].order	    = in[i].order;
     out[i].Mx		    = in[i].Mx;
Index: /trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c	(revision 15510)
+++ /trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c	(revision 15511)
@@ -10,9 +10,9 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].dR        = in[i].dR * 0.01;
-    out[i].dD        = in[i].dD * 0.01;
-    out[i].M         = in[i].M  * 0.001;
-    out[i].dM        = in[i].dM * 0.001;
-    out[i].Mcal      = in[i].Mcal * 0.001;
+    out[i].dR        = (in[i].dR      == NAN_S_SHORT) ? NAN : in[i].dR     * 0.01;
+    out[i].dD        = (in[i].dD      == NAN_S_SHORT) ? NAN : in[i].dD     * 0.01;
+    out[i].M         = (in[i].M       == NAN_S_SHORT) ? NAN : in[i].M      * 0.001;
+    out[i].dM        = (in[i].dM      == NAN_U_CHAR)  ? NAN : in[i].dM     * 0.001;
+    out[i].Mcal      = (in[i].Mcal    == NAN_S_SHORT) ? NAN : in[i].Mcal   * 0.001;
     out[i].dophot    = in[i].dophot;
     out[i].photcode  = in[i].source;
@@ -24,5 +24,5 @@
 
     /* these values don't exist in the Loneos format */
-    out[i].Mgal     = in[i].M;
+    out[i].Mgal     = out[i].M;
     out[i].dt       = 0;
     out[i].airmass  = 0;
@@ -62,9 +62,9 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].dR 	  = in[i].dR * 100.0;
-    out[i].dD 	  = in[i].dD * 100.0;
-    out[i].M  	  = in[i].M  * 1000.0;
-    out[i].dM 	  = in[i].dM * 1000.0;
-    out[i].Mcal   = in[i].Mcal * 1000.0;
+    out[i].dR     = isnan(in[i].dR     ) ? NAN_S_SHORT : in[i].dR      *  100.0;
+    out[i].dD     = isnan(in[i].dD     ) ? NAN_S_SHORT : in[i].dD      *  100.0;
+    out[i].M      = isnan(in[i].M      ) ? NAN_S_SHORT : in[i].M       * 1000.0;
+    out[i].dM     = isnan(in[i].dM     ) ? NAN_U_CHAR  : in[i].dM      * 1000.0;
+    out[i].Mcal   = isnan(in[i].Mcal   ) ? NAN_S_SHORT : in[i].Mcal    * 1000.0;
     out[i].dophot = in[i].dophot;
     out[i].source = in[i].photcode;
@@ -110,12 +110,9 @@
     out[i].objID_lo = 0;
 
-    primary[0][i].M  = in[i].M  * 0.001;      
+    primary[0][i].M  = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
     primary[0][i].Xm = in[i].Xm;     
-    primary[0][i].dM = 0xffff;
+    primary[0][i].dM = NAN;
     primary[0][i].Ncode = 0;     
     primary[0][i].Nused = 0;
-
-    // XXX drop this or keep this?
-    // primary[0][i].Xg = in[i].Xg;
   }
   return (out);
@@ -140,5 +137,5 @@
     out[i].missing = in[i].missing;
 
-    out[i].M       = primary[i].M * 1000.0;      
+    out[i].M       = isnan(primary[i].M)  ? NAN_S_SHORT : primary[i].M   * 1000.0;
     out[i].Xm      = primary[i].Xm;     
   }
@@ -155,7 +152,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M*0.001;      
+    out[i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M * 0.001;
     out[i].Xm    = in[i].Xm;      
-    out[i].dM    = 0xffff;
+    out[i].dM    = NAN;
     out[i].Ncode = 0;
     out[i].Nused = 0;
@@ -173,5 +170,5 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M    = in[i].M*1000.0;      
+    out[i].M    = isnan(in[i].M)  ? NAN_S_SHORT : in[i].M * 1000.0;
     out[i].Xm   = in[i].Xm;      
   }
@@ -189,16 +186,17 @@
   for (i = 0; i < Nvalues; i++) {
     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
-    memcpy (out[i].dummy, in[i].dummy, 20);
-    strcpy (out[i].name, in[i].name);
+    strcpy (out[i].name, in[i].name); // out[64], in[32]
 
     out[i].tzero    	    = in[i].tzero;
     out[i].nstar    	    = in[i].nstar;
-    out[i].secz    	    = in[i].secz * 0.001;
     out[i].NX	    	    = in[i].NX;
     out[i].NY	    	    = in[i].NY;
-    out[i].apmifit  	    = in[i].apmifit * 0.001;
-    out[i].dapmifit 	    = in[i].dapmifit * 0.001;
-    out[i].Mcal	    = in[i].Mcal * 0.001;
-    out[i].dMcal    	    = in[i].dMcal * 0.001;
+
+    out[i].secz    	    = (in[i].secz     == NAN_S_SHORT) ? NAN : in[i].secz     * 0.001;
+    out[i].apmifit  	    = (in[i].apmifit  == NAN_S_SHORT) ? NAN : in[i].apmifit  * 0.001;
+    out[i].dapmifit  	    = (in[i].dapmifit == NAN_S_SHORT) ? NAN : in[i].dapmifit * 0.001;
+    out[i].Mcal   	    = (in[i].Mcal     == NAN_S_SHORT) ? NAN : in[i].Mcal     * 0.001;
+    out[i].dMcal   	    = (in[i].dMcal    == NAN_S_SHORT) ? NAN : in[i].dMcal    * 0.001;
+
     out[i].Xm	    	    = in[i].Xm;
     out[i].photcode   	    = in[i].source;
@@ -244,16 +242,18 @@
   for (i = 0; i < Nvalues; i++) {
     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
-    memcpy (out[i].dummy, in[i].dummy, 20);
-    strcpy (out[i].name, in[i].name);
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[64]
+    out[i].name[31] = 0; // force termination
 
     out[i].tzero    	    = in[i].tzero;
     out[i].nstar    	    = in[i].nstar;
-    out[i].secz	    	    = in[i].secz * 1000.0;
     out[i].NX	    	    = in[i].NX;
     out[i].NY	    	    = in[i].NY;
-    out[i].apmifit  	    = in[i].apmifit * 1000.0;
-    out[i].dapmifit 	    = in[i].dapmifit * 1000.0;
-    out[i].Mcal	    	    = in[i].Mcal * 1000.0;
-    out[i].dMcal    	    = in[i].dMcal * 1000.0;
+
+    out[i].secz    	    = isnan(in[i].secz    ) ? NAN_S_SHORT : in[i].secz     * 1000.0;
+    out[i].apmifit    	    = isnan(in[i].apmifit ) ? NAN_S_SHORT : in[i].apmifit  * 1000.0;
+    out[i].dapmifit    	    = isnan(in[i].dapmifit) ? NAN_S_SHORT : in[i].dapmifit * 1000.0;
+    out[i].Mcal    	    = isnan(in[i].Mcal    ) ? NAN_S_SHORT : in[i].Mcal     * 1000.0;
+    out[i].dMcal    	    = isnan(in[i].dMcal   ) ? NAN_S_SHORT : in[i].dMcal    * 1000.0;
+
     out[i].Xm	    	    = in[i].Xm;
     out[i].source   	    = in[i].photcode;
Index: /trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 15510)
+++ /trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 15511)
@@ -34,5 +34,5 @@
     out[i].Sky        = in[i].Sky;
     out[i].dSky       = in[i].dSky;
-    out[i].qPSF       = in[i].qPSF;
+    out[i].qPSF       = (in[i].qPSF == NAN_S_SHORT) ? NAN : in[i].qPSF;
     out[i].detID      = in[i].detID_lo;
     out[i].imageID    = in[i].imageID_lo;
@@ -80,5 +80,5 @@
     out[i].Sky        = in[i].Sky;
     out[i].dSky       = in[i].dSky;
-    out[i].qPSF       = in[i].qPSF;
+    out[i].qPSF       = isnan(in[i].qPSF) ? NAN_S_SHORT : in[i].qPSF;
     out[i].detID_hi   = 0;
     out[i].detID_lo   = in[i].detID;
@@ -199,5 +199,5 @@
   for (i = 0; i < Nvalues; i++) {
     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
-    strcpy (out[i].name, in[i].name);
+    strcpy (out[i].name, in[i].name); // out[64], in[32]
 
     out[i].tzero    	    = in[i].tzero;
@@ -254,5 +254,6 @@
   for (i = 0; i < Nvalues; i++) {
     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
-    strcpy (out[i].name, in[i].name);
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[64]
+    out[i].name[31] = 0; // force termination
 
     out[i].tzero    	    = in[i].tzero;
Index: /trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 15510)
+++ /trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 15511)
@@ -34,5 +34,5 @@
     out[i].Sky        = in[i].Sky;
     out[i].dSky       = in[i].dSky;
-    out[i].qPSF       = in[i].qPSF;
+    out[i].qPSF       = (in[i].qPSF == NAN_S_SHORT) ? NAN : in[i].qPSF;
     out[i].detID      = in[i].detID_lo;
     out[i].imageID    = in[i].imageID_lo;
@@ -80,5 +80,5 @@
     out[i].Sky        = in[i].Sky;
     out[i].dSky       = in[i].dSky;
-    out[i].qPSF       = in[i].qPSF;
+    out[i].qPSF       = isnan(in[i].qPSF) ? NAN_S_SHORT : in[i].qPSF;
     out[i].detID_hi   = 0;
     out[i].detID_lo   = in[i].detID;
