Index: unk/ippScripts/scripts/detrend_create_resid.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_create_resid.pl	(revision 9094)
+++ 	(revision )
@@ -1,128 +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 Data::Dumper;
-
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use Pod::Usage qw( pod2usage );
-
-my ($det_id, $iter, $exp_id, $class_id, $det_type, $detrend,
-        $input_uri, $no_update);
-GetOptions(
-    'det_id|d=s'        => \$det_id,
-    'iteration=s'       => \$iter,
-    'exp_id|e=s'        => \$exp_id,
-    'class_id|i=s'      => \$class_id,
-    'det_type|t=s'      => \$det_type,
-    'detrend=s'         => \$detrend,
-    '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 --iteration --exp_id --class_id --det_type --detrend --input_uri",
-    -exitval => 3,
-) unless defined $det_id
-    and defined $iter
-    and defined $exp_id
-    and defined $class_id
-    and defined $det_type
-    and defined $detrend
-    and defined $input_uri;
-
-# Recipes to use, as a function of the detrend type
-use constant RECIPES => {
-    'bias' => 'PPIMAGE_B',	# Bias only
-    'dark' => 'PPIMAGE_D',	# Dark only
-    'flat' => 'PPIMAGE_F',	# Flat-field only
-};
-
-# Flags to specify the particular detrend to use
-use constant DETRENDS => {
-    'bias' => '-bias',		# Specify the bias frame
-    'dark' => '-dark',		# Specify the dark frame
-    'flat' => '-flat',		# Specify the flat frame
-};
-
-
-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;
-# Detrend to use in processing
-my $detFlag = DETRENDS->{$det_type};
-die "Unrecognised detrend type: $det_type\n" if not defined $detFlag;
-
-### Output file names --- must match camera configuration!
-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.fits';
-my $bin2Name =  $outputRoot . '.' . $class_id . '.b2.fits';
-
-# Run ppImage
-{
-    my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
-	" -stat $outputStats $detFlag $detrend"; # 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: $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;
-}
-
-# Get the statistics on the residual 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 doc";
-    $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 -addresidimfile -det_id $det_id -iteration $iter -exp_id $exp_id " .
-	"-class_id $class_id -recip $recipe -uri $outputName -b1_uri $bin1Name " .
-	"-b2_uri $bin2Name"; # 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 is 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_resid.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_resid.pl	(revision 9095)
+++ /trunk/ippScripts/scripts/detrend_resid.pl	(revision 9095)
@@ -0,0 +1,128 @@
+#!/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 Data::Dumper;
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use Pod::Usage qw( pod2usage );
+
+my ($det_id, $iter, $exp_id, $class_id, $det_type, $detrend,
+        $input_uri, $no_update);
+GetOptions(
+    'det_id|d=s'        => \$det_id,
+    'iteration=s'       => \$iter,
+    'exp_id|e=s'        => \$exp_id,
+    'class_id|i=s'      => \$class_id,
+    'det_type|t=s'      => \$det_type,
+    'detrend=s'         => \$detrend,
+    '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 --iteration --exp_id --class_id --det_type --detrend --input_uri",
+    -exitval => 3,
+) unless defined $det_id
+    and defined $iter
+    and defined $exp_id
+    and defined $class_id
+    and defined $det_type
+    and defined $detrend
+    and defined $input_uri;
+
+# Recipes to use, as a function of the detrend type
+use constant RECIPES => {
+    'bias' => 'PPIMAGE_B',	# Bias only
+    'dark' => 'PPIMAGE_D',	# Dark only
+    'flat' => 'PPIMAGE_F',	# Flat-field only
+};
+
+# Flags to specify the particular detrend to use
+use constant DETRENDS => {
+    'bias' => '-bias',		# Specify the bias frame
+    'dark' => '-dark',		# Specify the dark frame
+    'flat' => '-flat',		# Specify the flat frame
+};
+
+
+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;
+# Detrend to use in processing
+my $detFlag = DETRENDS->{$det_type};
+die "Unrecognised detrend type: $det_type\n" if not defined $detFlag;
+
+### Output file names --- must match camera configuration!
+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.fits';
+my $bin2Name =  $outputRoot . '.' . $class_id . '.b2.fits';
+
+# Run ppImage
+{
+    my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
+	" -stat $outputStats $detFlag $detrend"; # 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: $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;
+}
+
+# Get the statistics on the residual 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 doc";
+    $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 -addresidimfile -det_id $det_id -iteration $iter -exp_id $exp_id " .
+	"-class_id $class_id -recip $recipe -uri $outputName -b1_uri $bin1Name " .
+	"-b2_uri $bin2Name"; # 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 is 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__
