IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25151


Ignore:
Timestamp:
Aug 20, 2009, 11:50:15 AM (17 years ago)
Author:
watersc1
Message:
 
Location:
branches/czw_branch/cleanup/PS-IPP-PStamp/lib/PS/IPP/PStamp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r25051 r25151  
    3434    my $req_type = shift;   # required
    3535    my $img_type = shift;   # required
    36     my $id       = shift;   # required unless req_type eq bycoord
     36    my $id       = shift;   # required unless req_type eq bycoord or byskycell
    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        }
    59         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")) {
     65        if ($img_type eq "diff") {
     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
     76        } elsif ($img_type eq "warp") {
     77            $req_type = "byid";
     78            $id = $image->{warp_id};
     79            return undef if !$id;
     80            # fall through and lookup by warp_id
    7381        } elsif ($img_type eq "stack") {
    7482            $req_type = "byid";
    75             $id = $results->{stack_id};
     83            $id = $image->{stack_id};
    7684            return undef if !$id;
    77             # fall though and lookup by stack id
     85            # fall though and lookup by stack_id
    7886        } else {
    7987            # shouldn't I check this elsewhere?
     
    254262    return $output;
    255263}
    256 sub lookup_bydiff {
     264sub lookup_diff {
    257265    my $ipprc    = shift;
    258266    my $image_db = shift;
    259267    my $id       = shift;
     268    my $skycell_id = shift;
     269    my $byid     = shift;
     270    my $inverse  = shift;
    260271    my $img_type = shift;
    261272    my $verbose = shift;
     
    268279    }
    269280
    270     my $command = "$difftool -diffskyfile -diff_image_id $id -dbname $image_db";
     281    my $command = "$difftool -diffskyfile -dbname $image_db";
     282   
     283    if ($byid) {
     284        $command .= " -diff_id $id";
     285    } else {
     286        $command .= " -diff_skyfile_id $id";
     287    }
     288    $command .= " -skycell_id $skycell_id" if $skycell_id;
    271289
    272290    # run the tool and parse the output
     
    289307
    290308    my $n = @$images;
    291     if ($n > 1) {
     309    if (!$byid && ($n > 1)) {
    292310        die ("difftool returned an unexpected number of diffskyfiles: $n");
    293311    } elsif ($n == 0) {
     
    295313    }
    296314
    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;
     315    my @results;
     316    foreach my $image (@$images) {
     317        my $skycell_id = $image->{skycell_id};
     318
     319        if ($image->{fault}) {
     320            print STDERR "selected difference image $id $image->{diff_id} $skycell_id has fault: $image->{fault}\n";
     321            next;
     322        }
     323
     324        # The standard way to do a diff is warp - stack
     325        # so we interpret the requested image in that way
     326
     327        my $stack_id = $image->{stack2};
     328        # XXX difftool currently returns max long long for null
     329        # this line is ready if we switch the code to return zero for null
     330        if ($stack_id and ($stack_id != 9223372036854775807)) {
     331            $image->{stack_id} = $stack_id;
     332        }
     333
     334        my ($warp_id, $exp_id, $exp_name);
     335        if ($inverse and !$image->{bothways}) {
     336            print STDERR "Inverse images requested for diffRun that is not bothways. Ignoring.\n";
     337            $inverse = 0;
     338        }
     339        if ($inverse) {
     340            $warp_id =  $image->{warp2};
     341            $exp_id = $image->{exp_id_2};
     342            $exp_name = $image->{exp_name_2};
    344343        } 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});
     344            $warp_id =  $image->{warp1};
     345            $exp_id = $image->{exp_id_1};
     346            $exp_name = $image->{exp_name_1};
     347        }
     348        # XXX difftool currently returns max long long for null
     349        # this line is ready if we switch the code to return zero for null
     350        if ($warp_id and ($warp_id != 9223372036854775807)) {
     351            $image->{warp_id} = $warp_id;
     352            $image->{exp_id} = $exp_id;
     353            $image->{exp_name} = $exp_name;
     354        } else {
     355            print STDERR "unexpected result warp_id not defined\n";
     356            next;
     357        }
     358        if ($img_type eq "diff") {
     359            # the $image is going to be returned directly in this case so we need to duplicate
     360            # some of processing that lookup does for other img_types
     361            if ($image->{camera}) {
     362                $ipprc->define_camera($image->{camera});
     363                my $filerule_base = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT";
     364                $image->{image}  = $ipprc->filename($filerule_base, $image->{path_base});
     365                $image->{mask}   = $ipprc->filename($filerule_base . ".MASK", $image->{path_base});
     366                $image->{weight} = $ipprc->filename($filerule_base . ".VARIANCE", $image->{path_base});
    360367            } else {
    361                 $image->{mask}   = $ipprc->filename("PSWARP.OUTPUT.MASK",   $image->{path_base});
    362                 $image->{weight} = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $image->{path_base});
     368                # XXX this will only happen if the minuend is not a warp
     369                print STDERR "WARNING: cannot resolve camera so cannot get weight and mask images\n";
     370                next;
    363371            }
    364         } 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        }
     373        push @results, $image;
     374    }
     375    return \@results;
    371376}
    372377
  • branches/czw_branch/cleanup/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r24951 r25151  
    2222                    $PSTAMP_SELECT_MASK
    2323                    $PSTAMP_SELECT_WEIGHT
     24                    $PSTAMP_SELECT_INVERSE
     25                    $PSTAMP_SUCCESS
     26                    $PSTAMP_SYSTEM_ERROR
     27                    $PSTAMP_NOT_IMPLEMENTED
     28                    $PSTAMP_UNKNOWN_ERROR
     29                    $PSTAMP_DUP_REQUEST
     30                    $PSTAMP_INVALID_REQUEST
     31                    $PSTAMP_UNKNOWN_PRODUCT
     32                    $PSTAMP_NO_IMAGE_MATCH
     33                    $PSTAMP_NOT_DESTREAKED
     34                    $PSTAMP_NOT_AVAILABLE
     35                    $PSTAMP_GONE
     36                    $PSTAMP_NO_JOBS_QUEUED
     37                    $PSTAMP_NO_OVERLAP
    2438                    );
    2539our %EXPORT_TAGS = (standard => [@EXPORT_OK]);
     
    3347our $PSTAMP_SELECT_MASK      = 2;
    3448our $PSTAMP_SELECT_WEIGHT    = 4;
     49
     50our $PSTAMP_SELECT_INVERSE   = 1024;
     51
     52# job and result codes
     53# NOTE: these must match the values in pstamp/src/pstamp.h
     54our $PSTAMP_SUCCESS          = 0;
     55our $PSTAMP_SYSTEM_ERROR     = 10;
     56our $PSTAMP_NOT_IMPLEMENTED  = 11;
     57our $PSTAMP_UNKNOWN_ERROR    = 12;
     58
     59our $PSTAMP_DUP_REQUEST      = 20;
     60our $PSTAMP_INVALID_REQUEST  = 21;
     61our $PSTAMP_UNKNOWN_PRODUCT  = 22;
     62our $PSTAMP_NO_IMAGE_MATCH   = 23;
     63our $PSTAMP_NOT_DESTREAKED   = 24;
     64our $PSTAMP_NOT_AVAILABLE    = 25;
     65our $PSTAMP_GONE             = 26;
     66our $PSTAMP_NO_JOBS_QUEUED   = 27;
     67our $PSTAMP_NO_OVERLAP       = 28;
    3568
    3669use IPC::Cmd 0.36 qw( can_run run );
Note: See TracChangeset for help on using the changeset viewer.