Index: trunk/ippScripts/scripts/phase0_exp.pl
===================================================================
--- trunk/ippScripts/scripts/phase0_exp.pl	(revision 9098)
+++ trunk/ippScripts/scripts/phase0_exp.pl	(revision 9098)
@@ -0,0 +1,173 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+use IPC::Cmd qw( can_run run );
+use PS::IPP::Metadata::Config;
+use PS::IPP::Metadata::List qw( parse_md_list );
+use Statistics::Descriptive;
+use Data::Dumper;
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+
+my ($exptag, $no_update);
+
+GetOptions(
+    'exp_tag|e=s'    => \$exptag,
+    'no-update'     => \$no_update
+) or pod2usage( 2 );
+
+pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
+pod2usage(
+    -msg => "Required options: --exp_tag",
+    -exitval => 3,
+) unless defined $exptag;
+
+# Define setup
+use constant TYPE => "exp_type"; # Observation type keyword
+use constant DETRENDS => [ "bias", "dark", "flat", "fringe" ]; # Observation types to mark as detrend
+use constant DETREND_FLAG => "-detrend"; # Flag to use to mark detrend exposure
+
+use constant PHASE0_URI => 'uri'; # Key for the URI
+use constant PHASE0_CLASSID => 'class_id'; # Key for the class id
+use constant PHASE0_BG => 'bg';        # Key for the background
+use constant PHASE0_BG_STDEV => 'bg_stdev'; # Key for the background standard deviation
+use constant PHASE0_BG_MEAN_STDEV => 'bg_mean_stdev'; # Key for the mean of the background standard deviation
+
+use constant EXP_BG => '-background'; # Switch to add background for exposure
+use constant EXP_BGSD => '-background_stdev'; # Switch to add background standard deviation
+use constant EXP_BGMEANSD => '-background_mean_stdev'; # Switch to add mean of background standard deviation
+
+# These values should be constant for all components
+use constant CONSTANTS => [
+                           "exp_type", #exposure type
+                           "filter", # Filter used
+                           "airmass", # Airmass
+                           "ra", # Right ascension
+                           "decl", # Declination
+                           "posang", # Position angle
+                           "alt", # Altitude
+                           "az", # Azimuth
+                           "ccd_temp" # CCD temperature
+                       ];
+
+# These values may vary across components; we will take the average
+use constant VARIABLES => [
+                           "exp_time", # Exposure time
+###                           "time" # Time of exposure --- not yet implemented
+                           ];
+
+
+# Look for commands we need
+my $missing_tools;
+my $p0tool = can_run('p0tool')
+    or (warn "can't find p0tool" and $missing_tools = 1);
+my $ppStats = can_run('ppStats')
+    or (warn "can't find ppStats" and $missing_tools = 1);
+die "Can't find required tools.\n" if $missing_tools;
+
+my $mdcParser = PS::IPP::Metadata::Config->new;        # Parser for metadata config files
+
+# Get the list of imfiles
+my $imfiles;
+{
+    my $command = "$p0tool -rawimfile -exp_tag $exptag";
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => 1);
+    die "Unable to perform p0tool on exposure id $exptag: $error_code\n" if not $success;
+    my $metadata = $mdcParser->parse(join "", @$stdout_buf)
+            or die "unable to parse metadata config doc";
+    $imfiles = parse_md_list($metadata); # Data for imfiles
+}
+
+# Process the values
+my %values;                        # Values to update
+foreach my $variable (@{VARIABLES()}) {
+    $values{$variable} = [];
+}
+my @backgrounds;                # Array of backgrounds
+my @stdevs;                        # Array of background standard deviations\
+my $obsType;                        # Observation type
+  
+foreach my $imfile (@$imfiles) {
+    foreach my $constant (@{CONSTANTS()}) {
+        my $value = get_value($imfile, $constant); # Value for imfile
+        if (not defined $values{$constant}) {
+            $values{$constant} = $value;
+        } elsif ($values{$constant} ne $value) {
+            die "Value of $constant for " . $imfile->{PHASE0_CLASSID} .
+                " doesn't match previous value.\n";
+        }
+    }
+    
+    foreach my $variable (@{VARIABLES()}) {
+        my $value = get_value($imfile, $variable); # Value for imfile
+        my $array = $values{$variable};        # Array of data
+        push @$array, $value;
+    }
+    
+    my $bg = get_value($imfile, PHASE0_BG());
+    push @backgrounds, $bg;
+    
+    my $stdev = get_value($imfile, PHASE0_BG_MEAN_STDEV());
+    push @stdevs, $stdev;
+}
+
+# Output results to the database
+unless ($no_update) {
+    my $command = "$p0tool -updateexp -exp_tag $exptag"; # Command to execute to update exposure parameters
+    
+    # Add the values of interest
+    foreach my $constant (@{CONSTANTS()}) {
+        $command .= " -" . $constant . " " . $values{$constant};
+    }
+    foreach my $variable (@{VARIABLES()}) {
+        my $array = $values{$variable};        # Array of values
+        my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
+        $stats->add_data(@$array);
+        $command .= " -" . $variable . " " . $stats->mean();
+    }
+
+    # Add the statistics
+    {
+        my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
+        $stats->add_data(@backgrounds);
+        $command .= " -" . PHASE0_BG() . " " . $stats->mean();
+        if (scalar @backgrounds == 1) {
+            $command .= ' -' . PHASE0_BG_STDEV() . " 0.0";
+        } else {
+            $command .= " -" . PHASE0_BG_STDEV() . " " . $stats->standard_deviation();
+        }
+    }
+    {
+        my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
+        $stats->add_data(@stdevs);
+        $command .= " -" . PHASE0_BG_MEAN_STDEV() . " " . $stats->mean();
+    }
+    
+    # Add the detrend flag
+    foreach my $detrendType (@{DETRENDS()}) {
+        if (lc($values{TYPE()}) eq lc($detrendType)) {
+            $command .= " " . DETREND_FLAG;
+            last;
+        }
+    }
+ 
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => 1);
+    die "Unable to run phase0 update for $exptag: $error_code\n" if not $success;
+}
+
+### Pau.
+
+
+# Get the value for a particular imfile, along with a strong check for its existence
+sub get_value {
+    my $imfile = shift;                # The hash of values
+    my $name = shift;                # The name of the value to check
+
+    my $source = $imfile->{PHASE0_CLASSID()}; # Where it comes from
+    die "Couldn't find value of $name for class_id=$source\n" if not defined $imfile->{$name};
+    return $imfile->{$name};
+}
Index: trunk/ippScripts/scripts/phase0_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/phase0_imfile.pl	(revision 9098)
+++ trunk/ippScripts/scripts/phase0_imfile.pl	(revision 9098)
@@ -0,0 +1,121 @@
+#!/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 ($exp_tag, $class_id, $uri, $no_update);
+
+GetOptions(
+    'exp_tag|e=s'    => \$exp_tag,
+    'class_id|i=s'  => \$class_id,
+    'uri|u=s'       => \$uri,
+    'no-update'     => \$no_update
+) or pod2usage( 2 );
+
+pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
+pod2usage(
+    -msg => "Required options: --exp_tag --class_id --uri",
+    -exitval => 3,
+) unless defined $exp_tag 
+    and defined $class_id 
+    and defined $uri;
+
+# XXX the uri should be processed either here or by ppImage
+my $file = $uri;
+
+use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats
+
+# These values should be constant for all components
+# The key is the name in the ppStats output; the value is the switch for "phase0 -updateexp"
+use constant CONSTANTS => {
+    "FPA.OBSTYPE"  => "-exp_type", # Exposure type
+    "FPA.FILTER"   => "-filter", # Filter used
+    "FPA.AIRMASS"  => "-airmass", # Airmass
+    "FPA.RA"       => "-ra",        # Right ascension
+    "FPA.DEC"      => "-decl",        # Declination
+    "FPA.ALT"      => "-alt",        # Altitude
+    "FPA.AZ"       => "-az",        # Azimuth
+    "FPA.POSANGLE" => "-posang" # Position angle
+    };
+
+# These values may vary across components; we will take the average
+# The key is the name in the ppStats output; the value is the switch for "phase0 -updateexp"
+use constant VARIABLES => {
+    "CHIP.TEMP"    => "-ccd_temp", # CCD temperature
+    "CELL.EXPOSURE" => "-exp_time" # Exposure time
+    };
+
+
+# Switches for p0tool
+use constant P0TOOL_MODE => '-updateimfile'; # Mode for p0tool
+use constant P0TOOL_EXPTAG => '-exp_tag'; # Switch to specify the exposure id
+use constant P0TOOL_CLASSID => '-class_id'; # Switch to specify the class id
+use constant P0TOOL_BG_MEAN => '-bg'; # Switch to add the background
+use constant P0TOOL_BG_STDEV => '-bg_stdev'; # Switch to add the bg stdev
+use constant P0TOOL_BG_MEAN_STDEV => '-bg_mean_stdev'; # Switch to add the bg mean stdev
+
+# Look for programs we need
+my $missing_tools;
+my $p0tool = can_run('p0tool') or (warn "Can't find p0tool" and $missing_tools = 1);
+my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1);
+die "Can't find required tools.\n" if $missing_tools;
+
+# Run ppStats on the input file
+my $stats;
+{
+    my $command = "$ppStats $file -recipe PPSTATS " . RECIPE; # Command to run ppStats
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => 1);
+    die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n" if not $success;
+    
+    # Parse the output
+    my $mdcParser = PS::IPP::Metadata::Config->new;        # Parser for metadata config files
+    my $metadata = $mdcParser->parse(join "", @$stdout_buf)
+            or die "unable to parse metadata config doc";
+    my @constants = keys %{CONSTANTS()}; # List of constants to parse out
+    my @variables = keys %{VARIABLES()}; # List of variables to parse out
+    $stats = PS::IPP::Metadata::Stats->new(\@constants, \@variables); # Stats parser
+    $stats->parse($metadata) or die "Unable to find all values.\n";
+}
+
+# Push the results into the database
+unless ($no_update) {
+    my $command = $p0tool . " " . P0TOOL_MODE() . " " . P0TOOL_EXPTAG() . " " . $exp_tag . " " .
+        P0TOOL_CLASSID() . " " . $class_id; # Command to run p0tool
+    
+    foreach my $constant (keys %{CONSTANTS()}) {
+        $command .= " " . CONSTANTS->{$constant} . " " . ($stats->data($constant))->{value};
+    }
+    foreach my $variable (keys %{VARIABLES()}) {
+        # Just use the mean value
+        $command .= " " . VARIABLES->{$variable} . " " . ($stats->data($variable))->{mean};
+    }
+
+    $command .= " " . P0TOOL_BG_MEAN() . " " . $stats->bg_mean();
+    if (defined($stats->bg_stdev())) {
+	$command .= " " . P0TOOL_BG_STDEV() . " " . $stats->bg_stdev();
+    } else {
+	# Will not be defined if there is only a single imfile
+	$command .= " " . P0TOOL_BG_STDEV() . " 0";
+    }
+    $command .= " " . P0TOOL_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 p0tool -updateimfile: $error_code\n" if not $success;
+}
+
+# Pau.
+
+__END__
Index: trunk/ippScripts/scripts/phase0exp.pl
===================================================================
--- trunk/ippScripts/scripts/phase0exp.pl	(revision 9097)
+++ 	(revision )
@@ -1,173 +1,0 @@
-#!/usr/bin/env perl
-
-use warnings;
-use strict;
-
-use IPC::Cmd qw( can_run run );
-use PS::IPP::Metadata::Config;
-use PS::IPP::Metadata::List qw( parse_md_list );
-use Statistics::Descriptive;
-use Data::Dumper;
-
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-
-my ($exptag, $no_update);
-
-GetOptions(
-    'exp_tag|e=s'    => \$exptag,
-    'no-update'     => \$no_update
-) or pod2usage( 2 );
-
-pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage(
-    -msg => "Required options: --exp_tag",
-    -exitval => 3,
-) unless defined $exptag;
-
-# Define setup
-use constant TYPE => "exp_type"; # Observation type keyword
-use constant DETRENDS => [ "bias", "dark", "flat", "fringe" ]; # Observation types to mark as detrend
-use constant DETREND_FLAG => "-detrend"; # Flag to use to mark detrend exposure
-
-use constant PHASE0_URI => 'uri'; # Key for the URI
-use constant PHASE0_CLASSID => 'class_id'; # Key for the class id
-use constant PHASE0_BG => 'bg';        # Key for the background
-use constant PHASE0_BG_STDEV => 'bg_stdev'; # Key for the background standard deviation
-use constant PHASE0_BG_MEAN_STDEV => 'bg_mean_stdev'; # Key for the mean of the background standard deviation
-
-use constant EXP_BG => '-background'; # Switch to add background for exposure
-use constant EXP_BGSD => '-background_stdev'; # Switch to add background standard deviation
-use constant EXP_BGMEANSD => '-background_mean_stdev'; # Switch to add mean of background standard deviation
-
-# These values should be constant for all components
-use constant CONSTANTS => [
-                           "exp_type", #exposure type
-                           "filter", # Filter used
-                           "airmass", # Airmass
-                           "ra", # Right ascension
-                           "decl", # Declination
-                           "posang", # Position angle
-                           "alt", # Altitude
-                           "az", # Azimuth
-                           "ccd_temp" # CCD temperature
-                       ];
-
-# These values may vary across components; we will take the average
-use constant VARIABLES => [
-                           "exp_time", # Exposure time
-###                           "time" # Time of exposure --- not yet implemented
-                           ];
-
-
-# Look for commands we need
-my $missing_tools;
-my $p0tool = can_run('p0tool')
-    or (warn "can't find p0tool" and $missing_tools = 1);
-my $ppStats = can_run('ppStats')
-    or (warn "can't find ppStats" and $missing_tools = 1);
-die "Can't find required tools.\n" if $missing_tools;
-
-my $mdcParser = PS::IPP::Metadata::Config->new;        # Parser for metadata config files
-
-# Get the list of imfiles
-my $imfiles;
-{
-    my $command = "$p0tool -rawimfile -exp_tag $exptag";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => 1);
-    die "Unable to perform p0tool on exposure id $exptag: $error_code\n" if not $success;
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf)
-            or die "unable to parse metadata config doc";
-    $imfiles = parse_md_list($metadata); # Data for imfiles
-}
-
-# Process the values
-my %values;                        # Values to update
-foreach my $variable (@{VARIABLES()}) {
-    $values{$variable} = [];
-}
-my @backgrounds;                # Array of backgrounds
-my @stdevs;                        # Array of background standard deviations\
-my $obsType;                        # Observation type
-  
-foreach my $imfile (@$imfiles) {
-    foreach my $constant (@{CONSTANTS()}) {
-        my $value = get_value($imfile, $constant); # Value for imfile
-        if (not defined $values{$constant}) {
-            $values{$constant} = $value;
-        } elsif ($values{$constant} ne $value) {
-            die "Value of $constant for " . $imfile->{PHASE0_CLASSID} .
-                " doesn't match previous value.\n";
-        }
-    }
-    
-    foreach my $variable (@{VARIABLES()}) {
-        my $value = get_value($imfile, $variable); # Value for imfile
-        my $array = $values{$variable};        # Array of data
-        push @$array, $value;
-    }
-    
-    my $bg = get_value($imfile, PHASE0_BG());
-    push @backgrounds, $bg;
-    
-    my $stdev = get_value($imfile, PHASE0_BG_MEAN_STDEV());
-    push @stdevs, $stdev;
-}
-
-# Output results to the database
-unless ($no_update) {
-    my $command = "$p0tool -updateexp -exp_tag $exptag"; # Command to execute to update exposure parameters
-    
-    # Add the values of interest
-    foreach my $constant (@{CONSTANTS()}) {
-        $command .= " -" . $constant . " " . $values{$constant};
-    }
-    foreach my $variable (@{VARIABLES()}) {
-        my $array = $values{$variable};        # Array of values
-        my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
-        $stats->add_data(@$array);
-        $command .= " -" . $variable . " " . $stats->mean();
-    }
-
-    # Add the statistics
-    {
-        my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
-        $stats->add_data(@backgrounds);
-        $command .= " -" . PHASE0_BG() . " " . $stats->mean();
-        if (scalar @backgrounds == 1) {
-            $command .= ' -' . PHASE0_BG_STDEV() . " 0.0";
-        } else {
-            $command .= " -" . PHASE0_BG_STDEV() . " " . $stats->standard_deviation();
-        }
-    }
-    {
-        my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
-        $stats->add_data(@stdevs);
-        $command .= " -" . PHASE0_BG_MEAN_STDEV() . " " . $stats->mean();
-    }
-    
-    # Add the detrend flag
-    foreach my $detrendType (@{DETRENDS()}) {
-        if (lc($values{TYPE()}) eq lc($detrendType)) {
-            $command .= " " . DETREND_FLAG;
-            last;
-        }
-    }
- 
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => 1);
-    die "Unable to run phase0 update for $exptag: $error_code\n" if not $success;
-}
-
-### Pau.
-
-
-# Get the value for a particular imfile, along with a strong check for its existence
-sub get_value {
-    my $imfile = shift;                # The hash of values
-    my $name = shift;                # The name of the value to check
-
-    my $source = $imfile->{PHASE0_CLASSID()}; # Where it comes from
-    die "Couldn't find value of $name for class_id=$source\n" if not defined $imfile->{$name};
-    return $imfile->{$name};
-}
Index: trunk/ippScripts/scripts/phase0imfile.pl
===================================================================
--- trunk/ippScripts/scripts/phase0imfile.pl	(revision 9097)
+++ 	(revision )
@@ -1,121 +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 ($exp_tag, $class_id, $uri, $no_update);
-
-GetOptions(
-    'exp_tag|e=s'    => \$exp_tag,
-    'class_id|i=s'  => \$class_id,
-    'uri|u=s'       => \$uri,
-    'no-update'     => \$no_update
-) or pod2usage( 2 );
-
-pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage(
-    -msg => "Required options: --exp_tag --class_id --uri",
-    -exitval => 3,
-) unless defined $exp_tag 
-    and defined $class_id 
-    and defined $uri;
-
-# XXX the uri should be processed either here or by ppImage
-my $file = $uri;
-
-use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats
-
-# These values should be constant for all components
-# The key is the name in the ppStats output; the value is the switch for "phase0 -updateexp"
-use constant CONSTANTS => {
-    "FPA.OBSTYPE"  => "-exp_type", # Exposure type
-    "FPA.FILTER"   => "-filter", # Filter used
-    "FPA.AIRMASS"  => "-airmass", # Airmass
-    "FPA.RA"       => "-ra",        # Right ascension
-    "FPA.DEC"      => "-decl",        # Declination
-    "FPA.ALT"      => "-alt",        # Altitude
-    "FPA.AZ"       => "-az",        # Azimuth
-    "FPA.POSANGLE" => "-posang" # Position angle
-    };
-
-# These values may vary across components; we will take the average
-# The key is the name in the ppStats output; the value is the switch for "phase0 -updateexp"
-use constant VARIABLES => {
-    "CHIP.TEMP"    => "-ccd_temp", # CCD temperature
-    "CELL.EXPOSURE" => "-exp_time" # Exposure time
-    };
-
-
-# Switches for p0tool
-use constant P0TOOL_MODE => '-updateimfile'; # Mode for p0tool
-use constant P0TOOL_EXPTAG => '-exp_tag'; # Switch to specify the exposure id
-use constant P0TOOL_CLASSID => '-class_id'; # Switch to specify the class id
-use constant P0TOOL_BG_MEAN => '-bg'; # Switch to add the background
-use constant P0TOOL_BG_STDEV => '-bg_stdev'; # Switch to add the bg stdev
-use constant P0TOOL_BG_MEAN_STDEV => '-bg_mean_stdev'; # Switch to add the bg mean stdev
-
-# Look for programs we need
-my $missing_tools;
-my $p0tool = can_run('p0tool') or (warn "Can't find p0tool" and $missing_tools = 1);
-my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1);
-die "Can't find required tools.\n" if $missing_tools;
-
-# Run ppStats on the input file
-my $stats;
-{
-    my $command = "$ppStats $file -recipe PPSTATS " . RECIPE; # Command to run ppStats
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => 1);
-    die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n" if not $success;
-    
-    # Parse the output
-    my $mdcParser = PS::IPP::Metadata::Config->new;        # Parser for metadata config files
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf)
-            or die "unable to parse metadata config doc";
-    my @constants = keys %{CONSTANTS()}; # List of constants to parse out
-    my @variables = keys %{VARIABLES()}; # List of variables to parse out
-    $stats = PS::IPP::Metadata::Stats->new(\@constants, \@variables); # Stats parser
-    $stats->parse($metadata) or die "Unable to find all values.\n";
-}
-
-# Push the results into the database
-unless ($no_update) {
-    my $command = $p0tool . " " . P0TOOL_MODE() . " " . P0TOOL_EXPTAG() . " " . $exp_tag . " " .
-        P0TOOL_CLASSID() . " " . $class_id; # Command to run p0tool
-    
-    foreach my $constant (keys %{CONSTANTS()}) {
-        $command .= " " . CONSTANTS->{$constant} . " " . ($stats->data($constant))->{value};
-    }
-    foreach my $variable (keys %{VARIABLES()}) {
-        # Just use the mean value
-        $command .= " " . VARIABLES->{$variable} . " " . ($stats->data($variable))->{mean};
-    }
-
-    $command .= " " . P0TOOL_BG_MEAN() . " " . $stats->bg_mean();
-    if (defined($stats->bg_stdev())) {
-	$command .= " " . P0TOOL_BG_STDEV() . " " . $stats->bg_stdev();
-    } else {
-	# Will not be defined if there is only a single imfile
-	$command .= " " . P0TOOL_BG_STDEV() . " 0";
-    }
-    $command .= " " . P0TOOL_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 p0tool -updateimfile: $error_code\n" if not $success;
-}
-
-# Pau.
-
-__END__
