- Timestamp:
- Feb 11, 2011, 4:29:48 PM (15 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/nightly_science.pl (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/ippScripts/scripts/nightly_science.pl
r30017 r30586 44 44 my ( $date, $datetime, $camera, $dbname, $logfile, $verbose, $manual); 45 45 my ( $help, $isburning, $force_stack_count, $force_diff_count, $test_mode, $this_target_only, $this_filter_only, $this_mode_only, $check_mode); 46 my ( $registration_status, $burntool_status, $observing_status );46 my ( $registration_status, $burntool_status, $observing_status, $old_date); 47 47 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips); 48 48 my ( $check_stacks, $queue_stacks, $check_sweetspot, $queue_sweetspot, $check_diffs, $queue_diffs, $clean_old); … … 66 66 'registraion_status' => \$registration_status, 67 67 'burntool_status' => \$burntool_status, 68 'old_date=s' => \$old_date, 68 69 'check_stacks' => \$check_stacks, 69 70 'queue_stacks' => \$queue_stacks, … … 134 135 unless ($success) { 135 136 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 136 &my_die("Unable to perform ppConfigDump: $error_code", $date, $PS_EXIT_SYS_ERROR);137 &my_die("Unable to perform ppConfigDump: $error_code", 0, 0, $date, $PS_EXIT_SYS_ERROR); 137 138 } 138 139 … … 278 279 279 280 $metadata_out{nsObservingState} = &get_observing_state($date); 281 $metadata_out{nsRegistrationState} = &get_registration_state($date); 280 282 # 281 283 # Mode selection … … 396 398 exit(0); 397 399 } 398 exit(10); 400 399 401 if (defined($check_confirm_stacks) || defined($test_mode)) { 400 402 $metadata_out{nsStackState} = 'CONFIRM_STACKING'; … … 409 411 exit(0); 410 412 } 411 413 exit(10); 412 414 if (defined($check_sweetspot) || defined($test_mode) || defined($check_mode)) { 413 415 $metadata_out{nsSSState} = 'CHECKSWEETSPOT'; … … 1097 1099 my $pretend = shift; 1098 1100 1101 my $Npotential = 0; 1102 my $Nqueued = 0; 1103 my $is_processing = 0; 1104 my $is_registering; 1105 if ($metadata_out{nsRegistrationState} eq 'REGISTERED') { 1106 $is_registering = 0; 1107 } 1108 else { 1109 $is_registering = 1; 1110 } 1111 1099 1112 foreach my $target (sort (keys %science_config)) { 1100 1113 if ($science_config{$target}{STACKABLE} == 1) { … … 1105 1118 print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 1106 1119 } 1120 $is_processing = 1; 1107 1121 $metadata_out{nsStackState} = 'FORCETOWARP'; 1108 1122 next; … … 1120 1134 next; 1121 1135 } 1136 $Npotential++; 1122 1137 if ($Nalready != 0) { 1138 $Nqueued++; 1123 1139 if ($debug == 1) { 1124 1140 print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; … … 1137 1153 } 1138 1154 stack_queue($date,$target,$filter); 1155 $Nqueued ++; 1139 1156 } 1140 1157 if (defined($pretend)) { … … 1152 1169 } 1153 1170 } 1171 $metadata_out{nsStackPotential} = $Npotential; 1172 $metadata_out{nsStackQueued} = $Nqueued; 1173 if (($Npotential == $Nqueued)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)&&($is_registering == 0)) { 1174 $metadata_out{nsStackState} = 'FINISHED_STACKS'; 1175 } 1154 1176 } 1155 1177 … … 1231 1253 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target); 1232 1254 1233 my $sth = "SELECT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_1 AND warp2 = $warp_id_2"; 1255 my $count = 0; 1256 1257 my $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_1 AND warp2 = $warp_id_2"; 1234 1258 my $data_ref = $db->selectall_arrayref( $sth ); 1235 1236 return($#{ $data_ref } + 1); 1259 $count += $#{ $data_ref } + 1; 1260 1261 $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_2 AND warp2 = $warp_id_1"; 1262 $data_ref = $db->selectall_arrayref( $sth ); 1263 $count += $#{ $data_ref } + 1; 1264 1265 return($count); 1237 1266 } 1238 1267 … … 1272 1301 my $pretend = shift; 1273 1302 1303 my $Npotential = 0; 1304 my $Nnoexp = 0; 1305 my $is_processing = 0; 1306 my $is_registering; 1307 if ($metadata_out{nsRegistrationState} eq 'REGISTERED') { 1308 $is_registering = 0; 1309 } 1310 else { 1311 $is_registering = 1; 1312 } 1313 1274 1314 foreach my $target (sort (keys %science_config)) { 1275 1315 if ($science_config{$target}{DIFFABLE} == 1) { 1276 1316 foreach my $filter (@filter_list) { 1317 $Npotential ++; 1277 1318 my ($NprocChips,$NprocWarps) = pre_diff_queue($date,$observing_state,$target,$filter); 1278 1319 if ((!defined($force_diff_count))&&($NprocChips != $NprocWarps)) { … … 1280 1321 print STDERR "execute_diffs: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 1281 1322 } 1282 $metadata_out{nsDiffState} = 'FORCETOWARP'; 1283 next; 1284 } 1323 $is_processing = 1; 1324 } 1285 1325 if ($NprocChips == 0) { 1326 $Nnoexp ++; 1286 1327 if ($debug == 1) { 1287 1328 print STDERR "execute_diffs: Target $target in filter $filter on $date has no exposures.\n"; … … 1311 1352 } 1312 1353 } 1354 if ($debug == 1) { 1355 print "$metadata_out{nsObservingState} $metadata_out{nsDiffPotential} $metadata_out{nsDiffQueued} $is_processing $is_registering\n"; 1356 } 1357 1358 if ($metadata_out{nsObservingState} eq 'END_OF_NIGHT') { 1359 if ($is_processing == 1) { 1360 $metadata_out{nsDiffState} = 'DIFFING'; 1361 } 1362 elsif ($is_registering == 0) { 1363 if ($Npotential == $Nnoexp) { 1364 $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1365 } 1366 elsif ($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued}) { 1367 $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1368 } 1369 } 1370 else { 1371 $metadata_out{nsDiffState} = 'DIFFING'; 1372 } 1373 } 1374 else { 1375 $metadata_out{nsDiffState} = 'DIFFING'; 1376 } 1377 1378 # if (($Npotential == $Nnoexp)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)) { 1379 # $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1380 # } 1381 1382 # if ($is_processing == 1) { 1383 # $metadata_out{nsDiffState} = 'DIFFING'; 1384 # } 1313 1385 } 1314 1386 … … 1326 1398 1327 1399 my $object_ref = $db->selectall_arrayref( $obj_sth ); 1400 1401 my $Npotential = 0; 1402 my $Nqueued = 0; 1328 1403 1329 1404 foreach my $object_row (@{ $object_ref }) { 1330 1405 my $this_object = shift @{ $object_row }; 1331 my $input_sth = "select exp_id,warp_id,dateobsfrom warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) ";1332 $input_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";1333 $input_sth .= " ORDER BY dateobs ";1406 # my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) "; 1407 # $input_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1408 # $input_sth .= " ORDER BY dateobs "; 1334 1409 1410 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state FROM "; 1411 $input_sth .= " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) "; 1412 $input_sth .= " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1413 $input_sth .= " ORDER BY dateobs "; 1414 1335 1415 my $warps = $db->selectall_arrayref( $input_sth ); 1416 1417 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1418 my %comment_hash = (); 1419 foreach my $this_warp (@{ $warps }) { 1420 my $this_comment = ${ $this_warp }[3]; 1421 my $this_exp_id = ${ $this_warp }[0]; 1422 $comment_hash{$this_comment} = $this_exp_id; 1423 } 1336 1424 1337 1425 if (($#{ $warps } + 1) % 2 != 0) { 1338 print STDERR "diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps }\n"; 1339 next; 1426 print STDERR "diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } "; 1427 if ($#{ $warps} + 1 == 1) { 1428 print STDERR ": I can do no diffs with only one exposure.\n"; 1429 next; 1430 } 1431 else { 1432 print STDERR ": I should declare an exposure to be faulty.\n"; 1433 my @keep_warps = (); 1434 # print "@{ $warps }\n"; 1435 foreach my $this_warp (@{ $warps }) { 1436 my $this_comment = ${ $this_warp }[3]; 1437 my $this_exp_id = ${ $this_warp }[0]; 1438 if ($comment_hash{$this_comment} == $this_exp_id) { 1439 push @keep_warps, $this_warp; 1440 } 1441 else { 1442 print STDERR "diff_queue: excluding $this_exp_id for $this_object\n"; 1443 } 1444 } 1445 @{ $warps } = @keep_warps; 1446 # print "@{ $warps }\n"; 1447 } 1340 1448 } 1341 1449 1342 1450 while ($#{ $warps } > -1) { 1343 1451 my $input_warp = shift @{ $warps }; 1452 my $input_exp_id = ${ $input_warp }[0]; 1453 my $input_comment = ${ $input_warp }[3]; 1454 1455 1344 1456 my $template_warp = shift @{ $warps }; 1345 my $input_exp_id = ${ $input_warp }[0]; 1457 1346 1458 my $template_exp_id = ${ $template_warp }[0]; 1347 1459 1348 1460 my $input_warp_id = ${ $input_warp }[1]; 1349 1461 my $template_warp_id = ${ $template_warp }[1]; 1462 1463 my $input_warp_state = ${ $input_warp }[4]; 1464 my $template_warp_state = ${ $template_warp }[4]; 1350 1465 1466 $Npotential++; 1467 1468 unless (defined($input_warp_id) && defined($template_warp_id) && 1469 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) { 1470 print STDERR "Diff for this $date $target $input_exp_id $template_exp_id not fully processed\n"; 1471 next; 1472 } 1473 1351 1474 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1352 print STDERR "Diffs already queued for this $date $target $input_exp_id $template_exp_id\n"; 1475 $Nqueued++; 1476 print STDERR "Diffs already queued for this $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment\n"; 1353 1477 next; 1354 1478 } … … 1366 1490 $cmd .= ' -pretend '; 1367 1491 print STDERR "diff_queue: $cmd\n"; 1492 print STDERR " $input_warp_id $template_warp_id\n"; 1368 1493 } 1369 1494 … … 1375 1500 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1376 1501 } 1377 } 1378 } 1379 } 1502 $Nqueued++; 1503 } 1504 } 1505 } 1506 $metadata_out{nsDiffPotential} += $Npotential; 1507 $metadata_out{nsDiffQueued} += $Nqueued; 1508 # if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) { 1509 # $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1510 # } 1511 1380 1512 } 1381 1513 … … 1493 1625 } 1494 1626 } 1495 1627 # print "$datetime $eon_dt\n"; 1496 1628 if (DateTime->compare($datetime,$eon_dt) < 1) { 1497 1629 return("OBSERVING"); … … 1501 1633 } 1502 1634 } 1635 1636 # This basically does the end of night check, but does it "the hard way," to prevent the time from fooling us. 1637 sub get_registration_state { 1638 my $date = shift; 1639 1640 foreach my $eon (keys %eon_config) { 1641 my $command = "$regtool -processedexp -simple "; 1642 $command .= " -dbname $dbname "; 1643 $command .= " -dateobs_begin ${date}T00:00:00 -dateobs_end ${date}T23:59:59 "; 1644 $command .= " -object $eon_config{$eon}{OBJECT} " if defined($eon_config{$eon}{OBJECT}); 1645 $command .= " -obs_mode $eon_config{$eon}{OBSMODE} " if defined($eon_config{$eon}{OBSMODE}); 1646 $command .= " -exp_type $eon_config{$eon}{EXPTYPE} " if defined($eon_config{$eon}{EXPTYPE}); 1647 $command .= " -comment $eon_config{$eon}{COMMENT} " if defined($eon_config{$eon}{COMMENT}); 1648 1649 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1650 run ( command => $command, verbose => $verbose ); 1651 unless ($success) { 1652 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1653 &my_die("Unable to perform regtool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1654 } 1655 my @eon_exposures = split /\n/, (join '', @$stdout_buf); 1656 if ($#eon_exposures >= 0) { 1657 return("REGISTERED"); 1658 } 1659 } 1660 return("NOT_REGISTERED"); 1661 } 1662 1663 1503 1664 1504 1665 sub get_tool_parameters { … … 1620 1781 my $stage = shift; # stage name 1621 1782 my $stage_id = shift; # identifier 1783 my $date = shift; 1622 1784 my $exit_code = shift; # Exit code 1623 # outputImage and path_base are globals1624 1785 1625 1786 carp($msg);
Note:
See TracChangeset
for help on using the changeset viewer.
