Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 13926)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 13937)
@@ -29,6 +29,4 @@
 use Pod::Usage qw( pod2usage );
 
-my $RECIPE = 'PPIMAGE_OBDSFRA'; # Recipe to use
-
 # Parse the command-line arguments
 my ($exp_id,			# Exposure identifier
@@ -36,8 +34,8 @@
     $class_id,			# Class identifier
     $input,			# Input FITS file
-    $recipe,			# Recipe to use
     $camera,			# Camera
     $dbname,			# Database name
     $workdir,			# Working directory, for output files
+    $reduction,			# Reduction class
     $no_update,			# Don't update the database?
     $no_op,			# Don't do any operations?
@@ -48,8 +46,8 @@
 	   'class_id=s'    => \$class_id,
 	   'uri|u=s'       => \$input,
-	   'recipe=s'      => \$recipe,
 	   'camera|c=s'    => \$camera,
 	   'dbname|d=s'    => \$dbname, # Database name
 	   'workdir|w=s'   => \$workdir,
+	   'reduction=s'   => \$reduction,
 	   'no-update'     => \$no_update,
 	   'no-op'         => \$no_op,
@@ -67,4 +65,6 @@
 
 $ipprc->define_camera($camera);
+$reduction = 'DEFAULT' unless defined $reduction;
+my $recipe = $ipprc->reduction($reduction, 'CHIP'); # Recipe to use
 
 # Look for programs we need
@@ -97,5 +97,5 @@
 
     my $command = "$ppImage -file $input $outputRoot";
-    $command .= " -recipe PPIMAGE $RECIPE";
+    $command .= " -recipe PPIMAGE $recipe";
     $command .= " -recipe PPSTATS CHIPSTATS";
     $command .= " -stats $outputStats"; # Command to run ppImage
@@ -130,6 +130,6 @@
 my $bg_stdev = ($stats->bg_stdev() or 'NAN');
 my $bg_mean_stdev = ($stats->bg_mean_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';
 
Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 13926)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 13937)
@@ -32,5 +32,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $camera, $dbname, $workdir, $no_update, $no_op);
+my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $camera, $dbname, $workdir, $reduction, $no_update, $no_op);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -42,4 +42,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,
@@ -60,14 +61,6 @@
 $ipprc->define_camera($camera);
 
-# Recipes to use, as a function of the detrend type
-use constant RECIPES => {
-    'bias'     => 'PPIMAGE_O',	  # Overscan only
-    'dark'     => 'PPIMAGE_OB',	  # Overscan and bias only
-    'shutter'  => 'PPIMAGE_OBD',  # Overscan, bias and dark only
-    'flat'     => 'PPIMAGE_OBDS', # Overscan, bias, dark and shutter only
-    'domeflat' => 'PPIMAGE_OBDS', # Overscan, bias, dark and shutter only
-    'skyflat'  => 'PPIMAGE_OBDS', # Overscan, bias, dark and shutter only
-    'fringe'   => 'PPIMAGE_OBDSF',# Overscan, bias, dark, shutter and flat only
-};
+$reduction = "DETREND" unless defined $reduction;
+my $recipe = $ipprc->reduction($reduction, $det_type . '_PROCESS'); # Recipe name to use
 
 # Look for programs we need
@@ -80,11 +73,4 @@
 }
 $ppImage .= " -dbname $dbname" if defined $dbname;
-
-# Recipe to use in processing
-my $recipe = RECIPES->{lc($det_type)};
-unless (defined $recipe) {
-    warn("Unrecognised detrend type: $det_type");
-    exit($PS_EXIT_CONFIG_ERROR);
-}
 
 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
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';
 
Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 13926)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 13937)
@@ -33,5 +33,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $iter, $class_id, $det_type, $camera, $dbname, $workdir, $no_update, $no_op, $quiet);
+my ($det_id, $iter, $class_id, $det_type, $camera, $dbname, $workdir, $reduction, $no_update, $no_op, $quiet);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -42,4 +42,5 @@
     'dbname|d=s'        => \$dbname, # Database name
     'workdir|w=s'       => \$workdir,	# Working directory, for output files
+    'reduction=s'       => \$reduction,	# Reduction class for processing
     'no-update'         => \$no_update,
     'no-op'             => \$no_op,
@@ -58,14 +59,9 @@
 if (defined $quiet) { $verbose = 0; }
 
+$ipprc->define_camera($camera);
+
 # Recipes to use as a function of detrend type
-use constant RECIPES => {
-    'bias' => 'PPMERGE_BIAS',
-    'dark' => 'PPMERGE_DARK',
-    'shutter' => 'PPMERGE_SHUTTER',
-    'flat' => 'PPMERGE_FLAT',
-    'domeflat' => 'PPMERGE_FLAT',
-    'skyflat' => 'PPMERGE_FLAT',
-    'fringe' => 'PPMERGE_FRINGE',
-    };
+$reduction = "DETREND" unless defined $reduction;
+my $recipe = $ipprc->reduction($reduction, $det_type . '_STACK'); # Recipe name to use
 
 # Look for programs we need
@@ -77,7 +73,4 @@
     exit($PS_EXIT_CONFIG_ERROR); 
 }
-
-my $recipe = RECIPES()->{lc($det_type)}; # Recipe to use in stacking
-&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR) unless defined $recipe;
 
 my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
Index: trunk/ippScripts/scripts/ipp_serial_chip.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 13926)
+++ trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 13937)
@@ -54,6 +54,8 @@
     my $class_id = $item->{class_id};
     my $uri = $item->{uri};
+    my $reduction = $item->{reduction};
     
     my $command = "$chip --chip_id $chip_id --exp_id $exp_id --class_id $class_id --uri $uri --dbname $dbname --camera $camera";
+    $command .= " --reduction $reduction" if defined $reduction;
     $command .= " --no-op" if defined $no_op;
     $command .= " --no-update" if defined $no_update;
Index: trunk/ippScripts/scripts/ipp_serial_detrend.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_serial_detrend.pl	(revision 13926)
+++ trunk/ippScripts/scripts/ipp_serial_detrend.pl	(revision 13937)
@@ -65,6 +65,8 @@
 		my $camera = $item->{camera};
 		my $workdir = $item->{workdir};
-		
+		my $reduction = $item->{reduction};
+
 		my $command = "$detrend_process_imfile --det_id $det_id --exp_tag $exp_tag --class_id $class_id --det_type $det_type --input_uri $uri --camera $camera --dbname $dbname";
+		$command .= " --reduction $reduction" if defined $reduction;
 		$command .= " --workdir $workdir" if defined $workdir;
 		my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -119,6 +121,8 @@
 	my $camera = $item->{camera};
 	my $workdir = $item->{workdir};
+	my $reduction = $item->{reduction};
 
 	my $command = "$detrend_stack --det_id $det_id --iteration $iteration --class_id $class_id --det_type $det_type --camera $camera --dbname $dbname";
+	$command .= " --reduction $reduction" if defined $reduction;
 	$command .= " --workdir $workdir" if defined $workdir;
     	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -235,6 +239,8 @@
 		my $mode = $item->{mode};
 		my $workdir = $item->{workdir};
+		my $reduction = $item->{reduction};
 
 		my $command = "$detrend_resid --det_id $det_id --iteration $iteration --exp_tag $exp_tag --class_id $class_id --det_type $det_type --camera $camera --input_uri $uri --mode $mode --dbname $dbname";
+		$command .= " --reduction $reduction" if defined $reduction;
 		$command .= " --detrend $detrend" if defined $detrend;
 		$command .= " --workdir $workdir" if defined $workdir;
