Index: trunk/ippScripts/scripts/addstar_run.pl
===================================================================
--- trunk/ippScripts/scripts/addstar_run.pl	(revision 33525)
+++ trunk/ippScripts/scripts/addstar_run.pl	(revision 33989)
@@ -38,6 +38,6 @@
 }
 my $minidvodb_path;
-my $stage_extra1 ;
-my ( $add_id, $camera, $stage, $stage_id, $multi_num, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
+
+my ( $add_id, $camera, $stage, $stage_id, $stage_extra1, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
      $no_op, $redirect, $save_temps);
 GetOptions(
@@ -46,5 +46,5 @@
     'stage|s=s'        => \$stage, # Camera
     'stage_id|w=s'   => \$stage_id,
-    'multi_num|w=s'    => \$multi_num, # the number for a staticskymulti (for finding cmf)
+    'stage_extra1|w=s'    => \$stage_extra1, # the number for a staticskymulti (for finding cmf), or stack_id
     'dbname|d=s'        => \$dbname, # Database name
     'outroot|w=s'       => \$outroot, # output file base name
@@ -162,17 +162,47 @@
     }
 }
-if (($stage =~/staticsky/) || ($stage =~/stack/)) {
+if (($stage =~/stack/)) {
     $fpaObjects =~ s/smf$/cmf/;
     $fpaObjectsAlt =~ s/smf$/cmf/;
-}
+
+}
+my $fpaObjects1;
+my $fpaObjects2;
 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
-    }
+    $checkalt = 1;
+    my $sources   = $ipprc->filename("PSPHOT.OUT.CMF.MEF", $stageroot); #this is mostly rigtht except the .cmf needs either
+    # .000.cmf or .stk.xxxxx.cmf
+    print "$sources\n\n\n";
+    &my_die( "can't find the filter_num for staticsky_multi, giving up.", $add_id, $PS_EXIT_SYS_ERROR) unless (defined $stage_extra1);
+
+    
+    $fpaObjects1 = $sources;
+    $fpaObjects2 = $sources;
+    $fpaObjects = $sources;
+
+    my $nice_num = sprintf ("%03d", $stage_extra1);
+
+    $fpaObjects1 =~ s/cmf$/stk.$stage_extra1.cmf/;
+    $fpaObjects2 =~ s/cmf$/$nice_num.cmf/;  #this make it look for .001.cmf, etc
+ # we have 3 of them to try
+    my $realFile = $ipprc->file_resolve($fpaObjects);
+    my $realFile1 = $ipprc->file_resolve($fpaObjects1);
+    my $realFile2 = $ipprc->file_resolve($fpaObjects2);
+    if (!defined($realFile1)) {
+	if (!defined($realFile2)) {
+	    print "using $fpaObjects\n";
+	    
+	} else {
+	    print "using $fpaObjects2\n";
+	    $fpaObjects = $fpaObjects2;
+	}
+	
+    } else {
+	print "using $fpaObjects1\n";
+	$fpaObjects = $fpaObjects1;
+    }
+     
+
 }
 
@@ -230,17 +260,8 @@
 	    my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
 	   
-	    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);
-		}
-		
-	    }
+	    my $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)
