Index: trunk/ippScripts/scripts/detrend_reject_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 11829)
+++ trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 11837)
@@ -33,5 +33,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $no_update);
+my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $no_update, $no_op);
 GetOptions(
 	   'det_id|d=s'        => \$det_id,
@@ -45,4 +45,5 @@
 	   'workdir|w=s'       => \$workdir, # Working directory, for output files
 	   'no-update'         => \$no_update,
+	   'no-op'             => \$no_op,
 	   ) or pod2usage( 2 );
 
@@ -129,26 +130,29 @@
 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
 
-# Make the jpeg for binning 1
-{
-    my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
-    unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
-    }
-    &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name;
-}
-
-# Make the jpeg for binning 2
-{
-    my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
-    unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
-    }
-    &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name;
+unless ($no_op) {
+
+    # Make the jpeg for binning 1
+    {
+	my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run
+	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	    run(command => $command, verbose => 1);
+	unless ($success) {
+	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+	    &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
+	}
+	&my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name;
+    }
+    
+    # Make the jpeg for binning 2
+    {
+	my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run
+	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	    run(command => $command, verbose => 1);
+	unless ($success) {
+	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+	    &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
+	}
+	&my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name;
+    }
 }
 
@@ -172,4 +176,6 @@
     my $stdev = sqrt($variances[$i]);	# Stdev for this imfile
 
+    last if $no_op;
+
     if ($reject_imfile_mean) {
 	if (abs($mean) > $reject_imfile_mean * $stdev) {
@@ -212,5 +218,4 @@
 	print "no rejection for imfile S/N\n";
     }
-    
 }
 
@@ -235,42 +240,44 @@
 ## Reject based on the exposure ensemble stats
 # reject if the exposure ensemble mean is deviant
-if ($reject_exp_mean) {
-    if (abs($mean) > $reject_exp_mean * $stdev) {
-	print "Rejecting exposure based on bad mean: \n";
-	print "mean: $mean, stdev: $stdev (limit is: % $reject_exp_mean\n";
-	$reject = 1;
-    } 
-} else {
-    print "no rejection for exp mean\n";
-}
-# reject if the exposure ensemble stdev is deviant
-if ($reject_exp_stdev) {
-    if ($stdev > $reject_exp_stdev) {
-	print "Rejecting exposure based on bad mean stdev: " . $stdev . " vs " .
-	    $reject_exp_stdev . "\n";
-	$reject = 1;
-    }
-} else {
-    print "no rejection for exp stdev\n";
-}
-# reject if the exposure ensemble mean stdev is deviant
-if ($reject_exp_meanstdev) {
-    if ($meanStdev > $reject_exp_meanstdev) {
-	print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " .
-	    $reject_exp_meanstdev . "\n";
-	$reject = 1;
-    }
-} else {
-    print "no rejection for exp mean stdev\n";
-}
-# reject if the signal-to-noise is insufficient
-if ($reject_exp_sn) {
-    if (abs($mean) < abs($stdev * $reject_exp_sn)) {
-	print "Rejecting exposure based on poor S/N: \n";
-	print "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_sn)\n";
-	$reject = 1;
-    }
-} else {
-    print "no rejection for exp S/N\n";
+unless ($no_op) {
+    if ($reject_exp_mean) {
+	if (abs($mean) > $reject_exp_mean * $stdev) {
+	    print "Rejecting exposure based on bad mean: \n";
+	    print "mean: $mean, stdev: $stdev (limit is: % $reject_exp_mean\n";
+	    $reject = 1;
+	} 
+    } else {
+	print "no rejection for exp mean\n";
+    }
+    # reject if the exposure ensemble stdev is deviant
+    if ($reject_exp_stdev) {
+	if ($stdev > $reject_exp_stdev) {
+	    print "Rejecting exposure based on bad mean stdev: " . $stdev . " vs " .
+		$reject_exp_stdev . "\n";
+	    $reject = 1;
+	}
+    } else {
+	print "no rejection for exp stdev\n";
+    }
+    # reject if the exposure ensemble mean stdev is deviant
+    if ($reject_exp_meanstdev) {
+	if ($meanStdev > $reject_exp_meanstdev) {
+	    print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " .
+		$reject_exp_meanstdev . "\n";
+	    $reject = 1;
+	}
+    } else {
+	print "no rejection for exp mean stdev\n";
+    }
+    # reject if the signal-to-noise is insufficient
+    if ($reject_exp_sn) {
+	if (abs($mean) < abs($stdev * $reject_exp_sn)) {
+	    print "Rejecting exposure based on poor S/N: \n";
+	    print "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_sn)\n";
+	    $reject = 1;
+	}
+    } else {
+	print "no rejection for exp S/N\n";
+    }
 }
 
@@ -278,8 +285,13 @@
 $jpeg1Name = $ipprc->convert_filename_relative( $jpeg1Name );
 $jpeg2Name = $ipprc->convert_filename_relative( $jpeg2Name );
+
+my $bg = $mean;
+my $bg_stdev = $stdev;
+my $bg_mean_stdev = $meanStdev;
+
 unless ($no_update) {
     my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_tag $exp_tag " .
-	"-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $outputRoot " .
-	"-bg $mean -bg_stdev $stdev -bg_mean_stdev $meanStdev";	# Command to run
+	"-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $outputRoot "; # Command to run
+    $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev";
     $command .= ' -reject' if $reject;
     $command .= " -dbname $dbname" if defined $dbname;
