Index: trunk/ippScripts/scripts/detrend_create_resid.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_create_resid.pl	(revision 8491)
+++ trunk/ippScripts/scripts/detrend_create_resid.pl	(revision 8493)
@@ -17,10 +17,17 @@
 };
 
+# Flags to specify the particular detrend to use
+use constant DETRENDS => {
+    'bias' => '-bias',		# Specify the bias frame
+    'dark' => '-dark',		# Specify the dark frame
+    'flat' => '-flat',		# Specify the flat frame
+};
+
 use constant DELETE_STATS => 0;	# Delete the statistics file when done?
 
 # Parse the command-line arguments
 if (scalar @ARGV != 6) {
-    die "Perform detrend processing at the imfile level.\n\n" .
-	"Usage: $0 DET_ID EXP_ID CLASS_ID DETREND_TYPE INPUT.fits OUTPUT_ROOT\n\n";
+    die "Apply a stacked detrend image to an individual detrend.\n\n" .
+	"Usage: $0 DET_ID EXP_ID CLASS_ID DETREND_TYPE DETREND.fits INPUT.fits OUTPUT_ROOT\n\n";
 }
 my $detId = shift @ARGV;	# Detrend ID
@@ -28,4 +35,5 @@
 my $classId = shift @ARGV;	# Class ID
 my $detType = shift @ARGV;	# Detrend type
+my $detrend = shift @ARGV;	# The detrend frame to apply
 my $input = shift @ARGV;	# Input FITS file
 my $output = shift @ARGV;	# Output root name
@@ -40,4 +48,7 @@
 my $recipe = RECIPES->{$detType};
 die "Unrecognised detrend type: $detType\n" if not defined $recipe;
+# Detrend to use in processing
+my $detFlag = DETREND->{$detType};
+die "Unrecognised detrend type: $detType\n" if not defined $detFlag;
 
 ### Output file names --- must match camera configuration!
@@ -49,5 +60,5 @@
 {
     my $command = "$ppImage -file $input $output -recipe PPIMAGE $recipe" .
-	" -stat $output.stats"; # Command to run ppImage
+	" -stat $output.stats $detFlag $detrend"; # Command to run ppImage
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
