blib/lib/Astro/FITS/HdrTrans/CGS4New.pm

filter: Statementstmt 54.0% 27 / 50 Branchbran 12.5% 2 / 16 Conditioncond 29.6% 8 / 27 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 77.7% 7 / 9 Podpod 100% 3 / 3 totaltotal 40.1% 47 / 117 SCAR 44.9
CC
18
Cov
40%
to_ROTATION
110.0
can_translate
18.1
to_UTDATE
2.0
CRAP 88.7
« blib/lib/Astro/FITS/HdrTrans/CGS4Old.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/FITS.pm »
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 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # Inherit from UIST
27 10 ▶use base qw/ Astro::FITS::HdrTrans::UIST /;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 10 ▶use vars qw/ $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 10 $VERSION = "1.64";
32  
33 10 my %CONST_MAP = ( OBSERVATION_MODE => 'spectroscopy',
34 );
35  
36 10 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 10 __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 ▶ my $self = shift;
Subroutine can_translate: called CC=9 SCAR=29.0
Pod documented
77 20 my $headers = shift;
78  
79 20 ▶ if ( exists( $headers->{INSTRUME} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $headers->{"INSTRUME"} and uc $headers->{"INSTRUME"} eq "CGS4" and exists $headers->{"DHSVER"} and uc $headers->{"DHSVER"} eq "UKDHS 2008 DEC. 1") 0 20 20
Condition55%5/9
exists $headers->{"INSTRUME"} and uc $headers->{"INSTRUME"} eq "CGS4" and exists $headers->{"DHSVER"} and uc $headers->{"DHSVER"} eq "UKDHS 2008 DEC. 1"
!ll&&!rl&&r
2000
exists $headers->{"INSTRUME"} and uc $headers->{"INSTRUME"} eq "CGS4" and exists $headers->{"DHSVER"}
!ll&&!rl&&r
1820
exists $headers->{"INSTRUME"} and uc $headers->{"INSTRUME"} eq "CGS4"
!ll&&!rl&&r
0182
MC/DC0%0/4
exists $headers->{"INSTRUME"} and uc $headers->{"INSTRUME"} eq "CGS4" and exists $headers->{"DHSVER"} and uc $headers->{"DHSVER"} eq "UKDHS 2008 DEC. 1"
exists $headers->{"INSTRUME"} uc $headers->{"INSTRUME"} eq "CGS4" exists $headers->{"DHSVER"} uc $headers->{"DHSVER"} eq "UKDHS 2008 DEC. 1"
Truth table40%2/5
A and B and C and D
A= exists $headers->{"INSTRUME"}B= uc $headers->{"INSTRUME"} eq "CGS4"C= exists $headers->{"DHSVER"}D= uc $headers->{"DHSVER"} eq "UKDHS 2008 DEC. 1"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
80 uc( $headers->{INSTRUME} ) eq 'CGS4' &&
81 exists( $headers->{DHSVER} ) &&
82 uc( $headers->{DHSVER} ) eq 'UKDHS 2008 DEC. 1' ) {
83 0 return 1;
84 }
85  
86 # Handle the reverse case as well. This module can translate CGS4
87 # headers newer than 20081115.
88 20 ▶ if ( exists $headers->{INSTRUMENT} &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $headers->{"INSTRUMENT"} and uc $headers->{"INSTRUMENT"} eq "CGS4" and exists $headers->{"UTDATE"} and $headers->{"UTDATE"} >= 20081115) 0 20 20
Condition33%3/9
exists $headers->{"INSTRUMENT"} and uc $headers->{"INSTRUMENT"} eq "CGS4" and exists $headers->{"UTDATE"} and $headers->{"UTDATE"} >= 20081115
!ll&&!rl&&r
2000
exists $headers->{"INSTRUMENT"} and uc $headers->{"INSTRUMENT"} eq "CGS4" and exists $headers->{"UTDATE"}
!ll&&!rl&&r
2000
exists $headers->{"INSTRUMENT"} and uc $headers->{"INSTRUMENT"} eq "CGS4"
!ll&&!rl&&r
2000
MC/DC0%0/4
exists $headers->{"INSTRUMENT"} and uc $headers->{"INSTRUMENT"} eq "CGS4" and exists $headers->{"UTDATE"} and $headers->{"UTDATE"} >= 20081115
exists $headers->{"INSTRUMENT"} uc $headers->{"INSTRUMENT"} eq "CGS4" exists $headers->{"UTDATE"} $headers->{"UTDATE"} >= 20081115
Truth table20%1/5
A and B and C and D
A= exists $headers->{"INSTRUMENT"}B= uc $headers->{"INSTRUMENT"} eq "CGS4"C= exists $headers->{"UTDATE"}D= $headers->{"UTDATE"} >= 20081115
ABCDresult
0XXX0
10XX0
110X0
11100
11111
89 uc( $headers->{INSTRUMENT} ) eq 'CGS4' &&
90 exists $headers->{UTDATE} &&
91 $headers->{UTDATE} >= 20081115 ) {
92 0 return 1;
93 }
94  
95 20 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 ▶ my $self = shift;
Subroutine to_ROTATION: not called CC=10 SCAR=47.0
Pod documented
117 0 my $FITS_headers = shift;
118 0 my $rotation;
119  
120 0 my $rtod = 45 / atan2( 1, 1 );
121  
122 0 ▶ if ( defined( $FITS_headers->{PC2_2} ) || defined( $FITS_headers->{PC2_3} ) ||
Branch: 2 branches
BranchTrueFalseTotal
if (defined $FITS_headers->{'PC2_2'} or defined $FITS_headers->{'PC2_3'} or defined $FITS_headers->{'PC3_2'} or defined $FITS_headers->{'PC3_3'}) { } 0 0 0
elsif (exists $FITS_headers->{'CROTA2'}) { } 0 0 0
Condition0%0/9
defined $FITS_headers->{"PC2_2"} or defined $FITS_headers->{"PC2_3"} or defined $FITS_headers->{"PC3_2"} or defined $FITS_headers->{"PC3_3"}
l!l&&r!l&&!r
000
defined $FITS_headers->{"PC2_2"} or defined $FITS_headers->{"PC2_3"} or defined $FITS_headers->{"PC3_2"}
l!l&&r!l&&!r
000
defined $FITS_headers->{"PC2_2"} or defined $FITS_headers->{"PC2_3"}
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $FITS_headers->{"PC2_2"} or defined $FITS_headers->{"PC2_3"} or defined $FITS_headers->{"PC3_2"} or defined $FITS_headers->{"PC3_3"}
defined $FITS_headers->{"PC2_2"} defined $FITS_headers->{"PC2_3"} defined $FITS_headers->{"PC3_2"} defined $FITS_headers->{"PC3_3"}
Truth table0%0/5
A or B or C or D
A= defined $FITS_headers->{"PC2_2"}B= defined $FITS_headers->{"PC2_3"}C= defined $FITS_headers->{"PC3_2"}D= defined $FITS_headers->{"PC3_3"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
123 defined( $FITS_headers->{PC3_2} ) || defined( $FITS_headers->{PC3_3} ) ) {
124 0 ▶ my $pc22 = defined( $FITS_headers->{PC2_2} ) ? $FITS_headers->{PC2_2} : 1.0;
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'PC2_2'} ? : 0 0 0
125 0 ▶ my $pc32 = defined( $FITS_headers->{PC3_2} ) ? $FITS_headers->{PC3_2} : 0.0;
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'PC3_2'} ? : 0 0 0
126 0 ▶ my $pc23 = defined( $FITS_headers->{PC2_3} ) ? $FITS_headers->{PC2_3} : 0.0;
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'PC2_3'} ? : 0 0 0
127 0 ▶ my $pc33 = defined( $FITS_headers->{PC3_3} ) ? $FITS_headers->{PC3_3} : 1.0;
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'PC3_3'} ? : 0 0 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 ▶ my $self = shift;
Subroutine to_UTDATE: not called CC=1 SCAR=6.9
Pod documented
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 10 1;
« blib/lib/Astro/FITS/HdrTrans/CGS4Old.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/FITS.pm »