Index: trunk/pstamp/scripts/detectability_respond.pl
===================================================================
--- trunk/pstamp/scripts/detectability_respond.pl	(revision 27643)
+++ trunk/pstamp/scripts/detectability_respond.pl	(revision 27788)
@@ -73,4 +73,5 @@
 #my $tmp_dir = "/data/${host}.0/tmp/";
 
+my $project = resolve_project($ipprc,"project_name",$dbname);
 #
 # Parse input request file using detect_query_read (as it's already written).
@@ -120,5 +121,4 @@
 for (my $i = 1; $i < $Nrows; $i++) {
 #    print "$i $Nrows $query{CONTENT}{RA1_DEG}[$i] $query{CONTENT}{DEC1_DEG}[$i]\n";
-
     my $image_set_tmp  = find_image_set($query{HEADER}{FPA_ID}[0],$query{HEADER}{STAGE}[0],
 					$query{HEADER}{MJD_OBS}[0],$query{HEADER}{FILTER}[0],
@@ -143,4 +143,5 @@
 my $i = 0;
 
+
 foreach my $k (keys %image_list_hash) {
     # Write coordinates of the requested targets to a file.
@@ -153,5 +154,5 @@
 	print $coordfile "$image_list_hash{$k}{SKY_COORDINATES}[$j]\n";
     }
-
+    print "$k\n";
     # Convert the sky coordinates to image coordinates with ppCoord.
     my $command = "ppCoord -astrom $image_list_hash{$k}{CATALOG} -radec $coordname";
@@ -171,5 +172,5 @@
     }
 
-    
+    print "psphot $image_list_hash{$k}{PSF}\n";
     # Run psphotForced on the target list.
     my $tmpdir  = tempdir("detect.$i.XXXX", DIR => "/tmp/", CLEANUP => !$save_temps);
@@ -215,5 +216,5 @@
 		    $query{HEADER}{obscode}[0],
 		    \@rownums, \@psphot_Npix, \@psphot_Qfact, \@psphot_flux);
-
+print "Wrote response file $output\n";
 #
 # Add to datastore
@@ -252,8 +253,21 @@
     my $mjd_max = $mjd + 1;
 
+    # Construct a row list:
+
+    my @rowList;
+    $rowList[0]->{CENTER_X} = $ra;
+    $rowList[0]->{CENTER_Y} = $dec;
+    $rowList[0]->{ID} = 1;
+    $rowList[0]->{STAGE} = $stage;
+    $rowList[0]->{COORD_MASK} = 0;
+    print "$stage\n";
     # Call the PStamp code to find the images that contain the target on the given MJD in the specified filter.
-    my @images = locate_images($ipprc,$dbname,"bycoord",$stage,
-			       undef,undef,undef,$option_mask,$need_magic,
-			       $ra,$dec,$mjd_min,$mjd_max,$filter . ".00000",undef,$verbose);  
+    my @images = locate_images($ipprc,$dbname,
+			        \@rowList,
+			       "bycoord",$stage,
+			       undef,undef,undef,
+			       $option_mask,$need_magic,
+			       # $ra,$dec,
+			       $mjd_min,$mjd_max,$filter . ".00000",undef,$verbose);  
 
     my %image_info  = ();
