HdrTrans/CGS4New.pm

filter: Statementstmt 51.0% 24 / 47 Branchbran 12.5% 2 / 16 Conditioncond 29.6% 8 / 27 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 75.0% 6 / 8 Podpod 100% 3 / 3 totaltotal 38.0% 43 / 113 CC 18 SCAR 39.3
CC
18
Cov
38%
to_ROTATION
110.0
can_translate
18.1
to_UTDATE
2.0
CRAP 50.8
« HdrTrans/FITS.pm ↑ Summary HdrTrans/LCOFLI_1m0.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 our $VERSION = "1.66";
30  
31 10 my %CONST_MAP = ( OBSERVATION_MODE => 'spectroscopy',
32 );
33  
34 10 my %UNIT_MAP = ( DEC_BASE => "DECBASE",
35 DEC_SCALE => "CDELT3",
36 EXPOSURE_TIME => "DEXPTIME",
37 GRATING_DISPERSION => "GDISP",
38 GRATING_NAME => "GRATING",
39 GRATING_ORDER => "GORDER",
40 GRATING_WAVELENGTH => "GLAMBDA",
41 NSCAN_POSITIONS => "DETNINCR",
42 RA_BASE => "RABASE",
43 RA_SCALE => "CDELT2",
44 SCAN_INCREMENT => "DETINCR",
45 SLIT_ANGLE => "SANGLE",
46 SLIT_NAME => "SLIT",
47 SLIT_WIDTH => "SWIDTH",
48 X_BASE => "CRVAL2",
49 X_REFERENCE_PIXEL => "CRPIX2",
50 Y_BASE => "CRVAL3",
51 Y_REFERENCE_PIXEL => "CRPIX3",
52 );
53  
54 # Create the translation methods
55 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP );
56  
57 =head1 METHODS
58  
59 =over 4
60  
61 =item B<can_translate>
62  
63 Returns true if the supplied headers can be handled by this class.
64  
65 $cando = $class->can_translate( \%hdrs );
66  
67 This method returns tru if the INSTRUME header exists and is equal to
68 'CGS4', and if the DHSVER header exists and is equal to 'UKDHS 2008
69 Dec. 1'.
70  
71 =cut
72  
73 20 ▶sub can_translate {
Subroutine can_translate: called CC=9 SCAR=29.0
Pod documented
74 20 my $self = shift;
75 20 my $headers = shift;
76  
77 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
78 uc( $headers->{INSTRUME} ) eq 'CGS4' &&
79 exists( $headers->{DHSVER} ) &&
80 uc( $headers->{DHSVER} ) eq 'UKDHS 2008 DEC. 1' ) {
81 0 return 1;
82 }
83  
84 # Handle the reverse case as well. This module can translate CGS4
85 # headers newer than 20081115.
86 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
87 uc( $headers->{INSTRUMENT} ) eq 'CGS4' &&
88 exists $headers->{UTDATE} &&
89 $headers->{UTDATE} >= 20081115 ) {
90 0 return 1;
91 }
92  
93 20 return 0;
94 }
95  
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 0 ▶sub to_ROTATION {
Subroutine to_ROTATION: not called CC=10 SCAR=47.0
Pod documented
114 0 my $self = shift;
115 0 my $FITS_headers = shift;
116 0 my $rotation;
117  
118 0 my $rtod = 45 / atan2( 1, 1 );
119  
120 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
121 defined( $FITS_headers->{PC3_2} ) || defined( $FITS_headers->{PC3_3} ) ) {
122 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
123 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
124 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
125 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
126  
127 # Average the estimates of the rotation converting from radians to
128 # degrees (rtod) as the matrix may not represent a pure rotation.
129 0 $rotation = $rtod * 0.5 * ( atan2( -$pc32 / $rtod, $pc22 / $rtod ) +
130 atan2( $pc23 / $rtod, $pc33 / $rtod ) );
131  
132 } elsif ( exists $FITS_headers->{CROTA2} ) {
133 0 $rotation = $FITS_headers->{CROTA2} + 90.0;
134 } else {
135 0 $rotation = 90.0;
136 }
137 0 return $rotation;
138 }
139  
140 =item B<to_UTDATE>
141  
142 Sets the YYYYMMDD-style UTDATE generic header based on the DATE-OBS
143 header.
144  
145 =cut
146  
147 0 ▶sub to_UTDATE {
Subroutine to_UTDATE: not called CC=1 SCAR=6.9
Pod documented
148 0 my $self = shift;
149 0 my $FITS_headers = shift;
150 0 my $utdate;
151  
152 0 my $dateobs = $FITS_headers->{'DATE-OBS'};
153 0 $dateobs =~ /^(\d{4}-\d\d-\d\d)/;
154 0 $utdate = $1;
155 0 $utdate =~ s/-//g;
156  
157 0 return $utdate;
158 }
159  
160 =back
161  
162 =head1 SEE ALSO
163  
164 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>.
165  
166 =head1 AUTHOR
167  
168 Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt>
169 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
170 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
171  
172 =head1 COPYRIGHT
173  
174 Copyright (C) 2008 Science and Technology Facilities Council.
175 Copyright (C) 2003-2005 Particle Physics and Astronomy Research Council.
176 All Rights Reserved.
177  
178 This program is free software; you can redistribute it and/or modify it under
179 the terms of the GNU General Public License as published by the Free Software
180 Foundation; either Version 2 of the License, or (at your option) any later
181 version.
182  
183 This program is distributed in the hope that it will be useful,but WITHOUT ANY
184 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
185 PARTICULAR PURPOSE. See the GNU General Public License for more details.
186  
187 You should have received a copy of the GNU General Public License along with
188 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
189 Place, Suite 330, Boston, MA 02111-1307, USA.
190  
191 =cut
192  
193 10 1;
« HdrTrans/FITS.pm ↑ Summary HdrTrans/LCOFLI_1m0.pm »