Index: /tags/ipp-pv3-20140717/ippScripts/scripts/lap_science.pl
===================================================================
--- /tags/ipp-pv3-20140717/ippScripts/scripts/lap_science.pl	(revision 38093)
+++ /tags/ipp-pv3-20140717/ippScripts/scripts/lap_science.pl	(revision 38094)
@@ -1055,5 +1055,6 @@
     $command .= " -min_num ${minimum_stack_inputs} -random 100 -set_reduction THREEPI_STACK_1DG -set_dist_group $exposure->{dist_group} ";
     $command .= " $warps ";
-
+    
+    print "$command\n";
     my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => $verbose);
@@ -1064,4 +1065,33 @@
     my $stacks_made = $mdcParser->parse_list(join "", @$stdout_buf) or
 	&my_die("unable to parse metadata from stacktool -definebyquery", $lap_id, "");    
+    print "STACKS MADE: >>$#{ $stacks_made }<<\n";
+    if ($#{ $stacks_made} == -1) {
+	print "Zero made\n";
+	$command = "$stacktool ";
+	$command .= " -pretend " if defined $debug;
+	$command .= " -dbname $dbname " if defined $dbname;
+	$command .= " -definebyquery -select_skycell_id ${proj_cell}.% -select_filter $filter ";
+#	$command .= " -select_fwhm_major_max 10.0 -select_zpt_obs_min 25.85 -select_bg_max 425 ";
+	$command .= " -select_good_frac_min 0.20 ";
+#    $command .= " -select_label $label "; # Removed to allow exposure sharing to work
+	$command .= " -set_label ${label} -set_workdir $workdir -set_data_group $data_group ";
+	$command .= " -min_num ${minimum_stack_inputs} -random 100 -set_reduction THREEPI_STACK_1DG -set_dist_group $exposure->{dist_group} ";
+	$command .= " $warps ";
+	
+	print "$command\n";
+	($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 stacktool -definebyquery: $error_code :: $command", $lap_id);
+	}
+	my $stacks_made_attempt2 = $mdcParser->parse_list(join "", @$stdout_buf) or
+	    &my_die("unable to parse metadata from stacktool -definebyquery", $lap_id, "");    
+	
+	if ($#{ $stacks_made_attempt2} == -1) {
+	    &my_die("Unable to construct any stacks from these input warps.  Nothing with good_frac > 0.2?", $lap_id, "");
+	}
+	$stacks_made = $stacks_made_attempt2;
+    }
 
     ##
