Index: /tags/ipp-ops-20220906/ippScripts/scripts/nightly_science.pl
===================================================================
--- /tags/ipp-ops-20220906/ippScripts/scripts/nightly_science.pl	(revision 42343)
+++ /tags/ipp-ops-20220906/ippScripts/scripts/nightly_science.pl	(revision 42344)
@@ -1557,8 +1557,7 @@
         my $this_object = shift @{ $object_row };       
         my $this_chunk = shift @{ $object_row };
-        my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,chipRun.state FROM ";
+        my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,camProcessedExp.fwhm_major,chipRun.state,camRun.state FROM ";
         $input_sth .=   " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN camProcessedExp USING(cam_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) ";
         $input_sth .=   " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";
-        $input_sth .=   " AND camProcessedExp.fwhm_major <= $maxFWHM ";
         $input_sth .=   " AND substr(rawExp.comment, 1, position(' ' in rawExp.comment)) = '$this_chunk' ORDER BY rawExp.comment,dateobs ";
 
@@ -1574,13 +1573,18 @@
             my $this_state   = ${ $this_warp }[4];
             my $this_warp_id  = ${ $this_warp }[1];
-            my $chip_state   = ${ $this_warp }[6];
+            my $this_fwhm   = ${ $this_warp }[6];
+            my $chip_state   = ${ $this_warp }[7];
+            my $cam_state   = ${ $this_warp }[8];
 	    
 	    #find exposures for this object that have not been fully processed
-            if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL') || ($chip_state eq 'run') ) ) {
-                $Nbad += 1;
-            }
-
-            if (($this_quality != 0) || ($this_state eq 'drop') ) {
-                print STDERR "diff_queue: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality or state $this_state\n";
+            if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL')) ) {
+            	$Nbad += 1;
+            }
+            if (($chip_state ne 'full') || ($cam_state ne 'full') ) {
+            	$Nbad += 1;
+            }
+
+            if (($this_quality != 0) || ($this_state eq 'drop') || ($this_fwhm > $maxFWHM)) {
+                print STDERR "diff_queue: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality or state $this_state or FWHM $this_fwhm\n";
             }
             else {
@@ -1765,5 +1769,5 @@
             my $this_chunk = shift @{ $object_row };
        
-            my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,substr(comment, 1, position(' ' in comment)),camProcessedExp.fwhm_major,chipRun.state FROM ";
+            my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,camProcessedExp.fwhm_major,chipRun.state,camRun.state FROM ";
             $input_sth .=   " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN camProcessedExp USING(cam_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) ";
             $input_sth .=   " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";
@@ -1782,12 +1786,16 @@
                 my $this_quality = ${ $this_warp }[5];
                 my $this_state   = ${ $this_warp }[4];
-                my $this_fwhm   = ${ $this_warp }[7];
                 my $this_warp_id  = ${ $this_warp }[1];
-                my $chip_state   = ${ $this_warp }[8];
+                my $this_fwhm   = ${ $this_warp }[6];
+                my $chip_state   = ${ $this_warp }[7];
+                my $cam_state   = ${ $this_warp }[8];
 
 	        #find exposures for this object that have not been fully processed
-                if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL') || ($chip_state eq 'run') ) ) {
-                    $Nbad += 1;
-                }
+             	if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL')) ) {
+             	    $Nbad += 1;
+             	}
+             	if (($chip_state ne 'full') || ($cam_state ne 'full') ) {
+             	    $Nbad += 1;
+             	}
 
                 if (($this_quality != 0) || ($this_state eq 'drop') || ($this_fwhm > $maxFWHM)) {
@@ -2152,5 +2160,5 @@
             my $this_chunk = shift @{ $object_row };
        
-            my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.qualityy,substr(comment, 1, position(' ' in comment)),camProcessedExp.fwhm_major,chipRun.state FROM ";
+            my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,camProcessedExp.fwhm_major,chipRun.state,camRun.state FROM ";
             $input_sth .=   " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN camProcessedExp USING(cam_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) ";
             $input_sth .=   " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";
@@ -2169,12 +2177,16 @@
                 my $this_quality = ${ $this_warp }[5];
                 my $this_state   = ${ $this_warp }[4];
-                my $this_fwhm    = ${ $this_warp }[7];
                 my $this_warp_id  = ${ $this_warp }[1];
-                my $chip_state   = ${ $this_warp }[8];
+                my $this_fwhm    = ${ $this_warp }[6];
+                my $chip_state   = ${ $this_warp }[7];
+                my $cam_state   = ${ $this_warp }[8];
 
 	     	#find exposures for this object that have not been fully processed
-             	if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL') || ($chip_state eq 'run') ) ) {
+             	if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL')) ) {
              	    $Nbad += 1;
              	}
+                if (($chip_state ne 'full') || ($cam_state ne 'full') ) {
+            	    $Nbad += 1;
+                }
 
                 if (($this_quality != 0) || ($this_state eq 'drop') || ($this_fwhm > $maxFWHM)) {
