IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25107


Ignore:
Timestamp:
Aug 18, 2009, 11:55:23 AM (17 years ago)
Author:
bills
Message:

Various changes required to make postage stamps for the diff stage
work with the latest diff architecture especiallly warp warp diffs

Location:
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r24968 r25107  
    3636    my $id       = shift;   # required unless req_type eq bycoord
    3737    my $component= shift;   # class_id or skycell_id
     38    my $inverse  = shift;
    3839    my $x        = shift;
    3940    my $y        = shift;
     
    4344    my $verbose  = shift;
    4445
     46
    4547    # we die in response to bad data in request files
    4648    die "Unknown req_type: $req_type" if ($req_type ne "byid") and ($req_type ne "byexp")
    4749                                        and ($req_type ne "bycoord") and ($req_type ne "bydiff");
     50
    4851    if (($req_type eq "byid") and ($img_type eq "diff")) {
    4952        # lookups of all of the information for diff images requires a two level lookup to
     
    5154        # in one place
    5255        $req_type = "bydiff";
    53     }
     56        my $results = lookup_diff($ipprc, $image_db, $id, $component, 1, $inverse, $img_type, $verbose);
     57        return $results;
     58    }
     59
    5460    if ($req_type eq "bydiff") {
    55         my $results = lookup_bydiff($ipprc, $image_db, $id, $img_type, $verbose);
     61        my $results = lookup_diff($ipprc, $image_db, $id, $component, 0, $inverse, $img_type, $verbose);
    5662        if (!$results) {
    5763            return undef;
    5864        }
    5965        if (($img_type eq "warp") or ($img_type eq "diff")) {
    60             # lookup_bydiff has done all of the work
    61             return [$results];
    62         } elsif (($img_type eq "raw") or ($img_type eq "chip")) {
     66            # lookup_diff has done all of the work
     67            return $results;
     68        }
     69
     70        my $image = $results->[0];
     71        if (($img_type eq "raw") or ($img_type eq "chip")) {
    6372            $req_type = "byexp";
    64             $id = $results->{exp_name};
     73            $id = $image->{exp_name};
    6574            return undef if !$id;
    6675            # fall through and lookup byexp
    67 #        } elsif ($img_type eq "warp") {
    68 #            $req_type = "byid";
    69 #            $id = $results->{warp_id};
    70 #            $component = $results->{skycell_id};
    71 #            return undef if !$id;
    72 #            # fall through and lookup by warp_id
    7376        } elsif ($img_type eq "stack") {
    7477            $req_type = "byid";
    75             $id = $results->{stack_id};
     78            $id = $image->{stack_id};
    7679            return undef if !$id;
    7780            # fall though and lookup by stack id
     
    254257    return $output;
    255258}
    256 sub lookup_bydiff {
     259sub lookup_diff {
    257260    my $ipprc    = shift;
    258261    my $image_db = shift;
    259262    my $id       = shift;
     263    my $skycell_id = shift;
     264    my $byid     = shift;
     265    my $inverse  = shift;
    260266    my $img_type = shift;
    261267    my $verbose = shift;
     
    268274    }
    269275
    270     my $command = "$difftool -diffskyfile -diff_image_id $id -dbname $image_db";
     276    my $command = "$difftool -diffskyfile -dbname $image_db";
     277   
     278    if ($byid) {
     279        $command .= " -diff_id $id";
     280    } else {
     281        $command .= " -diff_skyfile_id $id";
     282    }
     283    $command .= " -skycell_id $skycell_id" if $skycell_id;
    271284
    272285    # run the tool and parse the output
     
    289302
    290303    my $n = @$images;
    291     if ($n > 1) {
     304    if (!$byid && ($n > 1)) {
    292305        die ("difftool returned an unexpected number of diffskyfiles: $n");
    293306    } elsif ($n == 0) {
     
    295308    }
    296309
    297     my $image = $images->[0];
    298 
    299     my $skycell_id = $image->{skycell_id};
    300 
    301     if ($image->{fault}) {
    302         print STDERR "selected difference image $id $image->{diff_id} $skycell_id has fault: $image->{fault}\n";
    303         return undef;
    304     }
    305 
    306     # The standard way to do a diff is warp - stack
    307     # so we interpret the requested image in that way
    308 
    309     my $stack_id = $image->{stack2};
    310     # XXX difftool currently returns max long long for null
    311     # this line is ready if we switch the code to return zero for null
    312     if ($stack_id and ($stack_id != 9223372036854775807)) {
    313         $image->{stack_id} = $stack_id;
    314     }
    315 
    316     my $warp_id =  $image->{warp1};
    317     # XXX difftool currently returns max long long for null
    318     # this line is ready if we switch the code to return zero for null
    319     if ($warp_id and ($warp_id != 9223372036854775807)) {
    320         $image->{warp_id} = $warp_id;
    321 
    322         ## now use the warp and go get the exposure information
    323         $command = "warptool -warped -warp_id $warp_id -skycell_id $skycell_id -dbname $image_db -limit 1";
    324         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    325                     run(command => $command, verbose => $verbose);
    326         unless ($success) {
    327             # not sure if we should die here
    328             print STDERR @$stderr_buf;
    329             return undef;
    330         }
    331 
    332         my $buf = join "", @$stdout_buf;
    333         if (!$buf) {
    334             return undef;
    335         }
    336 
    337         my $mdcParser = PS::IPP::Metadata::Config->new;
    338         my $warps = parse_md_fast($mdcParser, $buf)
    339             or die ("Unable to parse metadata config doc");
    340         my $warp = $warps->[0];
    341 
    342         if ($img_type eq "warp") {
    343             $image = $warp;
     310    my @results;
     311    foreach my $image (@$images) {
     312        my $skycell_id = $image->{skycell_id};
     313
     314        if ($image->{fault}) {
     315            print STDERR "selected difference image $id $image->{diff_id} $skycell_id has fault: $image->{fault}\n";
     316            next;
     317        }
     318
     319        # The standard way to do a diff is warp - stack
     320        # so we interpret the requested image in that way
     321
     322        my $stack_id = $image->{stack2};
     323        # XXX difftool currently returns max long long for null
     324        # this line is ready if we switch the code to return zero for null
     325        if ($stack_id and ($stack_id != 9223372036854775807)) {
     326            $image->{stack_id} = $stack_id;
     327        }
     328
     329        my $warp_id;
     330        if ($inverse and !$image->{bothways}) {
     331            print STDERR "inverse image requested for diffRun that is not bothways ignoring\n";
     332            $inverse = 0;
     333        }
     334        if ($inverse) {
     335            $warp_id =  $image->{warp2};
    344336        } else {
    345             $image->{exp_id} = $warp->{exp_id};
    346             $image->{exp_name} = $warp->{exp_name};
    347             $image->{camera} = $warp->{camera};
    348         }
    349     }
    350 
    351     if (($img_type eq "diff") or ($img_type eq "warp")) {
    352         # the $image is going to be returned directly in this case so we need to duplicate
    353         # some of processing that lookup does for other img_types
    354         $image->{image} = $image->{uri};
    355         if ($image->{camera}) {
    356             $ipprc->define_camera($image->{camera});
    357             if ($img_type eq "diff") {
    358                 $image->{mask}   = $ipprc->filename("PPSUB.OUTPUT.MASK", $image->{path_base});
    359                 $image->{weight} = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $image->{path_base});
     337            $warp_id =  $image->{warp1};
     338        }
     339        # XXX difftool currently returns max long long for null
     340        # this line is ready if we switch the code to return zero for null
     341        if ($warp_id and ($warp_id != 9223372036854775807)) {
     342            $image->{warp_id} = $warp_id;
     343
     344            ## now use the warp and go get the exposure information
     345            $command = "warptool -warped -warp_id $warp_id -skycell_id $skycell_id -dbname $image_db -limit 1";
     346            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     347                        run(command => $command, verbose => $verbose);
     348            unless ($success) {
     349                # XXX: I'm not sure if we should die here
     350                print STDERR @$stderr_buf;
     351                return undef;
     352            }
     353
     354            my $buf = join "", @$stdout_buf;
     355            if (!$buf) {
     356                next;
     357            }
     358
     359            my $mdcParser = PS::IPP::Metadata::Config->new;
     360            my $warps = parse_md_fast($mdcParser, $buf)
     361                or die ("Unable to parse metadata config doc");
     362            my $warp = $warps->[0];
     363
     364            if ($img_type eq "warp") {
     365                $image = $warp;
    360366            } else {
    361                 $image->{mask}   = $ipprc->filename("PSWARP.OUTPUT.MASK",   $image->{path_base});
    362                 $image->{weight} = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $image->{path_base});
     367                $image->{exp_id} = $warp->{exp_id};
     368                $image->{exp_name} = $warp->{exp_name};
     369                $image->{camera} = $warp->{camera};
    363370            }
    364371        } else {
    365             # XXX this will only happen if the minuend is not a warp
    366             print STDERR "WARNING: cannot resolve camera so cannot get weight and mask images\n";
    367         }
    368     }
    369 
    370     return $image;
     372            print STDERR "unexpected result warp_id not defined\n";
     373            next;
     374        }
     375
     376        if (($img_type eq "diff") or ($img_type eq "warp")) {
     377            # the $image is going to be returned directly in this case so we need to duplicate
     378            # some of processing that lookup does for other img_types
     379            if ($image->{camera}) {
     380                $ipprc->define_camera($image->{camera});
     381                if ($img_type eq "diff") {
     382                    my $filerule_base = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT";
     383                    $image->{image}  = $ipprc->filename($filerule_base, $image->{path_base});
     384                    $image->{mask}   = $ipprc->filename($filerule_base . ".MASK", $image->{path_base});
     385                    $image->{weight} = $ipprc->filename($filerule_base . ".VARIANCE", $image->{path_base});
     386                } else {
     387                    $image->{image}  = $ipprc->filename("PSWARP.OUTPUT",   $image->{path_base});
     388                    $image->{mask}   = $ipprc->filename("PSWARP.OUTPUT.MASK",   $image->{path_base});
     389                    $image->{weight} = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $image->{path_base});
     390                }
     391            } else {
     392                # XXX this will only happen if the minuend is not a warp
     393                print STDERR "WARNING: cannot resolve camera so cannot get weight and mask images\n";
     394                next;
     395            }
     396        }
     397        push @results, $image;
     398    }
     399    return \@results;
    371400}
    372401
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r25077 r25107  
    2222                    $PSTAMP_SELECT_MASK
    2323                    $PSTAMP_SELECT_WEIGHT
     24                    $PSTAMP_SELECT_INVERSE
    2425                    $PSTAMP_SUCCESS
    2526                    $PSTAMP_SYSTEM_ERROR
     
    4647our $PSTAMP_SELECT_WEIGHT    = 4;
    4748
     49our $PSTAMP_SELECT_INVERSE   = 1024;
     50
    4851# job and result codes
    4952# NOTE: these must match the values in pstamp/src/pstamp.h
     
    5154our $PSTAMP_SYSTEM_ERROR     = 10;
    5255our $PSTAMP_NOT_IMPLEMENTED  = 11;
    53 our $PSTAMP_UNKNOWN_ERROR   = 12;
     56our $PSTAMP_UNKNOWN_ERROR    = 12;
    5457
    5558our $PSTAMP_DUP_REQUEST      = 20;
Note: See TracChangeset for help on using the changeset viewer.