Index: /trunk/tools/ipp_apply_burntool.pl
===================================================================
--- /trunk/tools/ipp_apply_burntool.pl	(revision 24858)
+++ /trunk/tools/ipp_apply_burntool.pl	(revision 24859)
@@ -20,5 +20,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ( $class_id, $dateobs_begin, $dateobs_end, $skip_burned, $dbname, $logfile, $verbose, $save_temps);
+my ( $class_id, $dateobs_begin, $dateobs_end, $skip_burned, $rerun_from_first, $dbname, $logfile, $verbose, $save_temps);
 GetOptions(
     'class_id=s'        => \$class_id, # chip identifier
@@ -28,4 +28,5 @@
     'logfile=s'         => \$logfile,
     'skip_burned'       => \$skip_burned,   # Print to stdout
+    'rerun_from_first'  => \$rerun_from_first,   # Print to stdout
     'verbose'           => \$verbose,   # Print to stdout
     'save-temps'        => \$save_temps, # Save temporary files?
@@ -42,4 +43,6 @@
     defined $dbname;
 
+if ($skip_burned and $rerun_from_first) { &my_die("-rerun_from_first and -skip_burned are incompatible"); }
+
 my $missing_tools;
 my $regtool  = can_run('regtool')  or (warn "Can't find regtool" and $missing_tools = 1);
@@ -58,5 +61,5 @@
 $command .= " -dateobs_begin $dateobs_begin";
 $command .= " -dateobs_end $dateobs_end";
-# $command .= " -limit 20";
+$command .= " -ordered_by_date";
 $command .= " -dbname $dbname" if defined $dbname;
 
@@ -101,4 +104,12 @@
 if (! $skip_burned)  {
     foreach my $file (@files) {
+	
+	# rerun_from_first treats the first image as already burned (if it is already burned)
+	# the artifact table from the first file is used for the rest of the sequence.
+	if ($rerun_from_first) {
+	    $skip_burned = 1;
+	    $rerun_from_first = 0;
+	    next;
+	}
 	my $exp_id = $file->{exp_id};
 
@@ -108,4 +119,5 @@
 	    &my_die("failed to update imfile");
 	}
+	$file->{user_1} = 0.1;
     }
 }
@@ -122,5 +134,5 @@
 	($rawImfileReal) = $rawImfile =~ m|^neb:/(.*)|;
     }
-    # print "rawImfile: $rawImfile -> $rawImfileReal\n";
+    print "rawImfile: $rawImfile -> $rawImfileReal\n";
 
     # mangle name, create tmp file (always a UNIX file)
@@ -149,5 +161,8 @@
     }
 
+    print "$rawImfile : $skip_burned, $file->{user_1}\n";
+
     if (! ($skip_burned and ($file->{user_1} > 0.5))) {
+	print "running on: $rawImfile\n";
         # uncompress the image (do we need to check if it is compressed?)
         my $status = vsystem ("$funpack -S $rawImfileReal > $tmpImfileReal", $REALRUN);
