IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38076


Ignore:
Timestamp:
Apr 1, 2015, 10:17:36 AM (11 years ago)
Author:
bills
Message:

when processing a stack job, if the user requests sources and there is no skycal cmf
accessible look for a staticsky cmf for the stack. If found use that.
If neither skycal nor staticsky is found silently return no sources.
The ones from the stack run are bogus and useless.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20141024/pstamp/scripts/pstamp_job_run.pl

    r37408 r38076  
    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.