Index: trunk/ippScripts/scripts/detrend_process_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 13275)
+++ trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 13552)
@@ -56,7 +56,25 @@
 $ipprc->define_camera($camera);
 
-use constant RECIPE1 => 'PPIMAGE_J1'; # Recipe to use for ppImage to make JPEGs
-use constant RECIPE2 => 'PPIMAGE_J2'; # Recipe to use for ppImage to make JPEGs
-
+# Recipes to use, as a function of the detrend type
+use constant RECIPES => {
+    'bin1' => {		# We're creating a master --- already processed the input
+	'bias'     => 'PPIMAGE_J1_IMAGE_B',	# Bias only
+	'dark'     => 'PPIMAGE_J1_IMAGE_B',	# Dark only
+	'shutter'  => 'PPIMAGE_J1_IMAGE_B',	# Shutter only
+	'flat'     => 'PPIMAGE_J1_IMAGE_F',	# Flat-field only
+	'domeflat' => 'PPIMAGE_J1_IMAGE_F',	# Flat-field only
+	'skyflat'  => 'PPIMAGE_J1_IMAGE_F',	# Flat-field only
+	'fringe'   => 'PPIMAGE_J1_IMAGE_F',	# Fringe only
+    },
+    'bin2' => {		# We're checking the master --- input is not already processed
+	'bias'     => 'PPIMAGE_J2_IMAGE_B',	# Bias only
+	'dark'     => 'PPIMAGE_J2_IMAGE_B',	# Dark only
+	'shutter'  => 'PPIMAGE_J2_IMAGE_B',	# Shutter only
+	'flat'     => 'PPIMAGE_J2_IMAGE_F',	# Flat-field only
+	'domeflat' => 'PPIMAGE_J2_IMAGE_F',	# Flat-field only
+	'skyflat'  => 'PPIMAGE_J2_IMAGE_F',	# Flat-field only
+	'fringe'   => 'PPIMAGE_J2_IMAGE_F',	# Fringe only
+    },
+};
 
 # Look for programs we need
@@ -135,8 +153,15 @@
 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
 
+# Recipes to use in processing
+my $recipe1 = RECIPES->{"bin1"}->{lc($det_type)};
+&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR) unless defined $recipe1;
+
+my $recipe2 = RECIPES->{"bin2"}->{lc($det_type)};
+&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR) unless defined $recipe2;
+
 unless ($no_op) {
     # Make the jpeg for binning 1
     {
-	my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run
+	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);
@@ -150,5 +175,5 @@
     # Make the jpeg for binning 2
     {
-	my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run
+	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);
@@ -162,7 +187,7 @@
 
 unless ($no_update) {
-    my $command = "$dettool -addprocessedexp -det_id $det_id -exp_tag $exp_tag " .
-	"-recip " . RECIPE1() . "," . RECIPE2() . " -path_base $outputRoot " .
-	"-bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; # Command to run
+    my $command = "$dettool -addprocessedexp -det_id $det_id -exp_tag $exp_tag";
+    $command .= " -recip $recipe1,$recipe2 -path_base $outputRoot";
+    $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev";
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
