line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Astro::FITS::HdrTrans::CGS4New - UKIRT CGS4 translations for "new" |
5
|
|
|
|
|
|
|
style CGS4 headers. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Astro::FITS::HdrTrans::CGS4New; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
%gen = Astro::FITS::HdrTrans::CGS4New->translate_from_FITS( %hdr ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This class provides a generic set of translations that are specific to |
16
|
|
|
|
|
|
|
the CGS4 spectrometer of the United Kingdom Infrared Telescope. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use 5.006; |
21
|
10
|
|
|
10
|
|
24742785
|
use warnings; |
|
10
|
|
|
|
|
40
|
|
22
|
10
|
|
|
10
|
|
43
|
use strict; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
358
|
|
23
|
10
|
|
|
10
|
|
121
|
use Carp; |
|
10
|
|
|
|
|
30
|
|
|
10
|
|
|
|
|
295
|
|
24
|
10
|
|
|
10
|
|
43
|
|
|
10
|
|
|
|
|
34
|
|
|
10
|
|
|
|
|
787
|
|
25
|
|
|
|
|
|
|
# Inherit from UIST |
26
|
|
|
|
|
|
|
use base qw/ Astro::FITS::HdrTrans::UIST /; |
27
|
10
|
|
|
10
|
|
57
|
|
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
4015
|
|
28
|
|
|
|
|
|
|
use vars qw/ $VERSION /; |
29
|
10
|
|
|
10
|
|
59
|
|
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
4237
|
|
30
|
|
|
|
|
|
|
$VERSION = "1.65"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %CONST_MAP = ( OBSERVATION_MODE => 'spectroscopy', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my %UNIT_MAP = ( DEC_BASE => "DECBASE", |
36
|
|
|
|
|
|
|
DEC_SCALE => "CDELT3", |
37
|
|
|
|
|
|
|
EXPOSURE_TIME => "DEXPTIME", |
38
|
|
|
|
|
|
|
GRATING_DISPERSION => "GDISP", |
39
|
|
|
|
|
|
|
GRATING_NAME => "GRATING", |
40
|
|
|
|
|
|
|
GRATING_ORDER => "GORDER", |
41
|
|
|
|
|
|
|
GRATING_WAVELENGTH => "GLAMBDA", |
42
|
|
|
|
|
|
|
NSCAN_POSITIONS => "DETNINCR", |
43
|
|
|
|
|
|
|
RA_BASE => "RABASE", |
44
|
|
|
|
|
|
|
RA_SCALE => "CDELT2", |
45
|
|
|
|
|
|
|
SCAN_INCREMENT => "DETINCR", |
46
|
|
|
|
|
|
|
SLIT_ANGLE => "SANGLE", |
47
|
|
|
|
|
|
|
SLIT_NAME => "SLIT", |
48
|
|
|
|
|
|
|
SLIT_WIDTH => "SWIDTH", |
49
|
|
|
|
|
|
|
X_BASE => "CRVAL2", |
50
|
|
|
|
|
|
|
X_REFERENCE_PIXEL => "CRPIX2", |
51
|
|
|
|
|
|
|
Y_BASE => "CRVAL3", |
52
|
|
|
|
|
|
|
Y_REFERENCE_PIXEL => "CRPIX3", |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Create the translation methods |
56
|
|
|
|
|
|
|
__PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 METHODS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item B<can_translate> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns true if the supplied headers can be handled by this class. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$cando = $class->can_translate( \%hdrs ); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This method returns tru if the INSTRUME header exists and is equal to |
69
|
|
|
|
|
|
|
'CGS4', and if the DHSVER header exists and is equal to 'UKDHS 2008 |
70
|
|
|
|
|
|
|
Dec. 1'. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
my $headers = shift; |
76
|
20
|
|
|
20
|
1
|
46
|
|
77
|
20
|
|
|
|
|
38
|
if ( exists( $headers->{INSTRUME} ) && |
78
|
|
|
|
|
|
|
uc( $headers->{INSTRUME} ) eq 'CGS4' && |
79
|
20
|
50
|
66
|
|
|
108
|
exists( $headers->{DHSVER} ) && |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
80
|
|
|
|
|
|
|
uc( $headers->{DHSVER} ) eq 'UKDHS 2008 DEC. 1' ) { |
81
|
|
|
|
|
|
|
return 1; |
82
|
|
|
|
|
|
|
} |
83
|
0
|
|
|
|
|
0
|
|
84
|
|
|
|
|
|
|
# Handle the reverse case as well. This module can translate CGS4 |
85
|
|
|
|
|
|
|
# headers newer than 20081115. |
86
|
|
|
|
|
|
|
if ( exists $headers->{INSTRUMENT} && |
87
|
|
|
|
|
|
|
uc( $headers->{INSTRUMENT} ) eq 'CGS4' && |
88
|
20
|
0
|
33
|
|
|
2824
|
exists $headers->{UTDATE} && |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
89
|
|
|
|
|
|
|
$headers->{UTDATE} >= 20081115 ) { |
90
|
|
|
|
|
|
|
return 1; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
0
|
|
93
|
|
|
|
|
|
|
return 0; |
94
|
|
|
|
|
|
|
} |
95
|
20
|
|
|
|
|
234
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COMPLEX CONVERSIONS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over 4 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item B<to_ROTATION> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This determines the angle, in decimal degrees, of the rotation of the |
105
|
|
|
|
|
|
|
sky component of the WCS. It uses the standard transformation matrix |
106
|
|
|
|
|
|
|
PCi_j as defined in the FITS WCS Standard. In the absence of a PCi_j |
107
|
|
|
|
|
|
|
matrix, it looks for the CROTA2 keyword. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
For CGS4 the PCi_j matrix is obtained from i=[2,3] and j=[2,3]. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $self = shift; |
114
|
|
|
|
|
|
|
my $FITS_headers = shift; |
115
|
|
|
|
|
|
|
my $rotation; |
116
|
0
|
|
|
0
|
1
|
|
|
117
|
0
|
|
|
|
|
|
my $rtod = 45 / atan2( 1, 1 ); |
118
|
0
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
if ( defined( $FITS_headers->{PC2_2} ) || defined( $FITS_headers->{PC2_3} ) || |
120
|
0
|
|
|
|
|
|
defined( $FITS_headers->{PC3_2} ) || defined( $FITS_headers->{PC3_3} ) ) { |
121
|
|
|
|
|
|
|
my $pc22 = defined( $FITS_headers->{PC2_2} ) ? $FITS_headers->{PC2_2} : 1.0; |
122
|
0
|
0
|
0
|
|
|
|
my $pc32 = defined( $FITS_headers->{PC3_2} ) ? $FITS_headers->{PC3_2} : 0.0; |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
123
|
|
|
|
|
|
|
my $pc23 = defined( $FITS_headers->{PC2_3} ) ? $FITS_headers->{PC2_3} : 0.0; |
124
|
0
|
0
|
|
|
|
|
my $pc33 = defined( $FITS_headers->{PC3_3} ) ? $FITS_headers->{PC3_3} : 1.0; |
125
|
0
|
0
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
|
# Average the estimates of the rotation converting from radians to |
127
|
0
|
0
|
|
|
|
|
# degrees (rtod) as the matrix may not represent a pure rotation. |
128
|
|
|
|
|
|
|
$rotation = $rtod * 0.5 * ( atan2( -$pc32 / $rtod, $pc22 / $rtod ) + |
129
|
|
|
|
|
|
|
atan2( $pc23 / $rtod, $pc33 / $rtod ) ); |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
} elsif ( exists $FITS_headers->{CROTA2} ) { |
132
|
|
|
|
|
|
|
$rotation = $FITS_headers->{CROTA2} + 90.0; |
133
|
|
|
|
|
|
|
} else { |
134
|
|
|
|
|
|
|
$rotation = 90.0; |
135
|
0
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
return $rotation; |
137
|
0
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
=item B<to_UTDATE> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Sets the YYYYMMDD-style UTDATE generic header based on the DATE-OBS |
142
|
|
|
|
|
|
|
header. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
my $self = shift; |
147
|
|
|
|
|
|
|
my $FITS_headers = shift; |
148
|
|
|
|
|
|
|
my $utdate; |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
0
|
1
|
|
my $dateobs = $FITS_headers->{'DATE-OBS'}; |
151
|
0
|
|
|
|
|
|
$dateobs =~ /^(\d{4}-\d\d-\d\d)/; |
152
|
0
|
|
|
|
|
|
$utdate = $1; |
153
|
|
|
|
|
|
|
$utdate =~ s/-//g; |
154
|
0
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
return $utdate; |
156
|
0
|
|
|
|
|
|
} |
157
|
0
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
0
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SEE ALSO |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt> |
167
|
|
|
|
|
|
|
Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>, |
168
|
|
|
|
|
|
|
Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 COPYRIGHT |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Copyright (C) 2008 Science and Technology Facilities Council. |
173
|
|
|
|
|
|
|
Copyright (C) 2003-2005 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 2 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; |