| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Astro::FITS::HdrTrans::NIRI - Gemini NIRI translations |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Astro::FITS::HdrTrans::NIRI; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
%gen = Astro::FITS::HdrTrans::NIRI->translate_from_FITS( %hdr ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This class provides a generic set of translations that are specific to |
|
15
|
|
|
|
|
|
|
NIRI on the Gemini Observatory. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use 5.006; |
|
20
|
10
|
|
|
10
|
|
4744113
|
use warnings; |
|
|
10
|
|
|
|
|
43
|
|
|
21
|
10
|
|
|
10
|
|
43
|
use strict; |
|
|
10
|
|
|
|
|
25
|
|
|
|
10
|
|
|
|
|
274
|
|
|
22
|
10
|
|
|
10
|
|
38
|
use Carp; |
|
|
10
|
|
|
|
|
16
|
|
|
|
10
|
|
|
|
|
185
|
|
|
23
|
10
|
|
|
10
|
|
39
|
|
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
653
|
|
|
24
|
|
|
|
|
|
|
# Inherit from GEMINI |
|
25
|
|
|
|
|
|
|
use base qw/ Astro::FITS::HdrTrans::GEMINI /; |
|
26
|
10
|
|
|
10
|
|
59
|
|
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
1311
|
|
|
27
|
|
|
|
|
|
|
use vars qw/ $VERSION /; |
|
28
|
10
|
|
|
10
|
|
52
|
|
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
5461
|
|
|
29
|
|
|
|
|
|
|
$VERSION = "1.65"; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# for a constant mapping, there is no FITS header, just a generic |
|
32
|
|
|
|
|
|
|
# header that is constant |
|
33
|
|
|
|
|
|
|
my %CONST_MAP = ( |
|
34
|
|
|
|
|
|
|
GAIN => 12.3, # hardwire for now |
|
35
|
|
|
|
|
|
|
OBSERVATION_MODE => 'imaging', |
|
36
|
|
|
|
|
|
|
SPEED_GAIN => "NA", |
|
37
|
|
|
|
|
|
|
STANDARD => 0, # hardwire for now as all objects not a standard. |
|
38
|
|
|
|
|
|
|
WAVEPLATE_ANGLE => 0, # hardwire for now |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# NULL mappings used to override base class implementations |
|
42
|
|
|
|
|
|
|
my @NULL_MAP = qw/ /; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# unit mapping implies that the value propogates directly |
|
45
|
|
|
|
|
|
|
# to the output with only a keyword name change |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my %UNIT_MAP = ( |
|
48
|
|
|
|
|
|
|
DETECTOR_READ_TYPE => "MODE", |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Create the translation methods |
|
53
|
|
|
|
|
|
|
__PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP ); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item B<this_instrument> |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The name of the instrument required to match (case insensitively) |
|
62
|
|
|
|
|
|
|
against the INSTRUME/INSTRUMENT keyword to allow this class to |
|
63
|
|
|
|
|
|
|
translate the specified headers. Called by the default |
|
64
|
|
|
|
|
|
|
C<can_translate> method. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$inst = $class->this_instrument(); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns "NIRI". |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return qr/^NIRI/; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
20
|
|
|
20
|
1
|
78
|
|
|
75
|
|
|
|
|
|
|
=back |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COMPLEX CONVERSIONS |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $self = shift; |
|
84
|
|
|
|
|
|
|
my $FITS_headers = shift; |
|
85
|
|
|
|
|
|
|
my $et = $FITS_headers->{EXPTIME}; |
|
86
|
0
|
|
|
0
|
0
|
|
my $co = $FITS_headers->{COADDS}; |
|
87
|
0
|
|
|
|
|
|
return $et *= $co; |
|
88
|
0
|
|
|
|
|
|
} |
|
89
|
0
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $self = shift; |
|
91
|
|
|
|
|
|
|
my $FITS_headers = shift; |
|
92
|
|
|
|
|
|
|
my $obsnum = 0; |
|
93
|
|
|
|
|
|
|
if ( exists ( $FITS_headers->{FRMNAME} ) ) { |
|
94
|
0
|
|
|
0
|
0
|
|
my $fname = $FITS_headers->{FRMNAME}; |
|
95
|
0
|
|
|
|
|
|
$obsnum = substr( $fname, index( $fname, ":" ) - 4, 4 ); |
|
96
|
0
|
|
|
|
|
|
} |
|
97
|
0
|
0
|
|
|
|
|
return $obsnum; |
|
98
|
0
|
|
|
|
|
|
} |
|
99
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item B<to_ROTATION> |
|
101
|
0
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Converts a linear transformation CD matrix into a single rotation angle. |
|
103
|
|
|
|
|
|
|
This angle is measured counter-clockwise from the positive x-axis. |
|
104
|
|
|
|
|
|
|
It uses the SLALIB routine slaDcmpf obtain the rotation angle without |
|
105
|
|
|
|
|
|
|
assuming perpendicular axes. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This routine also copes with errors in the matrix that can generate angles |
|
108
|
|
|
|
|
|
|
+/-90 degrees instead of near 0 that they should be. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $self = shift; |
|
113
|
|
|
|
|
|
|
my $FITS_headers = shift; |
|
114
|
|
|
|
|
|
|
my $rotation = 0.0; |
|
115
|
|
|
|
|
|
|
if ( exists( $FITS_headers->{CD1_1} ) ) { |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
0
|
1
|
|
# Access the CD matrix. |
|
118
|
0
|
|
|
|
|
|
my $cd11 = $FITS_headers->{"CD1_1"}; |
|
119
|
0
|
|
|
|
|
|
my $cd12 = $FITS_headers->{"CD1_2"}; |
|
120
|
0
|
0
|
|
|
|
|
my $cd21 = $FITS_headers->{"CD2_1"}; |
|
121
|
|
|
|
|
|
|
my $cd22 = $FITS_headers->{"CD2_2"}; |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
# Determine the orientation using PAL routine. This has the |
|
124
|
0
|
|
|
|
|
|
# advantage of not assuming perpendicular axes (i.e. allows for |
|
125
|
0
|
|
|
|
|
|
# shear). |
|
126
|
0
|
|
|
|
|
|
my ( $xz, $yz, $xs, $ys, $perp ); |
|
127
|
|
|
|
|
|
|
my @coeffs = ( 0.0, $cd11, $cd21, 0.0, $cd12, $cd22 ); |
|
128
|
|
|
|
|
|
|
eval { |
|
129
|
|
|
|
|
|
|
require Astro::PAL; |
|
130
|
|
|
|
|
|
|
( $xz, $yz, $xs, $ys, $perp, $rotation ) = Astro::PAL::palDcmpf( \@coeffs ); |
|
131
|
0
|
|
|
|
|
|
}; |
|
132
|
0
|
|
|
|
|
|
if (!defined $perp) { |
|
133
|
0
|
|
|
|
|
|
croak "NIRI translations require Astro::PAL"; |
|
134
|
0
|
|
|
|
|
|
} |
|
135
|
0
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Convert from radians to degrees. |
|
137
|
0
|
0
|
|
|
|
|
my $rtod = 45 / atan2( 1, 1 ); |
|
138
|
0
|
|
|
|
|
|
$rotation *= $rtod; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# The actual WCS matrix has errors and sometimes the angle which |
|
141
|
|
|
|
|
|
|
# should be near 0 degrees, can be out by 90 degrees. So for this |
|
142
|
0
|
|
|
|
|
|
# case we hardwire the main rotation and merely apply the small |
|
143
|
0
|
|
|
|
|
|
# deviation from the cardinal orientations. |
|
144
|
|
|
|
|
|
|
if ( abs( abs( $rotation ) - 90 ) < 2 ) { |
|
145
|
|
|
|
|
|
|
my $delta_rho = 0.0; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$delta_rho = $rotation - ( 90 * int( $rotation / 90 ) ); |
|
148
|
|
|
|
|
|
|
$delta_rho -= 90 if ( $delta_rho > 45 ); |
|
149
|
0
|
0
|
|
|
|
|
$delta_rho += 90 if ( $delta_rho < -45 ); |
|
150
|
0
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# Setting to near 180 is a fudge because the CD matrix appears is wrong |
|
152
|
0
|
|
|
|
|
|
# occasionally by 90 degrees, judging by the telescope offsets, CTYPEn, and |
|
153
|
0
|
0
|
|
|
|
|
# the support astronomer. |
|
154
|
0
|
0
|
|
|
|
|
$rotation = 180.0 + $delta_rho; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
return $rotation; |
|
159
|
0
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Shift the bounds to GRID co-ordinates. |
|
162
|
|
|
|
|
|
|
my $self = shift; |
|
163
|
0
|
|
|
|
|
|
my $FITS_headers = shift; |
|
164
|
|
|
|
|
|
|
my $bound = 1; |
|
165
|
|
|
|
|
|
|
if ( exists( $FITS_headers->{LOWCOL} ) ) { |
|
166
|
|
|
|
|
|
|
$bound = $self->nint( $FITS_headers->{LOWCOL} + 1 ); |
|
167
|
|
|
|
|
|
|
} |
|
168
|
0
|
|
|
0
|
0
|
|
return $bound; |
|
169
|
0
|
|
|
|
|
|
} |
|
170
|
0
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
my $self = shift; |
|
172
|
0
|
|
|
|
|
|
my $FITS_headers = shift; |
|
173
|
|
|
|
|
|
|
my $bound = 1; |
|
174
|
0
|
|
|
|
|
|
if ( exists( $FITS_headers->{LOWROW} ) ) { |
|
175
|
|
|
|
|
|
|
$bound = $self->nint( $FITS_headers->{LOWROW} + 1 ); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
return $bound; |
|
178
|
0
|
|
|
0
|
0
|
|
} |
|
179
|
0
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
my $self = shift; |
|
181
|
0
|
0
|
|
|
|
|
my $FITS_headers = shift; |
|
182
|
0
|
|
|
|
|
|
my $bound = 1024; |
|
183
|
|
|
|
|
|
|
if ( exists( $FITS_headers->{HICOL} ) ) { |
|
184
|
0
|
|
|
|
|
|
$bound = $self->nint( $FITS_headers->{HICOL} + 1 ); |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
return $bound; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
0
|
|
|
0
|
0
|
|
|
|
189
|
0
|
|
|
|
|
|
my $self = shift; |
|
190
|
0
|
|
|
|
|
|
my $FITS_headers = shift; |
|
191
|
0
|
0
|
|
|
|
|
my $bound = 1024; |
|
192
|
0
|
|
|
|
|
|
if ( exists( $FITS_headers->{HIROW} ) ) { |
|
193
|
|
|
|
|
|
|
$bound = $self->nint( $FITS_headers->{HIROW} + 1 ); |
|
194
|
0
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
return $bound; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
|
|
0
|
0
|
|
|
|
199
|
0
|
|
|
|
|
|
=back |
|
200
|
0
|
|
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
|
=head1 SEE ALSO |
|
202
|
0
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>. |
|
204
|
0
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 AUTHOR |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt> |
|
208
|
|
|
|
|
|
|
Paul Hirst E<lt>p.hirst@jach.hawaii.eduE<gt>, |
|
209
|
|
|
|
|
|
|
Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Copyright (C) 2008 Science and Technology Facilities Council |
|
214
|
|
|
|
|
|
|
Copyright (C) 1998-2005 Particle Physics and Astronomy Research Council. |
|
215
|
|
|
|
|
|
|
All Rights Reserved. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
218
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
|
219
|
|
|
|
|
|
|
Foundation; either Version 2 of the License, or (at your option) any later |
|
220
|
|
|
|
|
|
|
version. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,but WITHOUT ANY |
|
223
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
224
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
|
227
|
|
|
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|
228
|
|
|
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307, USA. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
1; |