line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::FITS::HdrTrans::CGS4New; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Astro::FITS::HdrTrans::CGS4New - UKIRT CGS4 translations for "new" |
6
|
|
|
|
|
|
|
style CGS4 headers. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Astro::FITS::HdrTrans::CGS4New; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
%gen = Astro::FITS::HdrTrans::CGS4New->translate_from_FITS( %hdr ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This class provides a generic set of translations that are specific to |
17
|
|
|
|
|
|
|
the CGS4 spectrometer of the United Kingdom Infrared Telescope. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
10
|
|
|
10
|
|
32495169
|
use 5.006; |
|
10
|
|
|
|
|
49
|
|
22
|
10
|
|
|
10
|
|
58
|
use warnings; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
366
|
|
23
|
10
|
|
|
10
|
|
59
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
288
|
|
24
|
10
|
|
|
10
|
|
54
|
use Carp; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
860
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Inherit from UIST |
27
|
10
|
|
|
10
|
|
77
|
use base qw/ Astro::FITS::HdrTrans::UIST /; |
|
10
|
|
|
|
|
41
|
|
|
10
|
|
|
|
|
5100
|
|
28
|
|
|
|
|
|
|
|
29
|
10
|
|
|
10
|
|
72
|
use vars qw/ $VERSION /; |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
5108
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$VERSION = "1.63"; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my %CONST_MAP = ( OBSERVATION_MODE => 'spectroscopy', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my %UNIT_MAP = ( DEC_BASE => "DECBASE", |
37
|
|
|
|
|
|
|
DEC_SCALE => "CDELT3", |
38
|
|
|
|
|
|
|
EXPOSURE_TIME => "DEXPTIME", |
39
|
|
|
|
|
|
|
GRATING_DISPERSION => "GDISP", |
40
|
|
|
|
|
|
|
GRATING_NAME => "GRATING", |
41
|
|
|
|
|
|
|
GRATING_ORDER => "GORDER", |
42
|
|
|
|
|
|
|
GRATING_WAVELENGTH => "GLAMBDA", |
43
|
|
|
|
|
|
|
NSCAN_POSITIONS => "DETNINCR", |
44
|
|
|
|
|
|
|
RA_BASE => "RABASE", |
45
|
|
|
|
|
|
|
RA_SCALE => "CDELT2", |
46
|
|
|
|
|
|
|
SCAN_INCREMENT => "DETINCR", |
47
|
|
|
|
|
|
|
SLIT_ANGLE => "SANGLE", |
48
|
|
|
|
|
|
|
SLIT_NAME => "SLIT", |
49
|
|
|
|
|
|
|
SLIT_WIDTH => "SWIDTH", |
50
|
|
|
|
|
|
|
X_BASE => "CRVAL2", |
51
|
|
|
|
|
|
|
X_REFERENCE_PIXEL => "CRPIX2", |
52
|
|
|
|
|
|
|
Y_BASE => "CRVAL3", |
53
|
|
|
|
|
|
|
Y_REFERENCE_PIXEL => "CRPIX3", |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Create the translation methods |
57
|
|
|
|
|
|
|
__PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP ); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over 4 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item B<can_translate> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns true if the supplied headers can be handled by this class. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$cando = $class->can_translate( \%hdrs ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This method returns tru if the INSTRUME header exists and is equal to |
70
|
|
|
|
|
|
|
'CGS4', and if the DHSVER header exists and is equal to 'UKDHS 2008 |
71
|
|
|
|
|
|
|
Dec. 1'. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub can_translate { |
76
|
20
|
|
|
20
|
1
|
47
|
my $self = shift; |
77
|
20
|
|
|
|
|
69
|
my $headers = shift; |
78
|
|
|
|
|
|
|
|
79
|
20
|
50
|
66
|
|
|
124
|
if ( exists( $headers->{INSTRUME} ) && |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
80
|
|
|
|
|
|
|
uc( $headers->{INSTRUME} ) eq 'CGS4' && |
81
|
|
|
|
|
|
|
exists( $headers->{DHSVER} ) && |
82
|
|
|
|
|
|
|
uc( $headers->{DHSVER} ) eq 'UKDHS 2008 DEC. 1' ) { |
83
|
0
|
|
|
|
|
0
|
return 1; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Handle the reverse case as well. This module can translate CGS4 |
87
|
|
|
|
|
|
|
# headers newer than 20081115. |
88
|
20
|
0
|
33
|
|
|
1695
|
if ( exists $headers->{INSTRUMENT} && |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
89
|
|
|
|
|
|
|
uc( $headers->{INSTRUMENT} ) eq 'CGS4' && |
90
|
|
|
|
|
|
|
exists $headers->{UTDATE} && |
91
|
|
|
|
|
|
|
$headers->{UTDATE} >= 20081115 ) { |
92
|
0
|
|
|
|
|
0
|
return 1; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
20
|
|
|
|
|
276
|
return 0; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COMPLEX CONVERSIONS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item B<to_ROTATION> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This determines the angle, in decimal degrees, of the rotation of the |
107
|
|
|
|
|
|
|
sky component of the WCS. It uses the standard transformation matrix |
108
|
|
|
|
|
|
|
PCi_j as defined in the FITS WCS Standard. In the absence of a PCi_j |
109
|
|
|
|
|
|
|
matrix, it looks for the CROTA2 keyword. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
For CGS4 the PCi_j matrix is obtained from i=[2,3] and j=[2,3]. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub to_ROTATION { |
116
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
117
|
0
|
|
|
|
|
|
my $FITS_headers = shift; |
118
|
0
|
|
|
|
|
|
my $rotation; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $rtod = 45 / atan2( 1, 1 ); |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
0
|
|
|
|
if ( defined( $FITS_headers->{PC2_2} ) || defined( $FITS_headers->{PC2_3} ) || |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
123
|
|
|
|
|
|
|
defined( $FITS_headers->{PC3_2} ) || defined( $FITS_headers->{PC3_3} ) ) { |
124
|
0
|
0
|
|
|
|
|
my $pc22 = defined( $FITS_headers->{PC2_2} ) ? $FITS_headers->{PC2_2} : 1.0; |
125
|
0
|
0
|
|
|
|
|
my $pc32 = defined( $FITS_headers->{PC3_2} ) ? $FITS_headers->{PC3_2} : 0.0; |
126
|
0
|
0
|
|
|
|
|
my $pc23 = defined( $FITS_headers->{PC2_3} ) ? $FITS_headers->{PC2_3} : 0.0; |
127
|
0
|
0
|
|
|
|
|
my $pc33 = defined( $FITS_headers->{PC3_3} ) ? $FITS_headers->{PC3_3} : 1.0; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Average the estimates of the rotation converting from radians to |
130
|
|
|
|
|
|
|
# degrees (rtod) as the matrix may not represent a pure rotation. |
131
|
0
|
|
|
|
|
|
$rotation = $rtod * 0.5 * ( atan2( -$pc32 / $rtod, $pc22 / $rtod ) + |
132
|
|
|
|
|
|
|
atan2( $pc23 / $rtod, $pc33 / $rtod ) ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} elsif ( exists $FITS_headers->{CROTA2} ) { |
135
|
0
|
|
|
|
|
|
$rotation = $FITS_headers->{CROTA2} + 90.0; |
136
|
|
|
|
|
|
|
} else { |
137
|
0
|
|
|
|
|
|
$rotation = 90.0; |
138
|
|
|
|
|
|
|
} |
139
|
0
|
|
|
|
|
|
return $rotation; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item B<to_UTDATE> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Sets the YYYYMMDD-style UTDATE generic header based on the DATE-OBS |
145
|
|
|
|
|
|
|
header. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub to_UTDATE { |
150
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
151
|
0
|
|
|
|
|
|
my $FITS_headers = shift; |
152
|
0
|
|
|
|
|
|
my $utdate; |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my $dateobs = $FITS_headers->{'DATE-OBS'}; |
155
|
0
|
|
|
|
|
|
$dateobs =~ /^(\d{4}-\d\d-\d\d)/; |
156
|
0
|
|
|
|
|
|
$utdate = $1; |
157
|
0
|
|
|
|
|
|
$utdate =~ s/-//g; |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
return $utdate; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=back |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SEE ALSO |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt> |
171
|
|
|
|
|
|
|
Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>, |
172
|
|
|
|
|
|
|
Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 COPYRIGHT |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Copyright (C) 2008 Science and Technology Facilities Council. |
177
|
|
|
|
|
|
|
Copyright (C) 2003-2005 Particle Physics and Astronomy Research Council. |
178
|
|
|
|
|
|
|
All Rights Reserved. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
181
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
182
|
|
|
|
|
|
|
Foundation; either Version 2 of the License, or (at your option) any later |
183
|
|
|
|
|
|
|
version. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,but WITHOUT ANY |
186
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
187
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
190
|
|
|
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
191
|
|
|
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307, USA. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
1; |