Index: trunk/ippScripts/Build.PL
===================================================================
--- trunk/ippScripts/Build.PL	(revision 26665)
+++ trunk/ippScripts/Build.PL	(revision 26670)
@@ -100,4 +100,5 @@
 	scripts/dqstats_bundle.pl
         scripts/whichimage
+        scripts/automate_stacks.pl
     )],
     dist_abstract => 'Scripts for running the Pan-STARRS IPP',
Index: trunk/ippScripts/MANIFEST
===================================================================
--- trunk/ippScripts/MANIFEST	(revision 26665)
+++ trunk/ippScripts/MANIFEST	(revision 26670)
@@ -36,3 +36,4 @@
 scripts/isp_trans.pl
 scripts/ds9_cmf_regions.pl
+scripts/automate_stacks.pl
 t/00_distribution.t
Index: trunk/ippScripts/scripts/automate_stacks.pl
===================================================================
--- trunk/ippScripts/scripts/automate_stacks.pl	(revision 26665)
+++ trunk/ippScripts/scripts/automate_stacks.pl	(revision 26670)
@@ -36,5 +36,5 @@
 my ( $date, $camera, $dbname, $logfile, $verbose);
 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips, $check_stacks, $queue_stacks);
-my ( $help, $this_target_only, $this_filter_only, $isburning);
+my ( $help, $this_target_only, $this_filter_only, $isburning, $force_stack_count);
 GetOptions(
     'help|h'               => \$help,
@@ -54,4 +54,5 @@
     'this_filter_only=s'   => \$this_filter_only,
     'isburning'            => \$isburning,
+    'force_stack_count'    => \$force_stack_count,
     ) or pod2usage ( 2 );
 pod2usage( -msg => 
@@ -65,4 +66,6 @@
            --this_target_only     Process only a single target.
            --this_filter_only     Process only a single filter.
+           --isburning            Signal that we are currently burntooling.
+           --force_stack_count    Force the chip/warp counts.
         Modes:
            --check_registration   Confirm the data downloaded correctly.
@@ -527,5 +530,5 @@
 	foreach my $filter (@filter_list) {
 	    my ($Nexposures,$NprocChips,$NprocWarps,$Nalready) = pre_stack_queue($date,$target,$filter);
-	    if (($NprocChips != $NprocWarps)) { #||($NprocWarps == 0)||($NprocChips == 0)) {
+	    if ((!defined($force_stack_count))&&($NprocChips != $NprocWarps)) { # This makes me sad. :(
 		print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n";
 		$metadata_out{nsState} = 'FORCETOWARP';
Index: trunk/ippTasks/Makefile.am
===================================================================
--- trunk/ippTasks/Makefile.am	(revision 26665)
+++ trunk/ippTasks/Makefile.am	(revision 26670)
@@ -30,5 +30,6 @@
 	publish.pro \
 	dqstats.pro \
-	science.cleanup.pro
+	science.cleanup.pro \
+	nightly_stacks.pro
 
 other_files = \
Index: trunk/tools/gpc1_find_images.pl
===================================================================
--- trunk/tools/gpc1_find_images.pl	(revision 26665)
+++ trunk/tools/gpc1_find_images.pl	(revision 26670)
@@ -208,4 +208,5 @@
 	    push @{ $mapping{$class} }, $skycell;
 	    push @{ $mapping{$raw_class} }, $skycell;
+#	    print STDERR "$raw_class $class $skycell\n";
 	}
     }
Index: trunk/tools/make_burntool_pcontrol.pl
===================================================================
--- trunk/tools/make_burntool_pcontrol.pl	(revision 26665)
+++ trunk/tools/make_burntool_pcontrol.pl	(revision 26670)
@@ -266,5 +266,7 @@
 	printf(" burntool %s %s\n",$date_min,$date_max);
     }
-    print "\n";
+    unless(exists($opt{d})) {
+        print "\n";
+    }
     $N_ranges += ($#start_s + 1);
 }
@@ -311,4 +313,8 @@
 }
 sub print_short_epilogue {
+    if (exists($opt{b})) {
+	print STDERR "There were no science exposures to process. Sorry, try again tomorrow.\n";
+	return();
+    }
     print << 'END_SHORT_EPILOGUE';
 
Index: trunk/tools/neb-ds9.pl
===================================================================
--- trunk/tools/neb-ds9.pl	(revision 26665)
+++ trunk/tools/neb-ds9.pl	(revision 26670)
@@ -4,5 +4,5 @@
 getopts('AM',\%opt);
 
-$cmd = 'ds9 -scale mode zscale ';
+$cmd = 'ds9  -scale mode zscale ';
 
 if (exists($opt{A})) {
@@ -21,3 +21,4 @@
     }
 }
+#$cmd .= "  -zoom to fit -regions format xy -regions system wcs -regions load targets.reg  ";
 system("$cmd");
Index: trunk/tools/wiki_nightly_stacks_table.pl
===================================================================
--- trunk/tools/wiki_nightly_stacks_table.pl	(revision 26665)
+++ trunk/tools/wiki_nightly_stacks_table.pl	(revision 26670)
@@ -133,5 +133,5 @@
 
 #warps
-$sth = "select rawExp.dateobs,warpRun.state,rawExp.filter,count(warpRun.state),warpRun.data_group,warpRun.dist_group from warpRun JOIN fakeRun using (fake_id) JOIN camRun using (cam_id) JOIN chipRun using (chip_id) JOIN rawExp using (exp_id)  where warpRun.label LIKE '%nightlystack' GROUP BY data_group,filter ORDER BY data_group,filter"; 
+$sth = "select rawExp.dateobs,warpRun.state,rawExp.filter,count(warpRun.state),warpRun.data_group,warpRun.dist_group from warpRun JOIN fakeRun using (fake_id) JOIN camRun using (cam_id) JOIN chipRun using (chip_id) JOIN rawExp using (exp_id)  where warpRun.label LIKE '%nightlystack' GROUP BY data_group,filter,state ORDER BY data_group,filter"; 
 $data_ref = $db->selectall_arrayref( $sth );
 
