IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2012, 5:10:41 PM (14 years ago)
Author:
watersc1
Message:

Add preliminary offnight diffs and mops ws diff handlers to nightly science code. Needs to be debugged when appropriate data is available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/nightly_science.pl

    r32968 r33371  
    14151415                }
    14161416            }
     1417            if ((defined($science_config{$target}{SELF_WSDIFFS})) && ($science_config{$target}{SELF_WSDIFFS} == 1)) {
     1418                foreach my $filter (@filter_list) {
     1419                    # This one needs to return a state to see if we need to wait on stacking before checking again.
     1420                    $metadata_out{nsDiffState} = self_WS_diff_queue($date,$target,$filter,$pretend);
     1421                }
     1422            }
    14171423        }
    14181424    }
     
    17071713
    17081714    my ($lunation_start,$lunation_end) = get_lunation_extent($date);
    1709    
     1715
     1716
     1717# Get a list of exposures that could be diffed   
    17101718    my $new_data_group = "${data_group}.offnight";
    17111719    my $new_dist_group = "${dist_group}.offnight";
    1712     my $cmd = "$difftool -dbname $dbname  -definewarpwarp ";
    1713     $cmd .= "-input_label $label  -template_label $label ";
    1714     $cmd .= "-set_workdir $workdir  -set_dist_group $new_dist_group  -set_data_group $new_data_group ";
    1715     $cmd .= " -mintimediff 40000 ";
    1716     $cmd .= " -simple  -set_label $label -filter $filter ";
    1717     $cmd .= " -dateobs_begin ${lunation_start}T00:00:00 -dateobs_end ${lunation_end}T23:59:59 -distance 1.5 ";
    1718 
    1719     if (defined($pretend)) {
    1720         $cmd .= ' -pretend ';
    1721     }
    1722     if (defined($debug)) {
    1723         print STDERR "ON_diffs wants to run this command: $cmd\n";
    1724     }
    1725    
    1726     if (($debug == 0)&&(!defined($pretend))) {
    1727         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    1728             run ( command => $cmd, verbose => $verbose );
    1729         unless ($success) {
    1730             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    1731             &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    1732         }
    1733     }
    1734 }
     1720    my $check_cmd = "$difftool -dbname $dbname  -definewarpwarp ";
     1721    $check_cmd .= "-input_label $label  -template_label $label ";
     1722    $check_cmd .= "-set_workdir $workdir  -set_dist_group $new_dist_group  -set_data_group $new_data_group ";
     1723    $check_cmd .= " -mintimediff 40000 ";
     1724    $check_cmd .= " -pretend -simple  -rerun -set_label $label -filter $filter ";
     1725    $check_cmd .= " -dateobs_begin ${lunation_start}T00:00:00 -dateobs_end ${lunation_end}T23:59:59 -distance 1.5 ";
     1726
     1727    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1728        run ( command => $check_cmd, verbose => $verbose );
     1729    unless ($success) {
     1730        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1731        &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     1732    }
     1733   
     1734    # Parse results
     1735    my $diffs = $mdcParser->parse_list(join "", @$stdout_buf) or
     1736        &my_die("Unable to parse metadata from difftool -definewarpwarp", 0, 0, $date, $PS_EXIT_PROG_ERROR);
     1737    foreach my $diff (@$diffs) {
     1738        unless (multi_date_verify_uniqueness_diff($diff->{input_warp_id},$diff->{template_warp_id},$date,$target)) {
     1739            # If we don't already have a diff with these inputs, make a diff with these inputs.
     1740            my $cmd = "$difftool -dbname $dbname -definewarpwarp ";
     1741            $cmd   .= "-input_label $label -template_label $label ";
     1742            $cmd   .= "-warp_id $diff->{input_warp_id} -template_warp_id $diff->{template_warp_id} ";
     1743            $cmd .= "-set_workdir $workdir  -set_dist_group $new_dist_group  -set_data_group $new_data_group ";
     1744            $cmd .= " -mintimediff 40000 ";
     1745            $cmd .= " -simple  -rerun -set_label $label -filter $filter ";
     1746            $cmd .= " -dateobs_begin ${lunation_start}T00:00:00 -dateobs_end ${lunation_end}T23:59:59 -distance 1.5 ";
     1747
     1748            if (defined($pretend)) {
     1749                $cmd .= ' -pretend ';
     1750            }
     1751            print STDERR "ON_diffs wants to run this command: $cmd\n";
    17351752           
     1753            if (($debug == 0)&&(!defined($pretend))) {
     1754                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1755                    run ( command => $cmd, verbose => $verbose );
     1756                unless ($success) {
     1757                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1758                    &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     1759                }
     1760            }
     1761        }
     1762    }
     1763}
     1764
     1765sub intranight_WS_diff_queue {
     1766    my $date = shift;
     1767    my $target = shift;
     1768    my $filter = shift;
     1769    my $pretend = shift;
     1770    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target);
     1771    my $db = init_gpc_db();
     1772
     1773    my ($stacks_to_finish,$stacks_total) = check_stack_count($label);
     1774    if (($stacks_to_finish == 0)&&($stacks_total != 0)) {
     1775        my $cmd = "$difftool -dbname $dbname -definewarpstack ";
     1776        $cmd .= " -good_frac 0.2 ";
     1777        $cmd .= " -warp_label $label -stack_label $label -set_label $label ";
     1778        $cmd .= " -set_workdir $workdir -available -set_reduction WARPSTACK -set_dist_group $dist_group ";
     1779        $cmd .= " -rerun ";
     1780    }
     1781}           
     1782
     1783sub check_stack_count {
     1784    my $label = shift;
     1785
     1786    my $stacks_to_finish = 0;
     1787    my $stacks_total = 0;
     1788
     1789    my $sth = "SELECT DISTINCT stack_id from stackRun where label = '$label' AND state = 'new'";
     1790    my $data_ref = $db->selectall_arrayref( $sth );
     1791    $stacks_to_finish = $#{ $data_ref } + 1;
     1792
     1793    $sth = "SELECT DISTINCT stack_id from stackRun where label = '$label'";
     1794    $data_ref = $db->selectall_arrayref( $sth );
     1795    $stacks_total = $#{ $data_ref } + 1;
     1796    return($stacks_to_finish,$stacks_total);
     1797}
    17361798
    17371799
Note: See TracChangeset for help on using the changeset viewer.