Changeset 20674 for trunk/ippScripts/scripts/magic_tree.pl
- Timestamp:
- Nov 10, 2008, 4:50:01 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/magic_tree.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_tree.pl
r20587 r20674 52 52 53 53 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 54 pod2usage( -msg => "Required options: --magic_id -- warp_id --camera --tess_id --ra --dec --outroot",54 pod2usage( -msg => "Required options: --magic_id --camera --tess_id --ra --dec --outroot", 55 55 -exitval => 3) unless 56 56 defined $magic_id and 57 defined $warp_id and58 57 defined $tess_id and 59 58 defined $ra0 and … … 78 77 79 78 ### Get a list of warpSkyfiles 79 ### This is a workaround to allow processing with older diffSkyfiles that don't have 80 ### a wcs. If warp_id is provided, we get the wcs from there 80 81 my %warpSkyfiles; # hash of warps 81 {82 if ($warp_id) { 82 83 my $command = "$warptool -warped -warp_id $warp_id"; # Command to run 83 84 $command .= " -dbname $dbname" if defined $dbname; … … 121 122 122 123 foreach my $input ( @$inputs ) { 123 push @skycells, $input ->{node}; # NB: Storing the skycell_id in magicInputSkyfile.node124 push @skycells, $input; # NB: Storing the skycell_id in magicInputSkyfile.node 124 125 } 125 126 } … … 127 128 ### For each skycell, project centre of skycell onto tangent plane of boresight 128 129 my @fields; 129 foreach my $ skycell_id( @skycells ) {130 foreach my $input ( @skycells ) { 130 131 # the filename method doesn't add the $skycell_id 131 132 … … 137 138 # $ipprc->skycell_file($tess_id, $skycell_id, $skyfile, $verbose) or &my_die("Unable to generate skycells $skycell_id", $magic_id, $PS_EXIT_PROG_ERROR); 138 139 139 my $warp = $warpSkyfiles{$skycell_id}; 140 die "warpSkyfile for $skycell_id not found" if !$warp; 141 my $skyfileBase = $warp->{path_base}; 142 my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $skyfileBase); 140 my $skyfile; 141 my $skycell_id = $input->{node}; 142 if ($warp_id) { 143 # Applying the workaround 144 my $warp = $warpSkyfiles{$skycell_id}; 145 die "warpSkyfile for $skycell_id not found" if !$warp; 146 my $skyfileBase = $warp->{path_base}; 147 $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $skyfileBase); 148 } else { 149 # using the diffSkyfile 150 $skyfile = $input->{uri}; 151 } 143 152 my $skyfileResolved = $ipprc->file_resolve( $skyfile ); 144 my ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $skyfileResolved ); 153 154 # my ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $skyfileResolved ); 155 # &my_die("Unable to read skycell header: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status; 156 157 my ($header, $status) = (undef, 0); 158 my $fits = Astro::FITS::CFITSIO::open_file( $skyfileResolved, READONLY, $status ); 159 &my_die("failed to open skycell file: $skyfileResolved: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status; 160 161 ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $fits ); 162 145 163 &my_die("Unable to read skycell header: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status; 146 164 165 147 166 # Get the useful header keywords 148 my $naxis1 = $$header{'NAXIS1'} or &my_die("Can't find NAXIS1", $magic_id, $PS_EXIT_SYS_ERROR); 167 # my $naxis1 = $$header{'NAXIS1'} or &my_die("Can't find NAXIS1", $magic_id, $PS_EXIT_SYS_ERROR); 168 my $naxis1 = $$header{'NAXIS1'}; 169 if (!$naxis1) { 170 # XXX: if the skyfile is compressed then the WCS won't be in the primary header 171 my $hdutype; 172 $fits->movrel_hdu(1, $hdutype, $status); 173 &my_die("Unable to movrel_hdu: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status; 174 175 ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $fits ); 176 &my_die("Unable to read extension header: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status; 177 $naxis1 = $$header{'NAXIS1'} or &my_die("Can't find NAXIS1", $magic_id, $PS_EXIT_SYS_ERROR); 178 } 149 179 my $naxis2 = $$header{'NAXIS2'} or &my_die("Can't find NAXIS2", $magic_id, $PS_EXIT_SYS_ERROR); 150 180 my $ctype1 = $$header{'CTYPE1'} or &my_die("Can't find CTYPE1", $magic_id, $PS_EXIT_SYS_ERROR);
Note:
See TracChangeset
for help on using the changeset viewer.
