Index: trunk/ippScripts/scripts/staticsky.pl
===================================================================
--- trunk/ippScripts/scripts/staticsky.pl	(revision 28096)
+++ trunk/ippScripts/scripts/staticsky.pl	(revision 28154)
@@ -38,5 +38,9 @@
 }
 
-my ($sky_id, $camera, $dbname, $threads, $outroot, $reduction, $inverse, $run_state, $verbose, $no_update, $no_op, $redirect, $save_temps);
+# XXX test:
+print "run staticsky.pl @ARGV\n";
+# exit 0;
+
+my ($sky_id, $camera, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
 GetOptions(
     'sky_id=s'          => \$sky_id, # Diff identifier
@@ -44,5 +48,4 @@
     'dbname|d=s'        => \$dbname, # Database name
     'threads=s'         => \$threads,   # Number of threads to use
-    'run-state=s'       => \$run_state,   # state for run: 'new' or 'update'
     'outroot=s'         => \$outroot, # Output root name
     'reduction=s'       => \$reduction, # Reduction class
@@ -56,5 +59,5 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --sky_id --outroot --camera (--run_state)",
+    -msg => "Required options: --sky_id --outroot --camera",
     -exitval => 3,
           ) unless 
@@ -62,10 +65,8 @@
     defined $outroot and
     defined $camera;
-#   and defined $run_state;
 
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $sky_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 
 my $logDest = $ipprc->filename("LOG.EXP", $outroot);
-# $logDest .= ".update" if $run_state eq "update";
 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $sky_id, $PS_EXIT_SYS_ERROR ) if $redirect;
 
@@ -85,5 +86,5 @@
     unless ($success) {
         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-        &my_die("Unable to perform difftool -inputskyfile: $error_code", $sky_id, $error_code);
+        &my_die("Unable to perform staticskytool -inputs: $error_code", $sky_id, $error_code);
     }
 
@@ -152,7 +153,7 @@
 print "recipe_psphot: $recipe_psphot\n";
 
-my $cmdflags;
-
-# Perform subtraction
+# my $cmdflags;
+
+# Perform stack photometry analysis
 {
     my $command = "$psphotStack $outroot";
@@ -167,10 +168,9 @@
 
     unless ($no_op) {
-        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 ppSub: $error_code", $sky_id, $error_code);
-        }
+	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 psphotStack: $error_code", $sky_id, $error_code);
+	}
 
         # my $outputStatsReal = $ipprc->file_resolve($outputStats);
@@ -190,6 +190,7 @@
         # chomp $cmdflags;
 
-        my ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag
-
+        # my ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag
+
+	my $quality = 0;
         if (!$quality) {
 
@@ -197,8 +198,8 @@
 	    # 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);
-		my $outputMask     = $ipprc->filename("PSPHOT.STACK.OUTPUT.MASK", $outroot);
-		my $outputVariance = $ipprc->filename("PSPHOT.STACK.OUTPUT.VARIANCE", $outroot);
-		my $outputSources  = $ipprc->filename("PSPHOT.STACK.OUTPUT", $outroot);
+		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_die("Couldn't find expected output file: $outputName", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
@@ -211,9 +212,4 @@
 	    #my $outputStats    = $ipprc->filename("SKYCELL.STATS", $outroot);
 	    #my $traceDest      = $ipprc->filename("TRACE.EXP", $outroot);
-
-	    # if ($run_state eq 'update') {
-	    # 	$traceDest .= '.update';
-	    # 	$outputStats .= '.update';
-	    # }
 
 	    my $chisqName     = $ipprc->filename("PSPHOT.CHISQ.IMAGE", $outroot);
@@ -235,13 +231,9 @@
     {
         my $command = "$staticskytool -sky_id $sky_id";
-        # if ($run_state eq 'new') {
 	$command .= " -addresult -path_base $outroot";
 	$command .= " -num_inputs $nInputs";
-	$command .= " $cmdflags";
+	# $command .= " $cmdflags";
 	$command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
 	$command .= " -hostname $host" if defined $host;
-        # } else {
-        #     $command .= " -tofullskyfile";
-        # }
         $command .= " -dbname $dbname" if defined $dbname;
 
@@ -250,8 +242,7 @@
         unless ($success) {
             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-            my $err_message = $run_state eq "update" ?
-                "Unable to perform difftool -adddiffskyfile" :
-                "Unable to perform difftool -tofullskyfile";
-            &my_die("$err_message: $error_code", $sky_id, $error_code);
+            my $err_message = "Unable to perform staticskytool -addresult";
+	    warn($err_message);
+	    exit $error_code;
         }
     }
@@ -270,13 +261,9 @@
     if (defined $sky_id and not $no_update) {
         my $command = "$staticskytool -sky_id $sky_id -fault $exit_code";
-        if ($run_state eq 'new') {
-            $command .= " -adddiffskyfile";
-            $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;
-        } else {
-            $command .= " -updatediffskyfile";
-        }
+	$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);
     }
