Index: trunk/ippScripts/scripts/detrend_correct_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_correct_imfile.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_correct_imfile.pl	(revision 24764)
@@ -57,4 +57,7 @@
     and defined $outroot
     and defined $camera;
+
+# force det_type to be upper-case in this script
+$det_type = uc($det_type);
 
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
Index: trunk/ippScripts/scripts/detrend_norm_apply.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 24764)
@@ -62,4 +62,7 @@
     defined $outroot;
 
+# force det_type to be upper-case in this script
+$det_type = uc($det_type);
+
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 
@@ -72,28 +75,28 @@
 # Define which detrend types we normalise
 use constant DETTYPE => {
-    'bias'             => 'bias',
-    'dark'             => 'dark',
-    'dark_premask'     => 'dark',
-    'shutter'          => 'shutter',
-    'flat_premask'     => 'flat',
-    'domeflat_premask' => 'flat',
-    'skyflat_premask'  => 'flat',
-    'flat_raw'         => 'flat',
-    'domeflat_raw'     => 'flat',
-    'skyflat_raw'      => 'flat',
-    'flat'             => 'flat',
-    'domeflat'         => 'flat',
-    'skyflat'          => 'flat',
-    'fringe'           => 'fringe',
-    'mask'             => 'mask',
-    'darkmask'         => 'mask',
-    'flatmask'         => 'mask',
-    'ctemask'          => 'mask',
-    'darktest'         => 'dark',
+    'BIAS'             => 'BIAS',
+    'DARK'             => 'DARK',
+    'DARK_PREMASK'     => 'DARK',
+    'SHUTTER'          => 'SHUTTER',
+    'FLAT_PREMASK'     => 'FLAT',
+    'DOMEFLAT_PREMASK' => 'FLAT',
+    'SKYFLAT_PREMASK'  => 'FLAT',
+    'FLAT_RAW'         => 'FLAT',
+    'DOMEFLAT_RAW'     => 'FLAT',
+    'SKYFLAT_RAW'      => 'FLAT',
+    'FLAT'             => 'FLAT',
+    'DOMEFLAT'         => 'FLAT',
+    'SKYFLAT'          => 'FLAT',
+    'FRINGE'           => 'FRINGE',
+    'MASK'             => 'MASK',
+    'DARKMASK'         => 'MASK',
+    'FLATMASK'         => 'MASK',
+    'CTEMASK'          => 'MASK',
+    'DARKTEST'         => 'DARK',
     };
 
 # convert supplied detrend type to a controlled namespace
-&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR) unless exists DETTYPE()->{lc($det_type)};
-my $det_type_real = DETTYPE()->{lc($det_type)};
+&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR) unless exists DETTYPE()->{$det_type};
+my $det_type_real = DETTYPE()->{$det_type};
 
 &my_die("Couldn't find input file: $input_uri\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri);
@@ -107,7 +110,7 @@
 $ipprc->outroot_prepare($outroot);
 
-my $outFile = ($det_type_real eq "mask") ? 'PPIMAGE.OUTPUT.DETMASK' : 'PPIMAGE.OUTPUT';; # XXXX something of a hack (too many places to control things...)
-
-my $RECIPE_PPSTATS = ($det_type_real eq "dark") ? 'DARKSTATS' : 'DETSTATS';; # XXXX something of a hack (too many places to control things...)
+my $outFile = ($det_type_real eq "MASK") ? 'PPIMAGE.OUTPUT.DETMASK' : 'PPIMAGE.OUTPUT';; # XXXX something of a hack (too many places to control things...)
+
+my $RECIPE_PPSTATS = ($det_type_real eq "DARK") ? 'DARKSTATS' : 'DETSTATS';; # XXXX something of a hack (too many places to control things...)
 
 my $output    = $ipprc->filename($outFile,        $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
@@ -123,5 +126,5 @@
 
     # we cannot use ppImage to load a normalized mask : just copy it and build the jpeg images
-    if ($det_type_real eq 'mask') {
+    if ($det_type_real eq 'MASK') {
         $RECIPE_PPIMAGE = 'PPIMAGE_BIN';
         my $input_real = $ipprc->file_resolve($input_uri, 0);
@@ -135,6 +138,6 @@
     $command .= " -recipe PPSTATS $RECIPE_PPSTATS";
     $command .= " -F PPIMAGE.OUTPUT $outFile" unless $outFile eq 'PPIMAGE.OUTPUT';
-    $command .= ' -isfringe' if $det_type_real eq 'fringe';
-    $command .= ' -isdark' if $det_type_real eq 'dark';
+    $command .= ' -isfringe' if $det_type_real eq 'FRINGE';
+    $command .= ' -isdark' if $det_type_real eq 'DARK';
     $command .= " -tracedest $traceDest -log $logDest";
     $command .= " -dbname $dbname" if defined $dbname;
Index: trunk/ippScripts/scripts/detrend_norm_calc.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_norm_calc.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_norm_calc.pl	(revision 24764)
@@ -33,9 +33,9 @@
 
 # Parse command-line arguments
-my ($det_id, $iter, $detType, $outroot, $dbname, $verbose, $no_update, $no_op, $redirect );
+my ($det_id, $iter, $det_type, $outroot, $dbname, $verbose, $no_update, $no_op, $redirect );
 GetOptions(
     'det_id|d=s'        => \$det_id,    # Detrend id
     'iteration|i=s'     => \$iter,      # Iteration
-    'det_type|t=s'      => \$detType,   # Detrend type
+    'det_type|t=s'      => \$det_type,   # Detrend type
     'outroot|w=s'       => \$outroot,   # output file base name
     'dbname|d=s'        => \$dbname,    # Database name
@@ -52,6 +52,9 @@
     defined $det_id  and
     defined $iter    and
-    defined $detType and
+    defined $det_type and
     defined $outroot;
+
+# force det_type to be upper-case in this script
+my $det_type = uc($det_type);
 
 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
@@ -64,26 +67,26 @@
 # Define which detrend types we normalise
 use constant NORMALIZE => {
-    'bias'             => 0,
-    'dark'             => 0,
-    'dark_premask'     => 0,
-    'darktest'         => 0,
-    'shutter'          => 0,
-    'flat_premask'     => 1,
-    'domeflat_premask' => 1,
-    'skyflat_premask'  => 1,
-    'flat_raw'         => 1,
-    'domeflat_raw'     => 1,
-    'skyflat_raw'      => 1,
-    'flat'             => 1,
-    'domeflat'         => 1,
-    'skyflat'          => 1,
-    'fringe'           => 0,
-    'mask'             => 0,
-    'darkmask'         => 0,
-    'flatmask'         => 0,
-    'ctemask'          => 0,
+    'BIAS'             => 0,
+    'DARK'             => 0,
+    'DARK_PREMASK'     => 0,
+    'SHUTTER'          => 0,
+    'FLAT_PREMASK'     => 1,
+    'DOMEFLAT_PREMASK' => 1,
+    'SKYFLAT_PREMASK'  => 1,
+    'FLAT_RAW'         => 1,
+    'DOMEFLAT_RAW'     => 1,
+    'SKYFLAT_RAW'      => 1,
+    'FLAT'             => 1,
+    'DOMEFLAT'         => 1,
+    'SKYFLAT'          => 1,
+    'FRINGE'           => 0,
+    'MASK'             => 0,
+    'DARKMASK'         => 0,
+    'FLATMASK'         => 0,
+    'CTEMASK'          => 0,
+    'DARKTEST'         => 0,
     };
 
-&my_die("Unrecognised detrend type: $detType", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless exists NORMALIZE()->{lc($detType)};
+&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless exists NORMALIZE()->{$det_type};
 
 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
@@ -125,5 +128,5 @@
 
 my $norms;                      # MDC with normalisations
-if (NORMALIZE()->{lc($detType)} and not $no_op) {
+if (NORMALIZE()->{$det_type} and not $no_op) {
 
     my %matrix; # Matrix of statistics as a function of exposures and classes
Index: trunk/ippScripts/scripts/detrend_norm_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 24764)
@@ -58,4 +58,6 @@
     defined $outroot;
 
+$det_type = uc($det_type);
+
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 my $logfile = $outroot . ".log";
Index: trunk/ippScripts/scripts/detrend_process_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 24764)
@@ -61,4 +61,6 @@
     defined $outroot;
 
+$det_type = uc($det_type);
+
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $exp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 if ($redirect) {
Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 24764)
@@ -63,4 +63,7 @@
     defined $outroot;
 
+# force det_type to be upper-case in this script
+$det_type = uc($det_type);
+
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR);
@@ -69,6 +72,6 @@
 # Recipes to use as a function of detrend type
 $reduction = "DETREND" unless defined $reduction;
-my $ppimage_recipe = $ipprc->reduction($reduction, uc($det_type) . '_PROCESS'); # Recipe name for ppImage
-my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG
+my $ppimage_recipe = $ipprc->reduction($reduction, $det_type . '_PROCESS'); # Recipe name for ppImage
+my $jpeg_recipe = $ipprc->reduction($reduction, $det_type . '_JPEG_IMAGE'); # Recipe name for JPEG
 
 # The output file rule name depends on the detrend type
Index: trunk/ippScripts/scripts/detrend_reject_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 24764)
@@ -58,4 +58,6 @@
     defined $outroot;
 
+$det_type = uc($det_type);
+
 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 $ipprc->outroot_prepare($outroot) or my_die( "Unable to prepare output root", $det_id, $iter, $PS_EXIT_SYS_ERROR );
Index: trunk/ippScripts/scripts/detrend_resid_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid_exp.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_resid_exp.pl	(revision 24764)
@@ -79,4 +79,7 @@
     defined $outroot;
 
+# force det_type to be upper-case in this script
+$det_type = uc($det_type);
+
 # load IPP config information for the specified camera
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $exp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
@@ -87,5 +90,5 @@
 $reduction = 'DETREND' unless defined $reduction;
 
-my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_RESID'); # Recipe to use
+my $recipe = $ipprc->reduction($reduction, $det_type . '_JPEG_RESID'); # Recipe to use
 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe;
 
Index: trunk/ippScripts/scripts/detrend_resid_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 24764)
@@ -74,4 +74,7 @@
     defined $detrend;
 
+# force det_type to be upper-case in this script
+$det_type = uc($det_type);
+
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or my_die( "Unable to find LOG.IMFILE", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR );
@@ -83,7 +86,7 @@
 my $recipe;                     # Name of recipe to use
 if ($mode eq 'master') {
-    $recipe = uc($det_type) . '_RESID';
+    $recipe = $det_type . '_RESID';
 } elsif ($mode eq 'verify') {
-    $recipe = uc($det_type) . '_VERIFY';
+    $recipe = $det_type . '_VERIFY';
 } else {
     &my_die("Unrecognised mode: $mode", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
@@ -92,28 +95,28 @@
 print "raw recipe: $recipe\n";
 my $ppimage_recipe = $ipprc->reduction($reduction, $recipe);
-my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_RESID');
+my $jpeg_recipe = $ipprc->reduction($reduction, $det_type . '_JPEG_RESID');
 print "real recipe: $recipe\n";
 
 # Flags to specify the particular detrend to use
 use constant DETRENDS => {
-    'bias'             => '-bias',      # Specify the bias frame
-    'dark'             => '-dark',      # Specify the dark frame
-    'darktest'         => '-dark',      # Specify the dark frame
-    'dark_premask'     => '-dark',      # Specify the dark frame
-    'shutter'          => '-shutter',   # Specify the shutter frame
-    'flat_premask'     => '-flat',      # Specify the flat frame
-    'domeflat_premask' => '-flat',      # Specify the flat frame
-    'skyflat_premask'  => '-flat',      # Specify the flat frame
-    'flat_raw'         => '-flat',      # Specify the flat frame
-    'domeflat_raw'     => '-flat',      # Specify the flat frame
-    'skyflat_raw'      => '-flat',      # Specify the flat frame
-    'flat'             => '-flat',      # Specify the flat frame
-    'domeflat'         => '-flat',      # Specify the flat frame
-    'skyflat'          => '-flat',      # Specify the flat frame
-    'fringe'           => '-fringe',    # Specify the fringe frame
-    'mask'             => '-mask',      # Specify the mask frame
-    'darkmask'         => '-mask',      # Specify the mask frame
-    'flatmask'         => '-mask',      # Specify the mask frame
-    'ctemask'          => '-mask',      # Specify the mask frame
+    'BIAS'             => '-bias',      # Specify the bias frame
+    'DARK'             => '-dark',      # Specify the dark frame
+    'DARK_PREMASK'     => '-dark',      # Specify the dark frame
+    'DARKTEST'         => '-dark',      # Specify the dark frame
+    'SHUTTER'          => '-shutter',   # Specify the shutter frame
+    'FLAT_PREMASK'     => '-flat',      # Specify the flat frame
+    'DOMEFLAT_PREMASK' => '-flat',      # Specify the flat frame
+    'SKYFLAT_PREMASK'  => '-flat',      # Specify the flat frame
+    'FLAT_RAW'         => '-flat',      # Specify the flat frame
+    'DOMEFLAT_RAW'     => '-flat',      # Specify the flat frame
+    'SKYFLAT_RAW'      => '-flat',      # Specify the flat frame
+    'FLAT'             => '-flat',      # Specify the flat frame
+    'DOMEFLAT'         => '-flat',      # Specify the flat frame
+    'SKYFLAT'          => '-flat',      # Specify the flat frame
+    'FRINGE'           => '-fringe',    # Specify the fringe frame
+    'MASK'             => '-mask',      # Specify the mask frame
+    'DARKMASK'         => '-mask',      # Specify the mask frame
+    'FLATMASK'         => '-mask',      # Specify the mask frame
+    'CTEMASK'          => '-mask',      # Specify the mask frame
 };
 
@@ -174,5 +177,5 @@
 
     # Detrend to use in processing
-    my $detFlag = DETRENDS->{lc($det_type)};
+    my $detFlag = DETRENDS->{$det_type};
     &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag;
     $command .= " $detFlag $detrend";
Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 24763)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 24764)
@@ -188,5 +188,5 @@
 $command = "$ppMerge $listName $outroot"; # Command to run
 $command .= " -recipe PPMERGE $recipe";
-$command .= ' -type ' . uc($det_type); # Type of stacking to perform
+$command .= ' -type $det_type'; # Type of stacking to perform
 $command .= " -stats $outputStats";     # Statistics output filename
 $command .= " -recipe PPSTATS $statrecipe";
