Index: trunk/ippScripts/scripts/ipp_detrend_combine.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_detrend_combine.pl	(revision 17671)
+++ trunk/ippScripts/scripts/ipp_detrend_combine.pl	(revision 27718)
@@ -7,6 +7,7 @@
 use Sys::Hostname;
 my $host = hostname();
+my $date = `date`;
 print "\n\n";
-print "Starting script $0 on $host\n\n";
+print "Starting script $0 on $host at $date\n\n";
 
 use vars qw( $VERSION );
@@ -32,24 +33,24 @@
     $workdir, $dbname, $no_update);
 GetOptions(
-	   'det_type=s'    => \$det_type, # Detrend type for new detrend
-	   'filelevel=s'   => \$filelevel, # File level for new detrend
-	   'inst=s'        => \$inst, # Instrument for new detrend
-	   'telescope=s'   => \$telescope, # Telescope for new detrend
-	   'filter=s'      => \$filter,	# Filter name for new detrend
-	   'det_id1=s'	   => \$det_id1, # Detrend id for detrend 1
-	   'iteration1=s'  => \$iter1, # Iteration for detrend 1
-	   'det_id2=s'	   => \$det_id2, # Detrend id for detrend 2
-	   'iteration2=s'  => \$iter2, # Iteration for detrend 2
-	   'operation=s'   => \$operation, # Operation to perform on files
-	   'mask'          => \$mask, # Operation is on a mask
-	   'workdir=s'     => \$workdir, # Working directory for output files
-	   'dbname=s'      => \$dbname,	# Database name
-	   'no-update'     => \$no_update, # Don't update the database
-	   ) or pod2usage( 2 );
+           'det_type=s'    => \$det_type, # Detrend type for new detrend
+           'filelevel=s'   => \$filelevel, # File level for new detrend
+           'inst=s'        => \$inst, # Instrument for new detrend
+           'telescope=s'   => \$telescope, # Telescope for new detrend
+           'filter=s'      => \$filter, # Filter name for new detrend
+           'det_id1=s'     => \$det_id1, # Detrend id for detrend 1
+           'iteration1=s'  => \$iter1, # Iteration for detrend 1
+           'det_id2=s'     => \$det_id2, # Detrend id for detrend 2
+           'iteration2=s'  => \$iter2, # Iteration for detrend 2
+           'operation=s'   => \$operation, # Operation to perform on files
+           'mask'          => \$mask, # Operation is on a mask
+           'workdir=s'     => \$workdir, # Working directory for output files
+           'dbname=s'      => \$dbname, # Database name
+           'no-update'     => \$no_update, # Don't update the database
+           ) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage( -msg => "Required options --det_type --filelevel --inst --telescope --det_id1 --iteration1 --det_id2 --iteration2 --workdir",
-	   -exitval => 3,
-	   )
+           -exitval => 3,
+           )
     unless defined $det_type
     and defined $filelevel
@@ -65,6 +66,6 @@
 $ipprc->define_camera($inst);
 
-my $STATS = 
-   [   
+my $STATS =
+   [
        #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
        { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",             dtype => "float" },
@@ -90,15 +91,15 @@
 die("File lists for detrends have differing lengths") unless scalar keys %$files1 == scalar keys %$files2;
 
-my ($det_id, $iter);	      # Detrend identifier for the new detrend
+my ($det_id, $iter);          # Detrend identifier for the new detrend
 unless ($no_update) {
     my $command = "$dettool -register_detrend -det_type $det_type -filelevel $filelevel -workdir $workdir " .
-	"-inst $inst -telescope $telescope"; # Command to run
+        "-inst $inst -telescope $telescope"; # Command to run
     $command .= " -filter $filter" if defined $filter;
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
+        run(command => $command, verbose => 1);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	die("Unable to run dettool -register_detrend: $error_code");
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        die("Unable to run dettool -register_detrend: $error_code");
     }
 
@@ -137,8 +138,8 @@
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
+        run(command => $command, verbose => 1);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	die("Unable to run ppArith: $error_code");
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        die("Unable to run ppArith: $error_code");
     }
 
@@ -149,28 +150,28 @@
     my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
     {
-	my $statsFile;		# File handle
-	open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!");
-	my @contents = <$statsFile>; # Contents of file
-	close $statsFile;
-	
-	my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc");
-
-	unless ($stats->parse($metadata)) {
-	    &my_die("Failure extracting metadata from the statistics output file.\n");
-	}
+        my $statsFile;          # File handle
+        open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!");
+        my @contents = <$statsFile>; # Contents of file
+        close $statsFile;
+
+        my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc");
+
+        unless ($stats->parse($metadata)) {
+            &my_die("Failure extracting metadata from the statistics output file.\n");
+        }
     }
 
     # Register the imfile
     unless ($no_update) {
-	my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run
-	$command .= " -class_id $class_id -uri $outName -path_base $outRoot";
-	$command .= $stats->cmdflags();
-	$command .= " -dbname $dbname" if defined $dbname;
-	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	    run(command => $command, verbose => 1);
-	unless ($success) {
-	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    die("Unable to run dettool -register_detrend_imfile: $error_code");
-	}
+        my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run
+        $command .= " -class_id $class_id -uri $outName -path_base $outRoot";
+        $command .= $stats->cmdflags();
+        $command .= " -dbname $dbname" if defined $dbname;
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            run(command => $command, verbose => 1);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            die("Unable to run dettool -register_detrend_imfile: $error_code");
+        }
     }
 }
@@ -183,14 +184,14 @@
 sub filelist
 {
-    my $det_id = shift;		# Detrend identifier
-    my $iter = shift;		# Iteration
+    my $det_id = shift;         # Detrend identifier
+    my $iter = shift;           # Iteration
 
     my $command = "$detselect -select -det_id $det_id -iteration $iter"; # Command to run
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
+        run(command => $command, verbose => 1);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	die("Unable to run detselect: $error_code");
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        die("Unable to run detselect: $error_code");
     }
 
@@ -202,8 +203,8 @@
 
     foreach my $item ( @$list ) {
-	my $class_id = $item->{class_id};
-	die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if
-	    defined $files{$class_id};
-	$files{$class_id} = parse_md_list($md);
+        my $class_id = $item->{class_id};
+        die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if
+            defined $files{$class_id};
+        $files{$class_id} = parse_md_list($md);
     }
 
