Index: /branches/eam_branches/ipp-20150112/ippconfig/gpc1/ppStack.config
===================================================================
--- /branches/eam_branches/ipp-20150112/ippconfig/gpc1/ppStack.config	(revision 38059)
+++ /branches/eam_branches/ipp-20150112/ippconfig/gpc1/ppStack.config	(revision 38060)
@@ -279,7 +279,7 @@
 
 
-STACK_CNP_PV3_IQ_1DG  METADATA       ## revised -- based on STACK_THREEPI/STACK_MD_DEEP_1DG -- not complete
-    OUTPUT.NOCOMP   	    BOOL  FALSE
-    OUTPUT.LOGFLUX  	    BOOL  TRUE
+STACK_CNP_PV3_IQ_1DG  METADATA       ## revised -- based on STACK_THREEPI/STACK_MD_DEEP_1DG
+    OUTPUT.NOCOMP           BOOL  TRUE 
+    OUTPUT.LOGFLUX          BOOL  FALSE
     STACK.TYPE              STR   DEEP_STACK
     PSF.INPUT.CLIP.SIMPLE   BOOL  True
@@ -290,7 +290,13 @@
     MATCH.REJ        F32    4.0
     SAFE		 BOOL	F
-    PSF.TARGET.AS.MAX.EPSILON F32 0.1
-    ## also unclear what rej mods needed
-    ## 
+    PSF.TARGET.AS.MAX        BOOL  TRUE   # Set the target PSF FWHM as the maximum of accepted input FWHM values.
+    PSF.TARGET.AS.MAX.EPSILON F32 0.1     # set the target PSF FWHM larger than the maximum input. Target = eps + max(input)
+    THRESHOLD.MASK  F32     0.1          # Threshold for mask deconvolution (0..1)
+    COMBINE.ITER    F32     0.5          # Number of rejection iterations per input
+    COMBINE.REJ     F32     3.0          # Rejection threshold in combination (sigma)
+    COMBINE.SYS     F32     0.1          # Relative systematic error in combination
+    COMBINE.DISCARD F32     0.2          # Discard fraction for Olympic weighted mean
+    IMAGE.REJ       F32     0.1          # Rejected pixel fraction threshold for rejecting entire image
+    NMINPIX         S32     3            # Minimum input per pixel     
     MASK.VAL        STR     SUSPECT,MASK.VALUE,CONV.BAD,GHOST # Mask value of input bad pixels 
     MASK.BLANKBORDER S32    20              # Mask blank border in final stack output
@@ -298,6 +304,6 @@
 END
 
-STACK_CNP_PV3_REF_1DG  METADATA  ## revised CNP PV3 REF stack -- not complete
-    OUTPUT.NOCOMP            BOOL  TRUE   # unclear if this necessary for CNP REF
+STACK_CNP_PV3_REF_1DG  METADATA  ## revised CNP PV3 REF stack --
+    OUTPUT.NOCOMP            BOOL  TRUE   # pointed field -- no compression, no logflux 
     OUTPUT.LOGFLUX           BOOL  FALSE  # 
     OUTPUT.REPLICATE         BOOL  TRUE
@@ -305,5 +311,5 @@
     PSF.INPUT.CLIP.SIMPLE    BOOL  True
     PSF.INPUT.MAX            F32   10.0   # CNP large FWHM, center/edge vary 1-2 pix? 
-    PSF.INPUT.CLIP.NSIGMA    F32   1.0    # sample typically on rising side of distribution (set smaller?)
+    PSF.INPUT.CLIP.NSIGMA    F32   0.0    # sample typically on rising side of distribution 
     PSF.INPUT.THRESH         F32   NAN
     PSF.INPUT.ASYMMETRY      F32   NAN
@@ -312,19 +318,17 @@
     PSF.TARGET.AS.MAX        BOOL  TRUE   # Set the target PSF FWHM as the maximum of accepted input FWHM values.
     PSF.TARGET.AS.MAX.EPSILON F32 0.1     # set the target PSF FWHM larger than the maximum input. Target = eps + max(input)
-    ## extra rej -- turn default for initial test run 
-    #THRESHOLD.MASK  F32     0.1          # Threshold for mask deconvolution (0..1)
-    #COMBINE.ITER    F32     0.5          # Number of rejection iterations per input
-    #COMBINE.REJ     F32     3.0          # Rejection threshold in combination (sigma)
-    #COMBINE.SYS     F32     0.1          # Relative systematic error in combination
-    #COMBINE.DISCARD F32     0.2          # Discard fraction for Olympic weighted mean
-    #IMAGE.REJ       F32     0.1          # Rejected pixel fraction threshold for rejecting entire image
-    #NMINPIX         S32     4            # Minimum input per pixel
-    #MASK.VAL        STR     SUSPECT,MASK.VALUE,CONV.BAD,GHOST # Mask value of input bad pixels 
-    ##
+    THRESHOLD.MASK  F32     0.1          # Threshold for mask deconvolution (0..1)
+    COMBINE.ITER    F32     0.5          # Number of rejection iterations per input
+    COMBINE.REJ     F32     3.0          # Rejection threshold in combination (sigma)
+    COMBINE.SYS     F32     0.1          # Relative systematic error in combination
+    COMBINE.DISCARD F32     0.2          # Discard fraction for Olympic weighted mean
+    IMAGE.REJ       F32     0.1          # Rejected pixel fraction threshold for rejecting entire image
+    NMINPIX         S32     3            # Minimum input per pixel
+    MASK.VAL        STR     SUSPECT,MASK.VALUE,CONV.BAD,GHOST # Mask value of input bad pixels 
     MASK.BLANKBORDER S32    20           # Mask blank border in final stack output
     BSCALEOFFSET    BOOL    FALSE        # MUST be FALSE for PV3
 END
 
-STACK_CNP_PV3_DEEP_1DG  METADATA   ## -- not complete
+STACK_CNP_PV3_DEEP_1DG  METADATA   ## -- 
     OUTPUT.NOCOMP           BOOL  TRUE
     OUTPUT.LOGFLUX          BOOL  FALSE
Index: /branches/eam_branches/ipp-20150112/ippconfig/gpc1/psastro.config
===================================================================
--- /branches/eam_branches/ipp-20150112/ippconfig/gpc1/psastro.config	(revision 38059)
+++ /branches/eam_branches/ipp-20150112/ippconfig/gpc1/psastro.config	(revision 38060)
@@ -267,5 +267,5 @@
 
 REFSTAR_MASK_CROSSTALK_MAG_SLOPE F32   3.44
-REFSTAR_MASK_CROSSTALK_MAG_MAX   F32 -14.47
+REFSTAR_MASK_CROSSTALK_MAG_MAX   F32 -13.47
 CROSSTALK_MAX_MAG                F32  20.0
 CROSSTALK_MASK                   BOOL TRUE
@@ -398,4 +398,52 @@
 END
 
+MD_ASTRO METADATA
+   ZERO.POINT.BY.EXPOSURE      BOOL  TRUE
+   ZERO.POINT.USE.MEAN         BOOL  TRUE
+   DVO.GETSTAR.MAX.RHO         F32   6000.0  # was globally changed to 10k, seems >6k more than 1600 NREF
+   PSASTRO.GRID.NREF.MAX       S32   1600    # max stars for grid search from ref catalog
+   PSASTRO.GRID.NRAW.MAX       S32   800     # max stars for grid search from raw/image  
+   DVO.GETSTAR.MIN.MAG         F32   12.0    # leave similar to default, MD in marginal weather and can lose 1-3 mags 
+   DVO.GETSTAR.MIN.MAG.INST    F32   -25.0
+   PSASTRO.CATDIR              STR   PS1.REF.20140713
+   ## refcat may be okay astrom but not faint phot -- so need to be able to further limit by ZP 
+   ## -- concern w/ new refcat >20 extra sources w/ larger merr over-dominating scatter in ZP 
+   ## -- CLAMP will limit both astrom and zp -- 
+   REFSTAR_CLAMP_MAG_MAX       F32   22.0
+   REFSTAR.ZP.MIN.MAG          F32   12.0
+   REFSTAR.ZP.MAX.MAG          F32   19.0
+   ## for ZP need extra limit by filter to avoid poorer photometry scatter on faint end
+   ## -- cannot restrict on bright end due to possible marginal nights
+   ## -- set for merr<0.02-0.03 in refcat, ~similar for each MD field
+#   PHOTCODE.DATA MULTI UPDATE
+   PHOTCODE.DATA MULTI   
+   PHOTCODE.DATA METADATA
+     FILTER   STR g
+     PHOTCODE STR g
+     REFSTAR.ZP.MAX.MAG    F32  19.0
+   END
+   PHOTCODE.DATA METADATA
+     FILTER   STR r
+     PHOTCODE STR r
+     REFSTAR.ZP.MAX.MAG    F32  19.0
+   END
+   PHOTCODE.DATA METADATA
+     FILTER   STR i
+     PHOTCODE STR i
+     REFSTAR.ZP.MAX.MAG    F32  18.5
+   END
+   PHOTCODE.DATA METADATA
+     FILTER   STR z
+     PHOTCODE STR z
+     REFSTAR.ZP.MAX.MAG    F32  18.5
+   END
+   PHOTCODE.DATA METADATA
+     FILTER   STR y
+     PHOTCODE STR y
+     REFSTAR.ZP.MAX.MAG    F32  17.5
+   END
+END
+
+
 CNP_ASTRO_PV3 METADATA
    PSASTRO.MAX.ALLOWED.FWHM    F32   25  # larger number typical >12, so include 2x larger
@@ -631,4 +679,45 @@
 END
 
+## MD version
+## revised setup for DEEP/MDS stacks with range of inputs, should work for N~2(edges)--500 inputs with large MIN/MAX.INST.MAG.RAW
+STATICSKY_MD_DEEPCAL   METADATA
+   #PSASTRO.CATDIR                  STR   PS1.REF.20120524  # reset here to ensure same catalog is used when reprocessing set uniformly
+   #PSASTRO.CATDIR                  STR   PS1.REF.20140605  # ensure same catalog is used when reprocessing MD set uniformly (BAD catalog)
+   PSASTRO.CATDIR                  STR   PS1.REF.20140713 
+   REFSTAR_MASK                    BOOL  FALSE
+   PSASTRO.SAVE.REFMATCH           BOOL  FALSE
+   PSASTRO.FIX.CHIPS               BOOL  FALSE
+   PSASTRO.USE.MODEL               BOOL  FALSE
+   PSASTRO.MOSAIC.MODE             BOOL  FALSE
+   ZERO.POINT.USE.MEAN             BOOL  TRUE
+   PSASTRO.FIELD.PADDING           F32   0.01   # skycells are well defined, don't need large padding. 1% of 6400 is 64 pixels
+   PSASTRO.MAX.NRAW                S32   1500   # include more than MAX.NREF to account for extras like false-positives
+   PSASTRO.MAX.NREF            	   S32   1000   # if edge skycell ~10% then try ~50 to match. increase to help odd bulk offsets
+   PSASTRO.MIN.INST.MAG.RAW        F32   -25.0  # 
+   PSASTRO.MAX.INST.MAG.RAW        F32   -5.0
+   PSASTRO.GRID.SEARCH 		   BOOL  FALSE  # skycell/stack and astrom well known, when used could cause problems and not help
+   #PSASTRO.GRID.NRAW.MAX           S32   2000
+   #PSASTRO.GRID.NREF.MAX 	    S32   2000
+   #PSASTRO.GRID.MIN.INST.MAG.RAW   F32   -21.0
+   #PSASTRO.GRID.MAX.INST.MAG.RAW   F32   -14.0
+   DVO.GETSTAR.MAX.RHO		   F32	 6000.0  # N/sqdeg, slightly larger than MAX.NREF 
+   DVO.GETSTAR.MIN.MAG.INST        F32   -25.0   # set absurd range to cover large range of exptime, then clamp...
+   DVO.GETSTAR.MIN.MAG		   F32	 16.5    # only used if keyword problem so also using CLAMP_MAG_MIN
+   REFSTAR_CLAMP_MAG_MIN 	   F32	 16.5    # saturation in MD ~14 even in y-band, so toss out brighter in the list. seeing offset in brighter stars
+   DVO.GETSTAR.FIXED.ZEROPT        F32   0.0     # not really needed, exptime overly dominates
+  
+   ## for skycell/stack astrom well known, radius shouldn't need to be as large as 90 pixel default. in deeper stacks can be problems
+   PSASTRO.MATCH.RADIUS.N0         F32   5 
+   PSASTRO.MATCH.RADIUS.N1 	   F32   3 
+   PSASTRO.MATCH.RADIUS.N2 	   F32   1
+   PSASTRO.MATCH.RADIUS.N3 	   F32   0.5
+   PSASTRO.MATCH.FIT.NITER 	   S32   4 
+   PSASTRO.MAX.ERROR       	   F32   0.2  # in arcsec units, still liberal limit for well known astrometry for skycells
+   PSASTRO.MIN.NSTAR       	   S32   10   # edges may not have many and require special treatment 
+
+   KH.CORRECT.APPLY              BOOL     FALSE
+END
+
+
 ## if defined for MD, needs to have MD name in group so shouldn't be modified except for MD work
 ## -- was ad hoc limit for NREF~150, rho~6000 due to issues fainter than 19 mag in all filters and brighter than 17.0 mag (except y ~16.5) in MD
Index: /branches/eam_branches/ipp-20150112/ippconfig/recipes/nightly_science.config
===================================================================
--- /branches/eam_branches/ipp-20150112/ippconfig/recipes/nightly_science.config	(revision 38059)
+++ /branches/eam_branches/ipp-20150112/ippconfig/recipes/nightly_science.config	(revision 38060)
@@ -87,4 +87,18 @@
 END
 TARGETS METADATA
+  NAME         STR SNIa
+  DISTRIBUTION STR SNIa.test
+  TESS         STR RINGS.V3
+  OBSMODE      STR SNIa
+  STACKABLE   BOOL FALSE
+  DIFFABLE    BOOL FALSE
+  OFFNIGHT_DIFFS BOOL FALSE
+  ## change days till cleanup
+  DIST      S16 300
+#  CHIP           S16  7
+  WARP      S16 300 
+  DIFF      S16 300 
+END
+TARGETS METADATA
   NAME      STR  MD01
   DISTRIBUTION STR MD01
@@ -95,4 +109,5 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
+  REDUCTION STR MD_DEFAULT
   DIST      S16  30
 END
@@ -106,4 +121,5 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
+  REDUCTION STR MD_DEFAULT
   DIST      S16 30
 END
@@ -117,4 +133,5 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
+  REDUCTION STR MD_DEFAULT
   DIST      S16 30
 END
@@ -128,4 +145,5 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
+  REDUCTION STR MD_DEFAULT
   DIST      S16 30
 END
@@ -139,5 +157,10 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
-  DIST      S16 30
+  REDUCTION STR MD_DEFAULT
+  DIST      S16 30
+  ## change days till cleanup
+  #CHIP S16 60
+  WARP S16 60
+  DIFF S16 60
 END
 TARGETS METADATA
@@ -150,5 +173,10 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
-  DIST      S16 30
+  REDUCTION STR MD_DEFAULT
+  DIST      S16 30
+  ## change days till cleanup
+  #CHIP S16 60
+  WARP S16 60
+  DIFF S16 60
 END
 TARGETS METADATA
@@ -161,5 +189,10 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
-  DIST      S16 30
+  REDUCTION STR MD_DEFAULT
+  DIST      S16 30
+  ## change days till cleanup
+  #CHIP S16 60
+  WARP S16 60
+  DIFF S16 60
 END
 TARGETS METADATA
@@ -172,5 +205,10 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
-  DIST      S16 30
+  REDUCTION STR MD_DEFAULT
+  DIST      S16 30
+  ## change days till cleanup
+  #CHIP S16 60
+  WARP S16 60
+  DIFF S16 60
 END
 TARGETS METADATA
@@ -183,4 +221,5 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
+  REDUCTION STR MD_DEFAULT
   DIST      S16 30
 END
@@ -194,4 +233,5 @@
   MIN_STACK U16 8
   DIFFABLE  BOOL FALSE
+  REDUCTION STR MD_DEFAULT
   DIST      S16 30
 END
Index: /branches/eam_branches/ipp-20150112/ippconfig/recipes/ppSub.config
===================================================================
--- /branches/eam_branches/ipp-20150112/ippconfig/recipes/ppSub.config	(revision 38059)
+++ /branches/eam_branches/ipp-20150112/ippconfig/recipes/ppSub.config	(revision 38060)
@@ -182,4 +182,12 @@
 END
 
+# WSdiff for PV3 to do inverse phot
+WARPSTACK_PV3       METADATA
+        DUAL            BOOL    FALSE   # Dual convolution?
+        INVERSE         BOOL    TRUE   # Generate inverse subtraction?
+        PHOTOMETRY      BOOL    TRUE    # Perform photometry?
+        CONVOLVE.TARGET STR     SINGLE2 # convolution direction
+END
+
 WARPSTACK_1DG	METADATA
 	KERNEL.TYPE	STR	SIMPLE
Index: /branches/eam_branches/ipp-20150112/ippconfig/recipes/psastro.config
===================================================================
--- /branches/eam_branches/ipp-20150112/ippconfig/recipes/psastro.config	(revision 38059)
+++ /branches/eam_branches/ipp-20150112/ippconfig/recipes/psastro.config	(revision 38060)
@@ -187,4 +187,6 @@
 MASKSTAT.ADVISORY   U32 0x080
 
+TRANSFORM.GALAXY.SHAPE.ERRORS  BOOL F
+
 # maximum allowed fwhm_major (moved from */camera.config)
 PSASTRO.MAX.ALLOWED.FWHM    F32     0
@@ -281,4 +283,7 @@
 END
 
+MD_ASTRO METADATA
+END
+
 CNP_ASTRO_PV3 METADATA
 END
@@ -314,2 +319,3 @@
 STATICSKY_MD_PV3_DEEPCAL   METADATA
 END
+
Index: /branches/eam_branches/ipp-20150112/ippconfig/recipes/reductionClasses.mdc
===================================================================
--- /branches/eam_branches/ipp-20150112/ippconfig/recipes/reductionClasses.mdc	(revision 38059)
+++ /branches/eam_branches/ipp-20150112/ippconfig/recipes/reductionClasses.mdc	(revision 38060)
@@ -200,5 +200,30 @@
 END
 
-
+# MD basic/nightly science analysis
+MD_DEFAULT		METADATA
+	CHIP_PPIMAGE	  STR	  CHIP
+	CHIP_PSPHOT	  STR	  CHIP
+	WARP_PSWARP	  STR	  WARP
+	## this should be updated when ready w/ revised _1DG version
+	STACK_PPSTACK	  STR	  STACK_NIGHTLY
+	STACK_PPSUB	  STR	  STACK
+	STACK_PSPHOT	  STR	  STACK
+	DIFF_PPSUB	  STR	  DIFF
+	DIFF_PSPHOT	  STR	  DIFF
+	JPEG_BIN1	  STR	  PPIMAGE_J1
+	JPEG_BIN2	  STR	  PPIMAGE_J2
+	FAKEPHOT	  STR	  FAKEPHOT
+	ADDSTAR		  STR	  ADDSTAR
+	PSASTRO		  STR	  MD_ASTRO
+	STACKPHOT_PSPHOT  STR     STACKPHOT
+	STACKPHOT_PPSUB   STR     STACKPHOT
+	STACKPHOT_PPSTACK STR     STACKPHOT
+	STACKPHOT_SINGLE_PSPHOT  STR     STACKPHOT_SINGLE
+	BACKGROUND_PPBACKGROUND	STR	BACKGROUND
+	BACKGROUND_PSWARP	STR	BACKGROUND
+        PSVIDEOPHOT             STR     PSVIDEOPHOT
+        STATICSKY_CALIBRATION   STR     STATICSKY_CAL
+        FULLFORCE_PSPHOT  STR   FULLFORCE_WARP
+END
 
 # basic science analysis
@@ -569,4 +594,12 @@
 	JPEG_BIN1	STR	PPIMAGE_J1
 	JPEG_BIN2	STR	PPIMAGE_J2
+END
+
+# specific for PV3 WSdiff processing to do inverse phot
+WARPSTACK_PV3       METADATA
+        DIFF_PPSUB      STR     WARPSTACK_PV3
+        DIFF_PSPHOT     STR     DIFF
+        JPEG_BIN1       STR     PPIMAGE_J1
+        JPEG_BIN2       STR     PPIMAGE_J2
 END
 
@@ -1436,5 +1469,5 @@
         BACKGROUND_PSWARP       STR     BACKGROUND
         PSVIDEOPHOT             STR     PSVIDEOPHOT
-        STATICSKY_CALIBRATION   STR     STATICSKY_MD_DEEPCAL_PV3
+        STATICSKY_CALIBRATION   STR     STATICSKY_MD_PV3_DEEPCAL
 END
 
