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

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