Index: /branches/eam_branch_20080223/Ohana/src/libautocode/Makefile.Targets
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/Makefile.Targets	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/Makefile.Targets	(revision 16699)
@@ -8,4 +8,5 @@
 $(ASRC)/average-panstarrs-dev-1.$(ARCH).o \
 $(ASRC)/average-ps1-dev-1.$(ARCH).o \
+$(ASRC)/average-ps1-dev-2.$(ARCH).o \
 $(ASRC)/secfilt.$(ARCH).o \
 $(ASRC)/secfilt-loneos.$(ARCH).o \
@@ -14,4 +15,5 @@
 $(ASRC)/secfilt-panstarrs-dev-1.$(ARCH).o \
 $(ASRC)/secfilt-ps1-dev-1.$(ARCH).o \
+$(ASRC)/secfilt-ps1-dev-2.$(ARCH).o \
 $(ASRC)/measure.$(ARCH).o \
 $(ASRC)/measure-loneos.$(ARCH).o \
@@ -20,8 +22,10 @@
 $(ASRC)/measure-panstarrs-dev-1.$(ARCH).o \
 $(ASRC)/measure-ps1-dev-1.$(ARCH).o \
+$(ASRC)/measure-ps1-dev-2.$(ARCH).o \
 $(ASRC)/missing.$(ARCH).o \
 $(ASRC)/photcode.$(ARCH).o \
 $(ASRC)/photcode-elixir.$(ARCH).o \
 $(ASRC)/photcode-ps1-dev-1.$(ARCH).o \
+$(ASRC)/photcode-ps1-dev-2.$(ARCH).o \
 $(ASRC)/image.$(ARCH).o \
 $(ASRC)/image-loneos.$(ARCH).o \
@@ -30,4 +34,5 @@
 $(ASRC)/image-panstarrs-dev-1.$(ARCH).o \
 $(ASRC)/image-ps1-dev-1.$(ARCH).o \
+$(ASRC)/image-ps1-dev-2.$(ARCH).o \
 $(ASRC)/regimage.$(ARCH).o \
 $(ASRC)/detreg.$(ARCH).o \
@@ -55,4 +60,5 @@
 $(AINC)/average-panstarrs-dev-1.h \
 $(AINC)/average-ps1-dev-1.h \
+$(AINC)/average-ps1-dev-2.h \
 $(AINC)/secfilt.h \
 $(AINC)/secfilt-loneos.h \
@@ -61,4 +67,5 @@
 $(AINC)/secfilt-panstarrs-dev-1.h \
 $(AINC)/secfilt-ps1-dev-1.h \
+$(AINC)/secfilt-ps1-dev-2.h \
 $(AINC)/measure.h \
 $(AINC)/measure-loneos.h \
@@ -67,8 +74,10 @@
 $(AINC)/measure-panstarrs-dev-1.h \
 $(AINC)/measure-ps1-dev-1.h \
+$(AINC)/measure-ps1-dev-2.h \
 $(AINC)/missing.h \
 $(AINC)/photcode.h \
 $(AINC)/photcode-elixir.h \
 $(AINC)/photcode-ps1-dev-1.h \
+$(AINC)/photcode-ps1-dev-2.h \
 $(AINC)/image.h \
 $(AINC)/image-loneos.h \
@@ -77,4 +86,5 @@
 $(AINC)/image-panstarrs-dev-1.h \
 $(AINC)/image-ps1-dev-1.h \
+$(AINC)/image-ps1-dev-2.h \
 $(AINC)/regimage.h \
 $(AINC)/detreg.h \
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/AddstarClientOptions.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/AddstarClientOptions.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/AddstarClientOptions.d	(revision 16699)
@@ -2,5 +2,5 @@
 EXTNAME OPTIONS
 TYPE    BINTABLE
-SIZE    76
+SIZE    80
 
 FIELD     Nsigma,           NSIGMA,               double,         match radius in terms of astrometric error 
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/Stars.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/Stars.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/Stars.d	(revision 16699)
@@ -2,5 +2,5 @@
 EXTNAME STARS
 TYPE    BINTABLE
-SIZE    244
+SIZE    248
 
 FIELD     X,                X,          double,    x coordinate on image,	     pixels
@@ -20,4 +20,5 @@
 FIELD     M,                M,          double,    instrumental mag
 FIELD     dM,               DM,         double,    error on mag
+FIELD     dMcal,            DMCAL,      double,    systematic error on mag
 FIELD     sky,              SKY,        double,    local sky counts
 FIELD     dsky,             dSKY,       double,    local sky error counts
@@ -25,12 +26,13 @@
 FIELD     fy,               FY,         double,    object FWHM y-dir,		     pixels?
 FIELD     df,               DF,         double,    object position angle,	     degrees
-FIELD     Mgal,             MGAL,       double,    alternative (galaxy) magnitude
+# FIELD     Mgal,             MGAL,       double,    alternative (galaxy) magnitude
 FIELD     Map,              MAP,        double,    alternative (aperture) magnitude
 FIELD     Mpeak,            MPEAK,      double,    alternative (peak) magnitude
 FIELD     detID,            ID,         int,       detection identifier
+FIELD     imageID,          IMAGE_ID,   int,       image identifier
 FIELD     found,            FOUND,      int,       found in database catalog?
 FIELD     t,                T,          e_time,    date/time of exposure (UNIX)
 FIELD     dt,               EXPTIME,    float,     exposure time,                    2.5*log(exptime)
-FIELD     psfProb,          PSF_PROB,   float
+FIELD     psfChisq,         PSF_CHISQ,  float
 FIELD     crNsigma,         CR_NSIGMA,  float
 FIELD     extNsigma,        EXT_NSIGMA, float
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-panstarrs-dev-0.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-panstarrs-dev-0.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-panstarrs-dev-0.d	(revision 16699)
@@ -27,6 +27,6 @@
 
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
-FIELD objID_hi,       OBJ_ID_HI,    unsigned int,   ID upper bytes
-FIELD objID_lo,       OBJ_ID_LO,    unsigned int,   ID lower bytes
+FIELD objID,          OBJ_ID,     unsigned int,   ID upper bytes
+FIELD catID,          CAT_ID,     unsigned int,   ID lower bytes
 
 # this structure should only be used for internal representations
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-panstarrs-dev-1.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-panstarrs-dev-1.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-panstarrs-dev-1.d	(revision 16699)
@@ -27,6 +27,6 @@
 
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
-FIELD objID_hi,       OBJ_ID_HI,    unsigned int,   ID upper bytes
-FIELD objID_lo,       OBJ_ID_LO,    unsigned int,   ID lower bytes
+FIELD objID,          OBJ_ID,     unsigned int,   ID upper bytes
+FIELD catID,          CAT_ID,     unsigned int,   ID lower bytes
 
 # this structure should only be used for internal representations
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-ps1-dev-1.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-ps1-dev-1.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-ps1-dev-1.d	(revision 16699)
@@ -27,6 +27,6 @@
 
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
-FIELD objID_hi,       OBJ_ID_HI,    unsigned int,   ID upper bytes
-FIELD objID_lo,       OBJ_ID_LO,    unsigned int,   ID lower bytes
+FIELD objID,          OBJ_ID,     unsigned int,   ID upper bytes
+FIELD catID,          CAT_ID,     unsigned int,   ID lower bytes
 
 # this structure should only be used for internal representations
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-ps1-dev-2.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-ps1-dev-2.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/average-ps1-dev-2.d	(revision 16699)
@@ -2,5 +2,5 @@
 EXTNAME      DVO_AVERAGE_PS1_DEV_2
 TYPE         BINTABLE
-SIZE         72
+SIZE         80
 DESCRIPTION  DVO Average Object Table
 
@@ -19,17 +19,26 @@
 FIELD dP,             PAR_ERR,    float,            parallax error,               arcsec
 
-FIELD Xp,             SIGMA_POS,  short, 	    position scatter,   	  1/100 arcsec
-FIELD Npsf,           NPSF,       unsigned short,   number of psf measurements
-FIELD Next,           NEXT,       unsigned short,   number of extended measurements
-FIELD Nmiss,          NMISS,      unsigned short,   number of missings
-FIELD psfOffset,      OFF_PSF,    int,     	    offset to first measurement
-FIELD extOffset,      OFF_EXT,    int,     	    offset to first measurement
-FIELD missOffset,     OFF_MISS,   int,     	    offset to first missing obs
+FIELD Xp,             SIGMA_POS,   short, 	    position scatter,   	  1/100 arcsec
+FIELD Nmeasure,       NMEASURE,    unsigned short,  number of psf measurements
+FIELD Nmissing,       NMISSING,    unsigned short,  number of missings
+FIELD Nextend,        NEXTEND,     unsigned short,  number of extended measurements
+FIELD measureOffset,  OFF_MEASURE, int,     	    offset to first psf measurement
+FIELD missingOffset,  OFF_MISSING, int,     	    offset to first missing obs
+FIELD extendOffset,   OFF_EXTEND,  int,     	    offset to first extended measurement
 
 FIELD code,           code,       unsigned short,   ID code (star; ghost; etc)
+FIELD dummy,          DUMMY,      char[2],          padding
 
-# Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
-FIELD objID_hi,       OBJ_ID_HI,  unsigned int,     ID upper bytes
-FIELD objID_lo,       OBJ_ID_LO,  unsigned int,     ID lower bytes
+# Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints
+# for C89 compatibility.  The objID is constructed based on the
+# position of first instatiation.  this is actually quite expensive
+# because we need to include the uniqueness test to construct this,
+# which requires a select for each new object.  Therefore, I will use
+# a table based ID (table ID + object ID), and we will have to
+# re-number the object IDs if we change the table density, OR treat
+# all subdivisions as entries which are from a foreign table.
+
+FIELD objID,          OBJ_ID,    unsigned int,   unique ID for object in table
+FIELD catID,          CAT_ID,    unsigned int,   unique ID for table in which object was first realized
 
 # this structure should only be used for internal representations
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/average.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/average.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/average.d	(revision 16699)
@@ -39,6 +39,6 @@
 # all subdivisions as entries which are from a foreign table.
 
-FIELD objID_hi,       OBJ_ID_HI,    unsigned int,   ID upper bytes
-FIELD objID_lo,       OBJ_ID_LO,    unsigned int,   ID lower bytes
+FIELD objID,          OBJ_ID,    unsigned int,   unique ID for object in table
+FIELD catID,          CAT_ID,    unsigned int,   unique ID for table in which object was first realized
 
 # this structure should only be used for internal representations
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/image-ps1-dev-2.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/image-ps1-dev-2.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/image-ps1-dev-2.d	(revision 16699)
@@ -1,6 +1,6 @@
-STRUCT       Image_PS1_DEV_1
-EXTNAME      DVO_IMAGE_PS1_DEV_1
+STRUCT       Image_PS1_DEV_2
+EXTNAME      DVO_IMAGE_PS1_DEV_2
 TYPE         BINTABLE
-SIZE         288
+SIZE         280
 DESCRIPTION  DVO Image Table 
 
@@ -26,6 +26,6 @@
 FIELD 	  nstar,            NSTAR,                unsigned int,   number of stars on image
 FIELD 	  secz,             SECZ,                 float,      	  airmass,                   mag
-FIELD 	  NX,               NX,                   short,      	  image width
-FIELD 	  NY,               NY,                   short,      	  image height
+FIELD 	  NX,               NX,                   unsigned short, image width
+FIELD 	  NY,               NY,                   unsigned short, image height
 FIELD 	  apmifit,          APMIFIT,              float,      	  aperture correction,       mag
 FIELD 	  dapmifit,         DAPMIFIT,             float,      	  apmifit error,             mag
@@ -48,8 +48,9 @@
 FIELD 	  code,             CODE,                 char,           image quality flag
 FIELD 	  ccdnum,           CCDNUM,               unsigned char,  CCD ID number
-FIELD 	  imageID,          IMAGE_ID,             unsigned int,   image ID
-# 44 bytes 
+FIELD 	  imageID,          IMAGE_ID,             unsigned int,   internal image ID
+FIELD 	  externID,         EXTERN_ID,            unsigned int,   external image ID
+FIELD 	  sourceID,         SOURCE_ID,            unsigned short, analysis source ID
+# 48 bytes 
 
-FIELD 	  dummy,            DUMMY,                char[14],       unused
 FIELD 	  order,            ORDER,                short,      	  Mrel 2D polynomical order 
 FIELD 	  Mx,               MX,                   short,      	  Mrel polyterm
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/image.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/image.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/image.d	(revision 16699)
@@ -2,5 +2,5 @@
 EXTNAME      DVO_IMAGE
 TYPE         BINTABLE
-SIZE         288
+SIZE         280
 DESCRIPTION  DVO Image Table 
 
@@ -53,5 +53,4 @@
 # 48 bytes 
 
-FIELD 	  dummy,            DUMMY,                char[14],       unused
 FIELD 	  order,            ORDER,                short,      	  Mrel 2D polynomical order 
 FIELD 	  Mx,               MX,                   short,      	  Mrel polyterm
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure-ps1-dev-1.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure-ps1-dev-1.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure-ps1-dev-1.d	(revision 16699)
@@ -34,5 +34,5 @@
 # do we need more resolution than a short? should this be a log?
 FIELD qPSF,           PSF_QF,       float,          psf coverage/quality factor
-FIELD psfProb,        PSF_PROB,     float,          psf coverage/quality factor
+FIELD psfChisq,       PSF_CHISQ,    float,          psf coverage/quality factor
 FIELD crNsigma,       CR_NSIGMA,    float,          psf coverage/quality factor
 FIELD extNsigma,      EXT_NSIGMA,   float,          psf coverage/quality factor
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure-ps1-dev-2.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure-ps1-dev-2.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure-ps1-dev-2.d	(revision 16699)
@@ -1,6 +1,6 @@
-STRUCT       Measure_PS1_DEV_1
-EXTNAME      DVO_MEASURE_PS1_DEV_1
+STRUCT       Measure_PS1_DEV_2
+EXTNAME      DVO_MEASURE_PS1_DEV_2
 TYPE         BINTABLE
-SIZE         104
+SIZE         112
 DESCRIPTION  DVO Detection Measurement Table 
 
@@ -9,6 +9,7 @@
 FIELD M,              MAG,          float,          catalog mag,       	       	  mag
 FIELD Mcal,           M_CAL,        float,          image cal mag,	          mag
-FIELD Mgal,           M_GAL,        float,          galaxy mag,			  mag
+FIELD Map,            M_APER,       float,          aperture mag,		  mag
 FIELD dM,             MAG_ERR,      float,          mag error,                    mag
+FIELD dMcal,          MAG_CAL_ERR,  float,          systematic calibration error, mag
 FIELD dt,             M_TIME,       float,          exposure time,                2.5*log(exptime)
 
@@ -30,11 +31,11 @@
 # Pan-STARRS uses a 64-bit detection ID.  keep this in two 32 bit ints for backwards compatibility?
 FIELD detID,          DET_ID,       unsigned int,   detection ID
-FIELD imageID,        IMAGE_ID,     unsigned int,   reference to image
+FIELD imageID,        IMAGE_ID,     unsigned int,   reference to DVO image ID
 
 # do we need more resolution than a short? should this be a log?
 FIELD qPSF,           PSF_QF,       float,          psf coverage/quality factor
-FIELD psfProb,        PSF_PROB,     float,          psf coverage/quality factor
-FIELD crNsigma,       CR_NSIGMA,    float,          psf coverage/quality factor
-FIELD extNsigma,      EXT_NSIGMA,   float,          psf coverage/quality factor
+FIELD psfChisq,       PSF_CHISQ,    float,          psf fit chisq
+FIELD crNsigma,       CR_NSIGMA,    float,          Nsigma deviation towards CR
+FIELD extNsigma,      EXT_NSIGMA,   float,          Nsigma deviation towards EXT
 
 FIELD FWx,            FWHM_MAJOR,   short,          object fwhm major axis,       1/100 of arcsec 
@@ -54,3 +55,3 @@
 FIELD dophot,         DOPHOT,       char,           dophot type
 
-FIELD dummy,          DUMMY,        char[2],        padding
+FIELD dummy,          DUMMY,        char[6],        padding
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/measure.d	(revision 16699)
@@ -2,5 +2,5 @@
 EXTNAME      DVO_MEASURE
 TYPE         BINTABLE
-SIZE         104
+SIZE         112
 DESCRIPTION  DVO Detection Measurement Table 
 
@@ -9,6 +9,7 @@
 FIELD M,              MAG,          float,          catalog mag,       	       	  mag
 FIELD Mcal,           M_CAL,        float,          image cal mag,	          mag
-FIELD Mgal,           M_GAL,        float,          galaxy mag,			  mag
+FIELD Map,            M_APER,       float,          aperture mag,		  mag
 FIELD dM,             MAG_ERR,      float,          mag error,                    mag
+FIELD dMcal,          MAG_CAL_ERR,  float,          systematic calibration error, mag
 FIELD dt,             M_TIME,       float,          exposure time,                2.5*log(exptime)
 
@@ -34,7 +35,7 @@
 # do we need more resolution than a short? should this be a log?
 FIELD qPSF,           PSF_QF,       float,          psf coverage/quality factor
-FIELD psfProb,        PSF_PROB,     float,          psf coverage/quality factor
-FIELD crNsigma,       CR_NSIGMA,    float,          psf coverage/quality factor
-FIELD extNsigma,      EXT_NSIGMA,   float,          psf coverage/quality factor
+FIELD psfChisq,       PSF_CHISQ,    float,          psf fit chisq
+FIELD crNsigma,       CR_NSIGMA,    float,          Nsigma deviation towards CR
+FIELD extNsigma,      EXT_NSIGMA,   float,          Nsigma deviation towards EXT
 
 FIELD FWx,            FWHM_MAJOR,   short,          object fwhm major axis,       1/100 of arcsec 
@@ -54,3 +55,3 @@
 FIELD dophot,         DOPHOT,       char,           dophot type
 
-FIELD dummy,          DUMMY,        char[2],        padding
+FIELD dummy,          DUMMY,        char[6],        padding
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/photcode-ps1-dev-2.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/photcode-ps1-dev-2.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/photcode-ps1-dev-2.d	(revision 16699)
@@ -1,4 +1,4 @@
-STRUCT       PhotCode_PS1_DEV_1
-EXTNAME      DVO_PHOTCODE_PS1_DEV_1
+STRUCT       PhotCode_PS1_DEV_2
+EXTNAME      DVO_PHOTCODE_PS1_DEV_2
 TYPE         BINTABLE
 SIZE         104
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/ps1_dev_0.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/ps1_dev_0.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/ps1_dev_0.d	(revision 16699)
@@ -16,5 +16,5 @@
 FIELD sky,    	SKY,              float,    sky flux,             cnts/sec
 FIELD dSky,    	SKY_SIG,          float,    sky flux errorf       cnts/sec
-FIELD psfProb,  PSF_PROBABILITY,  float,    psf probability
+FIELD psfChisq, PSF_CHISQ,        float,    psf fit chisq
 FIELD fx,     	PSF_WIDTH_X,      float,    semi-major,           pixels
 FIELD fy,     	PSF_WIDTH_Y,      float,    semi-minor,           pixels
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/ps1_dev_1.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/ps1_dev_1.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/ps1_dev_1.d	(revision 16699)
@@ -16,5 +16,5 @@
 FIELD sky,    	 SKY,              float,    sky flux,             cnts/sec
 FIELD dSky,    	 SKY_SIG,          float,    sky flux errorf       cnts/sec
-FIELD psfProb,   PSF_PROBABILITY,  float,    psf probability
+FIELD psfChisq,  PSF_CHISQ,        float,    psf fit chisq
 FIELD crNsigma,  CR_NSIGMA,        float,    Nsigma deviations from PSF to CF
 FIELD extNsigma, EXT_NSIGMA,       float,    Nsigma deviations from PSF to EXT
Index: /branches/eam_branch_20080223/Ohana/src/libautocode/def/secfilt-ps1-dev-2.d
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libautocode/def/secfilt-ps1-dev-2.d	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libautocode/def/secfilt-ps1-dev-2.d	(revision 16699)
@@ -1,4 +1,4 @@
-STRUCT       SecFilt_PS1_DEV_1
-EXTNAME      DVO_SECFILT_PS1_DEV_1
+STRUCT       SecFilt_PS1_DEV_2
+EXTNAME      DVO_SECFILT_PS1_DEV_2
 TYPE         BINTABLE
 SIZE         16
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/Makefile
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/Makefile	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/Makefile	(revision 16699)
@@ -29,5 +29,6 @@
 $(DESTINC)/panstarrs_dev_0_defs.h \
 $(DESTINC)/panstarrs_dev_1_defs.h \
-$(DESTINC)/ps1_dev_1_defs.h
+$(DESTINC)/ps1_dev_1_defs.h \
+$(DESTINC)/ps1_dev_2_defs.h
 
 INCS = $(DEFS) $(DESTINC)/dvo.h $(DESTINC)/autocode.h
@@ -37,7 +38,4 @@
 $(SRC)/coordops.$(ARCH).o	 \
 $(SRC)/dvosorts.$(ARCH).o	 \
-$(SRC)/dvo_photcode_ops.$(ARCH).o \
-$(SRC)/dvo_photcode_convert_elixir.$(ARCH).o \
-$(SRC)/dvo_photcode_convert_ps1_dev_1.$(ARCH).o \
 $(SRC)/dvo_photcode_ops.$(ARCH).o \
 $(SRC)/LoadPhotcodes.$(ARCH).o   \
@@ -64,4 +62,5 @@
 $(SRC)/dvo_convert_panstarrs_DEV_1.$(ARCH).o \
 $(SRC)/dvo_convert_PS1_DEV_1.$(ARCH).o \
+$(SRC)/dvo_convert_PS1_DEV_2.$(ARCH).o \
 $(SRC)/skyregion_io.$(ARCH).o    \
 $(SRC)/skyregion_gsc.$(ARCH).o    \
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/include/dvo.h	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/include/dvo.h	(revision 16699)
@@ -16,5 +16,6 @@
 	      DVO_FORMAT_PANSTARRS_DEV_0,
 	      DVO_FORMAT_PANSTARRS_DEV_1,
-	      DVO_FORMAT_PS1_DEV_1
+	      DVO_FORMAT_PS1_DEV_1,
+	      DVO_FORMAT_PS1_DEV_2
 } DVOTableFormat;
 
@@ -215,4 +216,7 @@
   struct Catalog *secfilt_catalog;		/* secfilt catalog data (split) */
 
+  unsigned int objID;
+  unsigned int catID;
+
   /* extra catalog information */
   int lockmode;
@@ -383,4 +387,5 @@
 # include "panstarrs_dev_1_defs.h"
 # include "ps1_dev_1_defs.h"
+# include "ps1_dev_2_defs.h"
 
 /*** DVO image db I/O Functions ***/
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/include/ps1_dev_2_defs.h
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/include/ps1_dev_2_defs.h	(revision 16699)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/include/ps1_dev_2_defs.h	(revision 16699)
@@ -0,0 +1,11 @@
+Image 		       	*Image_PS1_DEV_2_ToInternal (Image_PS1_DEV_2 *in, int Nvalues);
+Image_PS1_DEV_2  	*ImageInternalTo_PS1_DEV_2 (Image *in, int Nvalues);
+Average 	       	*Average_PS1_DEV_2_ToInternal (Average_PS1_DEV_2 *in, int Nvalues, SecFilt **primary);
+Average_PS1_DEV_2       *AverageInternalTo_PS1_DEV_2 (Average *in, int Nvalues, SecFilt *primary);
+Measure 	       	*Measure_PS1_DEV_2_ToInternal (Measure_PS1_DEV_2 *in, int Nvalues);
+Measure_PS1_DEV_2       *MeasureInternalTo_PS1_DEV_2 (Measure *in, int Nvalues);
+SecFilt 	       	*SecFilt_PS1_DEV_2_ToInternal (SecFilt_PS1_DEV_2 *in, int Nvalues);
+SecFilt_PS1_DEV_2       *SecFiltInternalTo_PS1_DEV_2 (SecFilt *in, int Nvalues);
+
+PhotCode *PhotCode_PS1_DEV_2_To_Internal (PhotCode_PS1_DEV_2 *in, int Nvalues);
+PhotCode_PS1_DEV_2 *PhotCode_Internal_To_PS1_DEV_2 (PhotCode *in, int Nvalues);
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/LoadPhotcodesFITS.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/LoadPhotcodesFITS.c	(revision 16699)
@@ -50,4 +50,10 @@
     photcode = PhotCode_PS1_DEV_1_To_Internal (photcode_ps1_dev_1, Ncode);
     free (photcode_ps1_dev_1);
+  } 
+
+  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_2")) {
+    PhotCode_PS1_DEV_2 *photcode_ps1_dev_2 = gfits_table_get_PhotCode_PS1_DEV_2 (&db.ftable, &Ncode, &db.swapped);
+    photcode = PhotCode_PS1_DEV_2_To_Internal (photcode_ps1_dev_2, Ncode);
+    free (photcode_ps1_dev_2);
   } 
 
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/SavePhotcodesFITS.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/SavePhotcodesFITS.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/SavePhotcodesFITS.c	(revision 16699)
@@ -29,9 +29,9 @@
   // for the moment, we simply support the latest photcode format for output
   // XXX update this as needed as new formats are defined
-  PhotCode_PS1_DEV_1 *photcode_output = PhotCode_Internal_To_PS1_DEV_1 (table[0].code, table[0].Ncode);
+  PhotCode_PS1_DEV_2 *photcode_output = PhotCode_Internal_To_PS1_DEV_2 (table[0].code, table[0].Ncode);
 
   /* convert FITS format data to internal format (byteswaps & EXTNAME) */
   gfits_db_create (&db);
-  gfits_table_set_PhotCode_PS1_DEV_1 (&db.ftable, photcode_output, table[0].Ncode);
+  gfits_table_set_PhotCode_PS1_DEV_2 (&db.ftable, photcode_output, table[0].Ncode);
   gfits_db_save (&db);
   gfits_db_close (&db);
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_catalog.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_catalog.c	(revision 16699)
@@ -51,4 +51,5 @@
   if (!strcasecmp (catformat, "PANSTARRS_DEV_1")) return (DVO_FORMAT_PANSTARRS_DEV_1);
   if (!strcasecmp (catformat, "PS1_DEV_1"))       return (DVO_FORMAT_PS1_DEV_1);
+  if (!strcasecmp (catformat, "PS1_DEV_2"))       return (DVO_FORMAT_PS1_DEV_2);
   return (DVO_FORMAT_UNDEF);
 }
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_catalog_raw.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_catalog_raw.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_catalog_raw.c	(revision 16699)
@@ -73,4 +73,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);
 
     default:
@@ -256,4 +257,5 @@
   if (catalog[0].catformat == DVO_FORMAT_PANSTARRS_DEV_1) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS_DEV_1");
   if (catalog[0].catformat == DVO_FORMAT_PS1_DEV_1)       gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_DEV_1");
+  if (catalog[0].catformat == DVO_FORMAT_PS1_DEV_2)       gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_DEV_2");
 
   /* rewind file pointers and truncate file */
@@ -350,4 +352,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);
 
     default:
@@ -395,4 +398,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);
 
     default:
@@ -444,4 +448,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);
 
     default:
@@ -489,4 +494,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);
 
     default:
@@ -538,4 +544,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);
 
     default:
@@ -583,4 +590,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);
 
     default:
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert.c	(revision 16699)
@@ -48,4 +48,5 @@
   CONVERT_FORMAT ("DVO_AVERAGE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
   CONVERT_FORMAT ("DVO_AVERAGE_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
+  CONVERT_FORMAT ("DVO_AVERAGE_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
 # undef CONVERT_FORMAT
 
@@ -77,4 +78,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1,       PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2,       PS1_DEV_2);
 # undef FORMAT_CASE
 
@@ -119,4 +121,5 @@
   CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
   CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
+  CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
 # undef CONVERT_FORMAT
 
@@ -148,4 +151,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1,       PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2,       PS1_DEV_2);
 # undef FORMAT_CASE
 
@@ -190,4 +194,5 @@
   CONVERT_FORMAT ("DVO_SECFILT_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
   CONVERT_FORMAT ("DVO_SECFILT_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
+  CONVERT_FORMAT ("DVO_SECFILT_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
 # undef CONVERT_FORMAT
 
@@ -219,4 +224,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1,       PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2,       PS1_DEV_2);
 # undef FORMAT_CASE
 
@@ -281,4 +287,5 @@
   CONVERT_FORMAT ("DVO_IMAGE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
   CONVERT_FORMAT ("DVO_IMAGE_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
+  CONVERT_FORMAT ("DVO_IMAGE_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
 # undef CONVERT_FORMAT
 
@@ -313,4 +320,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1,       PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2,       PS1_DEV_2);
 # undef FORMAT_CASE
 
@@ -361,4 +369,5 @@
       FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);
       FORMAT_CASE (PS1_DEV_1,       PS1_DEV_1);
+      FORMAT_CASE (PS1_DEV_2,       PS1_DEV_2);
 # undef FORMAT_CASE
 
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c	(revision 16699)
@@ -1,7 +1,6 @@
 # include <dvo.h>
 
-// XXX these functions ahve to be adjusted to agree with the new definition of PS1_DEV_1
-
-/* convert panstarrs-format measures to internal measures */
+/* convert PS1_DEV_1 formats to internal formats */
+
 Measure *Measure_PS1_DEV_1_ToInternal (Measure_PS1_DEV_1 *in, int Nvalues) {
 
@@ -16,5 +15,5 @@
     out[i].M          = in[i].M;
     out[i].Mcal       = in[i].Mcal;
-    out[i].Mgal       = in[i].Mgal;
+    out[i].Map        = in[i].Mgal;
     out[i].dM         = in[i].dM;
     out[i].dt         = in[i].dt;
@@ -30,5 +29,5 @@
     out[i].imageID    = in[i].imageID;
     out[i].qPSF       = in[i].qPSF;
-    out[i].psfProb    = in[i].psfProb;
+    out[i].psfChisq   = in[i].psfChisq;
     out[i].crNsigma   = in[i].crNsigma;
     out[i].extNsigma  = in[i].extNsigma;
@@ -47,5 +46,4 @@
 }
 
-/* convert internal measures to panstarrs-format measures */
 Measure_PS1_DEV_1 *MeasureInternalTo_PS1_DEV_1 (Measure *in, int Nvalues) {
 
@@ -60,5 +58,5 @@
     out[i].M          = in[i].M;
     out[i].Mcal       = in[i].Mcal;
-    out[i].Mgal       = in[i].Mgal;
+    out[i].Mgal       = in[i].Map;
     out[i].dM         = in[i].dM;
     out[i].dt         = in[i].dt;
@@ -74,5 +72,5 @@
     out[i].imageID    = in[i].imageID;
     out[i].qPSF       = in[i].qPSF;
-    out[i].psfProb    = in[i].psfProb;
+    out[i].psfChisq   = in[i].psfChisq;
     out[i].crNsigma   = in[i].crNsigma;
     out[i].extNsigma  = in[i].extNsigma;
@@ -91,6 +89,5 @@
 }
 
-/* convert panstarrs-format averages to internal averages */
-// 'primary is needed to conform with the API for Loneos and Elixir, but is not used
+// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
 Average *Average_PS1_DEV_1_ToInternal (Average_PS1_DEV_1 *in, int Nvalues, SecFilt **primary) {
 
@@ -117,12 +114,11 @@
     out[i].P        	 = in[i].P;
     out[i].dP       	 = in[i].dP;
-    out[i].objID_hi 	 = in[i].objID_hi;
-    out[i].objID_lo 	 = in[i].objID_lo;
-  }
-  return (out);
-}
-
-/* convert internal averages to panstarrs-format averages */
-// 'primary is needed to conform with the API for Loneos and Elixir, but is not used
+    out[i].objID 	 = in[i].objID;
+    out[i].catID 	 = in[i].catID;
+  }
+  return (out);
+}
+
+// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
 Average_PS1_DEV_1 *AverageInternalTo_PS1_DEV_1 (Average *in, int Nvalues, SecFilt *primary) {
 
@@ -149,11 +145,10 @@
     out[i].P        = in[i].P;
     out[i].dP       = in[i].dP;
-    out[i].objID_hi = in[i].objID_hi;
-    out[i].objID_lo = in[i].objID_lo;
-  }
-  return (out);
-}
-
-/* convert panstarrs-format secfilts to internal secfilts */
+    out[i].objID    = in[i].objID;
+    out[i].catID    = in[i].catID;
+  }
+  return (out);
+}
+
 SecFilt *SecFilt_PS1_DEV_1_ToInternal (SecFilt_PS1_DEV_1 *in, int Nvalues) {
 
@@ -173,5 +168,4 @@
 }
 
-/* convert internal secfilts to panstarrs-format secfilts */
 SecFilt_PS1_DEV_1 *SecFiltInternalTo_PS1_DEV_1 (SecFilt *in, int Nvalues) {
 
@@ -191,5 +185,4 @@
 }
 
-/* convert panstarrs-format images to internal images */
 Image *Image_PS1_DEV_1_ToInternal (Image_PS1_DEV_1 *in, int Nvalues) {
 
@@ -300,2 +293,60 @@
   return (out);
 }
+
+PhotCode_PS1_DEV_1 *PhotCode_Internal_To_PS1_DEV_1 (PhotCode *in, int Nvalues) {
+
+  int i;
+  PhotCode_PS1_DEV_1 *out;
+
+  ALLOCATE (out, PhotCode_PS1_DEV_1, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
+    out[i].name[31] = 0; // force termination
+
+    out[i].code = in[i].code;         
+    out[i].type = in[i].type;         
+    out[i].C = in[i].C;            
+    out[i].dC = in[i].dC;           
+    out[i].dX = in[i].dX;           
+    out[i].K = in[i].K;            
+    out[i].c1 = in[i].c1;           
+    out[i].c2 = in[i].c2;           
+    out[i].equiv = in[i].equiv;        
+    out[i].Nc = in[i].Nc;           
+    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
+
+    out[i].astromScale = in[i].astromScale;  
+    out[i].photSysErr = in[i].photSysErr;   
+  }
+  return (out);
+}
+
+PhotCode *PhotCode_PS1_DEV_1_To_Internal (PhotCode_PS1_DEV_1 *in, int Nvalues) {
+
+  int i;
+  PhotCode *out;
+
+  ALLOCATE (out, PhotCode, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
+    out[i].name[31] = 0; // force termination
+
+    out[i].code = in[i].code;         
+    out[i].type = in[i].type;         
+    out[i].C = in[i].C;            
+    out[i].dC = in[i].dC;           
+    out[i].dX = in[i].dX;           
+    out[i].K = in[i].K;            
+    out[i].c1 = in[i].c1;           
+    out[i].c2 = in[i].c2;           
+    out[i].equiv = in[i].equiv;        
+    out[i].Nc = in[i].Nc;           
+    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
+
+    out[i].astromScale = in[i].astromScale;  
+    out[i].photSysErr = in[i].photSysErr;   
+  }
+  return (out);
+}
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c	(revision 16699)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c	(revision 16699)
@@ -0,0 +1,361 @@
+# include <dvo.h>
+
+/* convert PS1_DEV_2 formats to internal formats */
+
+Measure *Measure_PS1_DEV_2_ToInternal (Measure_PS1_DEV_2 *in, int Nvalues) {
+
+  int i;
+  Measure *out;
+
+  ALLOCATE (out, Measure, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    out[i].dR         = in[i].dR;
+    out[i].dD         = in[i].dD;
+    out[i].M          = in[i].M;
+    out[i].Mcal       = in[i].Mcal;
+    out[i].Map        = in[i].Map;
+    out[i].dM         = in[i].dM;
+    out[i].dMcal      = in[i].dMcal;
+    out[i].dt         = in[i].dt;
+    out[i].airmass    = in[i].airmass;
+    out[i].az         = in[i].az;
+    out[i].Xccd       = in[i].Xccd;
+    out[i].Yccd       = in[i].Yccd;
+    out[i].Sky        = in[i].Sky;
+    out[i].dSky       = in[i].dSky;
+    out[i].t          = in[i].t;
+    out[i].averef     = in[i].averef;
+    out[i].detID      = in[i].detID;
+    out[i].imageID    = in[i].imageID;
+    out[i].qPSF       = in[i].qPSF;
+    out[i].psfChisq   = in[i].psfChisq;
+    out[i].crNsigma   = in[i].crNsigma;
+    out[i].extNsigma  = in[i].extNsigma;
+    out[i].FWx 	      = in[i].FWx;
+    out[i].FWy 	      = in[i].FWy;
+    out[i].theta      = in[i].theta;
+    out[i].photcode   = in[i].photcode;
+    out[i].dXccd      = in[i].dXccd;
+    out[i].dYccd      = in[i].dYccd;
+    out[i].dbFlags    = in[i].dbFlags;
+    out[i].photFlags  = in[i].photFlags;
+    out[i].stargal    = in[i].stargal;
+    out[i].dophot     = in[i].dophot;
+  }
+  return (out);
+}
+
+Measure_PS1_DEV_2 *MeasureInternalTo_PS1_DEV_2 (Measure *in, int Nvalues) {
+
+  int i;
+  Measure_PS1_DEV_2 *out;
+
+  ALLOCATE (out, Measure_PS1_DEV_2, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    out[i].dR         = in[i].dR;
+    out[i].dD         = in[i].dD;
+    out[i].M          = in[i].M;
+    out[i].Mcal       = in[i].Mcal;
+    out[i].Map        = in[i].Map;
+    out[i].dM         = in[i].dM;
+    out[i].dMcal      = in[i].dMcal;
+    out[i].dt         = in[i].dt;
+    out[i].airmass    = in[i].airmass;
+    out[i].az         = in[i].az;
+    out[i].Xccd       = in[i].Xccd;
+    out[i].Yccd       = in[i].Yccd;
+    out[i].Sky        = in[i].Sky;
+    out[i].dSky       = in[i].dSky;
+    out[i].t          = in[i].t;
+    out[i].averef     = in[i].averef;
+    out[i].detID      = in[i].detID;
+    out[i].imageID    = in[i].imageID;
+    out[i].qPSF       = in[i].qPSF;
+    out[i].psfChisq   = in[i].psfChisq;
+    out[i].crNsigma   = in[i].crNsigma;
+    out[i].extNsigma  = in[i].extNsigma;
+    out[i].FWx 	      = in[i].FWx;
+    out[i].FWy 	      = in[i].FWy;
+    out[i].theta      = in[i].theta;
+    out[i].photcode   = in[i].photcode;
+    out[i].dXccd      = in[i].dXccd;
+    out[i].dYccd      = in[i].dYccd;
+    out[i].dbFlags    = in[i].dbFlags;
+    out[i].photFlags  = in[i].photFlags;
+    out[i].stargal    = in[i].stargal;
+    out[i].dophot     = in[i].dophot;
+  }
+  return (out);
+}
+
+// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
+Average *Average_PS1_DEV_2_ToInternal (Average_PS1_DEV_2 *in, int Nvalues, SecFilt **primary) {
+
+  int i;
+  Average *out;
+
+  ALLOCATE (out, Average, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    out[i].R        	 = in[i].R;      
+    out[i].D        	 = in[i].D;      
+    out[i].dR       	 = in[i].dR;
+    out[i].dD       	 = in[i].dD;
+    out[i].uR       	 = in[i].uR;
+    out[i].uD       	 = in[i].uD;
+    out[i].duR      	 = in[i].duR;
+    out[i].duD      	 = in[i].duD;
+    out[i].P        	 = in[i].P;
+    out[i].dP       	 = in[i].dP;
+    out[i].Xp       	 = in[i].Xp;     
+    out[i].Nmeasure      = in[i].Nmeasure;     
+    out[i].Nmissing      = in[i].Nmissing;     
+    out[i].Nextend       = in[i].Nextend;     
+    out[i].code     	 = in[i].code;   
+    out[i].measureOffset = in[i].measureOffset; 
+    out[i].missingOffset = in[i].missingOffset;
+    out[i].extendOffset  = in[i].extendOffset;
+    out[i].objID 	 = in[i].objID;
+    out[i].catID 	 = in[i].catID;
+  }
+  return (out);
+}
+
+// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
+Average_PS1_DEV_2 *AverageInternalTo_PS1_DEV_2 (Average *in, int Nvalues, SecFilt *primary) {
+
+  int i;
+  Average_PS1_DEV_2 *out;
+
+  ALLOCATE (out, Average_PS1_DEV_2, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    out[i].R        	 = in[i].R;      
+    out[i].D        	 = in[i].D;      
+    out[i].dR       	 = in[i].dR;
+    out[i].dD       	 = in[i].dD;
+    out[i].uR       	 = in[i].uR;
+    out[i].uD       	 = in[i].uD;
+    out[i].duR      	 = in[i].duR;
+    out[i].duD      	 = in[i].duD;
+    out[i].P        	 = in[i].P;
+    out[i].dP       	 = in[i].dP;
+    out[i].Xp       	 = in[i].Xp;     
+    out[i].Nmeasure      = in[i].Nmeasure;     
+    out[i].Nmissing      = in[i].Nmissing;     
+    out[i].Nextend       = in[i].Nextend;     
+    out[i].code     	 = in[i].code;   
+    out[i].measureOffset = in[i].measureOffset; 
+    out[i].missingOffset = in[i].missingOffset;
+    out[i].extendOffset  = in[i].extendOffset;
+    out[i].objID 	 = in[i].objID;
+    out[i].catID 	 = in[i].catID;
+  }
+  return (out);
+}
+
+SecFilt *SecFilt_PS1_DEV_2_ToInternal (SecFilt_PS1_DEV_2 *in, int Nvalues) {
+
+  int i;
+  SecFilt *out;
+
+  ALLOCATE (out, SecFilt, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    out[i].M     = in[i].M;      
+    out[i].dM    = in[i].dM;      
+    out[i].Xm    = in[i].Xm;     
+    out[i].Ncode = in[i].Ncode;
+    out[i].Nused = in[i].Nused;
+ }
+  return (out);
+}
+
+SecFilt_PS1_DEV_2 *SecFiltInternalTo_PS1_DEV_2 (SecFilt *in, int Nvalues) {
+
+  int i;
+  SecFilt_PS1_DEV_2 *out;
+
+  ALLOCATE (out, SecFilt_PS1_DEV_2, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    out[i].M     = in[i].M;      
+    out[i].dM    = in[i].dM;      
+    out[i].Xm    = in[i].Xm;     
+    out[i].Ncode = in[i].Ncode;
+    out[i].Nused = in[i].Nused;
+  }
+  return (out);
+}
+
+Image *Image_PS1_DEV_2_ToInternal (Image_PS1_DEV_2 *in, int Nvalues) {
+
+  int i;
+  Image *out;
+
+  ALLOCATE (out, Image, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
+    strcpy (out[i].name, in[i].name);
+
+    out[i].tzero    	    = in[i].tzero;
+    out[i].nstar    	    = in[i].nstar;
+    out[i].secz	    	    = in[i].secz;
+    out[i].NX	    	    = in[i].NX;
+    out[i].NY	    	    = in[i].NY;
+    out[i].apmifit  	    = in[i].apmifit;
+    out[i].dapmifit 	    = in[i].dapmifit;
+    out[i].Mcal	    	    = in[i].Mcal;
+    out[i].dMcal    	    = in[i].dMcal;
+    out[i].Xm	    	    = in[i].Xm;
+    out[i].photcode   	    = in[i].photcode;
+    out[i].exptime  	    = in[i].exptime;
+    out[i].sidtime  	    = in[i].sidtime;
+    out[i].latitude  	    = in[i].latitude;
+    out[i].detection_limit  = in[i].detection_limit;
+    out[i].saturation_limit = in[i].saturation_limit;
+    out[i].cerror	    = in[i].cerror;
+    out[i].fwhm_x	    = in[i].fwhm_x;
+    out[i].fwhm_y	    = in[i].fwhm_y;
+    out[i].trate	    = in[i].trate;
+    out[i].code		    = in[i].code;
+    out[i].ccdnum	    = in[i].ccdnum;
+    out[i].imageID	    = in[i].imageID;
+    out[i].externID	    = in[i].externID;
+    out[i].sourceID	    = in[i].sourceID;
+
+    out[i].order	    = in[i].order;
+    out[i].Mx		    = in[i].Mx;
+    out[i].My		    = in[i].My;
+    out[i].Mxx		    = in[i].Mxx;
+    out[i].Mxy		    = in[i].Mxy;
+    out[i].Myy		    = in[i].Myy;
+    out[i].Mxxx		    = in[i].Mxxx;
+    out[i].Mxxy		    = in[i].Mxxy;
+    out[i].Mxyy		    = in[i].Mxyy;
+    out[i].Myyy		    = in[i].Myyy;
+    out[i].Mxxxx	    = in[i].Mxxxx;
+    out[i].Mxxxy	    = in[i].Mxxxy;
+    out[i].Mxxyy	    = in[i].Mxxyy;
+    out[i].Mxyyy	    = in[i].Mxyyy;
+    out[i].Myyyy	    = in[i].Myyyy;
+  }
+  return (out);
+}
+
+Image_PS1_DEV_2 *ImageInternalTo_PS1_DEV_2 (Image *in, int Nvalues) {
+
+  int i;
+  Image_PS1_DEV_2 *out;
+
+  ALLOCATE (out, Image_PS1_DEV_2, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
+    strcpy (out[i].name, in[i].name);
+
+    out[i].tzero    	    = in[i].tzero;
+    out[i].nstar    	    = in[i].nstar;
+    out[i].secz	    	    = in[i].secz;
+    out[i].NX	    	    = in[i].NX;
+    out[i].NY	    	    = in[i].NY;
+    out[i].apmifit  	    = in[i].apmifit;
+    out[i].dapmifit 	    = in[i].dapmifit;
+    out[i].Mcal	    	    = in[i].Mcal;
+    out[i].dMcal    	    = in[i].dMcal;
+    out[i].Xm	    	    = in[i].Xm;
+    out[i].photcode   	    = in[i].photcode;
+    out[i].exptime  	    = in[i].exptime;
+    out[i].sidtime  	    = in[i].sidtime;
+    out[i].latitude  	    = in[i].latitude;
+    out[i].detection_limit  = in[i].detection_limit;
+    out[i].saturation_limit = in[i].saturation_limit;
+    out[i].cerror	    = in[i].cerror;
+    out[i].fwhm_x	    = in[i].fwhm_x;
+    out[i].fwhm_y	    = in[i].fwhm_y;
+    out[i].trate	    = in[i].trate;
+    out[i].code		    = in[i].code;
+    out[i].ccdnum	    = in[i].ccdnum;
+    out[i].imageID	    = in[i].imageID;
+    out[i].externID	    = in[i].externID;
+    out[i].sourceID	    = in[i].sourceID;
+
+    out[i].order	    = in[i].order;
+    out[i].Mx		    = in[i].Mx;
+    out[i].My		    = in[i].My;
+    out[i].Mxx		    = in[i].Mxx;
+    out[i].Mxy		    = in[i].Mxy;
+    out[i].Myy		    = in[i].Myy;
+    out[i].Mxxx		    = in[i].Mxxx;
+    out[i].Mxxy		    = in[i].Mxxy;
+    out[i].Mxyy		    = in[i].Mxyy;
+    out[i].Myyy		    = in[i].Myyy;
+    out[i].Mxxxx	    = in[i].Mxxxx;
+    out[i].Mxxxy	    = in[i].Mxxxy;
+    out[i].Mxxyy	    = in[i].Mxxyy;
+    out[i].Mxyyy	    = in[i].Mxyyy;
+    out[i].Myyyy	    = in[i].Myyyy;
+  }
+  return (out);
+}
+
+PhotCode_PS1_DEV_2 *PhotCode_Internal_To_PS1_DEV_2 (PhotCode *in, int Nvalues) {
+
+  int i;
+  PhotCode_PS1_DEV_2 *out;
+
+  ALLOCATE (out, PhotCode_PS1_DEV_2, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
+    out[i].name[31] = 0; // force termination
+
+    out[i].code = in[i].code;         
+    out[i].type = in[i].type;         
+    out[i].C = in[i].C;            
+    out[i].dC = in[i].dC;           
+    out[i].dX = in[i].dX;           
+    out[i].K = in[i].K;            
+    out[i].c1 = in[i].c1;           
+    out[i].c2 = in[i].c2;           
+    out[i].equiv = in[i].equiv;        
+    out[i].Nc = in[i].Nc;           
+    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
+
+    out[i].astromScale = in[i].astromScale;  
+    out[i].photSysErr = in[i].photSysErr;   
+  }
+  return (out);
+}
+
+PhotCode *PhotCode_PS1_DEV_2_To_Internal (PhotCode_PS1_DEV_2 *in, int Nvalues) {
+
+  int i;
+  PhotCode *out;
+
+  ALLOCATE (out, PhotCode, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
+    out[i].name[31] = 0; // force termination
+
+    out[i].code = in[i].code;         
+    out[i].type = in[i].type;         
+    out[i].C = in[i].C;            
+    out[i].dC = in[i].dC;           
+    out[i].dX = in[i].dX;           
+    out[i].K = in[i].K;            
+    out[i].c1 = in[i].c1;           
+    out[i].c2 = in[i].c2;           
+    out[i].equiv = in[i].equiv;        
+    out[i].Nc = in[i].Nc;           
+    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
+
+    out[i].astromScale = in[i].astromScale;  
+    out[i].photSysErr = in[i].photSysErr;   
+  }
+  return (out);
+}
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_elixir.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_elixir.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_elixir.c	(revision 16699)
@@ -16,5 +16,8 @@
     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;
+
+    // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture
+    // magnitudes.  Most uses of Mgal in the past were actually aperture (isophotal) mags
+    out[i].Map      = (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;
@@ -39,5 +42,5 @@
     out[i].dSky      = 0;
     out[i].qPSF      = 0;
-    out[i].psfProb   = 0;
+    out[i].psfChisq  = 0;
     out[i].crNsigma  = 0;
     out[i].extNsigma = 0;
@@ -66,5 +69,5 @@
     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].Mgal     = isnan(in[i].Map    ) ? NAN_S_SHORT : in[i].Map     * 1000.0;
     out[i].airmass  = isnan(in[i].airmass) ? NAN_S_SHORT : in[i].airmass * 1000.0;
 
@@ -115,6 +118,6 @@
 
     /* XXX add these later */
-    out[i].objID_hi = 0;
-    out[i].objID_lo = 0;
+    out[i].objID   = 0;
+    out[i].catID   = 0;
 
     primary[0][i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
@@ -297,2 +300,58 @@
   return (out);
 }
+
+PhotCode_Elixir *PhotCode_Internal_To_Elixir (PhotCode *in, int Nvalues) {
+
+  int i;
+  PhotCode_Elixir *out;
+
+  ALLOCATE (out, PhotCode_Elixir, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
+    out[i].name[31] = 0; // force termination
+
+    out[i].code = in[i].code;         
+    out[i].type = in[i].type;         
+    out[i].C = in[i].C;            
+    out[i].dC = in[i].dC;           
+    out[i].dX = in[i].dX;           
+    out[i].K = in[i].K;            
+    out[i].c1 = in[i].c1;           
+    out[i].c2 = in[i].c2;           
+    out[i].equiv = in[i].equiv;        
+    out[i].Nc = in[i].Nc;           
+    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
+  }
+  return (out);
+}
+
+PhotCode *PhotCode_Elixir_To_Internal (PhotCode_Elixir *in, int Nvalues) {
+
+  int i;
+  PhotCode *out;
+
+  ALLOCATE (out, PhotCode, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
+    out[i].name[31] = 0; // force termination
+
+    out[i].code = in[i].code;         
+    out[i].type = in[i].type;         
+    out[i].C = in[i].C;            
+    out[i].dC = in[i].dC;           
+    out[i].dX = in[i].dX;           
+    out[i].K = in[i].K;            
+    out[i].c1 = in[i].c1;           
+    out[i].c2 = in[i].c2;           
+    out[i].equiv = in[i].equiv;        
+    out[i].Nc = in[i].Nc;           
+    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
+
+    // not defined in Elixir:
+    out[i].astromScale = 1.0;
+    out[i].photSysErr = 1.0;
+  }
+  return (out);
+}
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_loneos.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_loneos.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_loneos.c	(revision 16699)
@@ -24,16 +24,19 @@
 
     /* these values don't exist in the Loneos format */
-    out[i].Mgal     = out[i].M;
-    out[i].dt       = 0;
-    out[i].airmass  = 0;
-    out[i].az       = 0;
-    out[i].FWx 	    = 0;
-    out[i].FWy 	    = 0;
-    out[i].theta    = 0;
-    out[i].stargal  = 0;
-    out[i].Sky      = 0;
-    out[i].dSky     = 0;
-    out[i].qPSF     = 0;
-    out[i].psfProb   = 0;
+
+    // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture
+    // magnitudes.  Most uses of Mgal in the past were actually aperture (isophotal) mags
+    out[i].Map       = out[i].M;
+    out[i].dt        = 0;
+    out[i].airmass   = 0;
+    out[i].az        = 0;
+    out[i].FWx 	     = 0;
+    out[i].FWy 	     = 0;
+    out[i].theta     = 0;
+    out[i].stargal   = 0;
+    out[i].Sky       = 0;
+    out[i].dSky      = 0;
+    out[i].qPSF      = 0;
+    out[i].psfChisq  = 0;
     out[i].crNsigma  = 0;
     out[i].extNsigma = 0;
@@ -107,6 +110,6 @@
 
     /* XXX add these later */
-    out[i].objID_hi = 0;
-    out[i].objID_lo = 0;
+    out[i].objID   = 0;
+    out[i].catID   = 0;
 
     primary[0][i].M  = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 16699)
@@ -15,5 +15,8 @@
     out[i].dM         = in[i].dM;
     out[i].Mcal       = in[i].Mcal;
-    out[i].Mgal       = in[i].Mgal;
+
+    // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture
+    // magnitudes.  Most uses of Mgal in the past were actually aperture (isophotal) mags
+    out[i].Map        = in[i].Mgal;
     out[i].airmass    = in[i].airmass;
     out[i].az         = in[i].az;
@@ -39,5 +42,5 @@
 
     // these don't have a correspondence
-    out[i].psfProb   = 0;
+    out[i].psfChisq  = 0;
     out[i].crNsigma  = 0;
     out[i].extNsigma = 0;
@@ -61,5 +64,5 @@
     out[i].dM         = in[i].dM;
     out[i].Mcal       = in[i].Mcal;
-    out[i].Mgal       = in[i].Mgal;
+    out[i].Mgal       = in[i].Map;
     out[i].airmass    = in[i].airmass;
     out[i].az         = in[i].az;
@@ -115,6 +118,6 @@
     out[i].P        	 = in[i].P;
     out[i].dP       	 = in[i].dP;
-    out[i].objID_hi 	 = in[i].objID_hi;
-    out[i].objID_lo 	 = in[i].objID_lo;
+    out[i].objID 	 = in[i].objID;
+    out[i].catID 	 = in[i].catID;
   }
   return (out);
@@ -147,6 +150,6 @@
     out[i].P        = in[i].P;
     out[i].dP       = in[i].dP;
-    out[i].objID_hi = in[i].objID_hi;
-    out[i].objID_lo = in[i].objID_lo;
+    out[i].objID    = in[i].objID;
+    out[i].catID    = in[i].catID;
   }
   return (out);
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 16699)
@@ -15,5 +15,8 @@
     out[i].dM         = in[i].dM;
     out[i].Mcal       = in[i].Mcal;
-    out[i].Mgal       = in[i].Mgal;
+
+    // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture
+    // magnitudes.  Most uses of Mgal in the past were actually aperture (isophotal) mags
+    out[i].Map        = in[i].Mgal;
     out[i].airmass    = in[i].airmass;
     out[i].az         = in[i].az;
@@ -39,5 +42,5 @@
 
     // these don't have a correspondence
-    out[i].psfProb   = 0;
+    out[i].psfChisq  = 0;
     out[i].crNsigma  = 0;
     out[i].extNsigma = 0;
@@ -61,5 +64,5 @@
     out[i].dM         = in[i].dM;
     out[i].Mcal       = in[i].Mcal;
-    out[i].Mgal       = in[i].Mgal;
+    out[i].Mgal       = in[i].Map;
     out[i].airmass    = in[i].airmass;
     out[i].az         = in[i].az;
@@ -115,6 +118,6 @@
     out[i].P        	 = in[i].P;
     out[i].dP       	 = in[i].dP;
-    out[i].objID_hi 	 = in[i].objID_hi;
-    out[i].objID_lo 	 = in[i].objID_lo;
+    out[i].objID 	 = in[i].objID;
+    out[i].catID 	 = in[i].catID;
   }
   return (out);
@@ -147,6 +150,6 @@
     out[i].P        = in[i].P;
     out[i].dP       = in[i].dP;
-    out[i].objID_hi = in[i].objID_hi;
-    out[i].objID_lo = in[i].objID_lo;
+    out[i].objID    = in[i].objID;
+    out[i].catID    = in[i].catID;
   }
   return (out);
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_image.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_image.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_image.c	(revision 16699)
@@ -194,4 +194,5 @@
   if (db[0].format == DVO_FORMAT_PANSTARRS_DEV_1) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PANSTARRS_DEV_1");
   if (db[0].format == DVO_FORMAT_PS1_DEV_1)       gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_DEV_1");
+  if (db[0].format == DVO_FORMAT_PS1_DEV_2)       gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_DEV_2");
   
   return;
Index: /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_image_raw.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_image_raw.c	(revision 16698)
+++ /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_image_raw.c	(revision 16699)
@@ -53,4 +53,5 @@
   if (db[0].format == DVO_FORMAT_PANSTARRS_DEV_1) ImageSize = sizeof(Image_Panstarrs_DEV_1);
   if (db[0].format == DVO_FORMAT_PS1_DEV_1)       ImageSize = sizeof(Image_PS1_DEV_1);
+  if (db[0].format == DVO_FORMAT_PS1_DEV_2)       ImageSize = sizeof(Image_PS1_DEV_2);
 
   /* check that filesize makes sense */
@@ -76,4 +77,5 @@
   if (db[0].format == DVO_FORMAT_PANSTARRS_DEV_1) gfits_table_mkheader_Image_Panstarrs_DEV_1 (&db[0].theader);
   if (db[0].format == DVO_FORMAT_PS1_DEV_1)       gfits_table_mkheader_Image_PS1_DEV_1 (&db[0].theader);
+  if (db[0].format == DVO_FORMAT_PS1_DEV_2)       gfits_table_mkheader_Image_PS1_DEV_2 (&db[0].theader);
     
   /* read data from file */
Index: anches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_photcode_convert_elixir.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_photcode_convert_elixir.c	(revision 16698)
+++ 	(revision )
@@ -1,57 +1,0 @@
-# include <dvo.h>
-
-PhotCode_Elixir *PhotCode_Internal_To_Elixir (PhotCode *in, int Nvalues) {
-
-  int i;
-  PhotCode_Elixir *out;
-
-  ALLOCATE (out, PhotCode_Elixir, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
-    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
-    out[i].name[31] = 0; // force termination
-
-    out[i].code = in[i].code;         
-    out[i].type = in[i].type;         
-    out[i].C = in[i].C;            
-    out[i].dC = in[i].dC;           
-    out[i].dX = in[i].dX;           
-    out[i].K = in[i].K;            
-    out[i].c1 = in[i].c1;           
-    out[i].c2 = in[i].c2;           
-    out[i].equiv = in[i].equiv;        
-    out[i].Nc = in[i].Nc;           
-    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
-  }
-  return (out);
-}
-
-PhotCode *PhotCode_Elixir_To_Internal (PhotCode_Elixir *in, int Nvalues) {
-
-  int i;
-  PhotCode *out;
-
-  ALLOCATE (out, PhotCode, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
-    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
-    out[i].name[31] = 0; // force termination
-
-    out[i].code = in[i].code;         
-    out[i].type = in[i].type;         
-    out[i].C = in[i].C;            
-    out[i].dC = in[i].dC;           
-    out[i].dX = in[i].dX;           
-    out[i].K = in[i].K;            
-    out[i].c1 = in[i].c1;           
-    out[i].c2 = in[i].c2;           
-    out[i].equiv = in[i].equiv;        
-    out[i].Nc = in[i].Nc;           
-    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
-
-    // not defined in Elixir:
-    out[i].astromScale = 1.0;
-    out[i].photSysErr = 1.0;
-  }
-  return (out);
-}
Index: anches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_photcode_convert_ps1_dev_1.c
===================================================================
--- /branches/eam_branch_20080223/Ohana/src/libdvo/src/dvo_photcode_convert_ps1_dev_1.c	(revision 16698)
+++ 	(revision )
@@ -1,59 +1,0 @@
-# include <dvo.h>
-
-PhotCode_PS1_DEV_1 *PhotCode_Internal_To_PS1_DEV_1 (PhotCode *in, int Nvalues) {
-
-  int i;
-  PhotCode_PS1_DEV_1 *out;
-
-  ALLOCATE (out, PhotCode_PS1_DEV_1, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
-    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
-    out[i].name[31] = 0; // force termination
-
-    out[i].code = in[i].code;         
-    out[i].type = in[i].type;         
-    out[i].C = in[i].C;            
-    out[i].dC = in[i].dC;           
-    out[i].dX = in[i].dX;           
-    out[i].K = in[i].K;            
-    out[i].c1 = in[i].c1;           
-    out[i].c2 = in[i].c2;           
-    out[i].equiv = in[i].equiv;        
-    out[i].Nc = in[i].Nc;           
-    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
-
-    out[i].astromScale = in[i].astromScale;  
-    out[i].photSysErr = in[i].photSysErr;   
-  }
-  return (out);
-}
-
-PhotCode *PhotCode_PS1_DEV_1_To_Internal (PhotCode_PS1_DEV_1 *in, int Nvalues) {
-
-  int i;
-  PhotCode *out;
-
-  ALLOCATE (out, PhotCode, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
-    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
-    out[i].name[31] = 0; // force termination
-
-    out[i].code = in[i].code;         
-    out[i].type = in[i].type;         
-    out[i].C = in[i].C;            
-    out[i].dC = in[i].dC;           
-    out[i].dX = in[i].dX;           
-    out[i].K = in[i].K;            
-    out[i].c1 = in[i].c1;           
-    out[i].c2 = in[i].c2;           
-    out[i].equiv = in[i].equiv;        
-    out[i].Nc = in[i].Nc;           
-    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
-
-    out[i].astromScale = in[i].astromScale;  
-    out[i].photSysErr = in[i].photSysErr;   
-  }
-  return (out);
-}
