IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 26, 2009, 1:59:32 PM (17 years ago)
Author:
beaumont
Message:

merged with trunk

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/magic_process.pl

    r23352 r24244  
    3030my $missing_tools;
    3131my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
    32 my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);
     32my $detectstreaks = can_run('DetectStreaks') or (warn "Can't find DetectStreaks" and $missing_tools = 1);
    3333if ($missing_tools) {
    3434    warn("Can't find required tools.");
     
    6363$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $node, $PS_EXIT_SYS_ERROR ) if $logfile;
    6464
    65 # RemoveStreaks doesn't know about nebulous. It expects to be able to append strings to outroot
     65# DetectStreaks doesn't know about nebulous. It expects to be able to append strings to outroot
    6666# to form valid file names.
    67 # So forbid nebulous path in outroot. We could relax this by change RemoveStreaks to take all
    68 # of the file names as arguments
     67# So forbid nebulous path in outroot. We could relax this by change DetectStreaks to take all
     68# of the file names as arguments or by teaching it about Nebulous
    6969if ($outroot =~ 'neb:/') {
    70     &my_die("RemoveStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR);
     70    &my_die("DetectStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR);
    7171}
    7272
     
    100100{
    101101    my $command;                # Command to execute
    102     $command = "$removestreaks --outroot $outroot";
     102    $command = "$detectstreaks --outroot $outroot";
    103103    $command .= " --verbose" if $verbose;
    104104
    105     # added per Paul Sydney's Jan 6, 2009
    106     $command .= " -D 3";
     105    # added per Paul Sydney's request Jan 6, 2009
     106    # removed per Paul Sydney March 30, 2009
     107    # $command .= " -D 3";
    107108
    108109
     
    118119    if (scalar @$inputs == 1 and $node ne "root") {
    119120        #
    120         #  RemoveStreak --detect --image filename --mask maskname --weight weightname --outroot path_base
     121        #  DetectStreaks --detect --image filename --mask maskname --weight weightname --outroot path_base
    121122        #
    122123        # Leaf node: 'detect' stage
     
    131132        }
    132133        my ($image, $mask, $weight) = resolve_inputs($innode);
    133 
    134         $command .= " --detect --image $image --mask $mask --weight $weight";
     134        if (!defined($image) or !defined($mask) or !defined($weight)) {
     135            &my_die("failed to resolve inputs", $magic_id, $node, $PS_EXIT_DATA_ERROR);
     136        }
     137
     138        my $template = resolve_template($innode);
     139        &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR)
     140            unless defined $template;
     141
     142        $command .= " --detect --image $image --mask $mask --weight $weight -k $template";
    135143
    136144        # set threshold to 4 sigma
    137145        $command .= ' -t 4';
     146
     147        # add -S
     148        $command .= ' -S';
    138149
    139150        # create the list of inputs used at this stage. At higher levels the
     
    156167    } else {
    157168        #
    158         # RemoveStreak --merge --inputs input.list --images image0_1.list \
     169        # DetectStreaks --merge --inputs input.list --images image0_1.list \
    159170        #                      --masks mask0_1.list --weight weights0_1.list
    160171        #                      --outroot outroot
     
    176187            foreach my $innode (@$inputs) {
    177188                # root for inputs from previous stage
    178                 my $in_uri = $innode->{uri};
    179                 print $sfh "$in_uri\n";
    180 
    181                 cat_list_to_list($in_fh, $in_uri, "input.list");
     189                my $in_path_base = $innode->{magic_path_base};
     190                print $sfh "$in_path_base\n";
     191
     192                cat_list_to_list($in_fh, $in_path_base, "input.list");
    182193                # build input lists by combining the lists from
    183194                # previous stages
    184                 cat_list_to_list($ifh, $in_uri, "image.list");
    185                 cat_list_to_list($mfh, $in_uri, "mask.list");
    186                 cat_list_to_list($wfh, $in_uri, "weight.list");
     195                cat_list_to_list($ifh, $in_path_base, "image.list");
     196                cat_list_to_list($mfh, $in_path_base, "mask.list");
     197                cat_list_to_list($wfh, $in_path_base, "weight.list");
    187198            }
    188199            close $in_fh;
     
    195206            $command .= " --images $image_list --masks $mask_list --weights $weight_list" ;
    196207            $command .= " --inputstreaks $streaks_list";
     208            # new option to "merge duplicate streaks into unique streaks"
     209            $command .= " --duplicates";
    197210        };
    198211        if ($@) {
     
    202215
    203216    unless ($no_op) {
    204         # RemoveStreaks fails if an output file already exists
     217        # DetectStreaks fails if an output file already exists
    205218        foreach my $output (@outputs) {
    206219            unlink($output) if -e $output;
     
    211224        unless ($success) {
    212225            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    213             &my_die("Unable to perform RemoveStreaks: $error_code", $magic_id, $node, $error_code);
     226            &my_die("Unable to perform DetectStreaks: $error_code", $magic_id, $node, $error_code);
    214227        }
    215228
     
    228241    $command   .= " -magic_id $magic_id";
    229242    $command   .= " -node $node";
    230     $command   .= " -uri $outroot";
     243    $command   .= " -path_base $outroot";
    231244    $command   .= " -dbname $dbname" if defined $dbname;
    232245
     
    247260    my $resolved = $ipprc->file_resolve($streaks_file);
    248261
    249     my $fh;
    250     open $fh, "<$resolved" or
    251         &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
    252     # the first line in the streaks file contains the number of streaks found
    253     my $num_streaks = <$fh>;
    254     chomp $num_streaks;
    255     close $fh;
    256     print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
     262    my $num_streaks = -1;
     263    unless ($no_op) {
     264        my $fh;
     265        open $fh, "<$resolved" or
     266            &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     267        # the first line in the streaks file contains the number of streaks found
     268        $num_streaks = <$fh>;
     269        chomp $num_streaks;
     270        close $fh;
     271        print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
     272    }
    257273
    258274    my $command = "$magictool -addmask";
     
    294310sub cat_list_to_list   {
    295311    my $out = shift;        # output file handle
    296     my $uri = shift;        # uri to append ...
     312    my $path_base = shift;  # path_base to append ...
    297313    my $extension = shift;  # ... the extension to
    298314
    299     my $filename = "$uri.$extension";
     315    my $filename = "$path_base.$extension";
    300316
    301317    my $in;
     
    306322}
    307323
    308 sub resolve_inputs {
    309 
     324sub resolve_inputs
     325{
    310326    my $node = shift;
    311     my $input_base = $node->{path_base};
    312 
    313     my $image = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT", $input_base));
    314     my $mask = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.MASK", $input_base));
    315     my $weight= $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.VARIANCE", $input_base));
    316 
    317     return ($image, $mask, $weight);
     327    my $input_base = $node->{diff_path_base};
     328
     329    my ($image, $mask, $variance); # Names to return
     330    if ($node->{inverse}) {
     331        $image = "PPSUB.INVERSE";
     332        $mask = "PPSUB.INVERSE.MASK";
     333        $variance = "PPSUB.INVERSE.VARIANCE";
     334    } else {
     335        $image = "PPSUB.OUTPUT";
     336        $mask = "PPSUB.OUTPUT.MASK";
     337        $variance = "PPSUB.OUTPUT.VARIANCE";
     338    }
     339
     340    $image = $ipprc->file_resolve($ipprc->filename($image, $input_base));
     341    $mask = $ipprc->file_resolve($ipprc->filename($mask, $input_base));
     342    $variance= $ipprc->file_resolve($ipprc->filename($variance, $input_base));
     343
     344    return ($image, $mask, $variance);
     345}
     346
     347sub resolve_template
     348{
     349    my $node = shift;
     350
     351    my $image;                  # Name of template to return
     352    my $path_base;              # Base name for name
     353    if (defined $node->{warp_path_base} and $node->{warp_path_base} ne "NULL") {
     354        $path_base = $node->{warp_path_base};
     355        $image = "PSWARP.OUTPUT";
     356    } elsif (defined $node->{stack_path_base} and $node->{stack_path_base} ne "NULL") {
     357        $path_base = $node->{stack_path_base};
     358        $image = "PPSTACK.OUTPUT";
     359    } else {
     360        return undef;
     361    }
     362
     363    $image = $ipprc->file_resolve($ipprc->filename($image, $path_base));
     364
     365    return $image
    318366}
    319367
     
    339387        $command .= " -magic_id $magic_id";
    340388        $command .= " -node $node";
    341         $command .= " -code $exit_code";
     389        $command .= " -fault $exit_code";
    342390        $command .= " -dbname $dbname" if defined $dbname;
    343391        system($command);
Note: See TracChangeset for help on using the changeset viewer.