IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 12:45:24 PM (17 years ago)
Author:
eugene
Message:

update from mainline

Location:
branches/eam_branches/20090715
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715

  • branches/eam_branches/20090715/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r23292 r25022  
    2424use PS::IPP::Metadata::List qw( parse_md_list );
    2525use PS::IPP::Config qw( :standard );
     26use Carp;
    2627
    2728### my @images = locate_images($image_db, $req_type, $img_type, $id, $component,
     
    121122    my $command;
    122123    my $id_opt;     # option for the lookup
     124    my $image_name;
    123125    my $mask_name;
    124126    my $weight_name;
     
    130132
    131133    # special class_id value "null" means ignore
    132     if ($component eq "null") {
     134    if ($component and ($component eq "null")) {
    133135        $component = undef;
    134136    }
     
    146148        $command .= " -class_id $class_id" if $class_id;
    147149        $id_opt = "-chip_id";
     150        $image_name   = "PPIMAGE.CHIP";
    148151        $mask_name    = "PPIMAGE.CHIP.MASK";
    149152        $weight_name  = "PPIMAGE.CHIP.VARIANCE";
     
    156159        $command .= " -skycell_id $skycell_id" if $skycell_id;
    157160        $id_opt = "-warp_id";
     161        $image_name   = "PSWARP.OUTPUT";
    158162        $mask_name    = "PSWARP.OUTPUT.MASK";
    159163        $weight_name  = "PSWARP.OUTPUT.VARIANCE";
     
    164168        $command .= " -skycell_id $skycell_id" if $skycell_id;
    165169        $id_opt = "-diff_id";
     170        $image_name  = "PPSUB.OUTPUT";
    166171        $mask_name   = "PPSUB.OUTPUT.MASK";
    167172        $weight_name = "PPSUB.OUTPUT.VARIANCE";
     
    171176        $id_opt = "-stack_id";
    172177
     178        $image_name  = "PPSTACK.OUTPUT";
    173179        $mask_name   = "PPSTACK.OUTPUT.MASK";
    174180        $weight_name = "PPSTACK.OUTPUT.VARIANCE";
     
    210216        my $base;
    211217
    212         next if ($img_type eq "warp" and $image->{ignored});
     218        next if $image->{fault};
     219        next if ($img_type ne "raw") and $image->{quality};
    213220
    214221        if ($base_name) {
     
    224231            $ipprc->define_camera($camera);
    225232        }
    226         my $out = {};
    227         $out->{exp_id} = $image->{exp_id};
    228         $out->{exp_name} = $image->{exp_name};
     233        my $out = $image;
     234
     235        # if uri is nil this will get overridded below
     236        # (this is for raw stage)
    229237        $out->{image}  = $image->{uri};
    230         $out->{state}  = $image->{state}; # state is undef for rawExp, but that's ok
    231238        if ($set_class_id) {
    232239            $class_id = $image->{class_id};
    233             $out->{class_id} = $class_id;
     240            $out->{component} = $class_id;
    234241        }
    235242
    236243        # find the mask and weight images
    237244        if ($base) {
     245            $out->{image}  = $ipprc->filename($image_name,   $base, $class_id) if $image_name;
    238246            $out->{mask}   = $ipprc->filename($mask_name,   $base, $class_id) if $mask_name;
    239247            $out->{weight} = $ipprc->filename($weight_name, $base, $class_id) if $weight_name;
    240248        }
    241         $out->{camera} = $camera;
    242 
    243249        $out->{astrom} = find_astrometry($ipprc, $image_db, $image, $verbose) if $want_astrom;
    244250
     
    432438}
    433439
     440# cache of results of ppConfigDump
     441my %astromSources;
     442my $last_exp_id = 0;
     443my $lastAstromFile;
     444
    434445# find the astrometry file for a given exposure
    435446# return undef if no completed camRun exists
     
    440451    my $verbose = shift;
    441452
     453    my $exp_id = $image->{exp_id};
     454    if (($exp_id eq $last_exp_id) and $lastAstromFile) {
     455        # running camtool 60 times is really expensive when the answer is the same
     456        return $lastAstromFile;
     457    }
     458    $last_exp_id = 0;
     459    $lastAstromFile = undef;
     460
    442461    my $missing_tools;
    443462    my $camtool = can_run("camtool") or (warn "Can't find camtool" and $missing_tools = 1);
     
    448467    }
    449468
    450     my $command = "$camtool -dbname $image_db -processedexp -exp_id $image->{exp_id}";
     469    my $command = "$camtool -dbname $image_db -processedexp -exp_id $exp_id";
    451470    # run the tool and parse the output
    452471    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    478497    my $camRoot = $camdata->{path_base};
    479498    my $camera = $image->{camera};
    480     my $astromSource;
    481     {
     499    my $astromSource = $astromSources{$camera};
     500    if (!$astromSource) {
    482501       my $command = "$ppConfigDump -camera $camera -dump-recipe PSWARP -";
    483502        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    490509            die("Unable to parse metadata config doc");
    491510        $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE');
     511        $astromSources{$camera} = $astromSource;
    492512    }
    493513
    494514    my $astromFile = $ipprc->filename($astromSource, $camRoot);
     515    if ($astromFile) {
     516        $lastAstromFile = $astromFile;
     517        $last_exp_id = $exp_id;
     518    }
    495519
    496520    return $astromFile;
     
    538562# resolve_project()
    539563# get project specific information
     564my $last_project = "";
    540565sub resolve_project {
    541566    my $ipprc = shift;
    542567    my $project_name = shift;
     568
     569    if (!$project_name) {
     570        carp ("project is not defined");
     571        return undef;
     572    }
     573
     574    if ($project_name eq $last_project) {
     575        return $last_project;
     576    }
     577
    543578    my $dbname = shift;
    544     die "project is not defined" if !$project_name;
     579    my $dbserver = shift;
    545580
    546581    my $verbose = 0;
     
    555590    my $command = "$pstamptool -project -name $project_name";
    556591    $command .= " -dbname $dbname" if defined $dbname;
     592    $command .= " -dbserver $dbserver" if defined $dbserver;
    557593    # run the tool and parse the output
    558594    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    572608    my $proj_hash = parse_md_fast($mdcParser, $output);
    573609
    574     return $proj_hash->[0];
     610    $last_project = $proj_hash->[0];
     611
     612    return $last_project;
    575613}
    5766141;
Note: See TracChangeset for help on using the changeset viewer.