Index: trunk/ippScripts/scripts/warp_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/warp_imfile.pl	(revision 12021)
+++ trunk/ippScripts/scripts/warp_imfile.pl	(revision 12043)
@@ -16,4 +16,5 @@
 use PS::IPP::Metadata::Config;
 use PS::IPP::Metadata::Stats;
+use PS::IPP::Metadata::List qw( parse_md_list );
 
 use PS::IPP::Config qw(
@@ -32,8 +33,9 @@
 use Pod::Usage qw( pod2usage );
 
-my ($warp_id, $skycell_id, $camera, $dbname, $workdir, $no_update, $no_op);
+my ($warp_id, $skycell_id, $tess_id, $camera, $dbname, $workdir, $no_update, $no_op);
 GetOptions(
     'warp_id|i=s'       => \$warp_id, # Warp identifier
     'skycell_id|s=s'    => \$skycell_id, # Skycell identifier
+    'tess_id|s=s'       => \$tess_id, # Tesselation identifier
     'camera|c=s'        => \$camera, # Camera name
     'dbname|d=s'        => \$dbname, # Database name
@@ -45,8 +47,9 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --warp_id --skycell_id --camera",
+    -msg => "Required options: --warp_id --skycell_id --tess_id --camera",
     -exitval => 3,
 ) unless defined $warp_id
     and defined $skycell_id
+    and defined $tess_id
     and defined $camera;
 
@@ -66,5 +69,5 @@
 my $imfiles;
 {
-    my $command = "$warptool -imfile -warp_id $warp_id -skycell_id $skycell_id";
+    my $command = "$warptool -scmap -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id";
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -72,11 +75,11 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform warptool -imfile: $error_code", $warp_id, $skycell_id, $error_code);
+	&my_die("Unable to perform warptool -scmap: $error_code", $warp_id, $skycell_id, $tess_id, $error_code);
     }
 
     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata config doc", $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
+	&my_die("Unable to parse metadata config doc", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
     $imfiles = parse_md_list($metadata) or 
-	&my_die("Unable to parse metadata list", $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
+	&my_die("Unable to parse metadata list", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
 }
 
@@ -85,5 +88,6 @@
     $workdir = $ipprc->convert_filename_absolute( $workdir );
 } else {
-    my ($vol, $dir, $file) = File::Spec->splitpath( $$imfiles[0]->{uri} );
+    my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
+    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
     $workdir = $dir;
 }
@@ -97,5 +101,5 @@
 
 # Get list of filenames
-open my $listFile, '>' . $listName;
+open my $listFile, "> $listName" or &my_die("Unable to open $listName", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR);
 foreach my $imfile (@$imfiles) {
     my $uri = $ipprc->convert_filename_absolute( $imfile->{uri} );
@@ -115,8 +119,8 @@
 	&my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
-    &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
-    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
-    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
+    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
+    &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
+    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
+    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
 
     # Get the statistics on the warped image
@@ -126,6 +130,6 @@
     close $statsFile;
     my $metadata = $mdcParser->parse(join "", @contents)
-        or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
-    $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
+        or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
+    $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
 }
 
@@ -140,6 +144,6 @@
 # Add the processed file to the database
 unless ($no_update) {
-    my $command = "$warptool -warped -warp_id $warp_id -skycell_id $skycell_id" .
-	" -uri $outputImage -b1_uri $outputRoot";  # Command to run dettool
+    my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id" .
+	" -uri $outputImage"; # -b1_uri $outputRoot";  # Command to run dettool
     $command .= " -bg $bg -bg_stdev $bg_stdev";
     $command .= " -dbname $dbname" if defined $dbname;
@@ -149,5 +153,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	warn("Unable to perform warptool -addwarpedimfile: $error_code\n");
+	warn("Unable to perform warptool -addwarped: $error_code\n");
 	exit($error_code);
     }
@@ -161,9 +165,10 @@
     my $warp_id = shift;	# Warp identifier
     my $skycell_id = shift;	# Skycell identifier
+    my $tess_id = shift;	# Tesselation identifier
     my $exit_code = shift;	# Exit code to add
 
     warn($msg);
-    if ($warp_id and $skycell_id and not $no_update) {
-	my $command = "$warptool -warped -warp_id $warp_id -skycell_id $skycell_id -code $exit_code";
+    if ($warp_id and $skycell_id and $tess_id and not $no_update) {
+	my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id -code $exit_code";
 	$command .= " -dbname $dbname" if defined $dbname;
         system ($command);
