Index: trunk/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 42389)
+++ trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 42477)
@@ -13,4 +13,5 @@
 Catalog *Convert_PS1_V4            PROTO((FTable *table));
 Catalog *Convert_PS1_V5            PROTO((FTable *table));
+Catalog *Convert_PS1_V5_R0         PROTO((FTable *table));
 Catalog *Convert_PS1_V5_R0_Lensing PROTO((FTable *table));
 Catalog *Convert_PS1_V5_R1_Lensing PROTO((FTable *table));
@@ -99,4 +100,7 @@
       case 232:
         catalog = Convert_PS1_V5 (&table);
+        break;
+      case 288:
+        catalog = Convert_PS1_V5_R0 (&table);
         break;
       case 312:
@@ -859,4 +863,88 @@
 }
 
+// alternate version of PS1_V5 (UNIONS TEST?)
+Catalog *Convert_PS1_V5_R0 (FTable *table) {
+
+  off_t Nstars; 
+  unsigned int i;
+  double ZeroPt;
+  CMF_PS1_V5_R0 *ps1data;
+
+  ps1data = gfits_table_get_CMF_PS1_V5_R0 (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
+  ZeroPt = GetZeroPoint();
+
+  Catalog *catalog = addstar_catalog_init (Nstars);
+
+  for (i = 0; i < Nstars; i++) {
+    catalog->measure[i].Xccd       = ps1data[i].X;
+    catalog->measure[i].Yccd       = ps1data[i].Y;
+    catalog->measure[i].dXccd      = ToShortPixels(ps1data[i].dX);
+    catalog->measure[i].dYccd      = ToShortPixels(ps1data[i].dY);
+
+    catalog->measure[i].posangle   = ToShortDegrees(ps1data[i].posangle);
+    catalog->measure[i].pltscale   = ps1data[i].pltscale;
+
+    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
+      catalog->measure[i].M      = NAN;
+    } else {
+      catalog->measure[i].M      = ps1data[i].M + ZeroPt;
+    }
+    catalog->measure[i].dM         = ps1data[i].dM;
+    catalog->measure[i].dMcal      = ps1data[i].dMcal;
+    catalog->measure[i].Map        = ps1data[i].Map + ZeroPt;
+    catalog->measure[i].dMap       = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;
+                        
+    catalog->measure[i].Mkron      = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;
+    catalog->measure[i].dMkron     = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;
+                        
+    // these fluxes are converted from counts to counts/sec in FilterStars.c
+    catalog->measure[i].FluxPSF    = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 
+    catalog->measure[i].dFluxPSF   = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM);
+    catalog->measure[i].FluxKron   = ps1data[i].kronFlux;
+    catalog->measure[i].dFluxKron  = ps1data[i].kronFluxErr;
+    catalog->measure[i].FluxAp     = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 
+    catalog->measure[i].dFluxAp    = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap);
+
+    catalog->measure[i].Sky        = ps1data[i].sky;
+    catalog->measure[i].dSky       = ps1data[i].dSky;
+                        
+    catalog->measure[i].psfChisq   = ps1data[i].psfChisq;
+    catalog->measure[i].psfQF      = ps1data[i].psfQF;
+    catalog->measure[i].psfQFperf  = ps1data[i].psfQFperf;
+
+    catalog->measure[i].psfNdof    = ps1data[i].psfNdof;
+    catalog->measure[i].psfNpix    = ps1data[i].psfNpix;
+    catalog->measure[i].extNsigma  = ps1data[i].extNsigma;
+
+    catalog->measure[i].FWx        = ToShortPixels(ps1data[i].fx);
+    catalog->measure[i].FWy        = ToShortPixels(ps1data[i].fy);
+    catalog->measure[i].theta      = ToShortDegrees(ps1data[i].df);
+
+    catalog->measure[i].Mxx        = ToShortPixels(ps1data[i].Mxx);
+    catalog->measure[i].Mxy        = ToShortPixels(ps1data[i].Mxy);
+    catalog->measure[i].Myy        = ToShortPixels(ps1data[i].Myy);
+                        
+    catalog->measure[i].photFlags  = ps1data[i].flags;
+    catalog->measure[i].photFlags2 = ps1data[i].flags2;
+
+    // this is may optionally be replaced by the internal sequence (see FilterStars.c)
+    catalog->measure[i].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
+  }    
+  return catalog;
+}
+
 Catalog *Convert_PS1_V5_R0_Lensing (FTable *table) {
 
