Index: /tags/ipp-ops-20220705/ippScripts/scripts/nightly_science.pl
===================================================================
--- /tags/ipp-ops-20220705/ippScripts/scripts/nightly_science.pl	(revision 42303)
+++ /tags/ipp-ops-20220705/ippScripts/scripts/nightly_science.pl	(revision 42304)
@@ -1557,5 +1557,5 @@
         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 FROM ";
+        my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,chipRun.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' ";
@@ -1574,7 +1574,8 @@
             my $this_state   = ${ $this_warp }[4];
             my $this_warp_id  = ${ $this_warp }[1];
+            my $chip_state   = ${ $this_warp }[6];
 	    
 	    #find exposures for this object that have not been fully processed
-            if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL')) ) {
+            if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL') || ($chip_state eq 'run') ) ) {
                 $Nbad += 1;
             }
@@ -1749,5 +1750,5 @@
         my $difference=$date2->delta_ms($date1);
 
-        $summittimediff=(($difference->hours)*60.) + ($difference->minutes) + (($difference->seconds)/60.);
+        my $summittimediff=(($difference->hours)*60.) + ($difference->minutes) + (($difference->seconds)/60.);
     }
 
@@ -1764,5 +1765,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 FROM ";
+            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 ";
             $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' ";
@@ -1783,7 +1784,8 @@
                 my $this_fwhm   = ${ $this_warp }[7];
                 my $this_warp_id  = ${ $this_warp }[1];
+                my $chip_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')) ) {
+                if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL') || ($chip_state eq 'run') ) ) {
                     $Nbad += 1;
                 }
@@ -1914,5 +1916,5 @@
                     }
                     else {
-                        print STDERR "Preparing to diff $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment $template_comment\n";
+                        print STDERR "Preparing to single desperate diff $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment $template_comment\n";
                     }
            
@@ -2135,5 +2137,5 @@
         my $difference=$date2->delta_ms($date1);
 
-        $summittimediff=(($difference->hours)*60.) + ($difference->minutes) + (($difference->seconds)/60.);
+        my $summittimediff=(($difference->hours)*60.) + ($difference->minutes) + (($difference->seconds)/60.);
     }
 
@@ -2150,5 +2152,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,camProcessedExp.fwhm_major FROM ";
+            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 ";
             $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,7 +2171,8 @@
                 my $this_fwhm    = ${ $this_warp }[7];
                 my $this_warp_id  = ${ $this_warp }[1];
+                my $chip_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')) ) {
+             	if (($this_warp_id eq 'NULL') && (($this_quality == 0) || ($this_quality eq 'NULL') || ($chip_state eq 'run') ) ) {
              	    $Nbad += 1;
              	}
@@ -2276,5 +2279,5 @@
                     }
                     else {
-                        print STDERR "Preparing to diff $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment $template_comment\n";
+                        print STDERR "Preparing to desperate diff $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment $template_comment\n";
                     }
            
