Index: trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid.pl	(revision 13926)
+++ trunk/ippScripts/scripts/detrend_resid.pl	(revision 13937)
@@ -34,5 +34,5 @@
 
 my ($det_id, $iter, $exp_tag, $class_id, $det_type, $detrend,
-        $input_uri, $camera, $mode, $dbname, $workdir, $no_update, $no_op);
+        $input_uri, $camera, $mode, $dbname, $workdir, $reduction, $no_update, $no_op);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -47,4 +47,5 @@
     'dbname|d=s'        => \$dbname, # Database name
     'workdir|w=s'       => \$workdir,	# Working directory, for output files
+    'reduction=s'       => \$reduction,	# Reduction class
     'no-update'         => \$no_update,
     'no-op'             => \$no_op,
@@ -67,25 +68,14 @@
 $ipprc->define_camera($camera);
 
-# Recipes to use, as a function of the detrend type
-use constant RECIPES => {
-    '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
-	'domeflat' => 'PPIMAGE_F',	# Flat-field only
-	'skyflat'  => '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
-	'domeflat' => 'PPIMAGE_OBDSF',	# Flat-field only
-	'skyflat'  => 'PPIMAGE_OBDSF',	# Flat-field only
-	'fringe'   => 'PPIMAGE_OBDSFR',	# Fringe only
-    },
-};
+$reduction = 'DETREND' unless defined $reduction;
+my $recipe;			# Name of recipe to use
+if ($mode eq 'master') {
+    $recipe = $det_type . '_RESID';
+} elsif ($mode eq 'verify') {
+    $recipe = $det_type . '_VERIFY';
+} else {
+    &my_die("Unrecognised mode: $mode", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
+}
+$recipe = $ipprc->reduction($reduction, $recipe);
 
 # Flags to specify the particular detrend to use
@@ -113,9 +103,4 @@
 $ppImage .= " -dbname $dbname" if defined $dbname;
 
-# Recipe to use in processing
-&my_die("Unrecognised mode: $mode", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined RECIPES->{$mode};
-my $recipe = RECIPES->{$mode}->{lc($det_type)};
-&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $recipe;
-
 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
 
@@ -183,6 +168,6 @@
 my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN');
 my $bin_stdev	  = ($binnedStats->bg_stdev() or 'NAN');
-my $fringe_0 	  = (${$stats->fringe()[0]} or 'NAN');
-my $fringe_1 	  = (${$stats->fringe_err()[0]} or 'NAN');
+my $fringe_0 	  = (${$stats->fringe()}[0] or 'NAN');
+my $fringe_1 	  = (${$stats->fringe_err()}[0] or 'NAN');
 my $fringe_2 	  = 'NAN';
 
