Index: trunk/ippScripts/scripts/staticsky.pl
===================================================================
--- trunk/ippScripts/scripts/staticsky.pl	(revision 33957)
+++ trunk/ippScripts/scripts/staticsky.pl	(revision 33979)
@@ -81,5 +81,5 @@
     -msg => "Required options: --sky_id --outroot --camera",
     -exitval => 3,
-          ) unless 
+          ) unless
     defined $sky_id and
     defined $outroot and
@@ -120,5 +120,5 @@
 
 
-# generate the input 
+# generate the input
 print $listFile "INPUT   MULTI\n";
 my $nInputs = @$files;
@@ -194,5 +194,5 @@
         # Perform stack photometry analysis
         {
-            my $command = "$psphotStack $outroot.stk";
+            my $command = "$psphotStack $outroot";
             $command .= " -input $listName";
             $command .= " -threads $threads" if defined $threads;
@@ -235,8 +235,9 @@
                     # we have one set of output files per input file set
                     for (my $i = 0; $i < @$files; $i++) {
-                        my $outputName     = $ipprc->filename("PSPHOT.STACK.OUTPUT.IMAGE", $outroot, $i);
-                        my $outputMask     = $ipprc->filename("PSPHOT.STACK.OUTPUT.MASK", $outroot, $i);
-                        my $outputVariance = $ipprc->filename("PSPHOT.STACK.OUTPUT.VARIANCE", $outroot, $i);
-                        my $outputSources  = $ipprc->filename("PSPHOT.STACK.OUTPUT", $outroot, $i);
+                        my $stack_id = @$files[$i]->{stack_id};
+                        my $outputName     = $ipprc->filename("PSPHOT.STACK.OUTPUT.IMAGE", $outroot, $stack_id);
+                        my $outputMask     = $ipprc->filename("PSPHOT.STACK.OUTPUT.MASK", $outroot, $stack_id);
+                        my $outputVariance = $ipprc->filename("PSPHOT.STACK.OUTPUT.VARIANCE", $outroot, $stack_id);
+                        my $outputSources  = $ipprc->filename("PSPHOT.STACK.OUTPUT", $outroot, $stack_id);
 
                         # XXX these are optional and not generated by default
@@ -256,6 +257,6 @@
 
                     # XXX check the recipe -- should we expect these to exist?
-                    # &my_die("Couldn't find expected output file: $chisqName", 	  $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqName);
-                    # &my_die("Couldn't find expected output file: $chisqMask", 	  $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqMask);
+                    # &my_die("Couldn't find expected output file: $chisqName",           $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqName);
+                    # &my_die("Couldn't find expected output file: $chisqMask",           $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqMask);
                     # &my_die("Couldn't find expected output file: $chisqVariance", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqVariance);
                 }
@@ -346,5 +347,5 @@
                 }
 
-                &my_die("Couldn't find expected output file: $configuration", $sky_id, $PS_EXIT_SYS_ERROR) 
+                &my_die("Couldn't find expected output file: $configuration", $sky_id, $PS_EXIT_SYS_ERROR)
                     unless $ipprc->file_exists($configuration);
             } else {
@@ -359,9 +360,9 @@
     {
         my $command = "$staticskytool -sky_id $sky_id";
-	$command .= " -addresult -path_base $outroot";
-	$command .= " -num_inputs $nInputs";
-	# $command .= " $cmdflags";
-	$command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
-	$command .= " -hostname $host" if defined $host;
+        $command .= " -addresult -path_base $outroot";
+        $command .= " -num_inputs $nInputs";
+        # $command .= " $cmdflags";
+        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
+        $command .= " -hostname $host" if defined $host;
         $command .= " -dbname $dbname" if defined $dbname;
 
@@ -371,6 +372,6 @@
             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
             my $err_message = "Unable to perform staticskytool -addresult";
-	    warn($err_message);
-	    exit $error_code;
+            warn($err_message);
+            exit $error_code;
         }
     }
@@ -389,9 +390,9 @@
     if (defined $sky_id and not $no_update) {
         my $command = "$staticskytool -sky_id $sky_id -fault $exit_code";
-	$command .= " -addresult";
-	$command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
-	$command .= " -hostname $host" if defined $host;
-	$command .= " -path_base $outroot" if defined $outroot;
-	$command .= " -dbname $dbname" if defined $dbname;
+        $command .= " -addresult";
+        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
+        $command .= " -hostname $host" if defined $host;
+        $command .= " -path_base $outroot" if defined $outroot;
+        $command .= " -dbname $dbname" if defined $dbname;
         run(command => $command, verbose => $verbose);
     }
