IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31940


Ignore:
Timestamp:
Jul 26, 2011, 3:29:36 PM (15 years ago)
Author:
watersc1
Message:

Bugfix to allow SAS.12 gri data to process correctly without failing repeatedly at the stack queue stage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20110622/ippScripts/scripts/lap_science.pl

    r31678 r31940  
    2929my ( $lap_id );
    3030my ( $chip_mode, $monitor_mode, $cleanup_mode);
     31
     32# Global configuration constants that probably should be read from elsewhere.
     33my $qstack_threshold = 0.05; # Only make a quickstack if more than 5% of the exposures require it.
    3134
    3235GetOptions(
     
    8588    unless (($lapRunInfo{state} eq 'full')||
    8689            ($lapRunInfo{state} eq 'drop')) {
    87         &my_die("Cannot run cleanup_mode if lapRun != done!", $lap_id);
     90        &my_die("Cannot run cleanup_mode if lapRun != full!", $lap_id);
    8891    }
    8992    my $status = cleanup_mode($lap_id);
     
    456459    my $can_fstack = 0;
    457460    my $total_exposures = 0;
     461    my @lonely_exposures = ();
    458462    foreach my $exposure (@$exposures) {
    459463        $total_exposures++;
     
    473477       
    474478        if ($exposure->{private}) { # I've declared this exposure private to this lapRun.
    475             $needs_qstack = 1;
     479            $needs_qstack++;
     480            push @lonely_exposures, $exposure;
     481#           $lonely_exposures++;
    476482        }
    477483       
     
    510516            unless ((defined($exposure->{diffRun_state}))&&
    511517                    ($exposure->{diffRun_state} eq 'full')) {
    512                 $needs_qstack = 1;
     518                $needs_qstack++;
    513519                $needs_something_private = 1;
    514520                if ($companion) {
     
    516522                    $companion->{pairwise} = 0;
    517523                    &update_this_exposure($companion);
     524                    push @lonely_exposures, $companion;
     525#                   $lonely_exposures++;
    518526                }
    519527                $exposure->{private} = 1;
     
    566574        exit(0);
    567575    }
    568     if (($needs_qstack == 1)&&              # Do we need the quick stack?
     576    if (($needs_qstack > 0)&&              # Do we need the quick stack?
    569577        ($defined_qstack == 0)&&            # Have we not made it already?
    570578        ($can_qstack == $total_exposures)&& # Are all warps done?
    571579        ($needs_something_remade == 0)      # Do we need to wait for a stolen exposure?
    572580        ) {
    573         print "STATUS: Will now queue quickstacks\n";
    574         &queue_quickstack($exposures);
     581        if ($needs_qstack < $total_exposures * $qstack_threshold) { # Drop any exposures that are requiring the qstack
     582            print "STATUS: Insufficient unpaired exposures to justify quickstack.  Dropping unpaired exposures\n";
     583            foreach my $exposure (@lonely_exposures) {
     584                $exposure->{data_state} = 'drop';
     585                &update_this_exposure($exposure);
     586            }
     587        }
     588        else {
     589            print "STATUS: Will now queue quickstacks\n";
     590            &queue_quickstack($exposures);
     591        }
    575592    }
    576593
     
    623640    my $warps = '';
    624641    foreach $exposure (@$exposures) {
    625         if (($exposure->{data_state} != 'drop')&&
     642        if (($exposure->{data_state} ne 'drop')&&
    626643            (S64_IS_NOT_NULL($exposure->{warp_id}))) {
    627644            $warps .= " -warp_id $exposure->{warp_id} ";
     
    640657    $command .= " -pretend " if defined $debug;
    641658    $command .= " -dbname $dbname " if defined $dbname;
    642     $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
     659    $command .= " -definebyquery -select_label ${label}% -select_skycell_id ${proj_cell}.% -select_filter $filter ";
    643660    $command .= " -set_label ${label} -set_data_group $data_group ";
    644661    $command .= "  -set_workdir $workdir  -set_dist_group NODIST ";
     
    702719    my $warps = '';
    703720    foreach $exposure (@$exposures) {
    704         if (($exposure->{data_state} != 'drop')&&
     721        if (($exposure->{data_state} ne 'drop')&&
    705722            (S64_IS_NOT_NULL($exposure->{magicked}))&&
    706723            (S64_IS_NOT_NULL($exposure->{warp_id}))) {
     
    720737    $command .= " -pretend " if defined $debug;
    721738    $command .= " -dbname $dbname " if defined $dbname;
    722     $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
     739    $command .= " -definebyquery -select_label ${label}% -select_skycell_id ${proj_cell}.% -select_filter $filter ";
    723740    $command .= " -set_label ${label} -set_workdir $workdir -set_data_group $data_group ";
    724741    $command .= " -min_num 2 -set_reduction THREEPI_STACK -set_dist_group $exposure->{dist_group} ";
     
    897914
    898915    my @clean_modes = (
    899         'chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -chip_id @CHIP_ID@',
    900         'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@',
    901         'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@',
     916        'chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -chip_id @CHIP_ID@',
     917        'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@',
     918        'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@',
    902919        'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage chip -stage_id @CHIP_ID@',
    903920        'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage warp -stage_id @WARP_ID@',
     
    910927            my $command = $clean_mode;
    911928            $command =~ s/\@DBNAME\@/$dbname/g;
    912             $command =~ s/\@CHIP_ID\@/$exposure->{chip_id}/;
    913             $command =~ s/\@WARP_ID\@/$exposure->{warp_id}/;
    914             $command =~ s/\@DIFF_ID\@/$exposure->{diff_id}/;
     929            if ($command =~ /\@CHIP_ID\@/) {
     930                if (S64_IS_NOT_NULL($exposure->{chip_id})) {
     931                    $command =~ s/\@CHIP_ID\@/$exposure->{chip_id}/;
     932                }
     933                else {
     934                    next;
     935                }
     936            }
     937            if ($command =~ /\@WARP_ID\@/) {
     938                if (S64_IS_NOT_NULL($exposure->{warp_id})) {
     939                    $command =~ s/\@WARP_ID\@/$exposure->{warp_id}/;
     940                }
     941                else {
     942                    next;
     943                }
     944            }
     945            if ($command =~ /\@DIFF_ID\@/) {
     946                if (S64_IS_NOT_NULL($exposure->{diff_id})) {
     947                    $command =~ s/\@DIFF_ID\@/$exposure->{diff_id}/;
     948                }
     949                else {
     950                    next;
     951                }
     952            }
    915953            $command =~ s/\@LABEL\@/$exposure->{label}/;
    916954           
     
    925963        update_this_exposure($exposure);
    926964    }
     965   
     966    # Cleanup quickstacks.
     967    $command = "$laptool -stacks -lap_id $lap_id";
     968    $command .= " -dbname $dbname" if defined $dbname;
     969   
     970    ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     971        run(command => $command, verbose => $verbose);
     972    unless ($success) {
     973        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     974        &my_die("Unable to perform laptool -stacks: $error_code", "none", "none");
     975    }
     976    if (@$stdout_buf == 0) {
     977        # Nothing to do.
     978        return(0);
     979    }
     980   
     981    my $stacks = $mdcParser->parse_list(join "", @$stdout_buf) or
     982        &my_die("Unable to parse metadata from laptool -inactiveexp", $lap_id);
     983   
     984
     985    @clean_modes = (
     986        'stacktool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -stack_id @STACK_ID@');
     987    foreach my $stack (@$stacks) {
     988        if (!S64_IS_NOT_NULL($stack->{quick_stack_id})) {
     989            next;
     990        }
     991        foreach my $clean_mode (@clean_modes) {
     992            my $command = $clean_mode;
     993            $command =~ s/\@DBNAME\@/$dbname/g;
     994            $command =~ s/\@LABEL\@/$stack->{label}/;
     995            $command =~ s/\@STACK_ID\@/$stack->{quick_stack_id}/;
     996
     997            ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     998                run(command => $command, verbose => $verbose);
     999            unless ($success) {
     1000                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1001                &my_die("Unable to perform cleantool: $command : $error_code", "none", "none");
     1002            }
     1003        }
     1004    }   
     1005
     1006    $command = "$laptool -updaterun -lap_id $lap_id";
     1007    $command .= " -dbname $dbname " if defined $dbname;
     1008    $command .= " -set_state done ";
     1009    ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1010        run(command => $command, verbose => $verbose);
     1011    unless ($success) {
     1012        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1013        &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id);
     1014    }
     1015
    9271016}
    9281017   
Note: See TracChangeset for help on using the changeset viewer.