Index: branches/eam_branches/ipp-20110213/Ohana/src/addstar/include/addstar.h
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/addstar/include/addstar.h	(revision 31144)
+++ branches/eam_branches/ipp-20110213/Ohana/src/addstar/include/addstar.h	(revision 31145)
@@ -263,4 +263,6 @@
 Stars     *Convert_PS1_V2	  PROTO((FTable *table, unsigned int *nstars));
 Stars     *Convert_PS1_V3	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_SV1	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_SV1_Alt	  PROTO((FTable *table, unsigned int *nstars));
 
 int        InitStar               PROTO((Stars *star));
Index: branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/MatchHeaders.c
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/MatchHeaders.c	(revision 31144)
+++ branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/MatchHeaders.c	(revision 31145)
@@ -58,4 +58,5 @@
     if (!strcmp (exttype, "PS1_V2")) goto keep;
     if (!strcmp (exttype, "PS1_V3")) goto keep;
+    if (!strcmp (exttype, "PS1_SV1")) goto keep;
     continue;
 
Index: branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 31144)
+++ branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 31145)
@@ -54,4 +54,7 @@
     stars = Convert_PS1_V3 (&table, &Nstars);
   }
+  if (!strcmp (type, "PS1_SV1")) {
+    stars = Convert_PS1_SV1 (&table, &Nstars);
+  }
   if (stars == NULL) {
     fprintf (stderr, "invalid table type %s\n", type);
@@ -501,2 +504,146 @@
   return (stars);
 }
+
+Stars *Convert_PS1_SV1 (FTable *table, unsigned int *nstars) {
+
+  off_t Nstars; 
+  unsigned int i;
+  double ZeroPt;
+  Stars *stars;
+  CMF_PS1_SV1 *ps1data;
+
+  if (table[0].header[0].Naxis[0] == 196) {
+      stars = Convert_PS1_SV1_Alt (table, nstars);
+      return (stars);
+  }
+
+  ps1data = gfits_table_get_CMF_PS1_SV1 (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
+  ZeroPt = GetZeroPoint();
+
+  ALLOCATE (stars, Stars, Nstars);
+  for (i = 0; i < Nstars; i++) {
+    InitStar (&stars[i]);
+    stars[i].measure.Xccd       = ps1data[i].X;
+    stars[i].measure.Yccd       = ps1data[i].Y;
+    stars[i].measure.dXccd      = ToShortPixels(ps1data[i].dX);
+    stars[i].measure.dYccd      = ToShortPixels(ps1data[i].dY);
+
+    stars[i].measure.posangle   = ToShortDegrees(ps1data[i].posangle);
+    stars[i].measure.pltscale   = ps1data[i].pltscale;
+
+    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
+	stars[i].measure.M      = NAN;
+    } else {
+	stars[i].measure.M      = ps1data[i].M + ZeroPt;
+    }
+    stars[i].measure.dM         = ps1data[i].dM;
+    stars[i].measure.dMcal      = ps1data[i].dMcal;
+    stars[i].measure.Map        = ps1data[i].Map + ZeroPt;
+		        
+    stars[i].measure.Sky        = ps1data[i].sky;
+    stars[i].measure.dSky       = ps1data[i].dSky;
+		        
+    stars[i].measure.psfChisq   = ps1data[i].psfChisq;
+    stars[i].measure.psfQual    = ps1data[i].psfQual;
+    stars[i].measure.psfNdof    = ps1data[i].psfNdof;
+    stars[i].measure.psfNpix    = ps1data[i].psfNpix;
+    stars[i].measure.crNsigma   = ps1data[i].crNsigma;
+    stars[i].measure.extNsigma  = ps1data[i].extNsigma;
+
+    stars[i].measure.FWx        = ToShortPixels(ps1data[i].fx);
+    stars[i].measure.FWy        = ToShortPixels(ps1data[i].fy);
+    stars[i].measure.theta      = ToShortDegrees(ps1data[i].df);
+
+    stars[i].measure.Mxx        = ToShortPixels(ps1data[i].Mxx);
+    stars[i].measure.Mxy        = ToShortPixels(ps1data[i].Mxy);
+    stars[i].measure.Myy        = ToShortPixels(ps1data[i].Myy);
+		        
+    stars[i].measure.photFlags  = ps1data[i].flags;
+
+    // this is may optionally be replaced by the internal sequence (see FilterStars.c)
+    stars[i].measure.detID      = ps1data[i].detID; 
+
+    // the Average fields and the following Measure fields are set in FilterStars after
+    // the image metadata is in hand:  dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 
+    // averef is set in find_matches, dbFlags is zero on ingest.
+
+    // the following fields are currently not being set anywhere: t_msec
+  }    
+  *nstars = Nstars;
+  return (stars);
+}
+
+Stars *Convert_PS1_SV1_Alt (FTable *table, unsigned int *nstars) {
+
+  off_t Nstars; 
+  unsigned int i;
+  double ZeroPt;
+  Stars *stars;
+  CMF_PS1_SV1 *ps1data;
+
+  // some test output files were produced called CMF_PS1_SV1 but with mismatch byte boundaries
+
+  ps1data = gfits_table_get_CMF_PS1_SV1_Alt (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
+  ZeroPt = GetZeroPoint();
+
+  ALLOCATE (stars, Stars, Nstars);
+  for (i = 0; i < Nstars; i++) {
+    InitStar (&stars[i]);
+    stars[i].measure.Xccd       = ps1data[i].X;
+    stars[i].measure.Yccd       = ps1data[i].Y;
+    stars[i].measure.dXccd      = ToShortPixels(ps1data[i].dX);
+    stars[i].measure.dYccd      = ToShortPixels(ps1data[i].dY);
+
+    stars[i].measure.posangle   = ToShortDegrees(ps1data[i].posangle);
+    stars[i].measure.pltscale   = ps1data[i].pltscale;
+
+    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
+	stars[i].measure.M      = NAN;
+    } else {
+	stars[i].measure.M      = ps1data[i].M + ZeroPt;
+    }
+    stars[i].measure.dM         = ps1data[i].dM;
+    stars[i].measure.dMcal      = ps1data[i].dMcal;
+    stars[i].measure.Map        = ps1data[i].Map + ZeroPt;
+		        
+    stars[i].measure.Sky        = ps1data[i].sky;
+    stars[i].measure.dSky       = ps1data[i].dSky;
+		        
+    stars[i].measure.psfChisq   = ps1data[i].psfChisq;
+    stars[i].measure.psfQual    = ps1data[i].psfQual;
+    stars[i].measure.psfNdof    = ps1data[i].psfNdof;
+    stars[i].measure.psfNpix    = ps1data[i].psfNpix;
+    stars[i].measure.crNsigma   = ps1data[i].crNsigma;
+    stars[i].measure.extNsigma  = ps1data[i].extNsigma;
+
+    stars[i].measure.FWx        = ToShortPixels(ps1data[i].fx);
+    stars[i].measure.FWy        = ToShortPixels(ps1data[i].fy);
+    stars[i].measure.theta      = ToShortDegrees(ps1data[i].df);
+
+    stars[i].measure.Mxx        = ToShortPixels(ps1data[i].Mxx);
+    stars[i].measure.Mxy        = ToShortPixels(ps1data[i].Mxy);
+    stars[i].measure.Myy        = ToShortPixels(ps1data[i].Myy);
+		        
+    stars[i].measure.photFlags  = ps1data[i].flags;
+
+    // this is may optionally be replaced by the internal sequence (see FilterStars.c)
+    stars[i].measure.detID      = ps1data[i].detID; 
+
+    // the Average fields and the following Measure fields are set in FilterStars after
+    // the image metadata is in hand:  dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 
+    // averef is set in find_matches, dbFlags is zero on ingest.
+
+    // the following fields are currently not being set anywhere: t_msec
+  }    
+  *nstars = Nstars;
+  return (stars);
+}
+
Index: branches/eam_branches/ipp-20110213/Ohana/src/libautocode/Makefile.Targets
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/libautocode/Makefile.Targets	(revision 31144)
+++ branches/eam_branches/ipp-20110213/Ohana/src/libautocode/Makefile.Targets	(revision 31145)
@@ -60,4 +60,5 @@
 $(ASRC)/cmf-ps1-v2.$(ARCH).o \
 $(ASRC)/cmf-ps1-v3.$(ARCH).o \
+$(ASRC)/cmf-ps1-sv1.$(ARCH).o \
 $(ASRC)/cmf-smpdata.$(ARCH).o \
 $(ASRC)/getstar-ps1-dev-0.$(ARCH).o \
@@ -131,4 +132,5 @@
 $(AINC)/cmf-ps1-v2.h \
 $(AINC)/cmf-ps1-v3.h \
+$(AINC)/cmf-ps1-sv1.h \
 $(AINC)/cmf-smpdata.h \
 $(AINC)/getstar-ps1-dev-0.h \
Index: branches/eam_branches/ipp-20110213/Ohana/src/libautocode/def/cmf-ps1-sv1.d
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/libautocode/def/cmf-ps1-sv1.d	(revision 31145)
+++ branches/eam_branches/ipp-20110213/Ohana/src/libautocode/def/cmf-ps1-sv1.d	(revision 31145)
@@ -0,0 +1,127 @@
+# name of structure type
+STRUCT  CMF_PS1_SV1
+EXTNAME CMF_PS1_SV1
+TYPE    BINTABLE
+SIZE    200
+
+# elements of data structure / FITS table
+FIELD detID,          IPP_IDET,          unsigned int, detection ID                     
+FIELD X,              X_PSF,             float,    x coord,               pixels
+FIELD Y,              Y_PSF,             float,    y coord,               pixels
+FIELD dX,             X_PSF_SIG,         float,    x coord error,         pixels
+
+FIELD dY,             Y_PSF_SIG,         float,    y coord error,         pixels
+FIELD posangle,       POSANGLE,          float,    Posangle at source,    degrees
+FIELD pltscale,       PLTSCALE,          float,    Plate Scale at source, arcsec/pixel
+FIELD M,              PSF_INST_MAG,      float,    inst mags,             mags
+
+FIELD dM,             PSF_INST_MAG_SIG,  float,    inst mag error,        mags
+FIELD Flux,           PSF_INST_FLUX,     float,    psf flux,	       counts
+FIELD dFlux,          PSF_INST_FLUX_SIG, float,    psf flux error,        counts      
+FIELD Map,            AP_MAG_STANDARD,   float,    standard aperture mag, mags
+
+FIELD MapRaw,         AP_MAG_RAW,        float,    raw aperture mag,      mags
+FIELD apRadius,       AP_MAG_RADIUS,     float,    radius used for fit,   pixels
+FIELD Mcalib,         CAL_PSF_MAG,       float,    calibrated psf mag,    mags
+FIELD dMcal,          CAL_PSF_MAG_SIG,   float,    zero point scatter,    mags
+
+# NOTE: RA & DEC (both double) need to be on an 8-byte boundary...
+FIELD RA,             RA_PSF,            double,   PSF RA coord,          degrees
+FIELD DEC,            DEC_PSF,           double,   PSF DEC coord,         degrees
+
+FIELD Mpeak,          PEAK_FLUX_AS_MAG,  float,    peak flux as a mag,    mags
+FIELD sky,            SKY,               float,    sky flux,              cnts/sec
+FIELD dSky,           SKY_SIG,           float,    sky flux error,        cnts/sec
+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
+FIELD fx,             PSF_MAJOR,         float,    psf fit major axis,    pixels
+FIELD fy,             PSF_MINOR,         float,    psf fit minor axis,    pixels
+
+FIELD df,             PSF_THETA,         float,    ellipse angle,         degrees
+FIELD psfQual,        PSF_QF,            float,    quality factor
+FIELD psfQualPerfect, PSF_QF_PERFECT,    float,    quality factor perfect
+FIELD psfNdof,        PSF_NDOF,          int,      psf degrees of freedom
+
+FIELD psfNpix,        PSF_NPIX,          int,      psf number of pixels
+FIELD Mxx,            MOMENTS_XX,        float,    second moment X,       pixels^2
+FIELD Mxy,            MOMENTS_XY,        float,    second moment Y,       pixels^2
+FIELD Myy,            MOMENTS_YY,        float,    second moment XY,      pixels^2
+
+FIELD M3c,            MOMENTS_M3C,       float,    third moment cos(t),   pixels^3
+FIELD M3s,            MOMENTS_M3S,       float,    third moment sin(t),   pixels^3
+FIELD M4c,            MOMENTS_M4C,       float,    fourth moment cos(t),  pixels^4
+FIELD M4s,            MOMENTS_M4S,       float,    fourth moment sin(t),  pixels^4
+
+FIELD Mr1,            MOMENTS_R1,        float,    first radial moment,   pixels
+FIELD Mrh,            MOMENTS_RH,        float,    half radial moment,    pixels^1/2
+FIELD kronFlux,       KRON_FLUX,         float,    kron flux,             counts
+FIELD kronFluxErr,    KRON_FLUX_ERR,     float,    kron flux error,       counts
+
+FIELD kronInner,      KRON_FLUX_INNER,   float,    kron flux 1<R<2.5,     counts
+FIELD kronOuter,      KRON_FLUX_OUTER,   float,    kron flux 2.5<R<4,     counts
+FIELD flags,          FLAGS,             int,      analysis flags
+FIELD flags2,         FLAGS2,            int,      analysis flags (2)
+
+FIELD padding2,       PADDING,           int,      padding for 8byte records
+FIELD nFrames,        N_FRAMES,          short,    images overlapping peak
+FIELD padding,        PADDING,           short,    padding for 8byte records
+
+# for an object in an image, we have three triplets that tell us about the shape:
+# second moments: Mxx, Mxy, Myy 
+# model shape parameters: F_major, F_minor, F_theta
+# centroid errors: sigma_X, sigma_Y, sigma_XY
+
+# # elements of data structure / FITS table
+# FIELD detID,          IPP_IDET,          IPP_IDET           1J      unsigned int, detection ID                     
+# FIELD X,              X_PSF,             X_PSF              1E      float,    x coord,               pixels
+# FIELD Y,              Y_PSF,             Y_PSF              1E      float,    y coord,               pixels
+# FIELD dX,             X_PSF_SIG,         X_PSF_SIG          1E      float,    x coord error,         pixels
+# FIELD dY,             Y_PSF_SIG,         Y_PSF_SIG          1E      float,    y coord error,         pixels
+# FIELD posangle,       POSANGLE,          POSANGLE           1E      float,    Posangle at source,    degrees
+# FIELD pltscale,       PLTSCALE,          PLTSCALE           1E      float,    Plate Scale at source, arcsec/pixel
+# FIELD M,              PSF_INST_MAG,      PSF_INST_MAG       1E      float,    inst mags,             mags
+# FIELD dM,             PSF_INST_MAG_SIG,  PSF_INST_MAG_SIG   1E      float,    inst mag error,        mags
+# FIELD flux,           PSF_INST_FLUX,     PSF_INST_FLUX      1E      float,    psf flux,	       counts
+# FIELD flux,           PSF_INST_FLUX_SIG, PSF_INST_FLUX_SIG  1E      float,    psf flux error,        counts      
+# FIELD Map,            AP_MAG_STANDARD,   AP_MAG             1E      float,    standard aperture mag, mags
+# FIELD Map,            AP_MAG_RAW,        AP_MAG_RAW         1E      float,    raw aperture mag,      mags
+# FIELD apRadius,       AP_MAG_RADIUS,     AP_MAG_RADIUS      1E      float,    radius used for fit,   pixels
+# FIELD Mpeak,          PEAK_FLUX_AS_MAG,  PEAK_FLUX_AS_MAG   1E      float,    peak flux as a mag,    mags
+# FIELD Mcalib,         CAL_PSF_MAG,       CAL_PSF_MAG        1E      float,    calibrated psf mag,    mags
+# FIELD dMcal,          CAL_PSF_MAG_SIG,   CAL_PSF_MAG_SIG    1E      float,    zero point scatter,    mags
+# FIELD RA,             RA_PSF,            RA_PSF             1D      double,   PSF RA coord,          degrees
+# FIELD DEC,            DEC_PSF,           DEC_PSF            1D      double,   PSF DEC coord,         degrees
+# FIELD sky,            SKY,               SKY                1E      float,    sky flux,              cnts/sec
+# FIELD dSky,           SKY_SIG,           SKY_SIGMA          1E      float,    sky flux error,        cnts/sec
+# FIELD psfChisq,       PSF_CHISQ,         PSF_CHISQ          1E      float,    psf fit chisq
+# FIELD crNsigma,       CR_NSIGMA,         CR_NSIGMA          1E      float,    Nsigma deviations from PSF to CF
+# FIELD extNsigma,      EXT_NSIGMA,        EXT_NSIGMA         1E      float,    Nsigma deviations from PSF to EXT
+# FIELD fx,             PSF_MAJOR,         PSF_MAJOR          1E      float,    psf fit major axis,    pixels
+# FIELD fy,             PSF_MINOR,         PSF_MINOR          1E      float,    psf fit minor axis,    pixels
+# FIELD df,             PSF_THETA,         PSF_THETA          1E      float,    ellipse angle,         degrees
+# FIELD psfQual,        PSF_QF,            PSF_QF             1E      float,    quality factor
+# FIELD psfQualPerfect, PSF_QF_PERFECT,    PSF_QF_PERFECT     1E      float,    quality factor perfect
+# FIELD psfNdof,        PSF_NDOF,          PSF_NDOF           1J      int,      psf degrees of freedom
+# FIELD psfNpix,        PSF_NPIX,          PSF_NPIX           1J      int,      psf number of pixels
+# FIELD Mxx,            MOMENTS_XX,        MOMENTS_XX         1E      float,    second moment X,       pixels^2
+# FIELD Mxy,            MOMENTS_XY,        MOMENTS_XY         1E      float,    second moment Y,       pixels^2
+# FIELD Myy,            MOMENTS_YY,        MOMENTS_YY         1E      float,    second moment XY,      pixels^2
+# FIELD M3c,            MOMENTS_M3C,       MOMENTS_M3C        1E      float,    third moment cos(t),   pixels^3
+# FIELD M3s,            MOMENTS_M3S,       MOMENTS_M3S        1E      float,    third moment sin(t),   pixels^3
+# FIELD M4c,            MOMENTS_M4C,       MOMENTS_M4C        1E      float,    fourth moment cos(t),  pixels^4
+# FIELD M4s,            MOMENTS_M4S,       MOMENTS_M4S        1E      float,    fourth moment sin(t),  pixels^4
+# FIELD Mr1,            MOMENTS_R1,        MOMENTS_R1         1E      float,    first radial moment,   pixels
+# FIELD Mrh,            MOMENTS_RH,        MOMENTS_RH         1E      float,    half radial moment,    pixels^1/2
+# FIELD kronFlux,       KRON_FLUX,         KRON_FLUX          1E      float,    kron flux,             counts
+# FIELD kronFluxErr,    KRON_FLUX_ERR,     KRON_FLUX_ERR      1E      float,    kron flux error,       counts
+# FIELD kronInner,      KRON_FLUX_INNER,   KRON_FLUX_INNER    1E      float,    kron flux 1<R<2.5,     counts
+# FIELD kronOuter,      KRON_FLUX_OUTER,   KRON_FLUX_OUTER    1E      float,    kron flux 2.5<R<4,     counts
+# FIELD flags,          FLAGS,             FLAGS              1J      int,      analysis flags
+# FIELD flags2,         FLAGS,             FLAGS2             1J      int,      analysis flags (2)
+# FIELD nFrames,        N_FRAMES,          N_FRAMES           1I      short,    images overlapping peak
+# FIELD padding,        PADDING,           PADDING            1I      short,    padding for 8byte records
+
+      
+
Index: branches/eam_branches/ipp-20110213/Ohana/src/libdvo/Makefile
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/libdvo/Makefile	(revision 31144)
+++ branches/eam_branches/ipp-20110213/Ohana/src/libdvo/Makefile	(revision 31145)
@@ -74,4 +74,5 @@
 $(SRC)/skyregion_ops.$(ARCH).o \
 $(SRC)/cmf-ps1-v1-alt.$(ARCH).o \
+$(SRC)/cmf-ps1-sv1-alt.$(ARCH).o \
 $(SRC)/dvo_util.$(ARCH).o
 
Index: branches/eam_branches/ipp-20110213/Ohana/src/libdvo/include/dvo.h
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/libdvo/include/dvo.h	(revision 31144)
+++ branches/eam_branches/ipp-20110213/Ohana/src/libdvo/include/dvo.h	(revision 31145)
@@ -199,4 +199,5 @@
 // special-case function:
 CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
+CMF_PS1_SV1 *gfits_table_get_CMF_PS1_SV1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
 
 typedef struct {
Index: branches/eam_branches/ipp-20110213/Ohana/src/libdvo/src/cmf-ps1-sv1-alt.c
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/libdvo/src/cmf-ps1-sv1-alt.c	(revision 31145)
+++ branches/eam_branches/ipp-20110213/Ohana/src/libdvo/src/cmf-ps1-sv1-alt.c	(revision 31145)
@@ -0,0 +1,149 @@
+# include "dvo.h"
+
+/* if we are not correctly including the ohana headers, this will fail */
+# ifndef BYTE_SWAP
+# ifndef NOT_BYTE_SWAP
+# error "neither BYTE_SWAP not NOT_BYTE_SWAP is set"
+# endif
+# endif
+
+CMF_PS1_SV1 *gfits_table_get_CMF_PS1_SV1_Alt (FTable *ftable, off_t *Ndata, char *swapped) {
+
+  off_t i, nitems;
+  unsigned char *byte, *inbyte, *otbyte, tmp;
+  CMF_PS1_SV1 *output;
+
+  /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */
+  i = tmp = 0;
+  byte = NULL;
+
+  // this function is a special case : it must have Nx = 196
+  if (ftable[0].header[0].Naxis[0] != 196) { 
+    fprintf (stderr, "ERROR: wrong format for CMF_PS1_SV1_Alt: "OFF_T_FMT" vs %d\n",  ftable[0].header[0].Naxis[0], 196);
+    return (NULL);
+  }
+
+  *Ndata = ftable[0].header[0].Naxis[1];
+  nitems = ftable[0].header[0].Naxis[1];
+
+  if ((swapped == NULL) || (*swapped == FALSE)) {
+
+# ifdef BYTE_SWAP
+      // we need to do the byte swap before applying the table scaling:
+      byte = (unsigned char *) ftable[0].buffer;
+      for (i = 0; i < nitems; i++, byte += 196) {
+	  /** BYTE SWAP **/
+	  SWAP_WORD (0  ); // IPP_IDET
+	  SWAP_WORD (4  ); // X_PSF
+	  SWAP_WORD (8  ); // Y_PSF
+	  SWAP_WORD (12 ); // X_PSF_SIG
+	  SWAP_WORD (16 ); // Y_PSF_SIG
+	  SWAP_WORD (20 ); // POSANGLE
+	  SWAP_WORD (24 ); // PLTSCALE
+	  SWAP_WORD (28 ); // PSF_INST_MAG    
+	  SWAP_WORD (32 ); // PSF_INST_MAG_SIG
+	  SWAP_WORD (36 ); // PSF_INST_FLUX    
+	  SWAP_WORD (40 ); // PSF_INST_FLUX_SIG
+	  SWAP_WORD (44 ); // AP_MAG_STANDARD
+	  SWAP_WORD (48 ); // AP_MAG_RAW
+	  SWAP_WORD (52 ); // AP_MAG_RADIUS  
+	  SWAP_WORD (56 ); // PEAK_FLUX_AS_MAG
+	  SWAP_WORD (60 ); // CAL_PSF_MAG     
+	  SWAP_WORD (64 ); // CAL_PSF_MAG_SIG 
+	  SWAP_DBLE (68 ); // RA_PSF
+	  SWAP_DBLE (76 ); // DEC_PSF
+	  SWAP_WORD (84 ); // SKY
+	  SWAP_WORD (88 ); // SKY_SIG
+	  SWAP_WORD (92 ); // PSF_CHISQ
+	  SWAP_WORD (96 ); // CR_NSIGMA
+	  SWAP_WORD (100); // EXT_NSIGMA
+	  SWAP_WORD (104); // PSF_MAJOR
+	  SWAP_WORD (108); // PSF_MINOR
+	  SWAP_WORD (112); // PSF_THETA
+	  SWAP_WORD (116); // PSF_QF
+	  SWAP_WORD (120); // PSF_QF_PERFECT
+	  SWAP_WORD (124); // PSF_NDOF	
+	  SWAP_WORD (128); // PSF_NPIX	
+	  SWAP_WORD (132); // MOMENTS_XX
+	  SWAP_WORD (136); // MOMENTS_XY
+	  SWAP_WORD (140); // MOMENTS_YY
+	  SWAP_WORD (144); // MOMENTS_M3C    
+	  SWAP_WORD (148); // MOMENTS_M3S    
+	  SWAP_WORD (152); // MOMENTS_M4C    
+	  SWAP_WORD (156); // MOMENTS_M4S    
+	  SWAP_WORD (160); // MOMENTS_R1     
+	  SWAP_WORD (164); // MOMENTS_RH     
+	  SWAP_WORD (168); // KRON_FLUX      
+	  SWAP_WORD (172); // KRON_FLUX_ERR  
+	  SWAP_WORD (176); // KRON_FLUX_INNER
+	  SWAP_WORD (180); // KRON_FLUX_OUTER
+	  SWAP_WORD (184); // FLAGS
+	  SWAP_WORD (188); // FLAGS2
+	  SWAP_BYTE (192); // N_FRAMES
+	  SWAP_BYTE (194); // PADDING
+      }
+# endif  
+
+      gfits_table_scale_data (ftable);
+      if (swapped != NULL) *swapped = TRUE;
+  }
+
+  byte = (unsigned char *) ftable[0].buffer;
+
+  // allocate a new output data buffer
+  ALLOCATE (output, CMF_PS1_SV1, nitems);
+  inbyte = (unsigned char *) byte;
+  otbyte = (unsigned char *) output;
+
+  // the data in the input table does not line up with the output structure: copy carefully.
+  for (i = 0; i < nitems; i++, inbyte += 196, otbyte += 200) {
+    memcpy (&otbyte[  0], &inbyte[  0],  56); // IPP_IDET to AP_MAG_RADIUS
+    memcpy (&otbyte[ 56], &inbyte[ 60],  24); // CAL_PSF_MAG to DEC_PSF
+    memcpy (&otbyte[ 80], &inbyte[ 56],   4); // PEAK_FLUX_AS_MAG
+    memcpy (&otbyte[ 84], &inbyte[ 84], 108); // SKY to FLAGS2
+    memcpy (&otbyte[194], &inbyte[192],   2); // N_FRAMES
+  }
+
+  free (ftable[0].buffer);
+  ftable[0].buffer = (char *) output;
+
+  // XXX other mods to make ftable consistent with CMF_PS1_V2? (Nx, EXTNAME?)
+
+  return (output);
+} 
+
+// data organization (input vs output)
+//              FITS                       struct
+// WORD  0      IPP_IDET              0    IPP_IDET                
+// WORD  4      X_PSF                 4    X_PSF                   
+// WORD  8      Y_PSF                 8    Y_PSF                   
+// WORD  12     X_PSF_SIG             12   X_PSF_SIG               
+// WORD  16     Y_PSF_SIG             16   Y_PSF_SIG               
+// DBLE  20     RA_PSF                20   POSANGLE                
+// DBLE  28     DEC_PSF               24   PLTSCALE                
+// WORD  36     POSANGLE              28   PSF_INST_MAG            
+// WORD  40     PLTSCALE              32   PSF_INST_MAG_SIG        
+// WORD  44     PSF_INST_MAG          36   AP_MAG_STANDARD         
+// WORD  48     PSF_INST_MAG_SIG      40   AP_MAG_RADIUS           
+// WORD  52     AP_MAG_STANDARD       44   PEAK_FLUX_AS_MAG        
+// WORD  56     AP_MAG_RADIUS         48   CAL_PSF_MAG             
+// WORD  60     PEAK_FLUX_AS_MAG      52   CAL_PSF_MAG_SIG         
+// WORD  64     CAL_PSF_MAG           56   RA_PSF                  
+// WORD  68     CAL_PSF_MAG_SIG       64   DEC_PSF                 
+// WORD  72     SKY                   72   SKY                     
+// WORD  76     SKY_SIG               76   SKY_SIG                 
+// WORD  80     PSF_CHISQ             80   PSF_CHISQ               
+// WORD  84     CR_NSIGMA             84   CR_NSIGMA               
+// WORD  88     EXT_NSIGMA            88   EXT_NSIGMA              
+// WORD  92     PSF_MAJOR             92   PSF_MAJOR               
+// WORD  96     PSF_MINOR             96   PSF_MINOR               
+// WORD  100    PSF_THETA             100  PSF_THETA               
+// WORD  104    PSF_QF                104  PSF_QF                  
+// WORD  108    PSF_NDOF              108  PSF_NDOF                
+// WORD  112    PSF_NPIX              112  PSF_NPIX                
+// WORD  116    MOMENTS_XX            116  MOMENTS_XX              
+// WORD  120    MOMENTS_XY            120  MOMENTS_XY              
+// WORD  124    MOMENTS_YY            124  MOMENTS_YY              
+// WORD  128    FLAGS                 128  FLAGS                   
+// BYTE  132    N_FRAMES              132  N_FRAMES                
+// BYTE  134    PADDING               134  PADDING                 
