Index: trunk/ippScripts/scripts/warp_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/warp_skycell.pl	(revision 19071)
+++ trunk/ippScripts/scripts/warp_skycell.pl	(revision 19098)
@@ -119,5 +119,5 @@
 my $outputWeight = $ipprc->filename("PSWARP.OUTPUT.WEIGHT", $outroot, $skycell_id);
 my $outputSources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $outroot, $skycell_id);
-my $outputPSF = $ipprc->filename("PSPHOT.PSF.SAVE", $outroot, $skycell_id);
+my $outputPSF = $ipprc->filename("PSPHOT.PSF.SKY.SAVE", $outroot);
 my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outroot, $skycell_id );
 my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outroot, $skycell_id );
@@ -144,12 +144,5 @@
     &my_die("Couldn't find input file: $mask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($mask);
 
-    my $astrom;         # Astrometry file
-    if ($astromSource eq 'PSASTRO.OUTPUT.MEF') {
-        $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 $astrom = $ipprc->filename($astromSource, $imfile->{cam_path_base});
 
     &my_die("Couldn't find input file: $astrom", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless defined $astrom and $ipprc->file_exists($astrom);
@@ -161,8 +154,5 @@
     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;
-        }
+	$wrote_astrom = 1;
     }
 }
@@ -178,4 +168,5 @@
     my $command = "$pswarp";
     $command .= " -list $imageName";
+    # $command .= " -threads 4";
     $command .= " -masklist $maskName";
     $command .= " -weightlist $weightName";
@@ -184,4 +175,5 @@
     $command .= " -stats $outputStats";
     $command .= " -recipe PPSTATS WARPSTATS";
+    $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE";
     $command .= " -psf";        # Turn on PSF determination
     $command .= " -tracedest $traceDest -log $logDest";
@@ -207,4 +199,9 @@
         or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR);
     $accept = metadataLookupBool($metadata, "ACCEPT");
+
+    # $accept is set above based on the fraction of lit pixels
+    # XXX for some files, there may not be enough stars to find a good psf.  these should be dropped as well
+    $accept &= $ipprc->file_exists($outputPSF);
+
     if ($accept) {
         $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR);
@@ -214,5 +211,5 @@
         &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
         &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
-        &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF);
+#    &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF);
 #    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1);
 #    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2);
@@ -222,10 +219,14 @@
 unless ($no_update) {
     # XXX change -tess_id to -tess_dir when db is updated
-    my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_dir";
-    $command .= " -ignore" if not $accept; # Completed succesfully, but can't produce product
-    $command .= " -uri $outputImage -path_base $outroot" if $accept;
-    $command .= $stats->cmdflags() if $accept;
-    $command .= " -hostname $host" if defined $host;
-    $command .= " -dbname $dbname" if defined $dbname;
+    my $command = "$warptool -addwarped";
+    $command .= " -warp_id $warp_id";
+    $command .= " -skycell_id $skycell_id";
+    $command .= " -tess_id $tess_dir";
+    $command .= " -path_base $outroot"; # needed for logfile lookups
+    $command .= " -ignore"           if not $accept; # Completed succesfully, but can't produce product
+    $command .= " -uri $outputImage" if $accept;
+    $command .= $stats->cmdflags()   if $accept;
+    $command .= " -hostname $host"   if defined $host;
+    $command .= " -dbname $dbname"   if defined $dbname;
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -249,5 +250,10 @@
     if (defined $warp_id and defined $skycell_id and defined $tess_dir and not $no_update) {
         # XXX change -tess_id to -tess_dir when db is updated
-        my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_dir -code $exit_code";
+        my $command = "$warptool -addwarped";
+	$command .= " -warp_id $warp_id";
+	$command .= " -skycell_id $skycell_id";
+	$command .= " -tess_id $tess_dir";
+	$command .= " -code $exit_code";
+        $command .= " -path_base $outroot";
         $command .= " -hostname $host" if defined $host;
         $command .= " -dbname $dbname" if defined $dbname;
