IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24968


Ignore:
Timestamp:
Jul 31, 2009, 3:41:03 PM (17 years ago)
Author:
bills
Message:

remember the last astrometry file looked up and return it
if it still applies. (This avoids calling camtool 60 times for each chip or request specification)

File:
1 edited

Legend:

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

    r24921 r24968  
    232232        }
    233233        my $out = $image;
     234
    234235        # if uri is nil this will get overridded below
     236        # (this is for raw stage)
    235237        $out->{image}  = $image->{uri};
    236 #        $out->{exp_id} = $image->{exp_id};
    237 #        $out->{exp_name} = $image->{exp_name};
    238 #        $out->{state}  = $image->{state}; # state is undef for rawExp, but that's ok
    239 #        if ($set_class_id) {
    240 #            $class_id = $image->{class_id};
    241 #            $out->{class_id} = $class_id;
    242 #        }
     238        if ($set_class_id) {
     239            $class_id = $image->{class_id};
     240            $out->{component} = $class_id;
     241        }
    243242
    244243        # find the mask and weight images
     
    248247            $out->{weight} = $ipprc->filename($weight_name, $base, $class_id) if $weight_name;
    249248        }
    250 #        $out->{camera} = $camera;
    251 
    252249        $out->{astrom} = find_astrometry($ipprc, $image_db, $image, $verbose) if $want_astrom;
    253250
     
    441438}
    442439
     440# cache of results of ppConfigDump
     441my %astromSources;
     442my $last_exp_id = 0;
     443my $lastAstromFile;
     444
    443445# find the astrometry file for a given exposure
    444446# return undef if no completed camRun exists
     
    449451    my $verbose = shift;
    450452
     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
    451461    my $missing_tools;
    452462    my $camtool = can_run("camtool") or (warn "Can't find camtool" and $missing_tools = 1);
     
    457467    }
    458468
    459     my $command = "$camtool -dbname $image_db -processedexp -exp_id $image->{exp_id}";
     469    my $command = "$camtool -dbname $image_db -processedexp -exp_id $exp_id";
    460470    # run the tool and parse the output
    461471    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    487497    my $camRoot = $camdata->{path_base};
    488498    my $camera = $image->{camera};
    489     my $astromSource;
    490     {
     499    my $astromSource = $astromSources{$camera};
     500    if (!$astromSource) {
    491501       my $command = "$ppConfigDump -camera $camera -dump-recipe PSWARP -";
    492502        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    499509            die("Unable to parse metadata config doc");
    500510        $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE');
     511        $astromSources{$camera} = $astromSource;
    501512    }
    502513
    503514    my $astromFile = $ipprc->filename($astromSource, $camRoot);
     515    if ($astromFile) {
     516        $lastAstromFile = $astromFile;
     517        $last_exp_id = $exp_id;
     518    }
    504519
    505520    return $astromFile;
Note: See TracChangeset for help on using the changeset viewer.