IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31429


Ignore:
Timestamp:
May 3, 2011, 7:28:38 PM (15 years ago)
Author:
watersc1
Message:

Hard coded cleanup commands into the script, but it works, and triggers cleanup for the things we're done with. Edit to diff_skycell.pl to create a dummy refConv file for magic to use when we haven't convolved anything.

Location:
branches/czw_branch/20110406
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20110406/ippScripts/scripts/diff_skycell.pl

    r31302 r31429  
    3131my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);
    3232my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     33my $nebInsert = can_run('neb-insert') or (warn "Can't find neb-insert" and $missing_tools = 1);
    3334if ($missing_tools) {
    3435    warn("Can't find required tools.");
     
    383384                }
    384385            }
     386            if ($reduction eq 'NOCONVDIFF') {
     387                my $refConv = prepare_output("PPSUB.REF.CONV", $outroot, 0);
     388                my $templateFile = $ipprc->file_resolve($template,0);
     389                $command = "$nebInsert $refConv $templateFile";
     390                ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     391                    run(command => $command, verbose => $verbose);
     392                unless ($success) {
     393                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     394                    &my_die("Unable to perform neb-insert: $error_code", $diff_id, $skycell_id, $error_code);
     395                }
     396            }
     397
     398
    385399        } elsif ($run_state eq 'update') {
    386400            &my_die("Update resulted in poor quality image: $quality", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
  • branches/czw_branch/20110406/ippScripts/scripts/lap_science.pl

    r31428 r31429  
    8282}
    8383if (defined($cleanup_mode)) {
    84     unless (($lapRunInfo{state} eq 'done')||
     84    unless (($lapRunInfo{state} eq 'full')||
    8585            ($lapRunInfo{state} eq 'drop')) {
    8686        &my_die("Cannot run cleanup_mode if lapRun != done!", $lap_id);
     
    356356            $complete_qstacks++;
    357357        }
     358        elsif (($stack->{quick_state})&&($stack->{quick_state} eq 'new')&&
     359               ($stack->{quick_fault} >= 4)&&($stack->{quick_fault} != 32767)) {
     360            printf STDERR "Faulted quick stack: $stack->{quick_stack_id} $stack->{quick_fault}\n";
     361            $complete_qstacks++;# This is not the best solution, but if they continually fail, there's not much we can do.
     362        }
    358363        if (($stack->{final_state})&&
    359364            ($stack->{final_state} eq 'full')) {
    360365            $complete_fstacks++;
    361366        }
     367        elsif (($stack->{final_state})&&($stack->{final_state} eq 'new')&&
     368               ($stack->{final_fault} >= 4)&&($stack->{final_fault} != 32767)) {
     369            printf STDERR "Faulted final stack: $stack->{final_stack_id} $stack->{final_fault}\n";
     370            $complete_fstacks++; # This is not the best solution, but if they continually fail, there's not much we can do.
     371        }
     372
    362373    }
    363374    if (($complete_qstacks > 0)&&
     
    433444            $exposure = remake_this_exposure($exposure);
    434445        }
    435         if ($companion) { # Validate that there are no problems with the companion exposure
    436             if ($companion->{cam_quality}) { # Maybe other things here?
    437                 $exposure->{private} = 1;
    438                 $exposure->{data_state} = 'drop';
    439                 &update_this_exposure($exposure);
    440                 $needs_qstack = 1;
     446        if ($exposure->{cam_quality}) {
     447            $needs_qstack = 1;
     448            $needs_something_private = 1;
     449            if ($companion) {
     450                $companion->{private} = 1;
     451                $companion->{pairwise} = 0;
     452                &update_this_exposure($companion);
    441453            }
    442         }
    443         if (($exposure->{warpRun_state})&&  # This exposure has a warp
    444             (($exposure->{warpRun_state} eq 'full')|| # This exposure's warp is either done or impossible.
    445              ($exposure->{data_state} eq 'drop'))) {
     454            $exposure->{private} = 1;
     455            $exposure->{pairwise} = 0;
     456            $exposure->{data_state} = 'drop';
     457            &update_this_exposure($exposure);
     458
     459        }
     460#       if ($companion) { # Validate that there are no problems with the companion exposure
     461#           if ($companion->{cam_quality}) { # Maybe other things here?
     462#               $exposure->{private} = 1;
     463#               $exposure->{data_state} = 'drop';
     464#               &update_this_exposure($exposure);
     465#               $needs_qstack = 1;
     466#           }
     467#       }
     468        if ((($exposure->{warpRun_state})&&  # This exposure has a warp
     469            ($exposure->{warpRun_state} eq 'full'))|| # This exposure's warp is either done or impossible.
     470             ($exposure->{data_state} eq 'drop')) {
    446471            $can_qstack ++;
    447472            $can_diff ++;
     
    535560    my $data_group = "${label}.${date}";
    536561
    537     my $command = "$stacktool -pretend";
     562    my $command = "$stacktool ";
     563    $command .= " -pretend " if defined $debug;
    538564    $command .= " -dbname $dbname " if defined $dbname;
    539565    $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
     
    567593    my $sass_id = $stack->{sass_id};
    568594    unless (defined($sass_id)) {
    569         &my_die("Unable to parse metadata from laptool", $lap_id, "");
    570     }
     595        &my_die("Unable to parse metadata from stacktool for sass_id", $lap_id, "");
     596    }
     597
     598    print "QUICK_SASS_ID: $sass_id\n";
    571599    $command = "$laptool -updaterun -lap_id $lap_id -set_quick_sass_id $sass_id";
    572600    $command .= " -dbname $dbname " if defined $dbname;
     
    635663    my $sass_id = $stack->{sass_id};
    636664    unless (defined($sass_id)) {
    637         &my_die("Unable to parse metadata from laptool", $lap_id, "");
     665        &my_die("Unable to parse metadata from stacktool for sass_id", $lap_id, "");
    638666    }
    639667    print "FINAL_SASS_ID: $sass_id\n";
     
    667695            next;
    668696        }
    669         if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # Not sure how this would happen, but still.
     697        if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # Not sure how this would happen, but still. ## This happens when we inherit a complete exposure.
    670698            next;
    671699        }
     
    705733        }
    706734        else { # warp-qstack
    707             $command .= " -definewarpstack -set_reduction WARPQSTACK -available -good_frac 0.2 ";
     735            $command .= " -definewarpstack -set_reduction NOCONVDIFF -available -good_frac 0.2 ";
    708736            $command .= " -warp_id $exposure->{warp_id} -stack_label ${label}.quick ";
    709737            $already_queued{$exposure->{warp_id}} = 1;
     
    716744            &my_die("unable to perform difftool: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
    717745        }
    718 
     746       
     747        my $diffs = $mdcParser->parse_list(join "", @$stdout_buf) or
     748            &my_die("Unable to parse metadata from laptool", $lap_id, "");
     749       
     750        my $diff = ${ $diffs }[0];
     751        my $diff_id = $diff->{diff_id};
     752        unless (defined($diff_id)) {
     753            $exposure->{data_state} = 'drop';
     754            &update_this_exposure($exposure);
     755        }
    719756       
    720757    }
     
    735772################################################################################
    736773
    737 # sub cleanup_exposures {
    738 #     my $command = "$laptool -inactive ";
    739 #     $command .= " -dbname $dbname " if defined $dbname;
    740 
    741 #     my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    742 #       run(command => $command, verbose => $verbose);
    743 #     unless ($success) {
    744 #       $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    745 #       &my_die("Unable to perform laptool: $error_code", "none", "none");
    746 #     }
    747 #     if (@$stdout_buf == 0) {
    748 #       # Nothing to do.
    749 #       return(0);
    750 #     }
    751    
    752 #     my $exposures = $mdcParser->parse_list(join "", @$stdout_buf) or
    753 #       &my_die("Unable to parse metadata from laptool", $lap_id);
    754 
    755 #     foreach my $exposure (@$exposures) {
    756 #       foreach my $clean_mode (@clean_modes) {
    757 #           $command = $clean_mode->{COMMAND};
    758 #           $clean_id = $clean_mode->{CLEAN_ID};
    759 #           $clean_state = $clean_mode->{CLEAN_STATE};
    760 #           if (($exposure->{$clean_id} != 0)&&
    761 #               (($exposure->{$clean_state} eq 'full')||
    762 #                ($exposure->{$clean_state} eq 'drop'))) {
    763 
    764 #               $command =~ s/\@DBNAME\@/$dbname/g;
    765 #               $command =~ s/\@CHIP_ID\@/$exposure->{chip_id}/;
    766 #               $command =~ s/\@CHIP_STATE\@/$exposure->{chip_state}/;
    767 #               $command =~ s/\@CHIP_LABEL\@/$exposure->{chip_label}/;
    768                
    769 #               $command =~ s/\@WARP_ID\@/$exposure->{chip_id}/;
    770 #               $command =~ s/\@WARP_STATE\@/$exposure->{chip_state}/;
    771 #               $command =~ s/\@WARP_LABEL\@/$exposure->{chip_label}/;
    772                
    773 #               $command =~ s/\@DIFF_ID\@/$exposure->{diff_id}/;
    774 #               $command =~ s/\@DIFF_STATE\@/$exposure->{diff_state}/;
    775 #               $command =~ s/\@DIFF_LABEL\@/$exposure->{diff_label}/;
    776                
    777 #               $command =~ s/\@MAGICDS_ID\@/$exposure->{magicDS_id}/;
    778 #               $command =~ s/\@MAGICDS_STATE\@/$exposure->{magicDS_state}/;
    779 #               $command =~ s/\@MAGICDS_LABEL\@/$exposure->{magicDS_label}/;
    780                
    781 #               ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    782 #                   run(command => $command, verbose => $verbose);
    783 #               unless ($success) {
    784 #                   $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    785 #                   &my_die("Unable to perform laptool: $error_code", "none", "none");
    786 #               }
    787 #           }
    788 #       }
    789 #       $exposure->{data_state} = 'cleaned';
    790 #       update_this_exposure($exposure);
    791 #     }
    792 # }
     774sub cleanup_mode {
     775    my $lap_id = shift;
     776    my $command = "$laptool -inactiveexp -lap_id $lap_id ";
     777    $command .= " -dbname $dbname " if defined $dbname;
     778
     779    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     780        run(command => $command, verbose => $verbose);
     781    unless ($success) {
     782        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     783        &my_die("Unable to perform laptool: $error_code", "none", "none");
     784    }
     785    if (@$stdout_buf == 0) {
     786        # Nothing to do.
     787        return(0);
     788    }
     789   
     790    my $exposures = $mdcParser->parse_list(join "", @$stdout_buf) or
     791        &my_die("Unable to parse metadata from laptool", $lap_id);
     792
     793    my @clean_modes = (
     794        'chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -chip_id @CHIP_ID@',
     795        'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@',
     796        'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@',
     797        'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage chip -stage_id @CHIP_ID@',
     798        'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage warp -stage_id @WARP_ID@',
     799        'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage diff -stage_id @DIFF_ID@');
     800    foreach my $exposure (@$exposures) {
     801        if ($exposure->{is_in_use}) {
     802            next;
     803        }
     804        foreach my $clean_mode (@clean_modes) {
     805            my $command = $clean_mode;
     806            $command =~ s/\@DBNAME\@/$dbname/g;
     807            $command =~ s/\@CHIP_ID\@/$exposure->{chip_id}/;
     808            $command =~ s/\@WARP_ID\@/$exposure->{warp_id}/;
     809            $command =~ s/\@DIFF_ID\@/$exposure->{diff_id}/;
     810            $command =~ s/\@LABEL\@/$exposure->{label}/;
     811           
     812            ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     813                run(command => $command, verbose => $verbose);
     814            unless ($success) {
     815                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     816                &my_die("Unable to perform laptool: $error_code", "none", "none");
     817            }
     818        }
     819        $exposure->{data_state} = 'cleaned';
     820        update_this_exposure($exposure);
     821    }
     822}
    793823   
    794824           
  • branches/czw_branch/20110406/ippTools/share/laptool_inactiveexp.sql

    r31409 r31429  
    11SELECT DISTINCT
    2     D.*,diffRun.state AS diff_state,CONVERT(sum(others.active),SIGNED) AS is_in_use FROM (
     2    D.*,diffRun.state AS diff_state,coalesce(CONVERT(sum(others.active),SIGNED),0) AS is_in_use FROM (
    33  SELECT DISTINCT
    44      W.*,IFNULL(diff1.diff_id,diff2.diff_id) AS diff_id FROM (
     
    2727    WHERE lapExp.active = FALSE
    2828    AND @WHERE@
     29    AND (warpSkyfile.quality IS NULL OR
     30         (warpSkyfile.quality != 8007      -- known cases where quality != 0, but everything's fine.
     31          AND warpSkyfile.quality != 3006  -- known cases where quality != 0, but everything's fine.
     32          ))
    2933    GROUP BY lap_id,exp_id
    3034    ) AS W
     
    3438) AS D
    3539LEFT JOIN diffRun USING(diff_id)
    36 JOIN lapExp AS others ON (D.chip_id = others.chip_id AND D.lap_id != others.lap_id)
     40LEFT JOIN lapExp AS others ON (D.chip_id = others.chip_id AND D.lap_id != others.lap_id)
    3741GROUP BY lap_id,exp_id
  • branches/czw_branch/20110406/ippTools/src/laptool.c

    r31428 r31429  
    473473      }
    474474    }
    475 
    476475  }
    477476
     
    690689  PXOPT_LOOKUP_S64(set_chip_id, config->args, "-set_chip_id", false, false);
    691690  PXOPT_LOOKUP_S64(set_pair_id, config->args, "-set_pair_id", false, false);
     691  PXOPT_LOOKUP_STR(set_data_state, config->args, "-set_data_state", false, false);
    692692  PXOPT_LOOKUP_BOOL(private,    config->args, "-private",     false);
    693693  PXOPT_LOOKUP_BOOL(public,     config->args, "-public",      false);
     
    711711  PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    712712  PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
    713   PXOPT_COPY_STR(config->args, where, "-set_data_state", "data_state", "==");
     713
    714714
    715715  psMetadata *values = psMetadataAlloc();
     
    738738    psMetadataAddBool(values, PS_LIST_TAIL, "pairwise", 0, "==", false);
    739739  }
    740  
     740  if (set_data_state) {
     741    PXOPT_COPY_STR(config->args, values, "-set_data_state", "data_state", "==");
     742  }
    741743  long rows = psDBUpdateRows(config->dbh,"lapExp",where,values);
    742744  if (rows) {
     
    755757{
    756758  PS_ASSERT_PTR_NON_NULL(config, false);
    757 
     759  PXOPT_LOOKUP_S64(lap_id,          config->args, "-lap_id",          true, false);
     760 
    758761  psMetadata *where = psMetadataAlloc();
    759762  PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "==");
Note: See TracChangeset for help on using the changeset viewer.