| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::FITS::Header::GSD; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Astro::FITS::Header::GSD - Manipulate FITS headers from GSD files |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Astro::FITS::Header::GSD; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$hdr = new Astro::FITS::Header::GSD( Cards => \@cards ); |
|
12
|
|
|
|
|
|
|
$hdr = new Astro::FITS::Header::GSD( gsdobj => $gsd ); |
|
13
|
|
|
|
|
|
|
$hdr = new Astro::FITS::Header::GSD( File => $file ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This module makes use of the Starlink L module to read from |
|
18
|
|
|
|
|
|
|
a GSD header. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
It stores information about a FITS header block in an object. Takes an |
|
21
|
|
|
|
|
|
|
hash as an argument, with either an array reference pointing to an |
|
22
|
|
|
|
|
|
|
array of FITS header cards, or a filename, or (alternatively) a GSD |
|
23
|
|
|
|
|
|
|
object. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
2110492
|
use strict; |
|
|
1
|
|
|
|
|
22
|
|
|
|
1
|
|
|
|
|
95
|
|
|
28
|
1
|
|
|
1
|
|
13
|
use Carp; |
|
|
1
|
|
|
|
|
41
|
|
|
|
1
|
|
|
|
|
242
|
|
|
29
|
1
|
|
|
1
|
|
794
|
use GSD; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Astro::FITS::Header::Item; |
|
32
|
|
|
|
|
|
|
use base qw/ Astro::FITS::Header /; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use vars qw/ $VERSION /; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$VERSION = 3.01; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over 4 |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item B |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Reads a header from a GSD file. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$hdr->configure( Cards => \@cards ); |
|
47
|
|
|
|
|
|
|
$hdr->configure( Items => \@items ); |
|
48
|
|
|
|
|
|
|
$hdr->configure( gsdobj => $gsd ); |
|
49
|
|
|
|
|
|
|
$hdr->configure( File => $filename ); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Accepts a GSD object or a filename. If both C and C keys |
|
52
|
|
|
|
|
|
|
exist, C key takes priority. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub configure { |
|
57
|
|
|
|
|
|
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my %args = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my ($indf, $started); |
|
62
|
|
|
|
|
|
|
my $task = ref($self); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $self->SUPER::configure(%args) if exists $args{Cards} or |
|
65
|
|
|
|
|
|
|
exists $args{Items}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $gsd; |
|
68
|
|
|
|
|
|
|
if (exists $args{gsdobj} && defined $args{gsdobj}) { |
|
69
|
|
|
|
|
|
|
$gsd = $args{gsdobj}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
croak "gsd object must be of class 'GSD'" |
|
72
|
|
|
|
|
|
|
unless UNIVERSAL::isa($gsd, 'GSD'); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} elsif (exists $args{File}) { |
|
75
|
|
|
|
|
|
|
# Open the file |
|
76
|
|
|
|
|
|
|
$gsd = new GSD( $args{File} ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
croak "Error opening gsd file $args{File}" |
|
79
|
|
|
|
|
|
|
unless defined $gsd; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} else { |
|
82
|
|
|
|
|
|
|
croak "Argument hash does not contain gsdobj, File or Cards!"; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Somewhere to store the FITS information |
|
86
|
|
|
|
|
|
|
my @cards; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Read through all the items extracting the scalar items |
|
90
|
|
|
|
|
|
|
for my $i (1..$gsd->nitems) { |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my ($name, $units, $type, $array) = $gsd->Item( $i ); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
if (!$array) { |
|
95
|
|
|
|
|
|
|
# Only scalars |
|
96
|
|
|
|
|
|
|
my $value = $gsd->GetByNum( $i ); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Generate a comment string |
|
99
|
|
|
|
|
|
|
my $comment = ''; |
|
100
|
|
|
|
|
|
|
$comment .= "[$units]" if $units; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
if (length($name) > 8 ) { |
|
103
|
|
|
|
|
|
|
$comment .= " Name shortened from $name"; |
|
104
|
|
|
|
|
|
|
$name = substr($name, 0, 8); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# We need to convert the type from GSD to one that's a FITS |
|
108
|
|
|
|
|
|
|
# type. |
|
109
|
|
|
|
|
|
|
if( ( $type eq 'R' ) || ( $type eq 'D' ) ) { |
|
110
|
|
|
|
|
|
|
$type = "FLOAT"; |
|
111
|
|
|
|
|
|
|
} elsif( ( $type eq 'I' ) || ( $type eq 'W' ) || ( $type eq 'B' ) ) { |
|
112
|
|
|
|
|
|
|
$type = "INT"; |
|
113
|
|
|
|
|
|
|
} elsif( $type eq 'C' ) { |
|
114
|
|
|
|
|
|
|
$type = "STRING"; |
|
115
|
|
|
|
|
|
|
} elsif( $type eq 'L' ) { |
|
116
|
|
|
|
|
|
|
$type = "LOGICAL"; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# We do not have an actual FITS style string so we just |
|
120
|
|
|
|
|
|
|
# create the item directly |
|
121
|
|
|
|
|
|
|
push(@cards, new Astro::FITS::Header::Item( |
|
122
|
|
|
|
|
|
|
Keyword => $name, |
|
123
|
|
|
|
|
|
|
Comment => $comment, |
|
124
|
|
|
|
|
|
|
Value => $value, |
|
125
|
|
|
|
|
|
|
Type => $type, |
|
126
|
|
|
|
|
|
|
)); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# Configure the object |
|
132
|
|
|
|
|
|
|
$self->SUPER::configure( Items => \@cards ); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
return; |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item B |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The GSD library is read-only. The writehdr method is not implemented |
|
141
|
|
|
|
|
|
|
for this sub-class. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub writehdr { |
|
146
|
|
|
|
|
|
|
croak "The GSD library is read-only. The writehdr method is not implemented |
|
147
|
|
|
|
|
|
|
for this sub-class."; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 NOTES |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This module requires the Starlink L module. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
GSD supports keys that are longer than the 8 characters allowed as |
|
157
|
|
|
|
|
|
|
part of the FITS standard. GSD keys are truncated to 8 characters |
|
158
|
|
|
|
|
|
|
by this module. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L, L, L |
|
163
|
|
|
|
|
|
|
L, L |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 AUTHORS |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Tim Jenness Et.jenness@jach.hawaii.eduE, |
|
168
|
|
|
|
|
|
|
Alasdair Allan Eaa@astro.ex.ac.ukE |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Copyright (C) 2008-2011 Science & Technology Facilities Council. |
|
173
|
|
|
|
|
|
|
Copyright (C) 2001-2002 Particle Physics and Astronomy Research Council. |
|
174
|
|
|
|
|
|
|
All Rights Reserved. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
177
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
|
178
|
|
|
|
|
|
|
Foundation; either version 3 of the License, or (at your option) any later |
|
179
|
|
|
|
|
|
|
version. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,but WITHOUT ANY |
|
182
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
183
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
|
186
|
|
|
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|
187
|
|
|
|
|
|
|
Place,Suite 330, Boston, MA 02111-1307, USA |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
1; |