Index: unk/ippScripts/scripts/detrend_process.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process.pl	(revision 9091)
+++ 	(revision )
@@ -1,108 +1,0 @@
-#!/usr/bin/env perl
-
-use warnings;
-use strict;
-
-use vars qw( $VERSION );
-$VERSION = '0.01';
-
-use IPC::Cmd qw( can_run run );
-use PS::IPP::Metadata::Config;
-use PS::IPP::Metadata::Stats;
-
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use Pod::Usage qw( pod2usage );
-
-my ($det_id, $exp_id, $class, $class_id, $det_type, $input_uri, $output_uri, $no_update);
-GetOptions(
-    'det_id|d=s'        => \$det_id,
-    'exp_id|e=s'        => \$exp_id,
-    'class=s'           => \$class,     # unused
-    'class_id|i=s'      => \$class_id,
-    'det_type|t=s'      => \$det_type,
-    'input_uri|u=s'     => \$input_uri,
-    'no-update'         => \$no_update
-) 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",
-    -exitval => 3,
-) unless defined $det_id
-    and defined $exp_id
-    and defined $class_id
-    and defined $det_type
-    and defined $input_uri;
-
-# 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
-    'flat' => 'PPIMAGE_OBD',	# Overscan, bias and dark only
-};
-
-use constant DELETE_STATS => 0;	# Delete the statistics file when done?
-
-# Look for programs we need
-my $missing_tools;
-my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
-my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
-die "Can't find required tools.\n" if $missing_tools;
-
-# Recipe to use in processing
-my $recipe = RECIPES->{$det_type};
-die "Unrecognised detrend type: $det_type\n" if not defined $recipe;
-
-### Output file name --- must match camera configuration!
-my $outputRoot =  $exp_id . '.detproc.' . $det_id;
-my $outputName = $outputRoot . '.' . $class_id ;
-my $outputImage = $outputName . '.fits';
-my $outputStats = $outputName . '.stats';
-
-# Run ppImage
-{
-    my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
-	" -stat $outputStats"; # Command to run ppImage
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
-    die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success;
-    die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage;
-    die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats;
-}
-
-# Get the statistics on the processed image
-my $stats;			# Statistics from ppImage
-{
-    my $statsFile;		# File handle
-    open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
-    my @contents = <$statsFile>; # Contents of file
-    close $statsFile;
-    my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
-    my $metadata = $mdcParser->parse(join "", @contents)
-        or die "unable to parse metadata config";
-    $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
-    $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";
-}
-
-# Add the processed file to the database
-unless ($no_update) {
-    my $command = "$dettool -addprocessed -det_id $det_id -exp_id $exp_id " .
-	"-class_id $class_id -recip $recipe -uri $outputImage"; # Command to run dettool
-    $command .= " -bg " . $stats->bg_mean();
-    if (defined($stats->bg_stdev())) {
-	$command .= " -bg_stdev " . $stats->bg_stdev();
-    } else {
-	# May be undefined if there's only a single imfile
-	$command .= " -bg_stdev 0";
-    }
-    $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev();
-
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
-    die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n"
-	if not $success;
-}
-
-unlink "$outputStats" if DELETE_STATS;
-
-__END__
Index: /trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9092)
+++ /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9092)
@@ -0,0 +1,108 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+use vars qw( $VERSION );
+$VERSION = '0.01';
+
+use IPC::Cmd qw( can_run run );
+use PS::IPP::Metadata::Config;
+use PS::IPP::Metadata::Stats;
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use Pod::Usage qw( pod2usage );
+
+my ($det_id, $exp_id, $class, $class_id, $det_type, $input_uri, $output_uri, $no_update);
+GetOptions(
+    'det_id|d=s'        => \$det_id,
+    'exp_id|e=s'        => \$exp_id,
+    'class=s'           => \$class,     # unused
+    'class_id|i=s'      => \$class_id,
+    'det_type|t=s'      => \$det_type,
+    'input_uri|u=s'     => \$input_uri,
+    'no-update'         => \$no_update
+) 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",
+    -exitval => 3,
+) unless defined $det_id
+    and defined $exp_id
+    and defined $class_id
+    and defined $det_type
+    and defined $input_uri;
+
+# 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
+    'flat' => 'PPIMAGE_OBD',	# Overscan, bias and dark only
+};
+
+use constant DELETE_STATS => 0;	# Delete the statistics file when done?
+
+# Look for programs we need
+my $missing_tools;
+my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
+my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
+die "Can't find required tools.\n" if $missing_tools;
+
+# Recipe to use in processing
+my $recipe = RECIPES->{$det_type};
+die "Unrecognised detrend type: $det_type\n" if not defined $recipe;
+
+### Output file name --- must match camera configuration!
+my $outputRoot =  $exp_id . '.detproc.' . $det_id;
+my $outputName = $outputRoot . '.' . $class_id ;
+my $outputImage = $outputName . '.fits';
+my $outputStats = $outputName . '.stats';
+
+# Run ppImage
+{
+    my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
+	" -stat $outputStats"; # Command to run ppImage
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run(command => $command, verbose => 1);
+    die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success;
+    die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage;
+    die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats;
+}
+
+# Get the statistics on the processed image
+my $stats;			# Statistics from ppImage
+{
+    my $statsFile;		# File handle
+    open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
+    my @contents = <$statsFile>; # Contents of file
+    close $statsFile;
+    my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
+    my $metadata = $mdcParser->parse(join "", @contents)
+        or die "unable to parse metadata config";
+    $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
+    $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";
+}
+
+# Add the processed file to the database
+unless ($no_update) {
+    my $command = "$dettool -addprocessed -det_id $det_id -exp_id $exp_id " .
+	"-class_id $class_id -recip $recipe -uri $outputImage"; # Command to run dettool
+    $command .= " -bg " . $stats->bg_mean();
+    if (defined($stats->bg_stdev())) {
+	$command .= " -bg_stdev " . $stats->bg_stdev();
+    } else {
+	# May be undefined if there's only a single imfile
+	$command .= " -bg_stdev 0";
+    }
+    $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev();
+
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run(command => $command, verbose => 1);
+    die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n"
+	if not $success;
+}
+
+unlink "$outputStats" if DELETE_STATS;
+
+__END__
