Changeset 20483 for trunk/ippScripts/scripts/magic_tree.pl
- Timestamp:
- Oct 30, 2008, 7:36:29 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/magic_tree.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_tree.pl
r18784 r20483 33 33 34 34 # Parse the command-line arguments 35 my ($magic_id, $ tess_id, $camera, $ra0, $dec0, $dbname, $outroot,35 my ($magic_id, $warp_id, $tess_id, $camera, $ra0, $dec0, $dbname, $outroot, 36 36 $save_temps, $verbose, $no_update, $no_op, $redirect); 37 37 GetOptions( 38 38 'magic_id=s' => \$magic_id, # Magic identifier 39 'warp_id=s' => \$warp_id, # id for corresponding warps 39 40 'tess_id=s' => \$tess_id, # Tessellation identifier 40 41 'camera=s' => \$camera, # Camera name … … 51 52 52 53 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 53 pod2usage( -msg => "Required options: --magic_id -- camera --tess_id --ra --dec --outroot",54 pod2usage( -msg => "Required options: --magic_id --warp_id --camera --tess_id --ra --dec --outroot", 54 55 -exitval => 3) unless 55 56 defined $magic_id and 57 defined $warp_id and 56 58 defined $tess_id and 57 59 defined $ra0 and … … 69 71 my $missing_tools; 70 72 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 73 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 71 74 if ($missing_tools) { 72 75 warn("Can't find required tools."); … … 76 79 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 77 80 81 ### Get a list of warpSkyfiles 82 my %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 } 78 106 ### Get a list of skycells 79 107 my @skycells; # List of skycells … … 102 130 my @fields; 103 131 foreach 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); 106 145 my $skyfileResolved = $ipprc->file_resolve( $skyfile ); 107 146 my ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $skyfileResolved ); … … 181 220 }; 182 221 my @tasks = ( $root ); 183 while (scalar @tasks > 1) {222 while (scalar @tasks) { 184 223 my $node = shift @tasks; 185 224 divide_node($node, \@tasks); 186 } 225 } 187 226 188 227 ### Format tree for magictool … … 193 232 194 233 ### Input tree into database 195 {234 if (!$no_update) { 196 235 my $command = "$magictool -inputtree"; 197 236 $command .= " -magic_id $magic_id"; … … 241 280 my @upper = splice(@sorted, $median); # Upper part of the sorted list 242 281 282 # print " median $median\n"; 283 243 284 return (\@sorted, \@upper); 244 285 } … … 257 298 children => {}, 258 299 }; 300 301 # my $n = scalar @$contents; 302 # print "new node: $node->{position}: $n\n"; 259 303 260 304 $parent->{children}->{$position} = $node;
Note:
See TracChangeset
for help on using the changeset viewer.
