HdrTrans/WFCAM.pm

filter: Statementstmt 88.7% 95 / 107 Branchbran 34.7% 16 / 46 Conditioncond 24.4% 11 / 45 MC/DCmcdc 0.0% 0 / 28 Subroutinesub 100% 17 / 17 Podpod 100% 11 / 11 totaltotal 59.0% 150 / 254 CC 39 SCAR 24.0
CC
39
Cov
62%
to_DEC_SCALE
21.3
to_RA_SCALE
15.1
from_DEC_SCALE
12.4
CRAP 11.0
« HdrTrans/RxH3.pm ↑ Summary HdrTrans/SPEX.pm »
1 package Astro::FITS::HdrTrans::WFCAM;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::WFCAM - UKIRT WFCAM translations
6  
7 =head1 SYNOPSIS
8  
9 use Astro::FITS::HdrTrans::WFCAM;
10  
11 %gen = Astro::FITS::HdrTrans::WFCAM->translate_from_FITS( %hdr );
12  
13 =head1 DESCRIPTION
14  
15 This class provides a generic set of translations that are specific to
16 the WFCAM camera of the United Kingdom Infrared Telescope.
17  
18 =cut
19  
20 10 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # Inherit from UKIRTNew.
26 10 ▶use base qw/ Astro::FITS::HdrTrans::UKIRTNew /;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 # We want the FITS standard versions of DATE-OBS/DATE-END parsing
29 # Not the UKIRT-specific versions that have Z problems.
30 10 ▶use Astro::FITS::HdrTrans::FITS qw/ UTSTART UTEND /;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 10 our $VERSION = "1.66";
33  
34 # For a constant mapping, there is no FITS header, just a generic
35 # header that is constant.
36 10 my %CONST_MAP = (
37 POLARIMETRY => 0,
38 );
39  
40 # NULL mappings used to override base class implementations
41 10 my @NULL_MAP = qw/ DETECTOR_INDEX WAVEPLATE_ANGLE /;
42  
43 # Unit mapping implies that the value propogates directly
44 # to the output with only a keyword name change.
45  
46 10 my %UNIT_MAP = (
47 # WFCAM specific
48 CAMERA_NUMBER => "CAMNUM",
49 DETECTOR_READ_TYPE => "READMODE",
50 NUMBER_OF_COADDS => "NEXP",
51 NUMBER_OF_JITTER_POSITIONS => "NJITTER",
52 NUMBER_OF_MICROSTEP_POSITIONS => "NUSTEP",
53 TILE_NUMBER => "TILENUM",
54  
55 # CGS4 + MICHELLE + WFCAM
56 CONFIGURATION_INDEX => 'CNFINDEX',
57 );
58  
59  
60 # Create the translation methods.
61 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
62  
63 =head1 METHODS
64  
65 =over 4
66  
67 =item B<this_instrument>
68  
69 The name of the instrument required to match (case insensitively)
70 against the INSTRUME/INSTRUMENT keyword to allow this class to
71 translate the specified headers. Called by the default
72 C<can_translate> method.
73  
74 $inst = $class->this_instrument();
75  
76 Returns "WFCAM".
77  
78 =cut
79  
80 20 ▶sub this_instrument {
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
81 20 return "WFCAM";
82 }
83  
84 =back
85  
86 =head1 COMPLEX CONVERSIONS
87  
88 These methods are more complicated than a simple mapping. We have to
89 provide both from- and to-FITS conversions All these routines are
90 methods and the to_ routines all take a reference to a hash and return
91 the translated value (a many-to-one mapping). The from_ methods take
92 a reference to a generic hash and return a translated hash (sometimes
93 these are many-to-many).
94  
95 =over 4
96  
97 =item B<to_DATA_UNITS>
98  
99 Returns the data units. This uses the C<BUNIT> header, with a default
100 of "counts/exp" (unless the observations was with a ND read type
101 between 2006-10-23 and 2006-12-20 when the default was "counts/sec").
102  
103 =cut
104  
105 1 ▶sub to_DATA_UNITS {
Subroutine to_DATA_UNITS: called CC=5 SCAR=20.9
Pod documented
106 1 my $self = shift;
107 1 my $FITS_headers = shift;
108 1 my $data_units = 'counts/exp';
109  
110 1 ▶ if ( defined( $FITS_headers->{BUNIT} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'BUNIT'}) { } 0 1 1
111 0 $data_units = $FITS_headers->{BUNIT};
112 } else {
113 1 my $date = $self->to_UTDATE( $FITS_headers );
114  
115 1 ▶ if ( $date > 20061023 && $date < 20061220 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($date > 20061023 and $date < 20061220) 0 1 1
Condition33%1/3
$date > 20061023 and $date < 20061220
!ll&&!rl&&r
100
MC/DC0%0/2
$date > 20061023 and $date < 20061220
$date > 20061023 $date < 20061220
Truth table33%1/3
A and B
A= $date > 20061023B= $date < 20061220
ABresult
0X0
100
111
116  
117 0 my $read_type = $self->to_DETECTOR_READ_TYPE( $FITS_headers );
118 0 ▶ if ( substr( $read_type, 0, 2 ) eq 'ND' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($read_type, 0, 2) eq "ND") 0 0 0
119  
120 0 $data_units = 'counts/sec';
121 }
122 }
123 }
124  
125 1 return $data_units;
126  
127 }
128  
129 =item B<to_DEC_SCALE>
130  
131 Returns the declination pixel scale in in arcseconds per pixel. For
132 Cameras 1 and 3, it scales the C<CD2_1> keyword to the C<DEC_SCALE>
133 generic header. For Cameras 2 and 4, it scales the C<CD2_2> keyword
134 instead.
135  
136 =cut
137  
138 1 ▶sub to_DEC_SCALE {
Subroutine to_DEC_SCALE: called CC=9 SCAR=30.6
Pod documented
139 1 my $self = shift;
140 1 my $FITS_headers = shift;
141  
142 1 my $scale;
143 1 my $camnum = $self->to_CAMERA_NUMBER( $FITS_headers );
144 1 ▶ if ( defined( $camnum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $camnum) 1 0 1
145 1 ▶ if ( defined( $FITS_headers->{CD2_1} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"CD2_1"} and defined $FITS_headers->{"CD1_2"} and defined $FITS_headers->{"CD2_2"}) 1 0 1
Condition33%2/6
defined $FITS_headers->{"CD2_1"} and defined $FITS_headers->{"CD1_2"} and defined $FITS_headers->{"CD2_2"}
!ll&&!rl&&r
001
defined $FITS_headers->{"CD2_1"} and defined $FITS_headers->{"CD1_2"}
!ll&&!rl&&r
001
MC/DC0%0/3
defined $FITS_headers->{"CD2_1"} and defined $FITS_headers->{"CD1_2"} and defined $FITS_headers->{"CD2_2"}
defined $FITS_headers->{"CD2_1"} defined $FITS_headers->{"CD1_2"} defined $FITS_headers->{"CD2_2"}
Truth table25%1/4
A and B and C
A= defined $FITS_headers->{"CD2_1"}B= defined $FITS_headers->{"CD1_2"}C= defined $FITS_headers->{"CD2_2"}
ABCresult
0XX0
10X0
1100
1111
146 defined( $FITS_headers->{CD1_2} ) &&
147 defined( $FITS_headers->{CD2_2} ) ) {
148  
149 1 ▶ if ( $camnum == 1 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($camnum == 1) { } 1 0 1
elsif ($camnum == 3) { } 0 0 0
elsif ($camnum == 2 or $camnum == 4) { } 0 0 0
150 1 $scale = $FITS_headers->{CD2_1} * 3600;
151 } elsif ( $camnum == 3 ) {
152 0 $scale = $FITS_headers->{CD2_1} * 3600;
153 ▶ } elsif ( $camnum == 2 || $camnum == 4 ) {
Condition0%0/3
$camnum == 2 or $camnum == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$camnum == 2 or $camnum == 4
$camnum == 2 $camnum == 4
Truth table0%0/3
A or B
A= $camnum == 2B= $camnum == 4
ABresult
1X1
011
000
154 0 $scale = $FITS_headers->{CD2_2} * 3600;
155 }
156 }
157 }
158 1 return $scale;
159 }
160  
161 =item B<from_DEC_SCALE>
162  
163 For Cameras 1 and 3, it scales the C<DEC_SCALE> generic header to the
164 C<CD2_1> header. For Cameras 2 and 4, it scales C<DEC_SCALE> to the
165 C<CD2_2> header. The returned units are degrees per pixel.
166  
167 =cut
168  
169 1 ▶sub from_DEC_SCALE {
Subroutine from_DEC_SCALE: called CC=7 SCAR=25.2
Pod documented
170 1 my $self = shift;
171 1 my $generic_headers = shift;
172  
173 1 my %return_hash;
174  
175 1 my $dec_scale = $generic_headers->{'DEC_SCALE'};
176 1 my $camnum = $generic_headers->{'CAMERA_NUMBER'};
177  
178 1 ▶ if ( defined( $dec_scale ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dec_scale and defined $camnum) 1 0 1
Condition33%1/3
defined $dec_scale and defined $camnum
!ll&&!rl&&r
001
MC/DC0%0/2
defined $dec_scale and defined $camnum
defined $dec_scale defined $camnum
Truth table33%1/3
A and B
A= defined $dec_scaleB= defined $camnum
ABresult
0X0
100
111
179 defined( $camnum ) ) {
180  
181 1 ▶ if ( $camnum == 1 || $camnum == 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($camnum == 1 or $camnum == 3) { } 1 0 1
elsif ($camnum == 2 or $camnum == 4) { } 0 0 0
Condition33%1/3
$camnum == 1 or $camnum == 3
l!l&&r!l&&!r
100
MC/DC0%0/2
$camnum == 1 or $camnum == 3
$camnum == 1 $camnum == 3
Truth table33%1/3
A or B
A= $camnum == 1B= $camnum == 3
ABresult
1X1
011
000
182 1 $return_hash{'CD2_1'} = $dec_scale / 3600;
183 ▶ } elsif ( $camnum == 2 || $camnum == 4 ) {
Condition0%0/3
$camnum == 2 or $camnum == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$camnum == 2 or $camnum == 4
$camnum == 2 $camnum == 4
Truth table0%0/3
A or B
A= $camnum == 2B= $camnum == 4
ABresult
1X1
011
000
184 0 $return_hash{'CD2_2'} = $dec_scale / 3600;
185 }
186 }
187  
188 1 return %return_hash;
189 }
190  
191 =item B<to_GAIN>
192  
193 Determines the gain entirely from camera number.
194  
195 The GAIN FITS header is not used.
196  
197 =cut
198  
199 1 ▶sub to_GAIN {
Subroutine to_GAIN: called CC=6 SCAR=23.0
Pod documented
200 1 my $self = shift;
201 1 my $FITS_headers = shift;
202 1 my $gain;
203 1 ▶ if ( defined( $FITS_headers->{CAMNUM} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'CAMNUM'}) { } 1 0 1
204 1 my $camnum = $FITS_headers->{CAMNUM};
205 1 ▶ if ( $camnum == 1 || $camnum == 2 || $camnum == 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($camnum == 1 or $camnum == 2 or $camnum == 3) { } 1 0 1
elsif ($camnum == 4) { } 0 0 0
Condition33%2/6
$camnum == 1 or $camnum == 2 or $camnum == 3
l!l&&r!l&&!r
100
$camnum == 1 or $camnum == 2
l!l&&r!l&&!r
100
MC/DC0%0/3
$camnum == 1 or $camnum == 2 or $camnum == 3
$camnum == 1 $camnum == 2 $camnum == 3
Truth table25%1/4
A or B or C
A= $camnum == 1B= $camnum == 2C= $camnum == 3
ABCresult
1XX1
01X1
0011
0000
206 1 $gain = 4.6;
207 } elsif ( $camnum == 4 ) {
208 0 $gain = 5.6;
209 } else {
210 0 $gain = 1.0;
211 }
212 } else {
213 0 $gain = 1.0;
214 }
215 1 return $gain;
216 }
217  
218 =item B<from_GAIN>
219  
220 This is a null operation. The C<GAIN> FITS header in WFCAM data is
221 always incorrect.
222  
223 =cut
224  
225 1 ▶sub from_GAIN {
Subroutine from_GAIN: called CC=1 SCAR=0.0
Pod documented
226 1 return ();
227 }
228  
229 =item B<to_NUMBER_OF_OFFSETS>
230  
231 Return the number of offsets (jitters and micro steps).
232  
233 =cut
234  
235 1 ▶sub to_NUMBER_OF_OFFSETS {
Subroutine to_NUMBER_OF_OFFSETS: called CC=3 SCAR=11.3
Pod documented
236 1 my $self = shift;
237 1 my $FITS_headers = shift;
238 1 ▶ my $njitter = ( defined( $FITS_headers->{NJITTER} ) ? $FITS_headers->{NJITTER} : 1 );
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'NJITTER'} ? : 1 0 1
239 1 ▶ my $nustep = ( defined( $FITS_headers->{NUSTEP} ) ? $FITS_headers->{NUSTEP} : 1 );
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'NUSTEP'} ? : 1 0 1
240  
241 1 return $njitter * $nustep + 1;
242  
243 }
244  
245 =item B<to_RA_BASE>
246  
247 Returns the C<RABASE> header converted to degrees.
248  
249 =cut
250  
251 1 ▶sub to_RA_BASE {
Subroutine to_RA_BASE: called CC=1 SCAR=0.0
Pod documented
252 1 my $self = shift;
253 1 my $FITS_headers = shift;
254 1 return ($FITS_headers->{RABASE} * 15.0);
255 }
256  
257 =item B<to_RA_SCALE>
258  
259 Returns the right-ascension pixel scale in arcseconds per pixel. For
260 Cameras 1 and 3, it scales the C<CD1_2> keyword to the C<RA_SCALE>
261 generic header. For Cameras 2 and 4, it scales the C<CD1_1> keyword
262 instead.
263  
264 =cut
265  
266 1 ▶sub to_RA_SCALE {
Subroutine to_RA_SCALE: called CC=8 SCAR=27.2
Pod documented
267 1 my $self = shift;
268 1 my $FITS_headers = shift;
269  
270 1 my $scale;
271 1 my $camnum = $self->to_CAMERA_NUMBER( $FITS_headers );
272 1 ▶ if ( defined( $camnum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $camnum) 1 0 1
273 1 ▶ if ( defined( $FITS_headers->{CD1_1} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"CD1_1"} and defined $FITS_headers->{"CD1_2"}) 1 0 1
Condition33%1/3
defined $FITS_headers->{"CD1_1"} and defined $FITS_headers->{"CD1_2"}
!ll&&!rl&&r
001
MC/DC0%0/2
defined $FITS_headers->{"CD1_1"} and defined $FITS_headers->{"CD1_2"}
defined $FITS_headers->{"CD1_1"} defined $FITS_headers->{"CD1_2"}
Truth table33%1/3
A and B
A= defined $FITS_headers->{"CD1_1"}B= defined $FITS_headers->{"CD1_2"}
ABresult
0X0
100
111
274 defined( $FITS_headers->{CD1_2} ) ) {
275  
276 1 ▶ if ( $camnum == 1 || $camnum == 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($camnum == 1 or $camnum == 3) { } 1 0 1
elsif ($camnum == 2 or $camnum == 4) { } 0 0 0
Condition33%1/3
$camnum == 1 or $camnum == 3
l!l&&r!l&&!r
100
MC/DC0%0/2
$camnum == 1 or $camnum == 3
$camnum == 1 $camnum == 3
Truth table33%1/3
A or B
A= $camnum == 1B= $camnum == 3
ABresult
1X1
011
000
277 1 $scale = $FITS_headers->{CD1_2} * 3600;
278 ▶ } elsif ( $camnum == 2 || $camnum == 4 ) {
Condition0%0/3
$camnum == 2 or $camnum == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$camnum == 2 or $camnum == 4
$camnum == 2 $camnum == 4
Truth table0%0/3
A or B
A= $camnum == 2B= $camnum == 4
ABresult
1X1
011
000
279 0 $scale = $FITS_headers->{CD1_1} * 3600;
280 }
281 }
282 }
283 1 return $scale;
284 }
285  
286 =item B<from_RA_SCALE>
287  
288 For Cameras 1 and 3, it scales the C<RA_SCALE> generic header to the
289 C<CD1_2> keyword. For Cameras 2 and 4, scales C<RA_SCALE> to the
290 C<CD1_1> keyword. Returned units are degrees per pixel.
291  
292 =cut
293  
294 1 ▶sub from_RA_SCALE {
Subroutine from_RA_SCALE: called CC=7 SCAR=25.2
Pod documented
295 1 my $self = shift;
296 1 my $generic_headers = shift;
297  
298 1 my %return_hash;
299  
300 1 my $ra_scale = $generic_headers->{'RA_SCALE'};
301 1 my $camnum = $generic_headers->{'CAMERA_NUMBER'};
302  
303 1 ▶ if ( defined( $ra_scale ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ra_scale and defined $camnum) 1 0 1
Condition33%1/3
defined $ra_scale and defined $camnum
!ll&&!rl&&r
001
MC/DC0%0/2
defined $ra_scale and defined $camnum
defined $ra_scale defined $camnum
Truth table33%1/3
A and B
A= defined $ra_scaleB= defined $camnum
ABresult
0X0
100
111
304 defined( $camnum ) ) {
305  
306 1 ▶ if ( $camnum == 1 || $camnum == 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($camnum == 1 or $camnum == 3) { } 1 0 1
elsif ($camnum == 2 or $camnum == 4) { } 0 0 0
Condition33%1/3
$camnum == 1 or $camnum == 3
l!l&&r!l&&!r
100
MC/DC0%0/2
$camnum == 1 or $camnum == 3
$camnum == 1 $camnum == 3
Truth table33%1/3
A or B
A= $camnum == 1B= $camnum == 3
ABresult
1X1
011
000
307 1 $return_hash{'CD1_2'} = $ra_scale / 3600;
308 ▶ } elsif ( $camnum == 2 || $camnum == 4 ) {
Condition0%0/3
$camnum == 2 or $camnum == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$camnum == 2 or $camnum == 4
$camnum == 2 $camnum == 4
Truth table0%0/3
A or B
A= $camnum == 2B= $camnum == 4
ABresult
1X1
011
000
309 0 $return_hash{'CD1_1'} = $ra_scale / 3600;
310 }
311 }
312  
313 1 return %return_hash;
314 }
315  
316 =item B<to_ROTATION>
317  
318 Determines the rotation of the array in world co-ordinates.
319  
320 =cut
321  
322 1 ▶sub to_ROTATION {
Subroutine to_ROTATION: called CC=1 SCAR=0.0
Pod documented
323 1 my $self = shift;
324 1 my $FITS_headers = shift;
325 1 my $cd11 = $FITS_headers->{CD1_1};
326 1 my $cd12 = $FITS_headers->{CD1_2};
327 1 my $cd21 = $FITS_headers->{CD2_1};
328 1 my $cd22 = $FITS_headers->{CD2_2};
329  
330 1 my $rad = 45 / atan2( 1, 1 );
331  
332 1 my $rho_a = $rad * atan2( -$cd12 / $rad, $cd22 / $rad );
333 1 my $rho_b = $rad * atan2( $cd21 / $rad, $cd11 / $rad );
334 1 my $rotation = -0.5 * ( $rho_a + $rho_b );
335  
336 1 return $rotation;
337 }
338  
339 =back
340  
341 =head1 SEE ALSO
342  
343 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>.
344  
345 =head1 AUTHOR
346  
347 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
348 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
349 Malcolm J. Currie E<lt>mjc@jach.hawaii.eduE<gt>
350  
351 =head1 COPYRIGHT
352  
353 Copyright (C) 2008 Science and Technology Facilities Council.
354 Copyright (C) 2003-2005 Particle Physics and Astronomy Research Council.
355 All Rights Reserved.
356  
357 This program is free software; you can redistribute it and/or modify it under
358 the terms of the GNU General Public License as published by the Free Software
359 Foundation; either Version 2 of the License, or (at your option) any later
360 version.
361  
362 This program is distributed in the hope that it will be useful,but WITHOUT ANY
363 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
364 PARTICULAR PURPOSE. See the GNU General Public License for more details.
365  
366 You should have received a copy of the GNU General Public License along with
367 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
368 Place, Suite 330, Boston, MA 02111-1307, USA.
369  
370 =cut
371  
372 10 1;
« HdrTrans/RxH3.pm ↑ Summary HdrTrans/SPEX.pm »