Index: trunk/ippScripts/scripts/phase3.pl
===================================================================
--- trunk/ippScripts/scripts/phase3.pl	(revision 11333)
+++ trunk/ippScripts/scripts/phase3.pl	(revision 11355)
@@ -53,4 +53,9 @@
 my $p3tool = can_run('p3tool') or (warn "Can't find p3tool" and $missing_tools = 1);
 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
+
+# test for addstar and psastro:
+my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);
+my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1);
+
 if ($missing_tools) { 
     warn("Can't find required tools.");
@@ -76,7 +81,4 @@
 	&my_die("Unable to parse metadata list", $exp_tag, $PS_EXIT_PROG_ERROR);
 }
-
-# XXX need to add the psastro +mosastro step here
-# XXX need to add the addstar step here
 
 # Gather the statistics
@@ -121,4 +123,6 @@
 }
 
+# make this a function which generates a specific list file for a specific filename
+
 # Generate the file list, and get the statistics
 my $outputRoot = $exp_tag . '.p3'; # Root output name
@@ -131,6 +135,16 @@
 open my $list2File, '>' . $list2Name;
 foreach my $file (@$files) {
-    print $list1File ($ipprc->convert_filename_absolute($file->{b1_uri}) . "\n");
-    print $list2File ($ipprc->convert_filename_absolute($file->{b2_uri}) . "\n");
+    # use the b1_uri as OUTPUT root and convert the filenames
+    # with ipprc->filename:
+    my $classID = $file->{class_id};
+    my $fileRoot = $file->{b1_uri};
+    print $list1File $ipprc->filename("PPIMAGE.BIN1", $file->{b1_uri}, $classID);
+    print $list2File $ipprc->filename("PPIMAGE.BIN2", $file->{b1_uri}, $classID);
+    print $list1File $ipprc->filename("PSPHOT.OUTPUT", $file->{b1_uri}, $classID);
+    print $list1File $ipprc->filename("PSASTRO.OUTPUT", $file->{b1_uri}, $classID);
+    # XXX PSASTRO.OUTPUT is explicitly a CHIP output file 
+    # XXX below the PSASTRO.OUTPUT must be an FPA output file
+    # print $list1File ($ipprc->convert_filename_absolute($file->{b1_uri}) . "\n");
+    # print $list2File ($ipprc->convert_filename_absolute($file->{b2_uri}) . "\n");
     push @means, $file->{bg};
     push @stdevs, $file->{bg_stdev};
@@ -142,4 +156,12 @@
 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
+my $objects = $ipprc->filename("PSASTRO.OUTPUT", $outputRoot); # MEF psastro output
+
+# if file == CHIP
+#    run psastro +mosastro on PSASTRO.OUTPUT.CHIP
+#    run addstar on PSASTRO.OUTPUT.FPA
+
+# if file == FPA
+#    run addstar on PSASTRO.OUTPUT.CHIP
 
 # Make the jpeg for binning 1
@@ -167,5 +189,5 @@
 }
 
-
+# XXX keep the same outroot as the input
 # Add the result into the database
 $outputRoot = $ipprc->convert_filename_relative($outputRoot);
