Changeset 41461
- Timestamp:
- Jan 4, 2021, 2:04:34 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/nightly_science.pl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/nightly_science.pl
r41226 r41461 1688 1688 print STDERR "desp_diff_singles: No desperate diffs will be attempted, since the number of exps at the summit and in rawExp do not match ($nsummitexps $nrawexps), or the timestamps are off ($summittimediff)\n"; 1689 1689 } 1690 return; 1691 } 1690 } 1691 else { 1692 foreach my $object_row (@{ $object_ref }) { 1693 my $this_object = shift @{ $object_row }; 1694 my $this_chunk = shift @{ $object_row }; 1695 1696 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,substr(comment, 1, position(' ' in comment)) FROM "; 1697 $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) "; 1698 $input_sth .= " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1699 $input_sth .= " AND substr(rawExp.comment, 1, position(' ' in rawExp.comment)) = '$this_chunk' ORDER BY dateobs "; 1700 1701 my $warps = $db->selectall_arrayref( $input_sth ); 1702 1703 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1704 my %comment_hash = (); 1705 foreach my $this_warp (@{ $warps }) { 1706 my $this_comment = ${ $this_warp }[3]; 1707 my $this_exp_id = ${ $this_warp }[0]; 1708 my $this_quality = ${ $this_warp }[5]; 1709 if ($this_quality != 0) { 1710 print STDERR "desp_diff_singles: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality\n"; 1711 } 1712 else { 1713 $comment_hash{$this_comment} = $this_exp_id; 1714 } 1715 } 1716 # Exclude any warps that are not stored in the comment_hash. 1717 my @keep_warps = (); 1718 foreach my $this_warp (@{ $warps }) { 1719 my $this_comment = ${ $this_warp }[3]; 1720 my $this_exp_id = ${ $this_warp }[0]; 1721 if ((exists($comment_hash{$this_comment}))&& 1722 ($comment_hash{$this_comment} == $this_exp_id)) { 1723 push @keep_warps, $this_warp; 1724 $this_date = ${ $this_warp }[2]; 1725 $chunk_name = ${ $this_warp }[6]; 1726 } 1727 else { 1728 print STDERR "desp_diff_singles: excluding $this_exp_id for $this_object due to being rejected $this_comment\n"; 1729 } 1730 } 1731 @{ $warps } = @keep_warps; 1732 1733 #find the time of the most recent exposure in that chunk 1734 my $input_chunk = "select max(dateobs) FROM rawExp WHERE substr(comment, 1, position(' ' in comment)) = '$chunk_name' AND filter = '$filter' "; 1735 my $chunk = $db->selectall_arrayref( $input_chunk ); 1736 foreach my $this_chunk (@{ $chunk }) { 1737 $this_date = ${ $this_chunk }[0]; 1738 } 1739 1740 #compute and store some stats for potential on-the-fly desperate diffs 1741 my $nwarps = ($#{ $warps } + 1); 1742 my $timediff = 0; 1743 my $now=DateTime->now; 1744 $now->set_time_zone("UTC"); 1745 1746 if($this_date) { 1747 if($this_date=~/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) { 1748 my $dt=DateTime->new(year=>$1,month=>$2,day=>$3,hour=>$4,minute=>$5,second=>$6,time_zone=>"UTC"); 1749 my $difference=$now->delta_ms($dt); 1750 $timediff=($difference->hours) + (($difference->minutes) + ($difference->seconds)/60.)/60.; 1751 } 1752 } 1753 1754 #Consider the special case of on-the-fly desperate diffs 1755 #The conditions are: uneven nr of warps greater than 3, and the most recent observations is more than $desdiffdt hours old 1756 if (($nwarps % 2 != 0) && ($nwarps >= 3) && ($timediff < $desdiffdt)) { 1757 print STDERR "desp_diff_singles: There are potential desperate diffs to be done, but the time criterium is not met.\n"; 1758 next; 1759 } 1760 if (($nwarps % 2 == 0) || ($nwarps == 1) || ($timediff < $desdiffdt)) { 1761 next; 1762 } 1763 1764 # We are attempting to do the missing diffs, so reverse the list of retained warps. 1765 # Good objects with all visits will be skipped due to the duplicate check. 1766 # Bad objects will have the earliest visit rejected, and the visits repaired in a way that will produce all desired pairs. 1767 @{ $warps } = reverse @keep_warps; 1768 1769 # Exclude the last entry if we do not have an even number of warps. 1770 if (($#{ $warps } + 1) % 2 != 0) { 1771 print STDERR "desp_diff_singles: Number of input warps to make diffs is not even for target $target and object $this_object!"; 1772 my $rejected_warp = pop @{ $warps }; 1773 my $rejected_exp_id = ${ $rejected_warp }[0]; 1774 print STDERR ": Rejecting ${rejected_exp_id} to force visit count.\n"; 1775 } 1776 1777 while ($#{ $warps } > -1) { 1778 # The array is sorted in pairs of input/template. 1779 my $template_warp = shift @{ $warps }; 1780 my $input_warp = shift @{ $warps }; 1692 1781 1693 foreach my $object_row (@{ $object_ref }) { 1694 my $this_object = shift @{ $object_row }; 1695 my $this_chunk = shift @{ $object_row }; 1782 my $input_exp_id = ${ $input_warp }[0]; 1783 my $input_comment = ${ $input_warp }[3]; 1784 1785 my $template_exp_id = ${ $template_warp }[0]; 1786 my $template_comment = ${ $template_warp }[3]; 1787 1788 my $input_warp_id = ${ $input_warp }[1]; 1789 my $template_warp_id = ${ $template_warp }[1]; 1790 1791 my $input_warp_state = ${ $input_warp }[4]; 1792 my $template_warp_state = ${ $template_warp }[4]; 1793 1794 my $input_warp_camQuality = ${ $input_warp }[5]; 1795 my $template_warp_camQuality = ${ $template_warp }[5]; 1796 1797 $Npotential++; 1798 1799 unless (defined($input_warp_id) && defined($template_warp_id) && 1800 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) { 1801 print STDERR "Desp 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"; 1802 if (($input_warp_camQuality == 4007)||($template_warp_camQuality == 4007)) { 1803 # This should now never be reached. 1804 # CZW: Trigger backup plan here? Or simply set up framework? 1805 print STDERR " ...but this is due to a camera stage astrometry quality\n"; 1806 $Npotential--; 1807 } 1808 next; 1809 } 1810 1811 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1812 $Nqueued++; 1813 print STDERR "Desp 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"; 1814 next; 1815 } 1816 else { 1817 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"; 1818 } 1819 1820 my $cmd = "$difftool -dbname $dbname -definewarpwarp "; 1821 $cmd .= "-input_label $label -template_label $label -good_frac 0.1 "; 1822 $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting. 1823 $cmd .= "-rerun "; # Needed because we may have some diffs that already use some of the exposures 1824 $cmd .= "-set_workdir $workdir -set_dist_group $dist_group -set_data_group $data_group "; 1825 $cmd .= " -simple -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id "; 1826 if (defined($reduction)) { 1827 $cmd .= " -set_reduction $reduction "; 1828 } 1696 1829 1697 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality,substr(comment, 1, position(' ' in comment)) FROM "; 1698 $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) "; 1699 $input_sth .= " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1700 $input_sth .= " AND substr(rawExp.comment, 1, position(' ' in rawExp.comment)) = '$this_chunk' ORDER BY dateobs "; 1701 1702 my $warps = $db->selectall_arrayref( $input_sth ); 1703 1704 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1705 my %comment_hash = (); 1706 foreach my $this_warp (@{ $warps }) { 1707 my $this_comment = ${ $this_warp }[3]; 1708 my $this_exp_id = ${ $this_warp }[0]; 1709 my $this_quality = ${ $this_warp }[5]; 1710 if ($this_quality != 0) { 1711 print STDERR "desp_diff_singles: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality\n"; 1712 } 1713 else { 1714 $comment_hash{$this_comment} = $this_exp_id; 1715 } 1716 } 1717 # Exclude any warps that are not stored in the comment_hash. 1718 my @keep_warps = (); 1719 foreach my $this_warp (@{ $warps }) { 1720 my $this_comment = ${ $this_warp }[3]; 1721 my $this_exp_id = ${ $this_warp }[0]; 1722 if ((exists($comment_hash{$this_comment}))&& 1723 ($comment_hash{$this_comment} == $this_exp_id)) { 1724 push @keep_warps, $this_warp; 1725 $this_date = ${ $this_warp }[2]; 1726 $chunk_name = ${ $this_warp }[6]; 1727 } 1728 else { 1729 print STDERR "desp_diff_singles: excluding $this_exp_id for $this_object due to being rejected $this_comment\n"; 1730 } 1731 } 1732 @{ $warps } = @keep_warps; 1733 1734 #find the time of the most recent exposure in that chunk 1735 my $input_chunk = "select max(dateobs) FROM rawExp WHERE substr(comment, 1, position(' ' in comment)) = '$chunk_name' AND filter = '$filter' "; 1736 my $chunk = $db->selectall_arrayref( $input_chunk ); 1737 foreach my $this_chunk (@{ $chunk }) { 1738 $this_date = ${ $this_chunk }[0]; 1830 if (defined($pretend)) { 1831 $cmd .= ' -pretend '; 1832 } 1833 if ($debug == 1) { 1834 $cmd .= ' -pretend '; 1835 print STDERR "desp_diff_singles: $cmd\n"; 1836 print STDERR " $input_warp_id $template_warp_id\n"; 1837 } 1838 1839 if (($debug == 0)&&(!defined($pretend))) { 1840 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1841 run ( command => $cmd, verbose => $verbose ); 1842 unless ($success) { 1843 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1844 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1845 } 1846 $Nqueued++; 1847 } 1848 } 1739 1849 } 1740 1741 #compute and store some stats for potential on-the-fly desperate diffs1742 my $nwarps = ($#{ $warps } + 1);1743 my $timediff = 0;1744 my $now=DateTime->now;1745 $now->set_time_zone("UTC");1746 1747 if($this_date) {1748 if($this_date=~/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {1749 my $dt=DateTime->new(year=>$1,month=>$2,day=>$3,hour=>$4,minute=>$5,second=>$6,time_zone=>"UTC");1750 my $difference=$now->delta_ms($dt);1751 $timediff=($difference->hours) + (($difference->minutes) + ($difference->seconds)/60.)/60.;1752 }1753 }1754 1755 #Consider the special case of on-the-fly desperate diffs1756 #The conditions are: uneven nr of warps greater than 3, and the most recent observations is more than $desdiffdt hours old1757 if (($nwarps % 2 != 0) && ($nwarps >= 3) && ($timediff < $desdiffdt)) {1758 print STDERR "desp_diff_singles: There are potential desperate diffs to be done, but the time criterium is not met.\n";1759 next;1760 }1761 if (($nwarps % 2 == 0) || ($nwarps == 1) || ($timediff < $desdiffdt)) {1762 next;1763 }1764 1765 # We are attempting to do the missing diffs, so reverse the list of retained warps.1766 # Good objects with all visits will be skipped due to the duplicate check.1767 # Bad objects will have the earliest visit rejected, and the visits repaired in a way that will produce all desired pairs.1768 @{ $warps } = reverse @keep_warps;1769 1770 # Exclude the last entry if we do not have an even number of warps.1771 if (($#{ $warps } + 1) % 2 != 0) {1772 print STDERR "desp_diff_singles: Number of input warps to make diffs is not even for target $target and object $this_object!";1773 my $rejected_warp = pop @{ $warps };1774 my $rejected_exp_id = ${ $rejected_warp }[0];1775 print STDERR ": Rejecting ${rejected_exp_id} to force visit count.\n";1776 }1777 1778 while ($#{ $warps } > -1) {1779 # The array is sorted in pairs of input/template.1780 my $template_warp = shift @{ $warps };1781 my $input_warp = shift @{ $warps };1782 1783 my $input_exp_id = ${ $input_warp }[0];1784 my $input_comment = ${ $input_warp }[3];1785 1786 my $template_exp_id = ${ $template_warp }[0];1787 my $template_comment = ${ $template_warp }[3];1788 1789 my $input_warp_id = ${ $input_warp }[1];1790 my $template_warp_id = ${ $template_warp }[1];1791 1792 my $input_warp_state = ${ $input_warp }[4];1793 my $template_warp_state = ${ $template_warp }[4];1794 1795 my $input_warp_camQuality = ${ $input_warp }[5];1796 my $template_warp_camQuality = ${ $template_warp }[5];1797 1798 $Npotential++;1799 1800 unless (defined($input_warp_id) && defined($template_warp_id) &&1801 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) {1802 print STDERR "Desp 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";1803 if (($input_warp_camQuality == 4007)||($template_warp_camQuality == 4007)) {1804 # This should now never be reached.1805 # CZW: Trigger backup plan here? Or simply set up framework?1806 print STDERR " ...but this is due to a camera stage astrometry quality\n";1807 $Npotential--;1808 }1809 next;1810 }1811 1812 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) {1813 $Nqueued++;1814 print STDERR "Desp 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";1815 next;1816 }1817 else {1818 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";1819 }1820 1821 my $cmd = "$difftool -dbname $dbname -definewarpwarp ";1822 $cmd .= "-input_label $label -template_label $label -good_frac 0.1 ";1823 $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting.1824 $cmd .= "-rerun "; # Needed because we may have some diffs that already use some of the exposures1825 $cmd .= "-set_workdir $workdir -set_dist_group $dist_group -set_data_group $data_group ";1826 $cmd .= " -simple -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id ";1827 if (defined($reduction)) {1828 $cmd .= " -set_reduction $reduction ";1829 }1830 1831 if (defined($pretend)) {1832 $cmd .= ' -pretend ';1833 }1834 if ($debug == 1) {1835 $cmd .= ' -pretend ';1836 print STDERR "desp_diff_singles: $cmd\n";1837 print STDERR " $input_warp_id $template_warp_id\n";1838 }1839 1840 if (($debug == 0)&&(!defined($pretend))) {1841 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =1842 run ( command => $cmd, verbose => $verbose );1843 unless ($success) {1844 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);1845 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);1846 }1847 $Nqueued++;1848 }1849 }1850 1850 } 1851 1851 $metadata_out{nsDiffPotential} += $Npotential; … … 1904 1904 print STDERR "desp_diff_queue: No desperate diffs will be attempted, since the number of exps at the summit and in rawExp do not match ($nsummitexps $nrawexps), or the timestamps are off ($summittimediff)\n"; 1905 1905 } 1906 return; 1907 } 1908 1909 foreach my $object_row (@{ $object_ref }) { 1910 my $this_object = shift @{ $object_row }; 1911 my $this_chunk = shift @{ $object_row }; 1906 } 1907 else { 1908 foreach my $object_row (@{ $object_ref }) { 1909 my $this_object = shift @{ $object_row }; 1910 my $this_chunk = shift @{ $object_row }; 1912 1911 1913 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality FROM ";1914 $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) ";1915 $input_sth .= " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";1916 $input_sth .= " AND substr(rawExp.comment, 1, position(' ' in rawExp.comment)) = '$this_chunk' ORDER BY dateobs ";1917 1918 my $warps = $db->selectall_arrayref( $input_sth );1919 1920 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra.1921 my %comment_hash = ();1922 foreach my $this_warp (@{ $warps }) {1923 my $this_comment = ${ $this_warp }[3];1924 my $this_exp_id = ${ $this_warp }[0];1925 my $this_quality = ${ $this_warp }[5];1926 if ($this_quality != 0) {1927 print STDERR "desp_diff_queue: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality\n";1928 }1929 else {1930 $comment_hash{$this_comment} = $this_exp_id;1931 }1932 }1933 # Exclude any warps that are not stored in the comment_hash.1934 my @keep_warps = ();1935 foreach my $this_warp (@{ $warps }) {1936 my $this_comment = ${ $this_warp }[3];1937 my $this_exp_id = ${ $this_warp }[0];1938 if ((exists($comment_hash{$this_comment}))&&1939 ($comment_hash{$this_comment} == $this_exp_id)) {1940 push @keep_warps, $this_warp;1941 }1942 else {1943 print STDERR "desp_diff_queue: excluding $this_exp_id for $this_object due to not being an accepted comment string $this_comment\n";1944 }1945 }1946 # We are attempting to do the missing diffs, so reverse the list of retained warps.1947 # Good objects with all visits will be skipped due to the duplicate check.1948 # Bad objects will have the earliest visit rejected, and the visits repaired in a way that will produce all desired pairs.1949 @{ $warps } = reverse @keep_warps;1912 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality FROM "; 1913 $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) "; 1914 $input_sth .= " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1915 $input_sth .= " AND substr(rawExp.comment, 1, position(' ' in rawExp.comment)) = '$this_chunk' ORDER BY dateobs "; 1916 1917 my $warps = $db->selectall_arrayref( $input_sth ); 1918 1919 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1920 my %comment_hash = (); 1921 foreach my $this_warp (@{ $warps }) { 1922 my $this_comment = ${ $this_warp }[3]; 1923 my $this_exp_id = ${ $this_warp }[0]; 1924 my $this_quality = ${ $this_warp }[5]; 1925 if ($this_quality != 0) { 1926 print STDERR "desp_diff_queue: excluding $this_exp_id for $this_object due to non-zero cam.quality $this_quality\n"; 1927 } 1928 else { 1929 $comment_hash{$this_comment} = $this_exp_id; 1930 } 1931 } 1932 # Exclude any warps that are not stored in the comment_hash. 1933 my @keep_warps = (); 1934 foreach my $this_warp (@{ $warps }) { 1935 my $this_comment = ${ $this_warp }[3]; 1936 my $this_exp_id = ${ $this_warp }[0]; 1937 if ((exists($comment_hash{$this_comment}))&& 1938 ($comment_hash{$this_comment} == $this_exp_id)) { 1939 push @keep_warps, $this_warp; 1940 } 1941 else { 1942 print STDERR "desp_diff_queue: excluding $this_exp_id for $this_object due to not being an accepted comment string $this_comment\n"; 1943 } 1944 } 1945 # We are attempting to do the missing diffs, so reverse the list of retained warps. 1946 # Good objects with all visits will be skipped due to the duplicate check. 1947 # Bad objects will have the earliest visit rejected, and the visits repaired in a way that will produce all desired pairs. 1948 @{ $warps } = reverse @keep_warps; 1950 1949 1951 # Exclude the last entry if we do not have an even number of warps.1952 if (($#{ $warps } + 1) % 2 != 0) {1953 print STDERR "desp_diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } ";1954 if ($#{ $warps} + 1 == 1) {1955 print STDERR ": I can do no diffs with only one exposure.\n";1956 next;1957 }1958 else {1959 my $rejected_warp = pop @{ $warps };1960 my $rejected_exp_id = ${ $rejected_warp }[0];1961 print STDERR ": Rejecting ${rejected_exp_id} to force visit count.\n";1962 }1963 }1950 # Exclude the last entry if we do not have an even number of warps. 1951 if (($#{ $warps } + 1) % 2 != 0) { 1952 print STDERR "desp_diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } "; 1953 if ($#{ $warps} + 1 == 1) { 1954 print STDERR ": I can do no diffs with only one exposure.\n"; 1955 next; 1956 } 1957 else { 1958 my $rejected_warp = pop @{ $warps }; 1959 my $rejected_exp_id = ${ $rejected_warp }[0]; 1960 print STDERR ": Rejecting ${rejected_exp_id} to force visit count.\n"; 1961 } 1962 } 1964 1963 1965 while ($#{ $warps } > -1) {1966 # In this mode, the array is sorted in pairs of template/input, counter to the standard queue.1967 my $template_warp = shift @{ $warps };1968 my $input_warp = shift @{ $warps };1969 1970 my $input_exp_id = ${ $input_warp }[0];1971 my $input_comment = ${ $input_warp }[3];1972 1973 my $template_exp_id = ${ $template_warp }[0];1974 my $template_comment = ${ $template_warp }[3];1975 1976 my $input_warp_id = ${ $input_warp }[1];1977 my $template_warp_id = ${ $template_warp }[1];1978 1979 my $input_warp_state = ${ $input_warp }[4];1980 my $template_warp_state = ${ $template_warp }[4];1981 1982 my $input_warp_camQuality = ${ $input_warp }[5];1983 my $template_warp_camQuality = ${ $template_warp }[5];1984 1985 $Npotential++;1986 1987 unless (defined($input_warp_id) && defined($template_warp_id) &&1988 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) {1989 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";1990 if (($input_warp_camQuality == 4007)||($template_warp_camQuality == 4007)) {1991 # This should now never be reached.1992 # CZW: Trigger backup plan here? Or simply set up framework?1993 print STDERR " ...but this is due to a camera stage astrometry quality\n";1994 $Npotential--;1995 }1996 next;1997 }1998 1999 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) {2000 $Nqueued++;2001 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";2002 next;2003 }2004 else {2005 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";2006 }1964 while ($#{ $warps } > -1) { 1965 # In this mode, the array is sorted in pairs of template/input, counter to the standard queue. 1966 my $template_warp = shift @{ $warps }; 1967 my $input_warp = shift @{ $warps }; 1968 1969 my $input_exp_id = ${ $input_warp }[0]; 1970 my $input_comment = ${ $input_warp }[3]; 1971 1972 my $template_exp_id = ${ $template_warp }[0]; 1973 my $template_comment = ${ $template_warp }[3]; 1974 1975 my $input_warp_id = ${ $input_warp }[1]; 1976 my $template_warp_id = ${ $template_warp }[1]; 1977 1978 my $input_warp_state = ${ $input_warp }[4]; 1979 my $template_warp_state = ${ $template_warp }[4]; 1980 1981 my $input_warp_camQuality = ${ $input_warp }[5]; 1982 my $template_warp_camQuality = ${ $template_warp }[5]; 1983 1984 $Npotential++; 1985 1986 unless (defined($input_warp_id) && defined($template_warp_id) && 1987 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) { 1988 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"; 1989 if (($input_warp_camQuality == 4007)||($template_warp_camQuality == 4007)) { 1990 # This should now never be reached. 1991 # CZW: Trigger backup plan here? Or simply set up framework? 1992 print STDERR " ...but this is due to a camera stage astrometry quality\n"; 1993 $Npotential--; 1994 } 1995 next; 1996 } 1997 1998 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1999 $Nqueued++; 2000 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"; 2001 next; 2002 } 2003 else { 2004 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"; 2005 } 2007 2006 2008 my $cmd = "$difftool -dbname $dbname -definewarpwarp ";2009 $cmd .= "-input_label $label -template_label $label -good_frac 0.1 ";2010 $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting.2011 $cmd .= "-rerun "; # Needed because we may have some diffs that already use some of the exposures2012 $cmd .= "-set_workdir $workdir -set_dist_group $dist_group -set_data_group $data_group ";2013 $cmd .= " -simple -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id ";2014 # $cmd .= " -pretend ";2015 if (defined($reduction)) {2016 $cmd .= " -set_reduction $reduction ";2017 }2018 2019 if (defined($pretend)) {2020 $cmd .= ' -pretend ';2021 }2022 if ($debug == 1) {2023 $cmd .= ' -pretend ';2024 print STDERR "desp_diff_queue: $cmd\n";2025 print STDERR " $input_warp_id $template_warp_id\n";2026 }2007 my $cmd = "$difftool -dbname $dbname -definewarpwarp "; 2008 $cmd .= "-input_label $label -template_label $label -good_frac 0.1 "; 2009 $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting. 2010 $cmd .= "-rerun "; # Needed because we may have some diffs that already use some of the exposures 2011 $cmd .= "-set_workdir $workdir -set_dist_group $dist_group -set_data_group $data_group "; 2012 $cmd .= " -simple -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id "; 2013 # $cmd .= " -pretend "; 2014 if (defined($reduction)) { 2015 $cmd .= " -set_reduction $reduction "; 2016 } 2017 2018 if (defined($pretend)) { 2019 $cmd .= ' -pretend '; 2020 } 2021 if ($debug == 1) { 2022 $cmd .= ' -pretend '; 2023 print STDERR "desp_diff_queue: $cmd\n"; 2024 print STDERR " $input_warp_id $template_warp_id\n"; 2025 } 2027 2026 2028 if (($debug == 0)&&(!defined($pretend))) { 2029 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 2030 run ( command => $cmd, verbose => $verbose ); 2031 unless ($success) { 2032 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 2033 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 2034 } 2035 $Nqueued++; 2036 } 2037 } 2027 if (($debug == 0)&&(!defined($pretend))) { 2028 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 2029 run ( command => $cmd, verbose => $verbose ); 2030 unless ($success) { 2031 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 2032 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 2033 } 2034 $Nqueued++; 2035 } 2036 } 2037 } 2038 2038 } 2039 2039 $metadata_out{nsDiffPotential} += $Npotential;
Note:
See TracChangeset
for help on using the changeset viewer.
