IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 30, 2012, 2:49:37 PM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/ippScripts/scripts/nightly_science.pl

    r32483 r33638  
    996996    $cmd .= " -min_num 4";
    997997    $cmd .= " -select_good_frac_min 0.05";
    998     $cmd .= " -set_reduction NIGHTLY_STACK ";
     998    if (defined($reduction)) {
     999        $cmd .= " -set_reduction $reduction ";
     1000    }
     1001    else {
     1002        $cmd .= " -set_reduction NIGHTLY_STACK ";
     1003    }
    9991004    $cmd .= " $select ";
    10001005    if ($debug == 1) {
     
    14101415                }
    14111416            }
     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            }
    14121423        }
    14131424    }
     
    17021713
    17031714    my ($lunation_start,$lunation_end) = get_lunation_extent($date);
    1704    
     1715
     1716
     1717# Get a list of exposures that could be diffed   
    17051718    my $new_data_group = "${data_group}.offnight";
    17061719    my $new_dist_group = "${dist_group}.offnight";
    1707     my $cmd = "$difftool -dbname $dbname  -definewarpwarp ";
    1708     $cmd .= "-input_label $label  -template_label $label ";
    1709     $cmd .= "-set_workdir $workdir  -set_dist_group $new_dist_group  -set_data_group $new_data_group ";
    1710     $cmd .= " -mintimediff 40000 ";
    1711     $cmd .= " -simple  -set_label $label -filter $filter ";
    1712     $cmd .= " -dateobs_begin ${lunation_start}T00:00:00 -dateobs_end ${lunation_end}T23:59:59 -distance 1.5 ";
    1713 
    1714     if (defined($pretend)) {
    1715         $cmd .= ' -pretend ';
    1716     }
    1717     if (defined($debug)) {
    1718         print STDERR "ON_diffs wants to run this command: $cmd\n";
    1719     }
    1720    
    1721     if (($debug == 0)&&(!defined($pretend))) {
    1722         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    1723             run ( command => $cmd, verbose => $verbose );
    1724         unless ($success) {
    1725             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    1726             &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    1727         }
    1728     }
    1729 }
     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";
    17301752           
     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}
    17311798
    17321799
Note: See TracChangeset for help on using the changeset viewer.