IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20483


Ignore:
Timestamp:
Oct 30, 2008, 7:36:29 PM (18 years ago)
Author:
bills
Message:

require --warp_id so we can look up the skycell files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_tree.pl

    r18784 r20483  
    3333
    3434# Parse the command-line arguments
    35 my ($magic_id, $tess_id, $camera, $ra0, $dec0, $dbname, $outroot,
     35my ($magic_id, $warp_id, $tess_id, $camera, $ra0, $dec0, $dbname, $outroot,
    3636    $save_temps, $verbose, $no_update, $no_op, $redirect);
    3737GetOptions(
    3838           'magic_id=s'      => \$magic_id,   # Magic identifier
     39           'warp_id=s'       => \$warp_id,    # id for corresponding warps
    3940           'tess_id=s'       => \$tess_id,    # Tessellation identifier
    4041           'camera=s'        => \$camera,     # Camera name
     
    5152
    5253pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    53 pod2usage( -msg => "Required options: --magic_id --camera --tess_id --ra --dec --outroot",
     54pod2usage( -msg => "Required options: --magic_id --warp_id --camera --tess_id --ra --dec --outroot",
    5455           -exitval => 3) unless
    5556    defined $magic_id and
     57    defined $warp_id and
    5658    defined $tess_id and
    5759    defined $ra0 and
     
    6971my $missing_tools;
    7072my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     73my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
    7174if ($missing_tools) {
    7275    warn("Can't find required tools.");
     
    7679my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    7780
     81### Get a list of warpSkyfiles
     82my %warpSkyfiles;                   # hash of warps
     83{
     84    my $command = "$warptool -warped -warp_id $warp_id"; # Command to run
     85    $command .= " -dbname $dbname" if defined $dbname;
     86    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     87        run(command => $command, verbose => $verbose);
     88    unless ($success) {
     89        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     90        &my_die("Unable to perform warptool -warped: $error_code", $magic_id, $error_code);
     91    }
     92
     93    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     94        &my_die("Unable to parse metadata config doc", $magic_id, $PS_EXIT_PROG_ERROR);
     95
     96    my $warps = parse_md_list($metadata) or
     97        &my_die("Unable to parse metadata list", $magic_id, $PS_EXIT_PROG_ERROR);
     98
     99    # make a hash indexed by skycell_id
     100    foreach my $warp ( @$warps ) {
     101        my $skycell_id = $warp->{skycell_id};
     102        die "failed to lookup skycell_id from warp" if !$skycell_id;
     103        $warpSkyfiles{$skycell_id} = $warp;
     104    }
     105}
    78106### Get a list of skycells
    79107my @skycells;                   # List of skycells
     
    102130my @fields;
    103131foreach my $skycell_id ( @skycells ) {
    104     my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
    105     $ipprc->skycell_file($tess_id, $skycell_id, $skyfile, $verbose) or &my_die("Unable to generate skycells $skycell_id", $magic_id, $PS_EXIT_PROG_ERROR);
     132    # the filename method doesn't add the $skycell_id
     133
     134    # my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
     135    #my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
     136
     137#    my $skycellBase = "$outroot/$skycell_id";
     138#    my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $skycellBase);
     139#    $ipprc->skycell_file($tess_id, $skycell_id, $skyfile, $verbose) or &my_die("Unable to generate skycells $skycell_id", $magic_id, $PS_EXIT_PROG_ERROR);
     140
     141    my $warp = $warpSkyfiles{$skycell_id};
     142    die "warpSkyfile for $skycell_id not found" if !$warp;
     143    my $skyfileBase = $warp->{path_base};
     144    my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $skyfileBase);
    106145    my $skyfileResolved = $ipprc->file_resolve( $skyfile );
    107146    my ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $skyfileResolved );
     
    181220};
    182221my @tasks = ( $root );
    183 while (scalar @tasks > 1) {
     222while (scalar @tasks) {
    184223    my $node = shift @tasks;
    185224    divide_node($node, \@tasks);
    186 }
     225} 
    187226
    188227### Format tree for magictool
     
    193232
    194233### Input tree into database
    195 {
     234if (!$no_update) {
    196235    my $command = "$magictool -inputtree";
    197236    $command   .= " -magic_id $magic_id";
     
    241280    my @upper = splice(@sorted, $median); # Upper part of the sorted list
    242281
     282#    print " median $median\n";
     283
    243284    return (\@sorted, \@upper);
    244285}
     
    257298        children => {},
    258299    };
     300
     301#    my $n = scalar @$contents;
     302#    print "new node: $node->{position}: $n\n";
    259303
    260304    $parent->{children}->{$position} = $node;
Note: See TracChangeset for help on using the changeset viewer.