Index: /branches/bills_branches/bills_201312/ippScripts/scripts/stack_skycell.pl
===================================================================
--- /branches/bills_branches/bills_201312/ippScripts/scripts/stack_skycell.pl	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippScripts/scripts/stack_skycell.pl	(revision 36437)
@@ -40,5 +40,5 @@
 }
 
-my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
+my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps, $delete_convolved_images);
 GetOptions(
     'stack_id|d=s'      => \$stack_id, # Stack identifier
@@ -55,4 +55,5 @@
     'redirect-output'   => \$redirect,
     'save-temps'        => \$save_temps, # Save temporary files?
+    'delete-convolved'  => \$delete_convolved_images,
 ) or pod2usage( 2 );
 
@@ -92,4 +93,5 @@
 );
 
+
 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 $| = 1;
@@ -360,5 +362,25 @@
 
     if (!$quality) {
+	
+
         check_outputs(\@outputFiles, $replicate_outputs);
+
+	if (($convolve)&&($delete_convolved_images)) { # We made convolved products, but do not wish to keep them anymore
+	    my @products_to_clear = ('PPSTACK.OUTPUT',
+				     'PPSTACK.OUTPUT.MASK',
+				     'PPSTACK.OUTPUT.VARIANCE',
+				     'PPSTACK.OUTPUT.EXP',
+				     'PPSTACK.OUTPUT.EXPNUM',
+				     'PPSTACK.OUTPUT.EXPWT');
+	    foreach my $product (@products_to_clear) {
+		my $file = $ipprc->filename($product,$outroot,$skycell_id);
+		print "Deleting unwanted convolved product: $file\n";
+		my $error= $ipprc->kill_file($file);
+		if ($error_code) {
+		    print "Failed to delete unwanted convolved product: $error_code\n";
+		}
+	    }
+	}
+
     }
 
Index: /branches/bills_branches/bills_201312/ippTasks/rawcheck.pro
===================================================================
--- /branches/bills_branches/bills_201312/ippTasks/rawcheck.pro	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippTasks/rawcheck.pro	(revision 36437)
@@ -75,5 +75,5 @@
   task.exec
       book npages rawcheckPending -var N
-      if ($N > 2000)
+      if ($N > 200)
         process_cleanup rawcheckPending
         break
Index: /branches/bills_branches/bills_201312/ippTools/share/chiptool_pendingcleanuprun.sql
===================================================================
--- /branches/bills_branches/bills_201312/ippTools/share/chiptool_pendingcleanuprun.sql	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippTools/share/chiptool_pendingcleanuprun.sql	(revision 36437)
@@ -4,8 +4,11 @@
     rawExp.exp_tag,
     chipRun.state,
-    chipRun.workdir
+    chipRun.workdir,
+    chipRun.label,
+    IFNULL(Label.priority, 10000) AS priority
 FROM chipRun
 JOIN rawExp 
 USING (exp_id)
+LEFT JOIN Label ON chipRun.label = Label.label
 WHERE
     (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_scrubbed' OR chipRun.state = 'goto_purged')
Index: /branches/bills_branches/bills_201312/ippTools/src/chiptool.c
===================================================================
--- /branches/bills_branches/bills_201312/ippTools/src/chiptool.c	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippTools/src/chiptool.c	(revision 36437)
@@ -1255,5 +1255,5 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxAddLabelSearchArgs (config, where, "-label", "label", "==");
+    pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "==");
 
     psString query = pxDataGet("chiptool_pendingcleanuprun.sql");
@@ -1269,4 +1269,6 @@
     }
     psFree(where);
+
+    psStringAppend(&query, "\nORDER BY priority DESC, chip_id");
 
     // treat limit == 0 as "no limit"
Index: /branches/bills_branches/bills_201312/ippTools/src/regtool.c
===================================================================
--- /branches/bills_branches/bills_201312/ippTools/src/regtool.c	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippTools/src/regtool.c	(revision 36437)
@@ -310,4 +310,9 @@
 }
 
+
+// CZW: 2013-12-11 A bad exposure caused this code to fail to return any rows.
+//      I don't clearly see any logic flaws, and so I fixed the issue by
+//      retricting dateobs_begin to exclude this exposure.  Problem for
+//      another day.
 static bool pendingburntoolimfileMode(pxConfig *config)
 {
Index: /branches/bills_branches/bills_201312/ippconfig/gpc1/psastro.config
===================================================================
--- /branches/bills_branches/bills_201312/ippconfig/gpc1/psastro.config	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippconfig/gpc1/psastro.config	(revision 36437)
@@ -380,4 +380,13 @@
 END
 
+POLE_REFCAT METADATA
+   PSASTRO.CATDIR		STR  SYNTH.GRIZY
+   ZERO.POINT.USE.MEAN		     BOOL TRUE  
+   PSASTRO.GRID.MIN.ANGLE       F32  -20
+   PSASTRO.GRID.MAX.ANGLE       F32  +20
+   PSASTRO.GRID.DEL.ANGLE       F32   0.5
+   PSASTRO.FIELD.PADDING        F32   0.5
+END
+
 TEST_REFCAT METADATA
    PSASTRO.CATDIR		STR /data/ipp064.0/ipp/ippRefs/catdir.refcat.20120524.v0
Index: /branches/bills_branches/bills_201312/ippconfig/recipes/psastro.config
===================================================================
--- /branches/bills_branches/bills_201312/ippconfig/recipes/psastro.config	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippconfig/recipes/psastro.config	(revision 36437)
@@ -273,4 +273,7 @@
 END
 
+POLE_REFCAT METADATA
+END
+
 TEST_REFCAT METADATA
 END
Index: /branches/bills_branches/bills_201312/ippconfig/recipes/reductionClasses.mdc
===================================================================
--- /branches/bills_branches/bills_201312/ippconfig/recipes/reductionClasses.mdc	(revision 36436)
+++ /branches/bills_branches/bills_201312/ippconfig/recipes/reductionClasses.mdc	(revision 36437)
@@ -251,4 +251,14 @@
 	BACKGROUND_PSWARP	STR	BACKGROUND
         FULLFORCE_PSPHOT  STR   FULLFORCE_WARP
+END
+
+# basic science analysis
+POLE_REFCAT		METADATA
+	CHIP_PPIMAGE	  STR	  CHIP
+	CHIP_PSPHOT	  STR	  CHIP
+	JPEG_BIN1	  STR	  PPIMAGE_J1
+	JPEG_BIN2	  STR	  PPIMAGE_J2
+	ADDSTAR		  STR	  ADDSTAR
+	PSASTRO		  STR	  POLE_REFCAT
 END
 
Index: /branches/bills_branches/bills_201312/psLib/src/math/psMixtureModels.c
===================================================================
--- /branches/bills_branches/bills_201312/psLib/src/math/psMixtureModels.c	(revision 36436)
+++ /branches/bills_branches/bills_201312/psLib/src/math/psMixtureModels.c	(revision 36437)
@@ -120,4 +120,5 @@
   *Ncensored = 0;
 
+  int k = 0;
   for (int i = 0; i < in->numRows; i++) {
     int isCensored = 0;
@@ -130,6 +131,11 @@
       *Ncensored = *Ncensored + 1;
     }
-    offsets->data.S32[i] = *Ncensored;
-  }
+    else {
+      offsets->data.S32[k] = i - k;
+      k++;
+    }
+    //    offsets->data.S32[i] = isCensored;
+  }
+
   psImage *out;
   if (*Ncensored == 0) {
@@ -320,6 +326,8 @@
 	}
       }
-      i = modes->data.F32[k];
-      counts->data.F32[i] += 1.0;
+      if (modes->data.F32[k] != -1) {
+	i = modes->data.F32[k];
+	counts->data.F32[i] += 1.0;
+      }
     }
 
@@ -335,6 +343,8 @@
     for (k = 0; k < N; k++) {
       i = modes->data.F32[k];
-      for (j = 0; j < dim; j++) {
-	means->data.F32[i][j] += D->data.F32[k][j];
+      if (i != -1) {
+	for (j = 0; j < dim; j++) {
+	  means->data.F32[i][j] += D->data.F32[k][j];
+	}
       }
     }
