IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38073 for trunk


Ignore:
Timestamp:
Mar 31, 2015, 3:14:22 PM (11 years ago)
Author:
bills
Message:

if stage is stack and sources are requested look for a staticsky
run to get them from unless the stack is from a release and is calibrated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_job_run.pl

    r38062 r38073  
    9292my $stack_bkg_mk_mdc = can_run('stack_bkg_mk_mdc.pl') or (warn "Can't find stack_bkg_mk_mdc.pl" and $missing_tools = 1);
    9393my $fpack = can_run('fpack') or (warn "Can't find fpack" and $missing_tools = 1);
    94 
     94my $staticskytool = can_run('staticskytool') or (warn "Can't find staticskytool" and $missing_tools = 1);
    9595
    9696if ($missing_tools) {
     
    177177                # be copied from the cmf file.
    178178                $argString .= " -recipe PSPHOT STACKPHOT"
     179            }
     180        } elsif ($stage eq 'stack') {
     181            # no astrom file for stack (skycal cmf) Go find a staticsky cmf and use that
     182            # otherwise silently ignore the request for sources since the stack smf is not useful.
     183            my $staticsky_cmf = findStaticskyCMF($params);
     184            if ($staticsky_cmf) {
     185                print "Using staticsky cmf file $staticsky_cmf for sources\n";
     186                $argString .= " -write_cmf";
     187                $fileArgs  .= " -sources $staticsky_cmf";
     188                # Set psphot recipe to STACKPHOT so that the extended source paramters will
     189                # be copied from the cmf file.
     190                $argString .= " -recipe PSPHOT STACKPHOT";
     191                push @file_list, $staticsky_cmf;
     192            } else {
     193                print "No skycal or staticsky cmf for $params->{stack_id} ignoring request for sources\n";
    179194            }
    180195        } elsif ($params->{cmf}) {
     
    864879    return 0;
    865880}
     881sub findStaticskyCMF {
     882    my $params = shift;
     883    my $stack_id = $params->{stack_id};
     884
     885    &my_die( "NO stack_id found in findStaticskyCMF\n",
     886            $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$stack_id;
     887
     888    my $command = "$staticskytool -dbname $params->{imagedb} -result -stack_id $stack_id";
     889    my $results = runToolAndParse($command, $verbose);
     890
     891    if (!$results) {
     892        print "no staticsky results found for stack $stack_id\n";
     893        return undef;
     894    }
     895
     896    my $latest;
     897    my $latest_sky_id = 0;
     898    foreach my $result (@$results) {
     899        if ($result->{sky_id} > $latest_sky_id) {
     900            $latest = $result;
     901            $latest_sky_id = $result->{sky_id};
     902        }
     903    }
     904    if ($latest) {
     905        # XXXX Use proper file rule
     906        return $latest->{path_base} .  ".stk.$stack_id.cmf";
     907    }
     908    # Can't happen can it?
     909    return undef;
     910}
    866911
    867912sub my_die
Note: See TracChangeset for help on using the changeset viewer.