Changeset 27838 for branches/tap_branches/tools/make_burntool_pcontrol.pl
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tools/make_burntool_pcontrol.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/tools/make_burntool_pcontrol.pl
r25562 r27838 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, 39 'ENGINEERING' => 0, 'NULL' => 0, 'Unknown' => 0, ' ' => 0);55 'ENGINEERING' => 0, 'NULL' => 0, 'Unknown' => 1, ' ' => 0); 40 56 if (exists($opt{P})) { 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); … … 123 144 ($date,$time) = split / /, $dateobs; 124 145 ($year,$month,$day) = split /-/, $date; 125 ($hour,$minute,$second) = split /:/, $time; 146 ($hour,$minute,$second) = split /:/, $time; #/ I hope emacs fixes this bug soon. ; 126 147 127 148 $dt = DateTime->new( year => $year, month => $month, day => $day, … … 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 ($comment =~ /MD/)||($comment =~ /ThreePi/)|| 148 ($comment =~ /STS/)||($comment =~ /M31/)|| 149 ($comment =~ /CAL/)||($comment =~ /SS/)))) 163 ($comment =~ /MD/)||($comment =~ /ThreePi/)|| 164 ($comment =~ /STS/i)||($comment =~ /M31/)|| 165 ($comment =~ /CAL/i)||($comment =~ /SS/)||($comment =~ /SVS/)|| 166 ($comment =~ /Stellar Transit/)|| 167 ($comment =~ /Sweetspot/)||($comment =~ /virgo/i)||($comment =~ /kepler/)|| 168 ($comment =~ /sdss/)))) 150 169 { 151 170 if ($start_s[-1] == 0) { … … 173 192 next; 174 193 } 194 175 195 # Scan again and count how many exposures are between windows 176 196 foreach $row_ref (@{ $data_ref }) { … … 211 231 } 212 232 } 213 # print ">>>$i $start_s[$i] $skips[$i]\n"; 214 } 215 # print ">>> $dateobs\n"; 233 } 216 234 } 217 235 … … 226 244 } 227 245 # Print out the end points in the format burntool wants. 246 228 247 for ($i = 0; $i <= $#start_s; $i++) { 229 248 @start_t = localtime($start_s[$i]); 230 249 @end_t = localtime($end_s[$i]); 231 printf(" burntool %04d-%02d-%02dT%02d:%02d:%02d %04d-%02d-%02dT%02d:%02d:%02d\n", 232 $start_t[5] + 1900,$start_t[4] + 1,$start_t[3], 233 $start_t[2],$start_t[1],$start_t[0], 234 $end_t[5] + 1900,$end_t[4] + 1,$end_t[3], 235 $end_t[2],$end_t[1],$end_t[0]); 236 } 237 print "\n"; 238 } 239 240 unless(exists($opt{b})) { 250 251 my $date_min = sprintf("%04d-%02d-%02dT%02d:%02d:%02d", 252 $start_t[5] + 1900,$start_t[4] + 1,$start_t[3], 253 $start_t[2],$start_t[1],$start_t[0]); 254 my $date_max = sprintf("%04d-%02d-%02dT%02d:%02d:%02d", 255 $end_t[5] + 1900,$end_t[4] + 1,$end_t[3], 256 $end_t[2],$end_t[1],$end_t[0]); 257 258 my $total_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max'"; 259 my $im_ref = $db->selectall_arrayref( $total_images_sth ); 260 $N_total_images += ${ $im_ref }[0][0]; 261 262 my $burntooled_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max' AND abs(burntool_state) = $burntoolStateGood"; 263 $im_ref = $db->selectall_arrayref( $burntooled_images_sth ); 264 $N_burntooled_images += ${ $im_ref }[0][0]; 265 266 267 printf(" burntool %s %s\n",$date_min,$date_max); 268 } 269 unless(exists($opt{d})) { 270 print "\n"; 271 } 272 $N_ranges += ($#start_s + 1); 273 } 274 275 if ($N_ranges == 0) { 276 print_short_epilogue(); 277 } 278 279 unless(exists($opt{b}) || ($N_ranges == 0)) { 241 280 print_epilogue(); 242 281 } … … 274 313 return(0); 275 314 } 315 sub print_short_epilogue { 316 if (exists($opt{b})) { 317 print STDERR "There were no science exposures to process. Sorry, try again tomorrow.\n"; 318 return(); 319 } 320 print << 'END_SHORT_EPILOGUE'; 321 322 echo "There were no science exposures to process. Sorry, try again tomorrow." 323 324 end 325 END_SHORT_EPILOGUE 326 } 276 327 277 328 sub print_epilogue { 329 print " echo 'There were $N_total_images total images, of which $N_burntooled_images were already burntooled.'\n"; 330 print "### BTSTAT $N_total_images $N_burntooled_images\n"; 278 331 print << 'END_EPILOGUE'; 279 332
Note:
See TracChangeset
for help on using the changeset viewer.
