File Coverage

blib/lib/Astro/FITS/Header/AST.pm
Criterion Covered Total %
statement 15 34 44.1
branch 0 8 0.0
condition 0 3 0.0
subroutine 5 8 62.5
pod n/a
total 20 53 37.7


line stmt bran cond sub pod time code
1             package Astro::FITS::Header::AST;
2              
3             =head1 NAME
4              
5             Astro::FITS::Header::AST - Manipulates FITS headers from an AST object
6              
7             =head1 SYNOPSIS
8              
9             use Astro::FITS::Header::AST;
10              
11             $header = new Astro::FITS::Header::AST( FrameSet => $wcsinfo );
12             $header = new Astro::FITS::Header::AST( FrameSet => $wcsinfo,
13             Encoding => 'FITS-IRAF' );
14              
15             $header = new Astro::FITS::Header::AST( Cards => \@cards );
16              
17             =head1 DESCRIPTION
18              
19             This module makes use of the L module to read
20             the FITS HDU from an AST FrameSet object.
21              
22             It stores information about a FITS header block in an object. Takes an hash
23             as an argument, with an array reference pointing to an Starlink::AST
24             FramSet object.
25              
26             =cut
27              
28             # L O A D M O D U L E S --------------------------------------------------
29              
30 1     1   2004488 use strict;
  1         15  
  1         118  
31 1     1   10 use vars qw/ $VERSION /;
  1         2  
  1         175  
32              
33 1     1   660 use Astro::FITS::Header::Item;
  1         3  
  1         56  
34 1     1   9 use base qw/ Astro::FITS::Header /;
  1         2  
  1         863  
35 1     1   8 use Carp;
  1         2  
  1         288  
36              
37             require Starlink::AST;
38              
39             $VERSION = '3.09';
40              
41             # C O N S T R U C T O R ----------------------------------------------------
42              
43             =head1 REVISION
44              
45             $Id$
46              
47             =head1 METHODS
48              
49             =over 4
50              
51             =item B
52              
53             Reads a FITS header from a Starlink::AST FrameSet object
54              
55             $header->configure( FrameSet => $wcsinfo );
56              
57             Base class initialisation also works:
58              
59             $header->configure( Cards => \@cards );
60              
61             Accepts a reference to an Starlink::AST FrameSet object.
62              
63             If a specific encoding is required, this can be specified using
64             the Encoding argument. Default is FITS-WCS if no Encoding is given.
65             Note that not all framesets can be encoded using FITS-WCS.
66              
67             $header->configure( FrameSet => $wcsinfo, Encoding => "Native" );
68              
69             If Encoding is specified but undefined, the default will be decided
70             by AST.
71              
72             =cut
73              
74             sub configure {
75 0     0     my $self = shift;
76 0           my %args = @_;
77              
78             # initialise the inherited status to OK.
79 0           my $status = 0;
80              
81             return $self->SUPER::configure(%args)
82 0 0 0       if exists $args{Cards} or exists $args{Items};
83              
84             # read the args hash
85 0 0         unless (exists $args{FrameSet}) {
86 0           croak("Arguement hash does not contain FrameSet or Cards");
87             }
88              
89 0           my $wcsinfo = $args{FrameSet};
90 0           my @cards;
91             {
92 0           my $fchan = new Starlink::AST::FitsChan(
93 0     0     sink => sub { push @cards, $_[0] } );
  0            
94 0 0         if (exists $args{Encoding}) {
95 0 0         if (defined $args{Encoding}) {
96             # use AST default if undef is supplied
97 0           $fchan->Set( Encoding => $args{Encoding} );
98             }
99             } else {
100             # Historical default
101 0           $fchan->Set( Encoding => "FITS-WCS" );
102             }
103 0           $status = $fchan->Write( $wcsinfo );
104             }
105 0           return $self->SUPER::configure( Cards => \@cards );
106             }
107              
108             # shouldn't need to do this, croak! croak!
109             sub writehdr {
110 0     0     my $self = shift;
111 0           croak("Not yet implemented");
112             }
113              
114             # T I M E A T T H E B A R --------------------------------------------
115              
116             =back
117              
118             =head1 SEE ALSO
119              
120             C, C
121              
122             =head1 AUTHORS
123              
124             Alasdair Allan Eaa@astro.ex.ac.ukE,
125             Tim Jenness Et.jenness@jach.hawaii.eduE
126              
127             =head1 COPYRIGHT
128              
129             Copyright (C) 2007-2011 Science and Technology Facilities Council.
130             Copyright (C) 2001-2005 Particle Physics and Astronomy Research Council.
131             All Rights Reserved.
132              
133             This program is free software; you can redistribute it and/or modify it under
134             the terms of the GNU General Public License as published by the Free Software
135             Foundation; either version 3 of the License, or (at your option) any later
136             version.
137              
138             This program is distributed in the hope that it will be useful,but WITHOUT ANY
139             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
140             PARTICULAR PURPOSE. See the GNU General Public License for more details.
141              
142             You should have received a copy of the GNU General Public License along with
143             this program; if not, write to the Free Software Foundation, Inc., 59 Temple
144             Place,Suite 330, Boston, MA 02111-1307, USA
145              
146             =cut
147              
148             # L A S T O R D E R S ------------------------------------------------------
149              
150             1;