Index: trunk/ippScripts/scripts/phase4_warp.pl
===================================================================
--- trunk/ippScripts/scripts/phase4_warp.pl	(revision 11830)
+++ trunk/ippScripts/scripts/phase4_warp.pl	(revision 11837)
@@ -32,5 +32,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($p4_id, $skycell_id, $camera, $dbname, $workdir, $no_update);
+my ($p4_id, $skycell_id, $camera, $dbname, $workdir, $no_update, $no_op);
 GetOptions(
     'p4_id|i=s'         => \$p4_id, # Phase 4 identifier
@@ -39,5 +39,6 @@
     'dbname|d=s'        => \$dbname, # Database name
     'workdir|w=s'       => \$workdir, # Working directory, for output files
-    'no-update'         => \$no_update
+    'no-update'         => \$no_update,	# Don't update the database?
+    'no-op'             => \$no_op, # Don't do any operations?
 ) or pod2usage( 2 );
 
@@ -62,4 +63,5 @@
 
 # Get list of component imfiles for exposure
+my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
 my $imfiles;
 {
@@ -97,13 +99,14 @@
 open my $listFile, '>' . $listName;
 foreach my $imfile (@$imfiles) {
-    my $uri = $ipprc->convert_filename_absolute( $file->{uri} );
+    my $uri = $ipprc->convert_filename_absolute( $imfile->{uri} );
 
-    print $listFile $uri . "\n";
+    print $listFile "$uri\n";
 }
 close $listFile;
 
 # Run pswarp
-{
-    my $command = "$pswarp -file $uri $outputRoot -stat $outputStats"; # Command to run pswarp
+my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
+unless ($no_op) {
+    my $command = "$pswarp -list $listName $outputRoot -stat $outputStats"; # Command to run pswarp
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
@@ -116,17 +119,12 @@
     &my_die("Couldn't find expected output file: $outputBin1", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
     &my_die("Couldn't find expected output file: $outputBin2", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
-}
 
-# Get the statistics on the warped image
-my $stats;			# Statistics from pswarp
-{
+    # Get the statistics on the warped image
     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 &my_die("Unable to parse metadata config", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR);
-    $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR);
 }
@@ -137,10 +135,12 @@
 $outputBin2  = $ipprc->convert_filename_relative( $outputBin2  );
 
+my $bg = ($stats->bg_mean() or 'NAN');
+my $bg_stdev = ($stats->bg_stdev() or 'NAN');
+
 # Add the processed file to the database
 unless ($no_update) {
     my $command = "$p4tool -warped -p4_id $p4_id -skycell_id $skycell_id" .
 	" -uri $outputImage -b1_uri $outputRoot";  # Command to run dettool
-    $command .= " -bg " . $stats->bg_mean();
-    $command .= " -bg_stdev " . $stats->bg_stdev();
+    $command .= " -bg $bg -bg_stdev $bg_stdev";
     $command .= " -dbname $dbname" if defined $dbname;
 
