Index: /trunk/psModules/src/camera/pmFPAfileIO.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 34402)
+++ /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 34403)
@@ -38,4 +38,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/camera/pmReadoutFake.c
===================================================================
--- /trunk/psModules/src/camera/pmReadoutFake.c	(revision 34402)
+++ /trunk/psModules/src/camera/pmReadoutFake.c	(revision 34403)
@@ -26,4 +26,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/extras/pmVisual.c
===================================================================
--- /trunk/psModules/src/extras/pmVisual.c	(revision 34402)
+++ /trunk/psModules/src/extras/pmVisual.c	(revision 34403)
@@ -40,4 +40,5 @@
 // #include "pmSourceExtendedPars.h"
 // #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 // #include "pmSource.h"
 // #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/imcombine/pmPSFEnvelope.c
===================================================================
--- /trunk/psModules/src/imcombine/pmPSFEnvelope.c	(revision 34402)
+++ /trunk/psModules/src/imcombine/pmPSFEnvelope.c	(revision 34403)
@@ -26,4 +26,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/imcombine/pmSubtractionStamps.c
===================================================================
--- /trunk/psModules/src/imcombine/pmSubtractionStamps.c	(revision 34402)
+++ /trunk/psModules/src/imcombine/pmSubtractionStamps.c	(revision 34403)
@@ -25,4 +25,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 
Index: /trunk/psModules/src/objects/Makefile.am
===================================================================
--- /trunk/psModules/src/objects/Makefile.am	(revision 34402)
+++ /trunk/psModules/src/objects/Makefile.am	(revision 34403)
@@ -26,4 +26,5 @@
 	pmSourceDiffStats.c \
 	pmSourceExtendedPars.c \
+	pmSourceSatstar.c \
 	pmSourceUtils.c \
 	pmSourceSky.c \
@@ -47,6 +48,8 @@
 	pmSourceIO_CMF_PS1_V4.c \
 	pmSourceIO_CMF_PS1_SV1.c \
+	pmSourceIO_CMF_PS1_SV2.c \
 	pmSourceIO_CMF_PS1_DV1.c \
 	pmSourceIO_CMF_PS1_DV2.c \
+	pmSourceIO_CMF_PS1_DV3.c \
 	pmSourceIO_MatchedRefs.c \
 	pmSourcePlots.c \
@@ -99,4 +102,5 @@
 	pmSourceDiffStats.h \
 	pmSourceExtendedPars.h \
+	pmSourceSatstar.h \
 	pmSourceUtils.h \
 	pmSourceSky.h \
@@ -133,5 +137,14 @@
 
 # pmSourceID_CMF_* functions use a common framework
-BUILT_SOURCES = pmSourceIO_CMF_PS1_V1.c pmSourceIO_CMF_PS1_V2.c pmSourceIO_CMF_PS1_V3.c pmSourceIO_CMF_PS1_DV1.c pmSourceIO_CMF_PS1_DV2.c pmSourceIO_CMF_PS1_SV1.c
+BUILT_SOURCES = \
+pmSourceIO_CMF_PS1_V1.c \
+pmSourceIO_CMF_PS1_V2.c \
+pmSourceIO_CMF_PS1_V3.c \
+pmSourceIO_CMF_PS1_V4.c \
+pmSourceIO_CMF_PS1_DV1.c \
+pmSourceIO_CMF_PS1_DV2.c \
+pmSourceIO_CMF_PS1_DV3.c \
+pmSourceIO_CMF_PS1_SV1.c \
+pmSourceIO_CMF_PS1_SV2.c
 
 pmSourceIO_CMF_PS1_V1.c : pmSourceIO_CMF.c.in mksource.pl
@@ -153,6 +166,12 @@
 	mksource.pl pmSourceIO_CMF.c.in PS1_DV2 pmSourceIO_CMF_PS1_DV2.c
 
+pmSourceIO_CMF_PS1_DV3.c : pmSourceIO_CMF.c.in mksource.pl
+	mksource.pl pmSourceIO_CMF.c.in PS1_DV3 pmSourceIO_CMF_PS1_DV3.c
+
 pmSourceIO_CMF_PS1_SV1.c : pmSourceIO_CMF.c.in mksource.pl
 	mksource.pl pmSourceIO_CMF.c.in PS1_SV1 pmSourceIO_CMF_PS1_SV1.c
 
+pmSourceIO_CMF_PS1_SV2.c : pmSourceIO_CMF.c.in mksource.pl
+	mksource.pl pmSourceIO_CMF.c.in PS1_SV2 pmSourceIO_CMF_PS1_SV2.c
+
 # EXTRA_DIST = pmErrorCodes.h.in pmErrorCodes.dat pmErrorCodes.c.in
Index: /trunk/psModules/src/objects/mksource.pl
===================================================================
--- /trunk/psModules/src/objects/mksource.pl	(revision 34402)
+++ /trunk/psModules/src/objects/mksource.pl	(revision 34403)
@@ -14,9 +14,16 @@
 # validate the cmfmode
 
-# see if we can add in PS1_DV* and PS1_SV* as well...
-%cmfmodes = ("PS1_V1", 1,
-	     "PS1_V2", 2,
-	     "PS1_V3", 3,
-	     "PS1_V4", 4,
+# keep the series (V1,SV1,DV1) separate)
+%cmfmodes_v = ("PS1_V1", 1,
+	       "PS1_V2", 2,
+	       "PS1_V3", 3,
+	       "PS1_V4", 4,
+    );
+%cmfmodes_dv = ("PS1_DV1", 1,
+		"PS1_DV2", 2,
+		"PS1_DV3", 3,
+    );
+%cmfmodes_sv = ("PS1_SV1", 1,
+		"PS1_SV2", 2,
     );
 
@@ -118,8 +125,11 @@
 	if ($rule =~ m|^>=|) {
 	    print ">= rule: $rule\n" if $DEBUG;
-	    if ($cmfmodes{$cmfmode} == 0) { next; }
+	    # find the cmfmode series (v, dv, sv)
 	    $realrule = substr($rule,2);
-	    $thisLevel = $cmfmodes{$realrule};
-	    $myLevel = $cmfmodes{$cmfmode};
+	    %series = &cmf_series ($realrule);
+	    if (! %series) { next; }
+	    if ($series{$cmfmode} == 0) { next; }
+	    $thisLevel = $series{$realrule};
+	    $myLevel = $series{$cmfmode};
 	    print "levels: $cmfmode, $realrule, $myLevel, $thisLevel\n" if $DEBUG;
 	    if ($myLevel >= $thisLevel) { $keepLine = 1; }
@@ -130,8 +140,11 @@
 	if ($rule =~ m|^>|) {
 	    print "> rule: $rule\n" if $DEBUG;
-	    if ($cmfmodes{$cmfmode} == 0) { next; }
+	    # find the cmfmode series (v, dv, sv)
 	    $realrule = substr($rule,1);
-	    $thisLevel = $cmfmodes{$realrule};
-	    $myLevel = $cmfmodes{$cmfmode};
+	    %series = &cmf_series ($realrule);
+	    if (! %series) { next; }
+	    if ($series{$cmfmode} == 0) { next; }
+	    $thisLevel = $series{$realrule};
+	    $myLevel = $series{$cmfmode};
 	    print "levels: $cmfmode, $realrule, $myLevel, $thisLevel\n" if $DEBUG;
 	    if ($myLevel > $thisLevel) { $keepLine = 1; }
@@ -142,8 +155,11 @@
 	if ($rule =~ m|^<=|) {
 	    print "<= rule: $rule\n" if $DEBUG;
-	    if ($cmfmodes{$cmfmode} == 0) { next; }
+	    # find the cmfmode series (v, dv, sv)
 	    $realrule = substr($rule,2);
-	    $thisLevel = $cmfmodes{$realrule};
-	    $myLevel = $cmfmodes{$cmfmode};
+	    %series = &cmf_series ($realrule);
+	    if (! %series) { next; }
+	    if ($series{$cmfmode} == 0) { next; }
+	    $thisLevel = $series{$realrule};
+	    $myLevel = $series{$cmfmode};
 	    print "levels: $cmfmode, $realrule, $myLevel, $thisLevel\n" if $DEBUG;
 	    if ($myLevel <= $thisLevel) { $keepLine = 1; }
@@ -154,8 +170,11 @@
 	if ($rule =~ m|^<|) {
 	    print "< rule: $rule\n" if $DEBUG;
-	    if ($cmfmodes{$cmfmode} == 0) { next; }
+	    # find the cmfmode series (v, dv, sv)
 	    $realrule = substr($rule,1);
-	    $thisLevel = $cmfmodes{$realrule};
-	    $myLevel = $cmfmodes{$cmfmode};
+	    %series = &cmf_series ($realrule);
+	    if (! %series) { next; }
+	    if ($series{$cmfmode} == 0) { next; }
+	    $thisLevel = $series{$realrule};
+	    $myLevel = $series{$cmfmode};
 	    print "levels: $cmfmode, $realrule, $myLevel, $thisLevel\n" if $DEBUG;
 	    if ($myLevel < $thisLevel) { $keepLine = 1; }
@@ -174,2 +193,12 @@
 
 exit 0;
+
+sub cmf_series {
+
+    my ($rule) = $_[0];
+
+    if ($cmfmodes_v{$rule})  { return %cmfmodes_v;  }
+    if ($cmfmodes_sv{$rule}) { return %cmfmodes_sv; }
+    if ($cmfmodes_dv{$rule}) { return %cmfmodes_dv; }
+    return 0;
+}
Index: /trunk/psModules/src/objects/models/pmModel_DEV.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_DEV.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_DEV.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_EXP.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_EXP.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_EXP.c	(revision 34403)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_GAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_GAUSS.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_GAUSS.c	(revision 34403)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_PGAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_PGAUSS.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_PGAUSS.c	(revision 34403)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_PS1_V1.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_PS1_V1.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_PS1_V1.c	(revision 34403)
@@ -40,4 +40,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_QGAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_QGAUSS.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_QGAUSS.c	(revision 34403)
@@ -40,4 +40,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_RGAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_RGAUSS.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_RGAUSS.c	(revision 34403)
@@ -40,4 +40,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_SERSIC.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_SERSIC.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_SERSIC.c	(revision 34403)
@@ -49,4 +49,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/models/pmModel_TRAIL.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_TRAIL.c	(revision 34402)
+++ /trunk/psModules/src/objects/models/pmModel_TRAIL.c	(revision 34403)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmDetEff.c
===================================================================
--- /trunk/psModules/src/objects/pmDetEff.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmDetEff.c	(revision 34403)
@@ -23,4 +23,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmGrowthCurve.c
===================================================================
--- /trunk/psModules/src/objects/pmGrowthCurve.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmGrowthCurve.c	(revision 34403)
@@ -36,4 +36,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmGrowthCurveGenerate.c
===================================================================
--- /trunk/psModules/src/objects/pmGrowthCurveGenerate.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmGrowthCurveGenerate.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmModelUtils.c
===================================================================
--- /trunk/psModules/src/objects/pmModelUtils.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmModelUtils.c	(revision 34403)
@@ -38,4 +38,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPCM_MinimizeChisq.c
===================================================================
--- /trunk/psModules/src/objects/pmPCM_MinimizeChisq.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPCM_MinimizeChisq.c	(revision 34403)
@@ -37,4 +37,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPCMdata.c
===================================================================
--- /trunk/psModules/src/objects/pmPCMdata.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPCMdata.c	(revision 34403)
@@ -37,4 +37,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPSF.c
===================================================================
--- /trunk/psModules/src/objects/pmPSF.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSF.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPSF_IO.c
===================================================================
--- /trunk/psModules/src/objects/pmPSF_IO.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSF_IO.c	(revision 34403)
@@ -53,4 +53,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPSFtry.c
===================================================================
--- /trunk/psModules/src/objects/pmPSFtry.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSFtry.c	(revision 34403)
@@ -35,4 +35,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPSFtryFitEXT.c
===================================================================
--- /trunk/psModules/src/objects/pmPSFtryFitEXT.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSFtryFitEXT.c	(revision 34403)
@@ -35,4 +35,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceUtils.h"
Index: /trunk/psModules/src/objects/pmPSFtryFitPSF.c
===================================================================
--- /trunk/psModules/src/objects/pmPSFtryFitPSF.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSFtryFitPSF.c	(revision 34403)
@@ -33,4 +33,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPSFtryMakePSF.c
===================================================================
--- /trunk/psModules/src/objects/pmPSFtryMakePSF.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSFtryMakePSF.c	(revision 34403)
@@ -34,4 +34,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPSFtryMetric.c
===================================================================
--- /trunk/psModules/src/objects/pmPSFtryMetric.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSFtryMetric.c	(revision 34403)
@@ -34,4 +34,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPSFtryModel.c
===================================================================
--- /trunk/psModules/src/objects/pmPSFtryModel.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPSFtryModel.c	(revision 34403)
@@ -35,4 +35,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmPhotObj.c
===================================================================
--- /trunk/psModules/src/objects/pmPhotObj.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmPhotObj.c	(revision 34403)
@@ -35,4 +35,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 
Index: /trunk/psModules/src/objects/pmSource.c
===================================================================
--- /trunk/psModules/src/objects/pmSource.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSource.c	(revision 34403)
@@ -40,4 +40,5 @@
 #include "pmSourceDiffStats.h"
 #include "pmSourcePhotometry.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 
@@ -61,9 +62,9 @@
     psFree(tmp->modelFits);
     psFree(tmp->extFitPars);
+    psFree(tmp->blends);
+    psFree(tmp->satstar);
     psFree(tmp->extpars);
-    psFree(tmp->moments);
     psFree(tmp->diffStats);
     psFree(tmp->radialAper);
-    psFree(tmp->blends);
     psTrace("psModules.objects", 10, "---- end ----\n");
 }
@@ -160,4 +161,5 @@
     source->region = psRegionSet(NAN, NAN, NAN, NAN);
     source->blends = NULL;
+    source->satstar = NULL;
     source->extpars = NULL;
     source->diffStats = NULL;
@@ -650,4 +652,13 @@
         if (source->peak->y >= region->y1) continue;
 
+# define DEBUG 0
+# define TEST_X 2792
+# define TEST_Y 1741
+# if (DEBUG) 
+	if ((fabs(source->peak->x - TEST_X) < 5) && (fabs(source->peak->y - TEST_Y) < 5)) {
+	  fprintf (stderr, "test peak\n");
+	}
+# endif	
+
         // should be set by pmSourceAlloc
         psAssert (source->type == PM_SOURCE_TYPE_UNKNOWN, "source type was not init-ed?");
@@ -665,4 +676,5 @@
 
         // XXX EAM : can we use the value of SATURATE if mask is NULL?
+	// XXX a 5x5 box centered on the peak is a rather small region to check for
         inner = psRegionForSquare (source->peak->x, source->peak->y, 2);
         inner = psRegionForImage (source->maskView, inner);
Index: /trunk/psModules/src/objects/pmSource.h
===================================================================
--- /trunk/psModules/src/objects/pmSource.h	(revision 34402)
+++ /trunk/psModules/src/objects/pmSource.h	(revision 34403)
@@ -114,4 +114,5 @@
     psRegion region;                    ///< area on image covered by selected pixels
     psArray *blends;                    ///< collection of sources thought to be confused with object
+    pmSourceSatstar *satstar;
     pmSourceExtendedPars *extpars;      ///< extended source parameters
     pmSourceDiffStats *diffStats;       ///< extra parameters for difference detections
Index: /trunk/psModules/src/objects/pmSourceContour.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceContour.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceContour.c	(revision 34403)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 
Index: /trunk/psModules/src/objects/pmSourceExtendedPars.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceExtendedPars.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceExtendedPars.c	(revision 34403)
@@ -190,4 +190,7 @@
 bool pmSourceRadialProfileSortPair (psVector *index, psVector *extra) {
 
+    psAssert (index->n == extra->n, "mismatched vector lengths");
+    if (index->n < 2) return true;
+
     // sort the vector set by the radius
     PSSORT (index->n, COMPARE_INDEX, SWAP_INDEX, NONE);
Index: /trunk/psModules/src/objects/pmSourceFitModel.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceFitModel.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceFitModel.c	(revision 34403)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourcePhotometry.h"
Index: /trunk/psModules/src/objects/pmSourceFitPCM.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceFitPCM.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceFitPCM.c	(revision 34403)
@@ -37,4 +37,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourcePhotometry.h"
Index: /trunk/psModules/src/objects/pmSourceFitSet.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceFitSet.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceFitSet.c	(revision 34403)
@@ -38,4 +38,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourcePhotometry.h"
Index: /trunk/psModules/src/objects/pmSourceGroups.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceGroups.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceGroups.c	(revision 34403)
@@ -24,4 +24,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO.c	(revision 34403)
@@ -46,4 +46,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
@@ -574,6 +575,8 @@
 	    PM_SOURCES_WRITE("PS1_V4",    CMF_PS1_V4);
 	    PM_SOURCES_WRITE("PS1_SV1",   CMF_PS1_SV1);
+	    PM_SOURCES_WRITE("PS1_SV2",   CMF_PS1_SV2);
 	    PM_SOURCES_WRITE("PS1_DV1",   CMF_PS1_DV1);
 	    PM_SOURCES_WRITE("PS1_DV2",   CMF_PS1_DV2);
+	    PM_SOURCES_WRITE("PS1_DV3",   CMF_PS1_DV3);
 
 	    psFree (outhead);
@@ -1047,6 +1050,8 @@
 	    PM_SOURCES_READ_PSF("PS1_V4",    CMF_PS1_V4);
 	    PM_SOURCES_READ_PSF("PS1_SV1",   CMF_PS1_SV1);
+	    PM_SOURCES_READ_PSF("PS1_SV2",   CMF_PS1_SV2);
 	    PM_SOURCES_READ_PSF("PS1_DV1",   CMF_PS1_DV1);
 	    PM_SOURCES_READ_PSF("PS1_DV2",   CMF_PS1_DV2);
+	    PM_SOURCES_READ_PSF("PS1_DV3",   CMF_PS1_DV3);
 
             long *sourceIndex = NULL;
@@ -1253,6 +1258,8 @@
 	PM_SOURCES_READ_XSRC("PS1_V4",    CMF_PS1_V4);
 	PM_SOURCES_READ_XSRC("PS1_SV1",   CMF_PS1_SV1);
+	PM_SOURCES_READ_XSRC("PS1_SV2",   CMF_PS1_SV2);
 	PM_SOURCES_READ_XSRC("PS1_DV1",   CMF_PS1_DV1);
 	PM_SOURCES_READ_XSRC("PS1_DV2",   CMF_PS1_DV2);
+	PM_SOURCES_READ_XSRC("PS1_DV3",   CMF_PS1_DV3);
     }
     psFree(tableHeader);
@@ -1289,6 +1296,8 @@
 	PM_SOURCES_READ_XFIT("PS1_V4",    CMF_PS1_V4);
 	PM_SOURCES_READ_XFIT("PS1_SV1",   CMF_PS1_SV1);
+	PM_SOURCES_READ_XFIT("PS1_SV2",   CMF_PS1_SV2);
 	PM_SOURCES_READ_XFIT("PS1_DV1",   CMF_PS1_DV1);
 	PM_SOURCES_READ_XFIT("PS1_DV2",   CMF_PS1_DV2);
+	PM_SOURCES_READ_XFIT("PS1_DV3",   CMF_PS1_DV3);
     }
     psFree(tableHeader);
@@ -1324,6 +1333,8 @@
 	PM_SOURCES_READ_XRAD("PS1_V4",    CMF_PS1_V4);
 	PM_SOURCES_READ_XRAD("PS1_SV1",   CMF_PS1_SV1);
+	PM_SOURCES_READ_XRAD("PS1_SV2",   CMF_PS1_SV2);
 	PM_SOURCES_READ_XRAD("PS1_DV1",   CMF_PS1_DV1);
 	PM_SOURCES_READ_XRAD("PS1_DV2",   CMF_PS1_DV2);
+	PM_SOURCES_READ_XRAD("PS1_DV3",   CMF_PS1_DV3);
     }
     psFree(tableHeader);
Index: /trunk/psModules/src/objects/pmSourceIO.h
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO.h	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO.h	(revision 34403)
@@ -36,6 +36,8 @@
 MK_PROTO(CMF_PS1_V4);
 MK_PROTO(CMF_PS1_SV1);
+MK_PROTO(CMF_PS1_SV2);
 MK_PROTO(CMF_PS1_DV1);
 MK_PROTO(CMF_PS1_DV2);
+MK_PROTO(CMF_PS1_DV3);
 
 int pmSourceGetDophotType (pmSource *source);
Index: /trunk/psModules/src/objects/pmSourceIO_CMF.c.in
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
@@ -135,9 +136,9 @@
 	@ALL,!PS1_V1,!PS1_V2@     psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux",             source->psfFluxErr);
 
-        @ALL@      		  psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",             source->apMag);
-	@>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW",       PS_DATA_F32, "magnitude in reported aperture",             source->apMagRaw);
-        @ALL@      		  psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",              outputs.apRadius);
-	@PS1_DV2@ 		  psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX",          PS_DATA_F32, "instrumental flux in standard aperture",     source->apFlux);
-	@PS1_DV2@ 		  psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX_SIG",      PS_DATA_F32, "aperture flux error",                        source->apFluxErr);
+        @ALL@      		    psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",             source->apMag);
+	@>PS1_V2,PS1_SV?,>PS1_DV1@  psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW",       PS_DATA_F32, "magnitude in reported aperture",             source->apMagRaw);
+        @ALL@      		    psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",              outputs.apRadius);
+	@>PS1_DV1,>PS1_V3,>PS1_SV1@ psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX",          PS_DATA_F32, "instrumental flux in standard aperture",     source->apFlux);
+	@>PS1_DV1,>PS1_V3,>PS1_SV1@ psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX_SIG",      PS_DATA_F32, "aperture flux error",                        source->apFluxErr);
 
 	@<PS1_V3,PS1_SV1,PS1_DV?@ psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           outputs.peakMag);
@@ -150,5 +151,5 @@
 	@ALL,!PS1_V1@             psMetadataAdd (row, PS_LIST_TAIL, "DEC_PSF",          PS_DATA_F64, "PSF DEC coordinate (degrees)",               outputs.dec);
 
-	@>=PS1_V3@ 		  psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           outputs.peakMag);
+	@>=PS1_V3,>PS1_SV1@	  psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           outputs.peakMag);
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "SKY",              PS_DATA_F32, "Sky level",                                  source->sky);
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "SKY_SIGMA",        PS_DATA_F32, "Sigma of sky level",                         source->skyErr);
@@ -162,5 +163,5 @@
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "PSF_THETA",        PS_DATA_F32, "PSF orientation angle",                      outputs.psfTheta);
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF",           PS_DATA_F32, "PSF coverage/quality factor (bad)",          source->pixWeightNotBad);
-	@>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF_PERFECT",   PS_DATA_F32, "PSF coverage/quality factor (poor)",         source->pixWeightNotPoor);
+	@>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF_PERFECT",   PS_DATA_F32, "PSF coverage/quality factor (poor)",         source->pixWeightNotPoor);
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "PSF_NDOF",         PS_DATA_S32, "degrees of freedom",                         outputs.nDOF);
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "PSF_NPIX",         PS_DATA_S32, "number of pixels in fit",                    outputs.nPix);
@@ -170,15 +171,15 @@
         @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_YY",       PS_DATA_F32, "second moments (Y*Y)",                       moments.Myy);
 
-	@>PS1_V2,PS1_SV1@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M3C",      PS_DATA_F32, "third momemt cos theta",                     moments.M_c3);
-	@>PS1_V2,PS1_SV1@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M3S",      PS_DATA_F32, "third momemt sin theta",                     moments.M_s3);
-	@>PS1_V2,PS1_SV1@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M4C",      PS_DATA_F32, "fourth momemt cos theta",                    moments.M_c4);
-	@>PS1_V2,PS1_SV1@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M4S",      PS_DATA_F32, "fourth momemt sin theta",                    moments.M_s4);
-
-        @>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_R1",       PS_DATA_F32, "first radial moment",                        moments.Mrf);
-        @>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_RH",       PS_DATA_F32, "half radial moment",                         moments.Mrh);
-        @>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX",        PS_DATA_F32, "Kron Flux (in 2.5 R1)",                      moments.Krf);
-        @>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_ERR",    PS_DATA_F32, "Kron Flux Error",                            moments.dKrf);
-        @>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER",  PS_DATA_F32, "Kron Flux (in 1.0 R1)",                      moments.Kinner);
-        @>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER",  PS_DATA_F32, "Kron Flux (in 4.0 R1)",                      moments.Kouter);
+	@>PS1_V2,PS1_SV?@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M3C",      PS_DATA_F32, "third momemt cos theta",                     moments.M_c3);
+	@>PS1_V2,PS1_SV?@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M3S",      PS_DATA_F32, "third momemt sin theta",                     moments.M_s3);
+	@>PS1_V2,PS1_SV?@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M4C",      PS_DATA_F32, "fourth momemt cos theta",                    moments.M_c4);
+	@>PS1_V2,PS1_SV?@ 	  psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M4S",      PS_DATA_F32, "fourth momemt sin theta",                    moments.M_s4);
+
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_R1",       PS_DATA_F32, "first radial moment",                        moments.Mrf);
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_RH",       PS_DATA_F32, "half radial moment",                         moments.Mrh);
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX",        PS_DATA_F32, "Kron Flux (in 2.5 R1)",                      moments.Krf);
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_ERR",    PS_DATA_F32, "Kron Flux Error",                            moments.dKrf);
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER",  PS_DATA_F32, "Kron Flux (in 1.0 R1)",                      moments.Kinner);
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER",  PS_DATA_F32, "Kron Flux (in 4.0 R1)",                      moments.Kouter);
 
         @>PS1_V3@ 		  psMetadataAdd (row, PS_LIST_TAIL, "SKY_LIMIT_RAD",    PS_DATA_F32, "Radius where object hits sky",               source->skyRadius);
@@ -197,9 +198,8 @@
         @PS1_DV2@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_M",        PS_DATA_F32, "signal-to-noise of neg match src",           diffStats.SNm);
 
-        @ALL@     		  psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U32, "psphot analysis flags",                      source->mode);
-	@>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags",                      source->mode2);
-	// @>PS1_V2,PS1_SV1,PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags",                      source->mode2 | (source->id<<8));
-	@>PS1_V2@                 psMetadataAdd (row, PS_LIST_TAIL, "PADDING2",         PS_DATA_S32, "more padding", 0);
-	@PS1_SV1@
+        @ALL@     		   psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U32, "psphot analysis flags",                      source->mode);
+	@>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags",                      source->mode2);
+	@PS1_V3,PS1_SV2@           psMetadataAdd (row, PS_LIST_TAIL, "PADDING2",         PS_DATA_S32, "more padding", 0);
+	@PS1_SV?@
 
 	  // note that this definition is inconsistent with the definition in
@@ -316,10 +316,10 @@
         @ALL@     source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
         @ALL@     source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->apMagRaw  = psMetadataLookupF32 (&status, row, "AP_MAG_RAW");
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->apMagRaw  = psMetadataLookupF32 (&status, row, "AP_MAG_RAW");
 
         // XXX use these to determine PAR[PM_PAR_I0] if they exist?
 	// XXX add these to PS1_SV1?
-	@>PS1_V2,PS1_SV1,PS1_DV?@ source->psfFlux   = psMetadataLookupF32 (&status, row, "PSF_INST_FLUX");
-	@>PS1_V2,PS1_SV1,PS1_DV?@ source->psfFluxErr= psMetadataLookupF32 (&status, row, "PSF_INST_FLUX_SIG");
+	@>PS1_V2,PS1_SV?,PS1_DV?@ source->psfFlux   = psMetadataLookupF32 (&status, row, "PSF_INST_FLUX");
+	@>PS1_V2,PS1_SV?,PS1_DV?@ source->psfFluxErr= psMetadataLookupF32 (&status, row, "PSF_INST_FLUX_SIG");
 
         // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
@@ -342,5 +342,5 @@
 
         @ALL@     source->pixWeightNotBad = psMetadataLookupF32 (&status, row, "PSF_QF");
-	@>PS1_V2,PS1_SV1,PS1_DV2@ source->pixWeightNotPoor = psMetadataLookupF32 (&status, row, "PSF_QF_PERFECT");
+	@>PS1_V2,PS1_SV?,>PS1_DV1@ source->pixWeightNotPoor = psMetadataLookupF32 (&status, row, "PSF_QF_PERFECT");
         @ALL@     source->crNsigma  = psMetadataLookupF32 (&status, row, "CR_NSIGMA");
         @ALL@     source->extNsigma = psMetadataLookupF32 (&status, row, "EXT_NSIGMA");
@@ -362,21 +362,21 @@
 	// XXX we do not save all of the 3rd and 4th moment parameters. when we load in data,
 	// we are storing enough information so the output will be consistent with the input
-        @>PS1_V2,PS1_SV1@ source->moments->Mxxx = +1.0 * psMetadataLookupF32 (&status, row, "MOMENTS_M3C");
-        @>PS1_V2,PS1_SV1@ source->moments->Mxxy = 0.0;
-        @>PS1_V2,PS1_SV1@ source->moments->Mxyy = 0.0;
-        @>PS1_V2,PS1_SV1@ source->moments->Myyy = -1.0 * psMetadataLookupF32 (&status, row, "MOMENTS_M3S");
-
-        @>PS1_V2,PS1_SV1@ source->moments->Mxxxx = +1.00 * psMetadataLookupF32 (&status, row, "MOMENTS_M4C");
-        @>PS1_V2,PS1_SV1@ source->moments->Mxxxy = 0.0;
-        @>PS1_V2,PS1_SV1@ source->moments->Mxxyy = 0.0;
-        @>PS1_V2,PS1_SV1@ source->moments->Mxyyy = -0.25 * psMetadataLookupF32 (&status, row, "MOMENTS_M4S");
-        @>PS1_V2,PS1_SV1@ source->moments->Myyyy = 0.0;
-
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->moments->Mrf         = psMetadataLookupF32 (&status, row, "MOMENTS_R1");
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->moments->Mrh         = psMetadataLookupF32 (&status, row, "MOMENTS_RH");
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->moments->KronFlux    = psMetadataLookupF32 (&status, row, "KRON_FLUX");
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->moments->KronFluxErr = psMetadataLookupF32 (&status, row, "KRON_FLUX_ERR");
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->moments->KronFinner  = psMetadataLookupF32 (&status, row, "KRON_FLUX_INNER");
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->moments->KronFouter  = psMetadataLookupF32 (&status, row, "KRON_FLUX_OUTER");
+        @>PS1_V2,PS1_SV?@ source->moments->Mxxx = +1.0 * psMetadataLookupF32 (&status, row, "MOMENTS_M3C");
+        @>PS1_V2,PS1_SV?@ source->moments->Mxxy = 0.0;
+        @>PS1_V2,PS1_SV?@ source->moments->Mxyy = 0.0;
+        @>PS1_V2,PS1_SV?@ source->moments->Myyy = -1.0 * psMetadataLookupF32 (&status, row, "MOMENTS_M3S");
+
+        @>PS1_V2,PS1_SV?@ source->moments->Mxxxx = +1.00 * psMetadataLookupF32 (&status, row, "MOMENTS_M4C");
+        @>PS1_V2,PS1_SV?@ source->moments->Mxxxy = 0.0;
+        @>PS1_V2,PS1_SV?@ source->moments->Mxxyy = 0.0;
+        @>PS1_V2,PS1_SV?@ source->moments->Mxyyy = -0.25 * psMetadataLookupF32 (&status, row, "MOMENTS_M4S");
+        @>PS1_V2,PS1_SV?@ source->moments->Myyyy = 0.0;
+
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->moments->Mrf         = psMetadataLookupF32 (&status, row, "MOMENTS_R1");
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->moments->Mrh         = psMetadataLookupF32 (&status, row, "MOMENTS_RH");
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->moments->KronFlux    = psMetadataLookupF32 (&status, row, "KRON_FLUX");
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->moments->KronFluxErr = psMetadataLookupF32 (&status, row, "KRON_FLUX_ERR");
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->moments->KronFinner  = psMetadataLookupF32 (&status, row, "KRON_FLUX_INNER");
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->moments->KronFouter  = psMetadataLookupF32 (&status, row, "KRON_FLUX_OUTER");
 
         @>PS1_V3@ source->skyRadius            = psMetadataLookupF32 (&status, row, "SKY_LIMIT_RAD");
@@ -393,13 +393,13 @@
 	@PS1_DV?@      source->diffStats->nRatioAll  = psMetadataLookupF32 (&status, row, "DIFF_NRATIO_ALL");
 	
-	@PS1_DV2@      source->diffStats->Rp         = psMetadataLookupF32 (&status, row, "DIFF_R_P");
-	@PS1_DV2@      source->diffStats->SNp        = psMetadataLookupF32 (&status, row, "DIFF_SN_P");
-	@PS1_DV2@      source->diffStats->Rm         = psMetadataLookupF32 (&status, row, "DIFF_R_M");
-	@PS1_DV2@      source->diffStats->SNm        = psMetadataLookupF32 (&status, row, "DIFF_SN_M");
+	@>PS1_DV1@      source->diffStats->Rp         = psMetadataLookupF32 (&status, row, "DIFF_R_P");
+	@>PS1_DV1@      source->diffStats->SNp        = psMetadataLookupF32 (&status, row, "DIFF_SN_P");
+	@>PS1_DV1@      source->diffStats->Rm         = psMetadataLookupF32 (&status, row, "DIFF_R_M");
+	@>PS1_DV1@      source->diffStats->SNm        = psMetadataLookupF32 (&status, row, "DIFF_SN_M");
 	@PS1_DV?@  }
 
-        @ALL@                     source->mode       = psMetadataLookupU32 (&status, row, "FLAGS");
-        @>PS1_V2,PS1_SV1,PS1_DV2@ source->mode2      = psMetadataLookupU32 (&status, row, "FLAGS2");
-        @ALL@                     source->nFrames    = psMetadataLookupU16 (&status, row, "N_FRAMES");
+        @ALL@                      source->mode       = psMetadataLookupU32 (&status, row, "FLAGS");
+        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->mode2      = psMetadataLookupU32 (&status, row, "FLAGS2");
+        @ALL@                      source->nFrames    = psMetadataLookupU16 (&status, row, "N_FRAMES");
         assert (status);
 
@@ -735,4 +735,6 @@
     }
 
+    @>PS1_DV2@ pmChip *chip = readout->parent->parent;
+
     table = psArrayAllocEmpty (sources->n);
 
@@ -768,4 +770,11 @@
             yErr = dPAR[PM_PAR_YPOS];
 
+	    @>PS1_DV2@ psSphere ptSky = {0.0, 0.0, 0.0, 0.0};
+	    @>PS1_DV2@ float posAngle = 0.0;
+	    @>PS1_DV2@ float pltScale = 0.0;
+	    @>PS1_DV2@ pmSourceLocalAstrometry (&ptSky, &posAngle, &pltScale, chip, xPos, yPos);
+	    @>PS1_DV2@ double raPos = ptSky.r*PS_DEG_RAD;
+	    @>PS1_DV2@ double decPos = ptSky.d*PS_DEG_RAD;
+
 	    float kronFlux = source->moments ? source->moments->KronFlux : NAN;
 	    float kronMag = isfinite(kronFlux) ? -2.5*log10(kronFlux) : NAN;
@@ -779,6 +788,11 @@
             psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG",        0, "Sigma in EXT x coordinate",                  xErr);
             psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG",        0, "Sigma in EXT y coordinate",                  yErr);
+            @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT",           0, "EXT model ra coordinate",                    raPos);
+            @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT",          0, "EXT model dec coordinate",                   decPos);
             psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG",     0, "EXT fit instrumental magnitude",             model->mag);
             psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude",        model->magErr);
+
+            @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "POSANGLE",   0, "position angle at source (degrees)",         posAngle);
+	    @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "PLTSCALE",   0, "plate scale at source (arcsec/pixel)",       pltScale);
 
             // psMetadataAddF32 (row, PS_LIST_TAIL, "MOMENTS_XX",       0, "second moment in x",                      extPars->Mxx);
@@ -792,5 +806,6 @@
             psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_MAG",         0, "Kron Mag",                                   kronMag);
 
-            psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
+            @ALL, <PS1_DV3@ psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
+            @>PS1_DV2@       psMetadataAddS32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
             psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE",       0, "name of model",                              pmModelClassGetName (model->type));
 
Index: /trunk/psModules/src/objects/pmSourceIO_CMP.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_CMP.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_CMP.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_MatchedRefs.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_MatchedRefs.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_MatchedRefs.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_OBJ.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_OBJ.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_OBJ.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_RAW.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_RAW.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_RAW.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_SMPDATA.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_SMPDATA.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_SMPDATA.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceIO_SX.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_SX.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceIO_SX.c	(revision 34403)
@@ -43,4 +43,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceMasks.h
===================================================================
--- /trunk/psModules/src/objects/pmSourceMasks.h	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceMasks.h	(revision 34403)
@@ -5,36 +5,36 @@
 // When adding to or subtracting from this list, please also modify pmSourceMaskHeader
 typedef enum {
-    PM_SOURCE_MODE_DEFAULT          = 0x00000000, ///< Initial value: resets all bits
-    PM_SOURCE_MODE_PSFMODEL         = 0x00000001, ///< Source fitted with a psf model (linear or non-linear)
-    PM_SOURCE_MODE_EXTMODEL         = 0x00000002, ///< Source fitted with an extended-source model
-    PM_SOURCE_MODE_FITTED           = 0x00000004, ///< Source fitted with non-linear model (PSF or EXT; good or bad)
-    PM_SOURCE_MODE_FAIL             = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero)
-    PM_SOURCE_MODE_POOR             = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?)
-    PM_SOURCE_MODE_PAIR             = 0x00000020, ///< Source fitted with a double psf
-    PM_SOURCE_MODE_PSFSTAR          = 0x00000040, ///< Source used to define PSF model
-    PM_SOURCE_MODE_SATSTAR          = 0x00000080, ///< Source model peak is above saturation
-    PM_SOURCE_MODE_BLEND            = 0x00000100, ///< Source is a blend with other sources
-    PM_SOURCE_MODE_EXTERNAL         = 0x00000200, ///< Source based on supplied input position
-    PM_SOURCE_MODE_BADPSF           = 0x00000400, ///< Failed to get good estimate of object's PSF
-    PM_SOURCE_MODE_DEFECT           = 0x00000800, ///< Source is thought to be a defect
-    PM_SOURCE_MODE_SATURATED        = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail)
-    PM_SOURCE_MODE_CR_LIMIT         = 0x00002000, ///< Source has crNsigma above limit
-    PM_SOURCE_MODE_EXT_LIMIT        = 0x00004000, ///< Source has extNsigma above limit
-    PM_SOURCE_MODE_MOMENTS_FAILURE  = 0x00008000, ///< could not measure the moments
-    PM_SOURCE_MODE_SKY_FAILURE      = 0x00010000, ///< could not measure the local sky
-    PM_SOURCE_MODE_SKYVAR_FAILURE   = 0x00020000, ///< could not measure the local sky variance
-    PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N
-    PM_SOURCE_MODE_BIG_RADIUS       = 0x00100000, ///< poor moments for small radius, try large radius
-    PM_SOURCE_MODE_AP_MAGS          = 0x00200000, ///< source has an aperture magnitude
-    PM_SOURCE_MODE_BLEND_FIT        = 0x00400000, ///< source was fitted as a blend
-    PM_SOURCE_MODE_EXTENDED_FIT     = 0x00800000, ///< full extended fit was used
-    PM_SOURCE_MODE_EXTENDED_STATS   = 0x01000000, ///< extended aperture stats calculated
-    PM_SOURCE_MODE_LINEAR_FIT       = 0x02000000, ///< source fitted with the linear fit
-    PM_SOURCE_MODE_NONLINEAR_FIT    = 0x04000000, ///< source fitted with the non-linear fit
-    PM_SOURCE_MODE_RADIAL_FLUX      = 0x08000000, ///< radial flux measurements calculated
-    PM_SOURCE_MODE_SIZE_SKIPPED     = 0x10000000, ///< size could not be determined
-    PM_SOURCE_MODE_ON_SPIKE         = 0x20000000, ///< peak lands on diffraction spike
-    PM_SOURCE_MODE_ON_GHOST         = 0x40000000, ///< peak lands on ghost or glint
-    PM_SOURCE_MODE_OFF_CHIP         = 0x80000000, ///< peak lands off edge of chip
+    PM_SOURCE_MODE_DEFAULT          	  = 0x00000000, ///< Initial value: resets all bits
+    PM_SOURCE_MODE_PSFMODEL         	  = 0x00000001, ///< Source fitted with a psf model (linear or non-linear)
+    PM_SOURCE_MODE_EXTMODEL         	  = 0x00000002, ///< Source fitted with an extended-source model
+    PM_SOURCE_MODE_FITTED           	  = 0x00000004, ///< Source fitted with non-linear model (PSF or EXT; good or bad)
+    PM_SOURCE_MODE_FAIL             	  = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero)
+    PM_SOURCE_MODE_POOR             	  = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?)
+    PM_SOURCE_MODE_PAIR             	  = 0x00000020, ///< Source fitted with a double psf
+    PM_SOURCE_MODE_PSFSTAR          	  = 0x00000040, ///< Source used to define PSF model
+    PM_SOURCE_MODE_SATSTAR          	  = 0x00000080, ///< Source model peak is above saturation
+    PM_SOURCE_MODE_BLEND            	  = 0x00000100, ///< Source is a blend with other sources
+    PM_SOURCE_MODE_EXTERNAL         	  = 0x00000200, ///< Source based on supplied input position
+    PM_SOURCE_MODE_BADPSF           	  = 0x00000400, ///< Failed to get good estimate of object's PSF
+    PM_SOURCE_MODE_DEFECT           	  = 0x00000800, ///< Source is thought to be a defect
+    PM_SOURCE_MODE_SATURATED        	  = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail)
+    PM_SOURCE_MODE_CR_LIMIT         	  = 0x00002000, ///< Source has crNsigma above limit
+    PM_SOURCE_MODE_EXT_LIMIT        	  = 0x00004000, ///< Source has extNsigma above limit
+    PM_SOURCE_MODE_MOMENTS_FAILURE  	  = 0x00008000, ///< could not measure the moments
+    PM_SOURCE_MODE_SKY_FAILURE      	  = 0x00010000, ///< could not measure the local sky
+    PM_SOURCE_MODE_SKYVAR_FAILURE   	  = 0x00020000, ///< could not measure the local sky variance
+    PM_SOURCE_MODE_BELOW_MOMENTS_SN 	  = 0x00040000, ///< moments not measured due to low S/N
+    PM_SOURCE_MODE_BIG_RADIUS       	  = 0x00100000, ///< poor moments for small radius, try large radius
+    PM_SOURCE_MODE_AP_MAGS          	  = 0x00200000, ///< source has an aperture magnitude
+    PM_SOURCE_MODE_BLEND_FIT        	  = 0x00400000, ///< source was fitted as a blend
+    PM_SOURCE_MODE_EXTENDED_FIT     	  = 0x00800000, ///< full extended fit was used
+    PM_SOURCE_MODE_EXTENDED_STATS   	  = 0x01000000, ///< extended aperture stats calculated
+    PM_SOURCE_MODE_LINEAR_FIT       	  = 0x02000000, ///< source fitted with the linear fit
+    PM_SOURCE_MODE_NONLINEAR_FIT    	  = 0x04000000, ///< source fitted with the non-linear fit
+    PM_SOURCE_MODE_RADIAL_FLUX      	  = 0x08000000, ///< radial flux measurements calculated
+    PM_SOURCE_MODE_SIZE_SKIPPED     	  = 0x10000000, ///< size could not be determined
+    PM_SOURCE_MODE_ON_SPIKE         	  = 0x20000000, ///< peak lands on diffraction spike
+    PM_SOURCE_MODE_ON_GHOST         	  = 0x40000000, ///< peak lands on ghost or glint
+    PM_SOURCE_MODE_OFF_CHIP         	  = 0x80000000, ///< peak lands off edge of chip
 } pmSourceMode;
 
@@ -42,20 +42,18 @@
 // When adding to or subtracting from this list, please also modify pmSourceMaskHeader
 typedef enum {
-    PM_SOURCE_MODE2_DEFAULT          = 0x00000000, ///< Initial value: resets all bits
-    PM_SOURCE_MODE2_DIFF_WITH_SINGLE = 0x00000001, ///< diff source matched to a single positive detection
-    PM_SOURCE_MODE2_DIFF_WITH_DOUBLE = 0x00000002, ///< diff source matched to positive detections in both images
-    PM_SOURCE_MODE2_MATCHED          = 0x00000004, ///< diff source matched to positive detections in both images
-    PM_SOURCE_MODE2_DIFF_SELF_MATCH  = 0x00000800, ///< positive detection match is probably this source 
-
-    PM_SOURCE_MODE2_ON_SPIKE         = 0x00000008, ///< > 25% of (PSF-weighted) pixels land on diffraction spike
-    PM_SOURCE_MODE2_ON_STARCORE      = 0x00000010, ///< > 25% of (PSF-weighted) pixels land on starcore
-    PM_SOURCE_MODE2_ON_BURNTOOL      = 0x00000020, ///< > 25% of (PSF-weighted) pixels land on burntool
-    PM_SOURCE_MODE2_ON_CONVPOOR      = 0x00000040, ///< > 25% of (PSF-weighted) pixels land on convpoor
-
-    PM_SOURCE_MODE2_PASS1_SRC        = 0x00000080, ///< source detected in first pass analysis
-
+    PM_SOURCE_MODE2_DEFAULT          	  = 0x00000000, ///< Initial value: resets all bits
+    PM_SOURCE_MODE2_DIFF_WITH_SINGLE 	  = 0x00000001, ///< diff source matched to a single positive detection
+    PM_SOURCE_MODE2_DIFF_WITH_DOUBLE 	  = 0x00000002, ///< diff source matched to positive detections in both images
+    PM_SOURCE_MODE2_MATCHED          	  = 0x00000004, ///< diff source matched to positive detections in both images
+    PM_SOURCE_MODE2_ON_SPIKE         	  = 0x00000008, ///< > 25% of (PSF-weighted) pixels land on diffraction spike
+    PM_SOURCE_MODE2_ON_STARCORE      	  = 0x00000010, ///< > 25% of (PSF-weighted) pixels land on starcore
+    PM_SOURCE_MODE2_ON_BURNTOOL      	  = 0x00000020, ///< > 25% of (PSF-weighted) pixels land on burntool
+    PM_SOURCE_MODE2_ON_CONVPOOR      	  = 0x00000040, ///< > 25% of (PSF-weighted) pixels land on convpoor
+    PM_SOURCE_MODE2_PASS1_SRC             = 0x00000080, ///< source detected in first pass analysis
     PM_SOURCE_MODE2_HAS_BRIGHTER_NEIGHBOR = 0x00000100, ///< peak is not the brightest in its footprint
     PM_SOURCE_MODE2_BRIGHT_NEIGHBOR_1     = 0x00000200, ///< flux_n / (r^2 flux_p) > 1
     PM_SOURCE_MODE2_BRIGHT_NEIGHBOR_10    = 0x00000400, ///< flux_n / (r^2 flux_p) > 10
+    PM_SOURCE_MODE2_DIFF_SELF_MATCH  	  = 0x00000800, ///< positive detection match is probably this source 
+    PM_SOURCE_MODE2_SATSTAR_PROFILE       = 0x00001000, ///< saturated source is modeled with a radial profile
 } pmSourceMode2;
 
Index: /trunk/psModules/src/objects/pmSourceMatch.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceMatch.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceMatch.c	(revision 34403)
@@ -24,4 +24,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceMoments.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceMoments.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceMoments.c	(revision 34403)
@@ -41,4 +41,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 
Index: /trunk/psModules/src/objects/pmSourceOutputs.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceOutputs.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceOutputs.c	(revision 34403)
@@ -32,4 +32,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
@@ -226,4 +227,9 @@
     *pltScale = 0.5*(pltScale_x + pltScale_y);
 
+    float crossProduct = dTPx_dCHx * dTPy_dCHy - dTPx_dCHy * dTPy_dCHx;
+    if  (crossProduct > 0.) {
+      *pltScale *= -1.0;
+    }
+
     float posAngle_x = atan2 (+dTPy_dCHx, +dTPx_dCHx);
     float posAngle_y = atan2 (-dTPy_dCHy, +dTPx_dCHy);
Index: /trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- /trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 34403)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourcePlotApResid.c
===================================================================
--- /trunk/psModules/src/objects/pmSourcePlotApResid.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourcePlotApResid.c	(revision 34403)
@@ -41,4 +41,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourcePlotMoments.c
===================================================================
--- /trunk/psModules/src/objects/pmSourcePlotMoments.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourcePlotMoments.c	(revision 34403)
@@ -44,4 +44,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourcePlotPSFModel.c
===================================================================
--- /trunk/psModules/src/objects/pmSourcePlotPSFModel.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourcePlotPSFModel.c	(revision 34403)
@@ -45,4 +45,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/objects/pmSourceSatstar.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceSatstar.c	(revision 34403)
+++ /trunk/psModules/src/objects/pmSourceSatstar.c	(revision 34403)
@@ -0,0 +1,46 @@
+/** @file  pmSourceSatstar.c
+ *
+ *  Functions to manage saturated star profiles
+ *  @author EAM, IfA
+ *
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:31:25 $
+ *
+ *  Copyright 2012 University of Hawaii
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pslib.h>
+#include "pmSourceSatstar.h"
+
+// pmSourceSatstar defines the profile
+static void pmSourceSatstarFree(pmSourceSatstar *satstar)
+{
+    if (!satstar) return;
+    psFree(satstar->logRmodel);
+    psFree(satstar->logFmodel);
+}
+
+pmSourceSatstar *pmSourceSatstarAlloc()
+{
+    pmSourceSatstar *satstar = (pmSourceSatstar *)psAlloc(sizeof(pmSourceSatstar));
+    psMemSetDeallocator(satstar, (psFreeFunc) pmSourceSatstarFree);
+
+    satstar->logRmodel = NULL;
+    satstar->logFmodel = NULL;
+
+    satstar->Xo = NAN;
+    satstar->Yo = NAN;
+    satstar->Rmax = NAN;
+
+    return satstar;
+}
+
+bool psMemCheckSourceSatstar(psPtr ptr)
+{
+    PS_ASSERT_PTR(ptr, false);
+    return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceSatstarFree);
+}
Index: /trunk/psModules/src/objects/pmSourceSatstar.h
===================================================================
--- /trunk/psModules/src/objects/pmSourceSatstar.h	(revision 34403)
+++ /trunk/psModules/src/objects/pmSourceSatstar.h	(revision 34403)
@@ -0,0 +1,27 @@
+/* @file  pmSourceSatstar.h
+ *
+ * @author EAM, IfA
+ * @date $Date: 2012-08-30 $
+ * Copyright 2012 University of Hawaii
+ */
+
+# ifndef PM_SOURCE_SATSTAR_H
+# define PM_SOURCE_SATSTAR_H
+
+/// @addtogroup Objects Object Detection / Analysis Functions
+/// @{
+
+typedef struct {
+    float Xo;
+    float Yo;
+    float Rmax;
+    psVector *logFmodel;
+    psVector *logRmodel;
+} pmSourceSatstar;
+
+
+pmSourceSatstar *pmSourceSatstarAlloc();
+bool psMemCheckSourceSatstar(psPtr ptr);
+
+/// @}
+# endif /* PM_SOURCE_SATSTAR_H */
Index: /trunk/psModules/src/objects/pmSourceSky.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceSky.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceSky.c	(revision 34403)
@@ -40,4 +40,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 
Index: /trunk/psModules/src/objects/pmSourceUtils.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceUtils.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceUtils.c	(revision 34403)
@@ -40,4 +40,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 
Index: /trunk/psModules/src/objects/pmSourceVisual.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceVisual.c	(revision 34402)
+++ /trunk/psModules/src/objects/pmSourceVisual.c	(revision 34403)
@@ -22,4 +22,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourceSatstar.h"
 #include "pmSource.h"
 #include "pmSourceFitModel.h"
Index: /trunk/psModules/src/psmodules.h
===================================================================
--- /trunk/psModules/src/psmodules.h	(revision 34402)
+++ /trunk/psModules/src/psmodules.h	(revision 34403)
@@ -132,4 +132,5 @@
 #include <pmSourceMasks.h>
 #include <pmSourceExtendedPars.h>
+#include <pmSourceSatstar.h>
 #include <pmSourceDiffStats.h>
 #include <pmSource.h>
