Index: trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid.pl	(revision 10534)
+++ trunk/ippScripts/scripts/detrend_resid.pl	(revision 10544)
@@ -20,5 +20,5 @@
 
 my ($det_id, $iter, $exp_tag, $class_id, $det_type, $detrend,
-        $input_uri, $camera, $no_update);
+        $input_uri, $camera, $mode, $no_update);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -30,10 +30,11 @@
     'input_uri|u=s'     => \$input_uri,
     'camera|c=s'        => \$camera,
-    'no-update'         => \$no_update
+    'mode|m=s'          => \$mode,
+    'no-update'         => \$no_update,
 ) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --iteration --exp_tag --class_id --det_type --detrend --camera --input_uri",
+    -msg => "Required options: --det_id --iteration --exp_tag --class_id --det_type --camera --input_uri --mode --detrend (not for 'verify' mode)",
     -exitval => 3,
 ) unless defined $det_id
@@ -42,7 +43,8 @@
     and defined $class_id
     and defined $det_type
-    and defined $detrend
     and defined $input_uri
-    and defined $camera;
+    and defined $camera
+    and defined $mode
+    and (defined $detrend or lc($mode) eq 'verify');
 
 $ipprc->define_camera($camera);
@@ -50,9 +52,18 @@
 # Recipes to use, as a function of the detrend type
 use constant RECIPES => {
-    'bias' => 'PPIMAGE_B',	# Bias only
-    'dark' => 'PPIMAGE_D',	# Dark only
-    'shutter' => 'PPIMAGE_S',	# Shutter only
-    'flat' => 'PPIMAGE_F',	# Flat-field only
-    'fringe' => 'PPIMAGE_R',	# Fringe only
+    'master' => {		# We're creating a master --- already processed the input
+	'bias' => 'PPIMAGE_B',	# Bias only
+	'dark' => 'PPIMAGE_D',	# Dark only
+	'shutter' => 'PPIMAGE_S',	# Shutter only
+	'flat' => 'PPIMAGE_F',	# Flat-field only
+	'fringe' => 'PPIMAGE_R',	# Fringe only
+    },
+    'verify' => {		# We're checking the master --- input is not already processed
+	'bias' => 'PPIMAGE_OB',	# Bias only
+	'dark' => 'PPIMAGE_OBD',	# Dark only
+	'shutter' => 'PPIMAGE_OBDS',	# Shutter only
+	'flat' => 'PPIMAGE_OBDSF',	# Flat-field only
+	'fringe' => 'PPIMAGE_OBDSFR',	# Fringe only
+    },
 };
 
@@ -76,9 +87,7 @@
 
 # Recipe to use in processing
-my $recipe = RECIPES->{$det_type};
+die "Unrecognised mode: $mode\n" if not defined RECIPES->{$mode};
+my $recipe = RECIPES->{$mode}->{$det_type};
 die "Unrecognised detrend type: $det_type\n" if not defined $recipe;
-# Detrend to use in processing
-my $detFlag = DETRENDS->{$det_type};
-die "Unrecognised detrend type: $det_type\n" if not defined $detFlag;
 
 ### Output file names --- must match camera configuration!
@@ -99,5 +108,13 @@
 {
     my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
-	" -stat $outputStats $detFlag $detrend"; # Command to run ppImage
+	" -stat $outputStats "; # Command to run ppImage
+
+    # Detrend to use in processing
+    if (lc($mode) ne 'verify') {
+	my $detFlag = DETRENDS->{$det_type};
+	die "Unrecognised detrend type: $det_type\n" if not defined $detFlag;
+	$command .= "$detFlag $detrend";
+    }
+
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
