Index: trunk/ippScripts/scripts/warp_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/warp_skycell.pl	(revision 17760)
+++ trunk/ippScripts/scripts/warp_skycell.pl	(revision 17787)
@@ -34,5 +34,5 @@
     'outroot=s'         => \$outroot, # Output root name
     'verbose'           => \$verbose,   # Print to stdout
-    'no-update'         => \$no_update,	# Don't update the database?
+    'no-update'         => \$no_update, # Don't update the database?
     'no-op'             => \$no_op, # Don't do any operations?
     'save-temps'        => \$save_temps, # Save temporary files?
@@ -51,11 +51,15 @@
 $ipprc->define_camera($camera);
 
-my $STATS = 
-   [   
+my $STATS =
+   [
        #          PPSTATS KEYWORD         STATISTIC          WARPTOOL FLAG
        { name => "ROBUST_MEDIAN",   type => "mean", flag => "-bg",         dtype => "float" },
        { name => "ROBUST_STDEV",    type => "rms",  flag => "-bg_stdev",   dtype => "float" },
-#      { name => "DT_WARP",         type => "sum",  flag => "-dtime_warp", dtype => "float" },
+       { name => "DT_WARP",         type => "sum",  flag => "-dtime_warp", dtype => "float" },
        { name => "GOOD_PIXEL_FRAC", type => "mean", flag => "-good_frac",  dtype => "float" },
+       { name => "RANGE.XMIN",      type => "mean", flag => "-xmin",       dtype => "int"   },
+       { name => "RANGE.XMAX",      type => "mean", flag => "-xmax",       dtype => "int"   },
+       { name => "RANGE.YMIN",      type => "mean", flag => "-ymin",       dtype => "int"   },
+       { name => "RANGE.YMAX",      type => "mean", flag => "-ymax",       dtype => "int"   },
    ];
 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
@@ -66,11 +70,11 @@
 my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1);
 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
-if ($missing_tools) { 
+if ($missing_tools) {
     warn("Can't find required tools.");
-    exit($PS_EXIT_CONFIG_ERROR); 
+    exit($PS_EXIT_CONFIG_ERROR);
 }
 
 # Get list of component imfiles for exposure
-my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
+my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
 my $imfiles;
 {
@@ -78,28 +82,28 @@
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
-    unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform warptool -scmap: $error_code", $warp_id, $skycell_id, $tess_id, $error_code);
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &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, $tess_id, $PS_EXIT_PROG_ERROR);
-    $imfiles = parse_md_list($metadata) or 
-	&my_die("Unable to parse metadata list", $warp_id, $skycell_id, $tess_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, $tess_id, $PS_EXIT_PROG_ERROR);
 }
 
 # Where do we get the astrometry source from?
-my $astromSource;		# The astrometry source
+my $astromSource;               # The astrometry source
 {
     my $command = "$ppConfigDump -camera $camera -dump-recipe PSWARP -";
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
-    unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform ppConfigDump: $error_code", $warp_id, $error_code);
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppConfigDump: $error_code", $warp_id, $error_code);
     }
     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata config doc", $warp_id, $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to parse metadata config doc", $warp_id, $PS_EXIT_PROG_ERROR);
     $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE');
 }
@@ -128,5 +132,5 @@
 my $wrote_astrom = 0;
 foreach my $imfile (@$imfiles) {
-    my $image = $imfile->{uri};	# Image name
+    my $image = $imfile->{uri}; # Image name
     my $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $imfile->{chip_path_base}, $imfile->{class_id}); # Mask name
     my $weight = $ipprc->filename("PPIMAGE.CHIP.WEIGHT", $imfile->{chip_path_base}, $imfile->{class_id}); # Mask name
@@ -135,25 +139,25 @@
     &my_die("Couldn't find input file: $mask", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($mask);
 
-    my $astrom;		# Astrometry file
+    my $astrom;         # Astrometry file
     if ($astromSource eq 'PSASTRO.OUTPUT.MEF') {
-	$astrom = $ipprc->filename($astromSource, $imfile->{cam_path_base});
+        $astrom = $ipprc->filename($astromSource, $imfile->{cam_path_base});
     } elsif ($astromSource eq 'PSASTRO.OUTPUT') {
-	my $chipRoot = $imfile->{chip_path_base};
-	my $classID = $imfile->{class_id};
-	$astrom = $ipprc->filename($astromSource, $chipRoot, $classID); # Astrometry file
+        my $chipRoot = $imfile->{chip_path_base};
+        my $classID = $imfile->{class_id};
+        $astrom = $ipprc->filename($astromSource, $chipRoot, $classID); # Astrometry file
     }
 
     &my_die("Couldn't find input file: $astrom", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless defined $astrom and $ipprc->file_exists($astrom);
-    
+
     print $imageFile  "$image\n";
     print $maskFile   "$mask\n";
     print $weightFile "$weight\n";
-    
+
     if (!$wrote_astrom) {
-	print $astromFile "$astrom\n";
-	# XXX simplify this?  only ever have one file for astrometry (must be MEF)
-	if ($astromSource eq 'PSASTRO.OUTPUT.MEF') { 
-	    $wrote_astrom = 1;
-	}
+        print $astromFile "$astrom\n";
+        # XXX simplify this?  only ever have one file for astrometry (must be MEF)
+        if ($astromSource eq 'PSASTRO.OUTPUT.MEF') {
+            $wrote_astrom = 1;
+        }
     }
 }
@@ -165,5 +169,5 @@
 
 # Run pswarp
-my $accept = 1;			# Accept the skycell?
+my $accept = 1;                 # Accept the skycell?
 unless ($no_op) {
     my $command = "$pswarp";
@@ -175,12 +179,12 @@
     $command .= " -stats $outputStats";
     $command .= " -recipe PPSTATS WARPSTATS";
-    $command .= " -psf";	# Turn on PSF determination
+    $command .= " -psf";        # Turn on PSF determination
     $command .= " -tracedest $traceDest -log $logDest";
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
-    unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $tess_id, $error_code);
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $tess_id, $error_code);
     }
 
@@ -188,5 +192,5 @@
     &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats);
     # Get the statistics on the warped image
-    my $statsFile;		# File handle
+    my $statsFile;              # File handle
     open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n";
     my @contents = <$statsFile>; # Contents of file
@@ -195,14 +199,14 @@
 
     my $metadata = $mdcParser->parse($contents)
-	or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
+        or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
     $accept = metadataLookupBool($metadata, "ACCEPT");
     if ($accept) {
-	$stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
-	
-	&my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
-	&my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
-	&my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
-	&my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
-	&my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF);
+        $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_id, $PS_EXIT_PROG_ERROR);
+
+        &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
+        &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
+        &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
+        &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
+        &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF);
 #    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1);
 #    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2);
@@ -218,9 +222,9 @@
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
-    unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	warn("Unable to perform warptool -addwarped: $error_code\n");
-	exit($error_code);
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform warptool -addwarped: $error_code\n");
+        exit($error_code);
     }
 }
@@ -228,14 +232,14 @@
 sub my_die
 {
-    my $msg = shift;		# Warning message on die
-    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
+    my $msg = shift;            # Warning message on die
+    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 (defined $warp_id and defined $skycell_id and defined $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;
+        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;
         run(command => $command, verbose => $verbose);
     }
