Changeset 26334 for trunk/tools/make_burntool_pcontrol.pl
- Timestamp:
- Dec 3, 2009, 5:53:09 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/make_burntool_pcontrol.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/make_burntool_pcontrol.pl
r25952 r26334 35 35 ) or die "Unable to connect to database $DBI::errstr\n"; 36 36 37 # Determine what the value of "BURNTOOL.STATE.GOOD" currently is: 38 $burntoolStateGood = 999; 39 open(LAZY,"ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n"; 40 while(<LAZY>) { 41 chomp; 42 if ($_ =~ /BURNTOOL.STATE.GOOD/) { 43 @line = split /\s+/; 44 $burntoolStateGood = $line[2]; 45 } 46 } 47 close(LAZY); 48 #unless( $burntoolStateGood == 999) { 49 # print STDERR "GOOD == $burntoolStateGood\n"; 50 #} 51 52 37 53 # List of which obs_modes are "science" and which are something else. 38 54 %science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1, … … 41 57 $science{Unknown} = 1; 42 58 } 43 # Zero the arrays. 59 60 # Zero the arrays and counters 44 61 @dates_min = (); 45 62 @dates_max = (); 46 63 $N_burntooled_images = 0; 64 $N_total_images = 0; 65 $N_ranges = 0; 47 66 # Parse SQL query and fill any valid dates to the arrays 48 67 if (exists($opt{Q})) { … … 66 85 } 67 86 } 87 68 88 # Read a single date, and calculate the end and insert 69 89 elsif (exists($opt{d})) { … … 73 93 push @dates_max, sprintf("%04d-%02d-%02d",$year,$mon,$date); 74 94 } 95 75 96 # Just shift the supplied values into the arrays. 76 97 else { … … 92 113 print "##query: SELECT dateobs FROM rawExp WHERE $opt{Q}\n"; 93 114 } 94 #for ($d = 0; $d <= $#dates_min; $d++) { 115 95 116 while ($#dates_min > -1) { 96 117 $date_min = shift(@dates_min); … … 138 159 $science{$obs_mode} = 0; 139 160 } 140 #%science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1,141 # 'ENGINEERING' => 0, 'NULL' => 0, 'Unknown' => 0, ' ' => 0);142 # I don't like this bit, but we need to work around the bad values of obs_mode that periodically crop up.143 # This isn't the most robust solution (which would of course be "having trustworthy obs_mode values"), but144 # it'll probably work for now.145 161 if ((($science{$obs_mode} == 1)&&($comment !~ /Daytime/))|| 146 162 (($science{$obs_mode} == 0)&&( 147 163 ($comment =~ /MD/)||($comment =~ /ThreePi/)|| 148 164 ($comment =~ /STS/)||($comment =~ /M31/)|| 149 ($comment =~ /CAL/)||($comment =~ /SS/)||($comment =~ /SVS/)|| ($comment =~ /Sweetspot/)|| ($comment =~ /cal/)|| ($comment =~ /virgo/)|| ($comment =~ /Virgo/)|| ($comment =~ /kepler/)|| 165 ($comment =~ /CAL/i)||($comment =~ /SS/)||($comment =~ /SVS/)|| 166 ($comment =~ /Sweetspot/)||($comment =~ /virgo/i)||($comment =~ /kepler/)|| 150 167 ($comment =~ /sdss/)))) 151 168 { … … 174 191 next; 175 192 } 193 176 194 # Scan again and count how many exposures are between windows 177 195 foreach $row_ref (@{ $data_ref }) { … … 212 230 } 213 231 } 214 # print ">>>$i $start_s[$i] $skips[$i]\n"; 215 } 216 # print ">>> $dateobs\n"; 232 } 217 233 } 218 234 … … 227 243 } 228 244 # Print out the end points in the format burntool wants. 245 229 246 for ($i = 0; $i <= $#start_s; $i++) { 230 247 @start_t = localtime($start_s[$i]); 231 248 @end_t = localtime($end_s[$i]); 232 printf(" burntool %04d-%02d-%02dT%02d:%02d:%02d %04d-%02d-%02dT%02d:%02d:%02d\n", 233 $start_t[5] + 1900,$start_t[4] + 1,$start_t[3], 234 $start_t[2],$start_t[1],$start_t[0], 235 $end_t[5] + 1900,$end_t[4] + 1,$end_t[3], 236 $end_t[2],$end_t[1],$end_t[0]); 249 250 my $date_min = sprintf("%04d-%02d-%02dT%02d:%02d:%02d", 251 $start_t[5] + 1900,$start_t[4] + 1,$start_t[3], 252 $start_t[2],$start_t[1],$start_t[0]); 253 my $date_max = sprintf("%04d-%02d-%02dT%02d:%02d:%02d", 254 $end_t[5] + 1900,$end_t[4] + 1,$end_t[3], 255 $end_t[2],$end_t[1],$end_t[0]); 256 257 my $total_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max'"; 258 my $im_ref = $db->selectall_arrayref( $total_images_sth ); 259 $N_total_images += ${ $im_ref }[0][0]; 260 261 my $burntooled_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max' AND abs(burntool_state) = $burntoolStateGood"; 262 $im_ref = $db->selectall_arrayref( $burntooled_images_sth ); 263 $N_burntooled_images += ${ $im_ref }[0][0]; 264 265 266 printf(" burntool %s %s\n",$date_min,$date_max); 237 267 } 238 268 print "\n"; 239 } 240 241 unless(exists($opt{b})) { 269 $N_ranges += $#start_s; 270 } 271 272 if ($N_ranges == 0) { 273 print_short_epilogue(); 274 } 275 276 unless(exists($opt{b}) || ($N_ranges == 0)) { 242 277 print_epilogue(); 243 278 } … … 275 310 return(0); 276 311 } 312 sub print_short_epilogue { 313 print << 'END_SHORT_EPILOGUE'; 314 315 echo "There were no science exposures to process. Sorry, try again tomorrow." 316 317 end 318 END_SHORT_EPILOGUE 319 } 277 320 278 321 sub print_epilogue { 322 print " echo 'There were $N_total_images total images, of which $N_burntooled_images were already burntooled.'\n"; 323 print "### BTSTAT $N_total_images $N_burntooled_images\n"; 279 324 print << 'END_EPILOGUE'; 280 325
Note:
See TracChangeset
for help on using the changeset viewer.
