Index: /trunk/ippScripts/scripts/detrend_apply_norm.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_apply_norm.pl	(revision 9003)
+++ /trunk/ippScripts/scripts/detrend_apply_norm.pl	(revision 9004)
@@ -5,6 +5,4 @@
 
 use IPC::Cmd qw( can_run run );
-use PS::IPP::Metadata::Config;
-use PS::IPP::Metadata::List qw( parse_md_list );
 use Data::Dumper;
 
@@ -18,5 +16,6 @@
     $value,			# Value to multiple (for normalisation)
     $input,			# Input file
-    $output			# Output file
+    $camera,			# Camera
+    $detType			# Detrend type
     );
 GetOptions(
@@ -26,17 +25,19 @@
     'value|v=s'		=> \$value,
     'input_uri|u=s'     => \$input,
-    'output_uri|o=s'    => \$output,
+    'camera|c=s'        => \$camera,
+    'det_type|t=s'      => \$detType
     ) or pod2usage( 2 );
     
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage(     -msg => "Required options: --det_id --iteration --class_id --value --input_uri --output_uri",
+pod2usage(     -msg => "Required options: --det_id --iteration --class_id --value --input_uri --camera --det_type",
     -exitval => 3,
     ) unless defined $detId
-        and defined $iter
-	    and defined $classId
-	        and defined $value
-		    and defined $input
-		        and defined $output;
-			
+    and defined $iter
+    and defined $classId
+    and defined $value
+    and defined $input
+    and defined $camera
+    and defined $detType;
+
 
 # Look for programs we need
@@ -46,5 +47,6 @@
 die "Can't find required tools.\n" if $missing_tools;
 
-my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
+# Output name
+my $output = $camera . '.' . $detType . '.norm.' . $detId . '.' . $iter . '.' . $classId . '.fits';
 
 # Run ppArith
Index: /trunk/ippScripts/scripts/detrend_calc_norm.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_calc_norm.pl	(revision 9003)
+++ /trunk/ippScripts/scripts/detrend_calc_norm.pl	(revision 9004)
@@ -16,13 +16,9 @@
 # Parse command-line arguments
 my ($detId,			# Detrend id
-    $iter,			# Iteration
-    $camera,			# Camera name
-    $detType			# Detrend type
+    $iter			# Iteration
     );
 GetOptions(
 	'det_id|d=s'	=> \$detId,
 	'iteration|i=s'	=> \$iter,
-	'camera|c=s'    => \$camera,
-	'det_type|t=s'  => \$detType
 	) or pod2usage( 2 );
 
@@ -31,7 +27,5 @@
 	   -exitval => 3,
 	   ) unless defined $detId
-    and defined $iter
-    and defined $camera
-    and defined $detType;
+    and defined $iter;
 
 
@@ -56,5 +50,5 @@
     
     # Parse the output
-    my $metadata = $mdcParser->parse(join "", @$stdout)
+    my $metadata = $mdcParser->parse($stdout)
         or die "unable to parse metadata config doc";
     $files = parse_md_list($metadata);
@@ -91,5 +85,5 @@
 
     # Parse the output
-    $norms = $mdcParser->parse(join "", @$stdout)
+    $norms = $mdcParser->parse($stdout)
         or die "unable to parse metadata config doc";
 }
Index: /trunk/ippScripts/scripts/detrend_create_resid.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_create_resid.pl	(revision 9003)
+++ /trunk/ippScripts/scripts/detrend_create_resid.pl	(revision 9004)
@@ -16,5 +16,5 @@
 
 my ($det_id, $iter, $exp_id, $class_id, $det_type, $detrend,
-        $input_uri, $output_uri);
+        $input_uri);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -25,10 +25,9 @@
     'detrend=s'         => \$detrend,
     'input_uri|u=s'     => \$input_uri,
-    'output_uri|o=s'    => \$output_uri,
 ) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --iteration --exp_id --class_id --det_type --detrend --input_uri --output_uri",
+    -msg => "Required options: --det_id --iteration --exp_id --class_id --det_type --detrend --input_uri",
     -exitval => 3,
 ) unless defined $det_id
@@ -38,6 +37,5 @@
     and defined $det_type
     and defined $detrend
-    and defined $input_uri
-    and defined $output_uri;
+    and defined $input_uri;
 
 # Recipes to use, as a function of the detrend type
@@ -53,11 +51,4 @@
     'dark' => '-dark',		# Specify the dark frame
     'flat' => '-flat',		# Specify the flat frame
-};
-
-# Prefix to add to filenames
-use constant PREFIX => {
-    'bias' => 'ob',		# Overscan only
-    'dark' => 'obd',		# Overscan and bias only
-    'flat' => 'obdf',		# Overscan, bias and dark only
 };
 
@@ -77,14 +68,11 @@
 my $detFlag = DETRENDS->{$det_type};
 die "Unrecognised detrend type: $det_type\n" if not defined $detFlag;
-# Prefix to use for filename
-my $prefix = PREFIX->{$det_type};
-die  "Unrecognised detrend type: $det_type\n" if not defined $prefix;
 
 ### Output file names --- must match camera configuration!
-my $outputRoot = $prefix . '_' . $output_uri;
-my $outputName = $outputRoot . '.' . $class_id . '.fit';
+my $outputRoot = $exp_id . '.detresid.' . $det_id . '.' . $iter; # Root name
+my $outputName = $outputRoot . '.' . $class_id . '.fits'; # Name for 
 my $outputStats = $outputRoot . '.' . $class_id . '.stats';
-my $bin1Name = $outputRoot . '.' . $class_id . '.b1.fit';
-my $bin2Name =  $outputRoot . '.' . $class_id . '.b2.fit';
+my $bin1Name = $outputRoot . '.' . $class_id . '.b1.fits';
+my $bin2Name =  $outputRoot . '.' . $class_id . '.b2.fits';
 
 # Run ppImage
@@ -96,4 +84,5 @@
     die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success;
     die "Couldn't find expected output file: $outputName\n" if not -f $outputName;
+    die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats;
     die "Couldn't find expected output file: $bin1Name\n" if not -f $bin1Name;
     die "Couldn't find expected output file: $bin2Name\n" if not -f $bin2Name;
@@ -104,5 +93,5 @@
 {
     my $statsFile;		# File handle
-    open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
+    open $statsFile, $outputStats or die "Can't open statistics file $outputStats: $!\n";
     my @contents = <$statsFile>; # Contents of file
     close $statsFile;
@@ -134,5 +123,5 @@
 }
 
-unlink "$output_uri.stats" if DELETE_STATS;
+unlink $outputStats if DELETE_STATS;
 
 __END__
Index: /trunk/ippScripts/scripts/detrend_process.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process.pl	(revision 9003)
+++ /trunk/ippScripts/scripts/detrend_process.pl	(revision 9004)
@@ -22,10 +22,9 @@
     'det_type|t=s'      => \$det_type,
     'input_uri|u=s'     => \$input_uri,
-    'output_uri|o=s'    => \$output_uri,
 ) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri",
+    -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri",
     -exitval => 3,
 ) unless defined $det_id
@@ -33,6 +32,5 @@
     and defined $class_id
     and defined $det_type
-    and defined $input_uri
-    and defined $output_uri;
+    and defined $input_uri;
 
 # Recipes to use, as a function of the detrend type
@@ -41,11 +39,4 @@
     'dark' => 'PPIMAGE_OB',	# Overscan and bias only
     'flat' => 'PPIMAGE_OBD',	# Overscan, bias and dark only
-};
-
-# Prefix to add to filenames
-use constant PREFIX => {
-    'bias' => 'o',		# Overscan only
-    'dark' => 'ob',		# Overscan and bias only
-    'flat' => 'obd',		# Overscan, bias and dark only
 };
 
@@ -61,10 +52,9 @@
 my $recipe = RECIPES->{$det_type};
 die "Unrecognised detrend type: $det_type\n" if not defined $recipe;
-die "Unrecognised detrend type: $det_type\n" if not defined PREFIX->{$det_type};
 
 ### Output file name --- must match camera configuration!
-my $outputRoot =  PREFIX->{$det_type} . '_' . $output_uri;
+my $outputRoot =  $exp_id . '.detproc' ;
 my $outputName = $outputRoot . '.' . $class_id ;
-my $outputImage = $outputName . '.fit';
+my $outputImage = $outputName . '.fits';
 my $outputStats = $outputName . '.stats';
 
Index: /trunk/ippScripts/scripts/detrend_reject_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 9003)
+++ /trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 9004)
@@ -24,5 +24,5 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri",
+    -msg => "Required options: --det_id --iteration --det_type",
     -exitval => 3,
 ) unless defined $det_id
Index: /trunk/ippScripts/scripts/detrend_reject_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 9003)
+++ /trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 9004)
@@ -96,7 +96,7 @@
 
 # Generate the file list, and get the statistics
-my $outputName = $exp_id . '_' . $det_id . '_' . $iter; # Root output name
-my $list1Name = $outputName . '_jpeg1.list'; # Name for the input file list for binning 1
-my $list2Name = $outputName . '_jpeg2.list'; # Name for the input file list for binning 2
+my $outputRoot = $exp_id . '.detresid.' . $det_id . '.' . $iter; # Root output name
+my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
+my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2
 my @means;			# Array of means
 my @stdevs;			# Array of stdevs
@@ -113,10 +113,10 @@
 
 # Output products --- need to synch with the camera configuration!
-my $jpeg1Name = $outputName . ".b1.jpg"; # Binned JPEG #1
-my $jpeg2Name = $outputName . ".b2.jpg"; # Binned JPEG #2
+my $jpeg1Name = $outputRoot . ".b1.jpg"; # Binned JPEG #1
+my $jpeg2Name = $outputRoot . ".b2.jpg"; # Binned JPEG #2
 
 # Make the jpeg for binning 1
 {
-    my $command = "$ppImage -list $list1Name $outputName -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);
@@ -126,5 +126,5 @@
 # Make the jpeg for binning 2
 {
-    my $command = "$ppImage -list $list2Name $outputName -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);
Index: /trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_stack.pl	(revision 9003)
+++ /trunk/ippScripts/scripts/detrend_stack.pl	(revision 9004)
@@ -15,5 +15,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $iter, $class_id, $det_type);
+my ($det_id, $iter, $class_id, $det_type, $camera);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -21,14 +21,16 @@
     'class_id|i=s'      => \$class_id,
     'det_type|t=s'      => \$det_type,
+    'camera|c=s'        => \$camera,
 ) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --iteration --class_id --det_type",
+    -msg => "Required options: --det_id --iteration --class_id --det_type --camera",
     -exitval => 3,
 ) unless defined $det_id
     and defined $iter
     and defined $class_id
-    and defined $det_type;
+    and defined $det_type
+    and defined $camera;
 
 # Recipes to use as a function of detrend type
@@ -44,7 +46,8 @@
     'dark' => 0,
     'flat' => 1
-    };    
+    };
 
-die "Unrecognised detrend type: $det_type\n" if not defined RECIPES()->{$det_type};
+die "Unrecognised detrend type: $det_type\n" if not defined RECIPES()->{$det_type}
+                                             or not defined NORMALISE()->{$det_type};
 my $recipe = RECIPES()->{$det_type}; # Recipe to use in stacking
 
@@ -70,8 +73,9 @@
 
 # Stack the files
-my $output = $det_type . '_' . $class_id . '_' . $det_id . '_' . $iter . '.fit'; # Output name
-my $outputStats = $det_type . '_' . $class_id . '_' . $det_id . '_' . $iter . '.stats'; # Statistics name
+my $outputRoot = $camera . '.' . $det_type . '.' . $det_id . '.' . $iter . '.' . $class_id; # Root name
+my $outputStack = $outputRoot . '.fits'; # Output name
+my $outputStats = $outputRoot . '.stats'; # Statistics name
 {
-    my $command = "$ppMerge $output"; # Command to run
+    my $command = "$ppMerge $outputStack"; # Command to run
     foreach my $file (@$files) {
 	my $uri = $file->{uri};	# URI for input file
@@ -85,5 +89,5 @@
 	run(command => $command, verbose => 1);
     die "Unable to perform ppMerge: $error_code\n" if not $success;
-    die "Unable to find expected output file: $output\n" if not -f $output;
+    die "Unable to find expected output file: $outputStack\n" if not -f $outputStack;
     die "Unable to find expected output file: $outputStats\n" if not -f $outputStats;
 }
@@ -109,5 +113,5 @@
 {
     my $command = "$dettool -addstacked -det_id $det_id -iteration $iter -class_id $class_id" .
-	" -uri $output -recip $recipe";	# Command to run
+	" -uri $outputStack -recip $recipe"; # Command to run
     $command .= ' -bg ' . $stats->bg_mean();
     if (defined($stats->bg_stdev())) {
