Index: trunk/psModules/src/objects/pmSource.h
===================================================================
--- trunk/psModules/src/objects/pmSource.h	(revision 28013)
+++ trunk/psModules/src/objects/pmSource.h	(revision 29004)
@@ -11,15 +11,6 @@
 # define PM_SOURCE_H
 
-#include <pslib.h>
-#include "pmPeaks.h"
-#include "pmModel.h"
-#include "pmMoments.h"
-#include "pmSourceExtendedPars.h"
-#include "pmSourceDiffStats.h"
-
 /// @addtogroup Objects Object Detection / Analysis Functions
 /// @{
-
-#include <pmSourceMasks.h>
 
 /** pmSourceType enumeration
@@ -74,4 +65,5 @@
     pmSourceType type;                  ///< Best identification of object.
     pmSourceMode mode;                  ///< analysis flags set for object.
+    pmSourceMode2 mode2;                ///< analysis flags set for object.
     pmSourceTmpF tmpFlags;              ///< internal-only flags
     psArray *blends;                    ///< collection of sources thought to be confused with object
@@ -82,10 +74,14 @@
     float errMag;                       ///< error in psfMag OR extMag (depending on type)
     float apMag;                        ///< apMag corresponding to psfMag or extMag (depending on type)
-    float pixWeight;                    ///< model-weighted coverage of valid pixels
+    float apMagRaw;                     ///< raw mag in given aperture
+    float apRadius;			///< radius for aperture magnitude
+
+    float pixWeightNotBad;              ///< PSF-weighted coverage of unmasked (not BAD) pixels
+    float pixWeightNotPoor;             ///< PSF-weighted coverage of unmasked (not POOR) pixels
+
     float psfChisq;                     ///< probability of PSF
     float crNsigma;                     ///< Nsigma deviation from PSF to CR
     float extNsigma;                    ///< Nsigma deviation from PSF to EXT
     float sky, skyErr;                  ///< The sky and its error at the center of the object
-    float apRadius;
     psRegion region;                    ///< area on image covered by selected pixels
     pmSourceExtendedPars *extpars;      ///< extended source parameters
@@ -113,4 +109,6 @@
 pmPSFClump;
 
+// private macro to set the source ID (a const)
+#define P_PM_SOURCE_SET_ID(S,V) { *(int *)&(S)->id = (V); }
 
 /** pmSourceAlloc()
@@ -126,4 +124,5 @@
 
 pmSource  *pmSourceCopy(pmSource *source);
+pmSource *pmSourceCopyData(pmSource *in);
 
 // free just the pixels for a source, keeping derived data
@@ -242,4 +241,7 @@
 bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy);
 
+bool pmSourceNoiseOpModel (pmModel *model, pmSource *source, pmModelOpMode mode, float FACTOR, float SIZE, bool add, psImageMaskType maskVal, int dx, int dy);
+bool pmSourceNoiseOp (pmSource *source, pmModelOpMode mode, float FACTOR, float SIZE, bool add, psImageMaskType maskVal, int dx, int dy);
+
 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psImageMaskType maskVal, int dx, int dy);
 bool pmSourceCacheModel (pmSource *source, psImageMaskType maskVal);
