Index: trunk/ippScripts/scripts/addstar_run.pl
===================================================================
--- trunk/ippScripts/scripts/addstar_run.pl	(revision 33524)
+++ trunk/ippScripts/scripts/addstar_run.pl	(revision 33525)
@@ -117,4 +117,6 @@
 
 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
+my $fpaObjectsAlt = $fpaObjects;
+
 
 if ($stage =~ /cam/) {
@@ -162,10 +164,15 @@
 if (($stage =~/staticsky/) || ($stage =~/stack/)) {
     $fpaObjects =~ s/smf$/cmf/;
-}
-if ($stage =~/staticsky_multi/) {
+    $fpaObjectsAlt =~ s/smf$/cmf/;
+}
+my $checkalt = 0;
+if ($stage =~/staticsky/) {
     $fpaObjects =~ s/smf$/cmf/; #this should do nothing because it was already modded above
     &my_die( "can't find the filter_num for staticsky_multi, giving up.", $add_id, $PS_EXIT_SYS_ERROR) unless (defined $multi_num);
     my $nice_num = sprintf ("%03d", $multi_num);
     $fpaObjects =~ s/cmf$/$nice_num.cmf/;  #this make it look for .001.cmf, etc
+    if ($multi_num == 0) {
+	$checkalt =1 ; #if it's staticsky and multi_num = 0 there's an alternate file to try if this one doesn't work
+    }
 }
 
@@ -222,6 +229,19 @@
 	    # get the names for the camera and the real input file
 	    my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
-	    my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);
-	    
+	   
+	    my $realFile = $ipprc->file_resolve($fpaObjects);
+	    if (!defined($realFile)) {
+		print "can't find $fpaObjects\n";
+		if ($checkalt)  {
+		    $realFile = $ipprc->file_resolve($fpaObjectsAlt) or &my_die("Unable to resolve $fpaObjectsAlt", $add_id, $PS_EXIT_SYS_ERROR);
+		    $fpaObjects = $fpaObjectsAlt; # want to make sure the correct value is used.
+		} else {
+		    # try the 'good one' again and fail i
+		    #$realFile = $ipprc->file_resolve($fpaObjects) or 
+		    &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);
+		}
+		
+	    }
+
 	    # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
 	    my $command  = "$addstar -update"; # XXX optionally set -update?
Index: trunk/ippTasks/addstar.pro
===================================================================
--- trunk/ippTasks/addstar.pro	(revision 33524)
+++ trunk/ippTasks/addstar.pro	(revision 33525)
@@ -26,7 +26,4 @@
     active true
   end
-  task addstar.exp.load.staticsky_multi
-    active true
-  end  
   task addstar.exp.run
     active true
@@ -44,7 +41,4 @@
     active false
   end
-  task addstar.exp.load.staticsky_multi
-    active false
-  end
   task addstar.exp.run
     active false
@@ -62,7 +56,4 @@
     active false
   end
- task addstar.revert.staticsky_multi
-    active false
-  end
 end
 macro addstar.revert.on
@@ -71,7 +62,4 @@
   end
   task addstar.revert.stack
-    active true
-  end
-  task addstar.revert.staticsky_multi
     active true
   end
@@ -218,59 +206,4 @@
    # if ($LABEL:n == 0) break
     $run = addtool -pendingexp -stage staticsky
-    if ($DB:n == 0)
-      option DEFAULT
-    else
-      # save the DB name for the exit tasks
-      option $DB:$addstar_DB
-      $run = $run -dbname $DB:$addstar_DB
-      $addstar_DB ++
-      if ($addstar_DB >= $DB:n) set addstar_DB = 0
-    end
-    add_poll_args run
-    add_poll_labels run
-    command $run
-  end
-
-  # success
-  task.exit    0
-    # convert 'stdout' to book format
-    ipptool2book stdout addPendingExp -key add_id -uniq -setword dbname $options:0 -setword pantaskState INIT
-    if ($VERBOSE > 2)
-      book listbook addPendingExp
-    end
-
-    # delete existing entries in the appropriate pantaskStates
-    process_cleanup addPendingExp
-  end
-
-  # default exit status
-  task.exit    default
-    showcommand failure
-  end
-
-  task.exit    crash
-    showcommand crash
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
-
-task	       addstar.exp.load.staticsky_multi
-  host         local
-
-  periods      -poll $LOADPOLL
-  periods      -exec $LOADEXEC
-  periods      -timeout 30
-  npending     1
-
-  stdout NULL
-  stderr $LOGDIR/addstar.exp.log
-
-  task.exec
-   # if ($LABEL:n == 0) break
-    $run = addtool -pendingexp -stage staticsky_multi
     if ($DB:n == 0)
       option DEFAULT
@@ -373,7 +306,4 @@
 	sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID
     end
-    if ("$STAGE" == "staticsky_multi")
-	sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID
-    end
     if ("$STAGE" == "stack")
 	sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID
@@ -388,5 +318,5 @@
       $run = $run --reduction $REDUCTION
     end
-    if ("$STAGE" == "staticsky_multi")
+    if ("$STAGE" == "staticsky")
       $run = $run --multi_num $STAGE_EXTRA1
     end
@@ -529,4 +459,5 @@
   end
 end
+
 task addstar.revert.staticsky
   host         local
@@ -544,50 +475,4 @@
     if ($LABEL:n == 0) break
     $run = addtool -revertprocessedexp -stage staticsky
-    if ($DB:n == 0)
-      option DEFAULT
-    else
-      # save the DB name for the exit tasks
-      option $DB:$addstar_revert_DB_SS
-      $run = $run -dbname $DB:$addstar_revert_DB_SS
-      $addstar_revert_DB_SS ++
-      if ($addstar_revert_DB_SS >= $DB:n) set addstar_revert_DB_SS = 0
-    end
-    add_poll_labels run
-    command $run
-  end
-
-  # success
-  task.exit    0
-  end
-
-  # locked list
-  task.exit    default
-    showcommand failure
-  end
-
-  task.exit    crash
-    showcommand crash
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
-task addstar.revert.staticsky_multi
-  host         local
-
-  periods      -poll 5.0
-  periods      -exec 60.0
-  periods      -timeout 1200
-  npending     1
-  active        false
-
-  stdout NULL
-  stderr $LOGDIR/revert.log
-
-  task.exec
-    if ($LABEL:n == 0) break
-    $run = addtool -revertprocessedexp -stage staticsky_multi
     if ($DB:n == 0)
       option DEFAULT
Index: trunk/ippTasks/survey.pro
===================================================================
--- trunk/ippTasks/survey.pro	(revision 33524)
+++ trunk/ippTasks/survey.pro	(revision 33525)
@@ -859,9 +859,4 @@
         $run = $run -uncensored
     end
-    if ("$stage" == "staticsky_multi") 
-        #only queue uncensored staticsky (multi filter)
-        $run = $run -uncensored
-    end
-
     if ("$stage" == "stack") 
         #only queue uncensored stacks
Index: trunk/ippTools/share/Makefile.am
===================================================================
--- trunk/ippTools/share/Makefile.am	(revision 33524)
+++ trunk/ippTools/share/Makefile.am	(revision 33525)
@@ -8,6 +8,4 @@
 	addtool_find_cam_id_dvo.sql \
 	addtool_find_cam_id.sql \
-	addtool_find_sky_id_dvo.sql \
-	addtool_find_sky_id.sql \
 	addtool_find_sky_id_multi_dvo.sql \
 	addtool_find_sky_id_multi.sql \
@@ -17,10 +15,8 @@
 	addtool_find_pendingexp_cam.sql \
 	addtool_find_pendingexp_stack.sql \
-	addtool_find_pendingexp_staticsky.sql \
 	addtool_find_pendingexp_staticsky_multi.sql \
 	addtool_find_pendingmergeprocess.sql \
 	addtool_find_processedexp_cam.sql \
 	addtool_find_processedexp_stack.sql \
-	addtool_find_processedexp_staticsky.sql \
 	addtool_find_processedexp_staticsky_multi.sql \
 	addtool_find_minidvodbprocessed.sql \
@@ -30,5 +26,4 @@
 	addtool_queue_cam_id.sql \
 	addtool_queue_stack_id.sql \
-	addtool_queue_sky_id.sql \
 	addtool_queue_sky_id_multi.sql \
 	addtool_queue_minidvodbrun.sql \
Index: trunk/ippTools/share/addtool_find_pendingexp_staticsky_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_find_pendingexp_staticsky_multi.sql	(revision 33524)
+++ trunk/ippTools/share/addtool_find_pendingexp_staticsky_multi.sql	(revision 33525)
@@ -25,5 +25,5 @@
 WHERE
     staticskyRun.state = 'full'
-    AND stage = 'staticsky_multi'
+    AND stage = 'staticsky'
     AND ((addRun.state = 'new' AND addProcessedExp.add_id IS NULL) OR addRun.state = 'update')
     AND addRun.dvodb IS NOT NULL
Index: trunk/ippTools/share/addtool_find_sky_id.sql
===================================================================
--- trunk/ippTools/share/addtool_find_sky_id.sql	(revision 33524)
+++ trunk/ippTools/share/addtool_find_sky_id.sql	(revision 33525)
@@ -2,6 +2,6 @@
     staticskyRun.*
 FROM 
-     staticskyResult
-join staticskyRun using (sky_id)
+     staticskyRun
+join staticskyResult using (sky_id)
 join staticskyInput using(sky_id)
 JOIN stackRun USING(stack_id)
@@ -19,4 +19,4 @@
     staticskyRun.state = 'full'
     AND staticskyResult.quality = 0
-    AND added_exp_id IS NULL
+    AND added_sky_id IS NULL
     -- addtool adds checks on exposure being added to the dvodb previously
Index: trunk/ippTools/share/addtool_find_sky_id_dvo.sql
===================================================================
--- trunk/ippTools/share/addtool_find_sky_id_dvo.sql	(revision 33524)
+++ trunk/ippTools/share/addtool_find_sky_id_dvo.sql	(revision 33525)
@@ -1,12 +1,13 @@
-SELECT staticskyRun.* FROM staticskyResult
-JOIN staticskyRun USING(sky_id)
+SELECT staticskyRun.* FROM staticskyRun
+JOIN staticskyResult USING(sky_id)
 join staticskyInput using(sky_id)
 JOIN stackRun USING(stack_id)
 
 WHERE staticskyRun.state = 'full' and staticskyResult.quality = 0
-    AND sky_id NOT IN (SELECT sky_id
+    AND stack_id NOT IN (SELECT stack_id
        FROM addRun
        JOIN staticskyResult on staticskyResult.sky_id = addRun.stage_id
        JOIN staticskyRun USING(sky_id)
+       JOIN staticskyInput USING(sky_id)
        WHERE addRun.stage = 'staticsky' AND %s
       )
Index: trunk/ippTools/share/addtool_find_sky_id_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_find_sky_id_multi.sql	(revision 33524)
+++ trunk/ippTools/share/addtool_find_sky_id_multi.sql	(revision 33525)
@@ -4,16 +4,16 @@
     staticskyResult.num_inputs
 FROM 
-     staticskyResult
-join staticskyRun using (sky_id)
+     staticskyRun
+join staticskyResult using (sky_id)
 join staticskyInput using(sky_id)
 JOIN stackRun USING(stack_id)
 
-LEFT JOIN (SELECT sky_id       AS added_sky_id,
+LEFT JOIN (SELECT stack_id       AS added_stack_id,
                   addRun.dvodb AS previous_dvodb
            FROM addRun
 JOIN staticskyRun on sky_id = stage_id
           ) as foo
-     ON sky_id = added_sky_id 
-     AND stage = 'staticsky_multi'
+     ON stack_id = added_stack_id 
+     AND stage = 'staticsky'
      -- hook for qualifying the join on the previous_dvodb
      AND %s
@@ -21,4 +21,4 @@
     staticskyRun.state = 'full'
     AND staticskyResult.quality = 0
-    AND added_exp_id IS NULL
+    AND added_stack_id IS NULL
     -- addtool adds checks on exposure being added to the dvodb previously
Index: trunk/ippTools/share/addtool_find_sky_id_multi_dvo.sql
===================================================================
--- trunk/ippTools/share/addtool_find_sky_id_multi_dvo.sql	(revision 33524)
+++ trunk/ippTools/share/addtool_find_sky_id_multi_dvo.sql	(revision 33525)
@@ -5,8 +5,9 @@
 
 WHERE staticskyRun.state = 'full' and staticskyResult.quality = 0
-    AND sky_id NOT IN (SELECT sky_id
+    AND stack_id NOT IN (SELECT stack_id
        FROM addRun
        JOIN staticskyResult on staticskyResult.sky_id = addRun.stage_id
        JOIN staticskyRun USING(sky_id)
-       WHERE addRun.stage = 'staticsky_multi' AND %s
+       JOIN staticskyInput USING(sky_id)
+       WHERE addRun.stage = 'staticsky' AND %s
       )
Index: trunk/ippTools/share/addtool_queue_sky_id_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_queue_sky_id_multi.sql	(revision 33524)
+++ trunk/ippTools/share/addtool_queue_sky_id_multi.sql	(revision 33525)
@@ -2,5 +2,5 @@
     SELECT
         0,              -- add_id
-        'staticsky_multi',		-- stage
+        'staticsky',		-- stage
         sky_id,         -- stage_id
 	%d,		-- stage_extra1
Index: trunk/ippTools/share/addtool_revertprocessedexp_staticsky_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_revertprocessedexp_staticsky_multi.sql	(revision 33524)
+++ trunk/ippTools/share/addtool_revertprocessedexp_staticsky_multi.sql	(revision 33525)
@@ -5,3 +5,3 @@
     AND addProcessedExp.fault != 0
     AND addRun.state = 'new'
-    AND addRun.stage = 'staticsky_multi'
+    AND addRun.stage = 'staticsky'
Index: trunk/ippTools/src/addtool.c
===================================================================
--- trunk/ippTools/src/addtool.c	(revision 33524)
+++ trunk/ippTools/src/addtool.c	(revision 33525)
@@ -141,11 +141,4 @@
     pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
     PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
-    pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
-    }
-        if (strcmp(stage, "staticsky_multi")== 0) {
-
-    pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
-    pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
-    PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
     //no filter here
     }
@@ -227,21 +220,6 @@
     }
     }
+  
     if (strcmp(stage,"staticsky") == 0) {
-    if (dvodb ) {
-      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_dvo.sql\n%s\n", dvodb,stage);
-        // find the cam_id of all the exposures that we want to queue up.
-        bare_query = pxDataGet("addtool_find_sky_id_dvo.sql");
-	// user supplied dvodb
-	psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
-    } else {
-      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id.sql\n%s\n",stage);
-        // find the cam_id of all the exposures that we want to queue up.
-        bare_query = pxDataGet("addtool_find_sky_id.sql");
-        // inherit dvodb from camRun, avoid matching NULL
-        psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
-    }
-    }
-
-    if (strcmp(stage,"staticsky_multi") == 0) {
       if (dvodb ) {
 	psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
@@ -310,8 +288,8 @@
 	psStringAppend(&query, " GROUP BY stack_id");
       }
+      //   if (strcmp(stage,"staticsky") == 0) {
+      //   psStringAppend(&query, " GROUP BY stack_id");
+      // }
     if (strcmp(stage,"staticsky") == 0) {
-	psStringAppend(&query, " GROUP BY stack_id");
-      }
-    if (strcmp(stage,"staticsky_multi") == 0) {
       psStringAppend(&query, " GROUP BY sky_id");  //some reason it needs this
       }
@@ -402,31 +380,6 @@
     }
     }
+   
     if (strcmp(stage,"staticsky") == 0) {
-    for (long i = 0; i < psArrayLength(output); i++) {
-        psMetadata *md = output->data[i];
-
-	staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
-	
-        if (!row) {
-            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
-            psFree(output);
-            return false;
-        }
-
-        if (!dvodb) {  //there's no staticsky.dvodb
-            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
-            psFree(output);
-            return false;
-        }
-        if (!workdir && !row->workdir) {
-            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
-            psFree(output);
-            return false;
-        }
-
-        psFree(row);
-    }
-    }
-    if (strcmp(stage,"staticsky_multi") == 0) {
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *md = output->data[i];
@@ -566,48 +519,6 @@
     }
       }
+   
     if (strcmp(stage,"staticsky") == 0) {
-    for (long i = 0; i < psArrayLength(output); i++) {
-        psMetadata *md = output->data[i];
-	psS64 stage_id =0; 
-	
-	staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
-	stage_id = row->sky_id;
-	
-        if (!row) {
-            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
-            psFree(output);
-            return false;
-        }
-
-        // queue the exp
-        if (!pxaddQueueByCamID(config,
-			       stage,
-                               stage_id,
-			       0,
-                               workdir     ? workdir   : row->workdir,
-                               reduction   ? reduction : row->reduction,
-                               label       ? label     : row->label,
-                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
-                               dvodb       ? dvodb     : NULL,
-                               note        ? note      : NULL,
-                               image_only,
-                               minidvodb,
-                               minidvodb_group,
-                               minidvodb_name
-        )) {
-            if (!psDBRollback(config->dbh)) {
-                psError(PS_ERR_UNKNOWN, false, "database error sfg");
-            }
-            psError(PS_ERR_UNKNOWN, false,
-                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
-            psFree(row);
-            psFree(output);
-            return false;
-        }
-        psFree(row);
-    }
-      }
-
-    if (strcmp(stage,"staticsky_multi") == 0) {
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *md = output->data[i];
@@ -705,7 +616,5 @@
     query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     }
-    if (strcmp(stage, "staticsky_multi")==0) {
-    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
-    }
+    
 
     // pxUpdateRun gets parameters from config->args and runs the update query
@@ -745,7 +654,4 @@
     }
     if (strcmp(stage, "staticsky")==0) { 
-    query = pxDataGet("addtool_find_pendingexp_staticsky.sql");
-    }
-    if (strcmp(stage, "staticsky_multi")==0) { 
     query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql");
     }
@@ -768,9 +674,9 @@
       psStringAppend(&query, " GROUP BY %s", "stack_id");
     }
+    //if (strcmp(stage, "staticsky") == 0) {
+    //  //this group by is needed to join against all the warps (to get camera)
+    //  psStringAppend(&query, " GROUP BY %s", "sky_id");
+    //}
     if (strcmp(stage, "staticsky") == 0) {
-      //this group by is needed to join against all the warps (to get camera)
-      psStringAppend(&query, " GROUP BY %s", "sky_id");
-    }
-    if (strcmp(stage, "staticsky_multi") == 0) {
       //this group by is needed to join against all the warps (to get camera)
       psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1");
@@ -977,7 +883,4 @@
     }
     if (strcmp (stage,"staticsky") == 0) {
-    query = pxDataGet("addtool_find_processedexp_staticsky.sql");
-    }
-    if (strcmp (stage,"staticsky_multi") == 0) {
     query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
     }
@@ -1090,8 +993,5 @@
 	 query = pxDataGet("addtool_revertprocessedexp_stack.sql");
       }
-     if (strcmp(stage, "staticsky") == 0) {
-	 query = pxDataGet("addtool_revertprocessedexp_staticsky.sql");
-      }
-   if (strcmp(stage, "staticsky_multi") == 0) {
+    if (strcmp(stage, "staticsky") == 0) {
 	 query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
       }
Index: trunk/ippTools/src/pxadd.c
===================================================================
--- trunk/ippTools/src/pxadd.c	(revision 33524)
+++ trunk/ippTools/src/pxadd.c	(revision 33525)
@@ -157,8 +157,4 @@
       }
       if (strcmp(stage,"staticsky") == 0) {
-	query = pxDataGet("addtool_queue_sky_id.sql");
-        psMemSetPersistent(query, true);
-      }
-      if (strcmp(stage,"staticsky_multi") == 0) {
 	query = pxDataGet("addtool_queue_sky_id_multi.sql");
         psMemSetPersistent(query, true);
