Changeset 39828
- Timestamp:
- Nov 29, 2016, 11:55:33 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
ippScripts/scripts/nightly_science.pl (modified) (10 diffs, 1 prop)
-
ippconfig/recipes/nightly_science.config (modified) (4 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/nightly_science.pl
-
Property svn:mergeinfo
set to
/branches/czw_branch/20160809/ippScripts/scripts/nightly_science.pl merged eligible
r38247 r39828 47 47 # Grab options 48 48 my ( $date, $datetime, $camera, $dbname, $logfile, $verbose, $manual); 49 my ( $help, $isburning, $force_stack_count, $force_diff_count, $ test_mode, $this_target_only, $this_filter_only, $this_mode_only, $check_mode);49 my ( $help, $isburning, $force_stack_count, $force_diff_count, $force_registration, $test_mode, $this_target_only, $this_filter_only, $this_mode_only, $check_mode); 50 50 my ( $registration_status, $burntool_status, $observing_status, $old_date); 51 51 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips); … … 65 65 'force_stack_count' => \$force_stack_count, 66 66 'force_diff_count' => \$force_diff_count, 67 'force_registration' => \$force_registration, 67 68 'this_target_only=s' => \$this_target_only, 68 69 'this_filter_only=s' => \$this_filter_only, … … 285 286 $metadata_out{nsObservingState} = &get_observing_state($date); 286 287 $metadata_out{nsRegistrationState} = &get_registration_state($date); 288 if ($force_registration) { 289 $metadata_out{nsRegistrationState} = 'REGISTERED'; 290 } 287 291 # 288 292 # Mode selection … … 1435 1439 if ($metadata_out{nsDiffState} eq 'FINISHED_DIFFS') { 1436 1440 foreach my $target (sort (keys %science_config)) { 1437 if ($science_config{$target}{DIFFABLE} == 1) { 1441 # CZW: We should only arrive at this point once, so we can construct a diff report and mail it now. 1442 if ((defined($science_config{$target}{DESPERATE_DIFFS})) && ($science_config{$target}{DESPERATE_DIFFS} == 1)) { 1438 1443 foreach my $filter (@filter_list) { 1439 multi_date_diff_queue($date,$target,$filter,$pretend); 1440 } 1441 } 1442 if ((defined($science_config{$target}{OFFNIGHT_DIFFS})) && ($science_config{$target}{OFFNIGHT_DIFFS} == 1)) { 1443 foreach my $filter (@filter_list) { 1444 offnight_diff_queue($date,$target,$filter,$pretend); 1445 } 1446 } 1444 # This one needs to return a state to see if we need to wait on stacking before checking again. 1445 $metadata_out{nsDiffState} = desperate_diff_queue($date,$target,$filter,$pretend); 1446 } 1447 } 1448 1447 1449 if ((defined($science_config{$target}{SELF_WSDIFFS})) && ($science_config{$target}{SELF_WSDIFFS} == 1)) { 1448 1450 foreach my $filter (@filter_list) { … … 1498 1500 my $this_comment = ${ $this_warp }[3]; 1499 1501 my $this_exp_id = ${ $this_warp }[0]; 1500 $comment_hash{$this_comment} = $this_exp_id; 1501 } 1502 1502 my $this_quality = ${ $this_warp }[5]; 1503 if ($this_quality != 0) { 1504 print STDERR "diff_queue: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality\n"; 1505 } 1506 else { 1507 $comment_hash{$this_comment} = $this_exp_id; 1508 } 1509 } 1510 # Exclude any warps that are not stored in the comment_hash. 1511 my @keep_warps = (); 1512 foreach my $this_warp (@{ $warps }) { 1513 my $this_comment = ${ $this_warp }[3]; 1514 my $this_exp_id = ${ $this_warp }[0]; 1515 if ((exists($comment_hash{$this_comment}))&& 1516 ($comment_hash{$this_comment} == $this_exp_id)) { 1517 push @keep_warps, $this_warp; 1518 } 1519 else { 1520 print STDERR "diff_queue: excluding $this_exp_id for $this_object due to not being an accepted comment string $this_comment\n"; 1521 } 1522 } 1523 @{ $warps } = @keep_warps; 1524 1525 # Exclude the last entry if we do not have an even number of warps. 1503 1526 if (($#{ $warps } + 1) % 2 != 0) { 1504 1527 print STDERR "diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } "; … … 1508 1531 } 1509 1532 else { 1510 print STDERR ": I should declare an exposure to be qualityy.\n"; 1511 my @keep_warps = (); 1512 # print "@{ $warps }\n"; 1513 foreach my $this_warp (@{ $warps }) { 1514 my $this_comment = ${ $this_warp }[3]; 1515 my $this_exp_id = ${ $this_warp }[0]; 1516 if ($comment_hash{$this_comment} == $this_exp_id) { 1517 push @keep_warps, $this_warp; 1518 } 1519 else { 1520 print STDERR "diff_queue: excluding $this_exp_id for $this_object\n"; 1521 } 1522 } 1523 @{ $warps } = @keep_warps; 1524 # print "@{ $warps }\n"; 1533 my $rejected_warp = pop @{ $warps }; 1534 my $rejected_exp_id = ${ $rejected_warp }[0]; 1535 print STDERR ": Rejecting ${rejected_exp_id} to force visit count.\n"; 1525 1536 } 1526 1537 } 1527 1538 1528 1539 while ($#{ $warps } > -1) { 1540 # The array is sorted in pairs of input/template. 1529 1541 my $input_warp = shift @{ $warps }; 1542 my $template_warp = shift @{ $warps }; 1543 1530 1544 my $input_exp_id = ${ $input_warp }[0]; 1531 1545 my $input_comment = ${ $input_warp }[3]; 1532 1546 1533 1534 my $template_warp = shift @{ $warps };1535 1536 1547 my $template_exp_id = ${ $template_warp }[0]; 1537 1548 my $template_comment = ${ $template_warp }[3]; 1549 1538 1550 my $input_warp_id = ${ $input_warp }[1]; 1539 1551 my $template_warp_id = ${ $template_warp }[1]; … … 1551 1563 print STDERR "Diff for this $date $target $input_exp_id $template_exp_id not fully processed ($input_warp_state $template_warp_state) ($input_warp_camQuality $template_warp_camQuality)\n"; 1552 1564 if (($input_warp_camQuality == 4007)||($template_warp_camQuality == 4007)) { 1565 # This should now never be reached. 1566 # CZW: Trigger backup plan here? Or simply set up framework? 1553 1567 print STDERR " ...but this is due to a camera stage astrometry quality\n"; 1554 1568 $Npotential--; … … 1559 1573 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1560 1574 $Nqueued++; 1561 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";1575 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 $template_comment\n"; 1562 1576 next; 1577 } 1578 else { 1579 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"; 1563 1580 } 1564 1581 … … 1601 1618 } 1602 1619 1620 1621 sub desperate_diff_queue { 1622 my $date = shift; 1623 my $target = shift; 1624 my $filter = shift; 1625 my $pretend = shift; 1626 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target); 1627 1628 my $db = init_gpc_db(); 1629 1630 my $obj_sth = "select DISTINCT rawExp.object from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) "; 1631 $obj_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' ORDER BY rawExp.object"; 1632 1633 my $object_ref = $db->selectall_arrayref( $obj_sth ); 1634 1635 my $Npotential = 0; 1636 my $Nqueued = 0; 1637 1638 foreach my $object_row (@{ $object_ref }) { 1639 my $this_object = shift @{ $object_row }; 1640 1641 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality FROM "; 1642 $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) "; 1643 $input_sth .= " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1644 $input_sth .= " ORDER BY dateobs "; 1645 1646 my $warps = $db->selectall_arrayref( $input_sth ); 1647 1648 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1649 my %comment_hash = (); 1650 foreach my $this_warp (@{ $warps }) { 1651 my $this_comment = ${ $this_warp }[3]; 1652 my $this_exp_id = ${ $this_warp }[0]; 1653 my $this_quality = ${ $this_warp }[5]; 1654 if ($this_quality != 0) { 1655 print STDERR "desp_diff_queue: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality\n"; 1656 } 1657 else { 1658 $comment_hash{$this_comment} = $this_exp_id; 1659 } 1660 } 1661 # Exclude any warps that are not stored in the comment_hash. 1662 my @keep_warps = (); 1663 foreach my $this_warp (@{ $warps }) { 1664 my $this_comment = ${ $this_warp }[3]; 1665 my $this_exp_id = ${ $this_warp }[0]; 1666 if ((exists($comment_hash{$this_comment}))&& 1667 ($comment_hash{$this_comment} == $this_exp_id)) { 1668 push @keep_warps, $this_warp; 1669 } 1670 else { 1671 print STDERR "desp_diff_queue: excluding $this_exp_id for $this_object due to not being an accepted comment string $this_comment\n"; 1672 } 1673 } 1674 # We are attempting to do the missing diffs, so reverse the list of retained warps. 1675 # Good objects with all visits will be skipped due to the duplicate check. 1676 # Bad objects will have the earliest visit rejected, and the visits repaired in a way that will produce all desired pairs. 1677 @{ $warps } = reverse @keep_warps; 1678 1679 # Exclude the last entry if we do not have an even number of warps. 1680 if (($#{ $warps } + 1) % 2 != 0) { 1681 print STDERR "desp_diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } "; 1682 if ($#{ $warps} + 1 == 1) { 1683 print STDERR ": I can do no diffs with only one exposure.\n"; 1684 next; 1685 } 1686 else { 1687 my $rejected_warp = pop @{ $warps }; 1688 my $rejected_exp_id = ${ $rejected_warp }[0]; 1689 print STDERR ": Rejecting ${rejected_exp_id} to force visit count.\n"; 1690 } 1691 } 1692 1693 while ($#{ $warps } > -1) { 1694 # In this mode, the array is sorted in pairs of template/input, counter to the standard queue. 1695 my $template_warp = shift @{ $warps }; 1696 my $input_warp = shift @{ $warps }; 1697 1698 my $input_exp_id = ${ $input_warp }[0]; 1699 my $input_comment = ${ $input_warp }[3]; 1700 1701 my $template_exp_id = ${ $template_warp }[0]; 1702 my $template_comment = ${ $template_warp }[3]; 1703 1704 my $input_warp_id = ${ $input_warp }[1]; 1705 my $template_warp_id = ${ $template_warp }[1]; 1706 1707 my $input_warp_state = ${ $input_warp }[4]; 1708 my $template_warp_state = ${ $template_warp }[4]; 1709 1710 my $input_warp_camQuality = ${ $input_warp }[5]; 1711 my $template_warp_camQuality = ${ $template_warp }[5]; 1712 1713 $Npotential++; 1714 1715 unless (defined($input_warp_id) && defined($template_warp_id) && 1716 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) { 1717 print STDERR "Diff for this $date $target $input_exp_id $template_exp_id not fully processed ($input_warp_state $template_warp_state) ($input_warp_camQuality $template_warp_camQuality)\n"; 1718 if (($input_warp_camQuality == 4007)||($template_warp_camQuality == 4007)) { 1719 # This should now never be reached. 1720 # CZW: Trigger backup plan here? Or simply set up framework? 1721 print STDERR " ...but this is due to a camera stage astrometry quality\n"; 1722 $Npotential--; 1723 } 1724 next; 1725 } 1726 1727 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1728 $Nqueued++; 1729 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 $template_comment\n"; 1730 next; 1731 } 1732 else { 1733 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"; 1734 } 1735 1736 my $cmd = "$difftool -dbname $dbname -definewarpwarp "; 1737 $cmd .= "-input_label $label -template_label $label -good_frac 0.1 "; 1738 $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting. 1739 $cmd .= "-rerun "; # Needed because we may have some diffs that already use some of the exposures 1740 $cmd .= "-set_workdir $workdir -set_dist_group $dist_group -set_data_group $data_group "; 1741 $cmd .= " -simple -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id "; 1742 # $cmd .= " -pretend "; 1743 if (defined($reduction)) { 1744 $cmd .= " -set_reduction $reduction "; 1745 } 1746 1747 if (defined($pretend)) { 1748 $cmd .= ' -pretend '; 1749 } 1750 if ($debug == 1) { 1751 $cmd .= ' -pretend '; 1752 print STDERR "desp_diff_queue: $cmd\n"; 1753 print STDERR " $input_warp_id $template_warp_id\n"; 1754 } 1755 1756 if (($debug == 0)&&(!defined($pretend))) { 1757 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1758 run ( command => $cmd, verbose => $verbose ); 1759 unless ($success) { 1760 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1761 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1762 } 1763 $Nqueued++; 1764 } 1765 } 1766 } 1767 $metadata_out{nsDiffPotential} += $Npotential; 1768 $metadata_out{nsDiffQueued} += $Nqueued; 1769 # if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) { 1770 # $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1771 # } 1772 1773 } 1774 1775 1603 1776 sub multi_date_diff_queue { 1604 1777 my $date = shift; … … 1626 1799 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state FROM "; 1627 1800 $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) "; 1628 $input_sth .= " WHERE warpRun.label = '$label' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";1801 $input_sth .= " WHERE warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1629 1802 $input_sth .= " ORDER BY dateobs "; 1630 1803 -
Property svn:mergeinfo
set to
-
trunk/ippconfig/recipes/nightly_science.config
-
Property svn:mergeinfo
set to
/branches/czw_branch/20160809/ippconfig/recipes/nightly_science.config merged eligible
r39759 r39828 324 324 REDUCTION STR SWEETSPOT 325 325 ADDITIONAL_STACK_LABEL STR ecliptic.rp 326 DESPERATE_DIFFS BOOL TRUE 326 327 # REDUCTION STR SSTF_4SIG 327 328 END … … 363 364 DIFF S16 5 364 365 END 365 TARGETS METADATA366 TARGETS METADATA 366 367 NAME STR NCU 367 DISTRIBUTION STR SweetSpot 368 DISTRIBUTION STR SweetSpot 368 369 TESS STR RINGS.V3 369 370 OBSMODE STR NCU … … 372 373 OFFNIGHT_DIFFS BOOL FALSE 373 374 REDUCTION STR SWEETSPOT 375 DIST S16 300 376 CHIP S16 300 374 377 WARP S16 300 375 378 DIFF S16 300 … … 402 405 DIFFABLE BOOL TRUE 403 406 OFFNIGHT_DIFFS BOOL FALSE 407 DESPERATE_DIFFS BOOL TRUE 404 408 # CHIP S16 7 405 409 # DIFF S16 7 -
Property svn:mergeinfo
set to
Note:
See TracChangeset
for help on using the changeset viewer.
