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

filter: Statementstmt 87.1% 108 / 124 Branchbran 46.8% 15 / 32 Conditioncond 45.8% 11 / 24 MC/DCmcdc 14.2% 2 / 14 Subroutinesub 100% 20 / 20 Podpod 92.8% 13 / 14 totaltotal 74.1% 169 / 228 SCAR 35.7
CC
25
Cov
74%
to_RA_SCALE
14.7
to_DEC_SCALE
13.1
to_SPEED_GAIN
4.2
CRAP 35.4
« blib/lib/Astro/FITS/HdrTrans/MICHELLE.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/JAC.pm »
1 package Astro::FITS::HdrTrans::IRCAM;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::IRCAM - UKIRT IRCAM translations
6  
7 =head1 SYNOPSIS
8  
9 use Astro::FITS::HdrTrans::IRCAM;
10  
11 %gen = Astro::FITS::HdrTrans::IRCAM->translate_from_FITS( %hdr );
12  
13 =head1 DESCRIPTION
14  
15 This class provides a generic set of translations that are specific
16 to the IRCAM 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 UKIRT "Old"
26 10 ▶use base qw/ Astro::FITS::HdrTrans::UKIRTOld /;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 10 ▶use vars qw/ $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 10 $VERSION = "1.64";
31  
32 # For a constant mapping, there is no FITS header, just a generic
33 # header that is constant.
34 10 my %CONST_MAP = (
35  
36 );
37  
38 # Unit mapping implies that the value propogates directly
39 # to the output with only a keyword name change.
40  
41 # Note that header merging fails with IRCAM in some cases because
42 # some items are duplicated in the .HEADER and .I1 but using different
43 # comment strings so the merging routine does not realise they are the
44 # same header. It is arguably an error that Astro::FITS::Header looks
45 # at comments.
46  
47 10 my %UNIT_MAP = (
48 AIRMASS_START => 'AMSTART',
49 # IRCAM Specific
50 OBSERVATION_NUMBER => 'RUN', # cf. OBSNUM
51 DEC_TELESCOPE_OFFSET => 'DECOFF',
52 DETECTOR_BIAS => 'DET_BIAS',
53 RA_TELESCOPE_OFFSET => 'RAOFF',
54 );
55  
56 # END observation unit maps
57 10 my %ENDOBS_MAP = (
58 AIRMASS_END => 'AMEND',
59 NUMBER_OF_EXPOSURES => 'NEXP', # need it from the last subheader
60 );
61  
62 # Create the translation methods
63 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, undef, \%ENDOBS_MAP );
64  
65 # Im
66  
67 =head1 METHODS
68  
69 =over 4
70  
71 =item B<this_instrument>
72  
73 The name of the instrument required to match (case insensitively)
74 against the INSTRUME/INSTRUMENT keyword to allow this class to
75 translate the specified headers. Called by the default
76 C<can_translate> method.
77  
78 $inst = $class->this_instrument();
79  
80 Returns a pattern match for /^IRCAM\d?/".
81  
82 =cut
83  
84 sub this_instrument {
85 24 ▶ return qr/^IRCAM\d?/i;
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
86 }
87  
88 =back
89  
90 =head1 COMPLEX CONVERSIONS
91  
92 =over 4
93  
94 =item B<to_DEC_SCALE>
95  
96 Pixel scale along the Declination axis in arcseconds. If the pixel
97 scale is not defined in the PIXELSIZ or CDELT2 headers, then default
98 to 0.08144 arcseconds for data taken after 19990901, or 0.286
99 arcseconds for older data. The value will always be positive.
100  
101 =cut
102  
103 sub to_DEC_SCALE {
104 4 ▶ my $self = shift;
Subroutine to_DEC_SCALE: called CC=7 SCAR=25.7
Pod documented
105 4 my $FITS_headers = shift;
106 4 my $scale;
107 4 my $pixelsiz = $FITS_headers->{PIXELSIZ};
108 4 my $ctype2 = $FITS_headers->{CTYPE2};
109 4 my $cdelt2 = $FITS_headers->{CDELT2};
110 4 my $utdate = $self->to_UTDATE( $FITS_headers );
111  
112 # The CDELTn headers may be part of a WCS in expressed in the AIPS-convention
113 # measured in degrees (but protect against cases where it may have been in
114 # arcsec).
115 4 ▶ if ( defined( $cdelt2 ) && defined( $ctype2 ) && $ctype2 eq "DEC--TAN" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cdelt2 and defined $ctype2 and $ctype2 eq 'DEC--TAN') { } 0 4 4
Condition33%2/6
defined $cdelt2 and defined $ctype2 and $ctype2 eq "DEC--TAN"
!ll&&!rl&&r
400
defined $cdelt2 and defined $ctype2
!ll&&!rl&&r
400
MC/DC0%0/3
defined $cdelt2 and defined $ctype2 and $ctype2 eq "DEC--TAN"
defined $cdelt2 defined $ctype2 $ctype2 eq "DEC--TAN"
Truth table25%1/4
A and B and C
A= defined $cdelt2B= defined $ctype2C= $ctype2 eq "DEC--TAN"
ABCresult
0XX0
10X0
1100
1111
116 0 $scale = $cdelt2;
117 0 ▶ if ( abs( $scale ) < 1.0E-3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (abs $scale < "0.001") 0 0 0
118 0 $scale *= 3600.0;
119 }
120 } else {
121 4 $scale = $pixelsiz;
122 }
123  
124 # Use the default scales. The first IRCAM scale did vary with time,
125 # but the information is no longer on the UKIRT web site.
126 4 ▶ if ( ! defined( $scale ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scale) 0 4 4
127 0 ▶ if ( $utdate > 19990901 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate > 19990901) { } 0 0 0
128 0 $scale = 0.08144;
129 } else {
130 0 $scale = 0.286;
131 }
132 }
133  
134 # Headers may be in scientific notation, but with a 'D' instead of
135 # an 'E'. Translate to an 'E' so Perl doesn't fall over.
136 4 $scale =~ s/D/E/;
137  
138 4 return abs( $scale );
139 }
140  
141 =item B<from_DEC_SCALE>
142  
143 Generate the PIXELSIZ or CDELT2 header for IRCAM2 or IRCAM3 data
144 respectively. The header will be returned in arcseconds, and will
145 always be positive.
146  
147 =cut
148  
149 sub from_DEC_SCALE {
150 4 ▶ my $self = shift;
Subroutine from_DEC_SCALE: called CC=1 SCAR=0.0
Pod documented
151 4 my $generic_headers = shift;
152 4 my $scale = abs( $generic_headers->{DEC_SCALE} );
153  
154 # Need to find way to allow for new and old headers with differing units.
155 4 return ( "PIXELSIZ", $scale );
156 }
157  
158 =item B<to_POLARIMETRY>
159  
160 Checks the filter name.
161  
162 =cut
163  
164 sub to_POLARIMETRY {
165 4 ▶ my $self = shift;
Subroutine to_POLARIMETRY: called CC=3 SCAR=11.8
Pod documented
166 4 my $FITS_headers = shift;
167 4 ▶ if ( exists( $FITS_headers->{FILTER} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'FILTER'} and $FITS_headers->{'FILTER'} =~ /pol/i) { } 0 4 4
Condition66%2/3
exists $FITS_headers->{"FILTER"} and $FITS_headers->{"FILTER"} =~ /pol/i
!ll&&!rl&&r
220
MC/DC0%0/2
exists $FITS_headers->{"FILTER"} and $FITS_headers->{"FILTER"} =~ /pol/i
exists $FITS_headers->{"FILTER"} $FITS_headers->{"FILTER"} =~ /pol/i
Truth table66%2/3
A and B
A= exists $FITS_headers->{"FILTER"}B= $FITS_headers->{"FILTER"} =~ /pol/i
ABresult
0X0
100
111
168 $FITS_headers->{FILTER} =~ /pol/i ) {
169 0 return 1;
170 } else {
171 4 return 0;
172 }
173 }
174  
175 =item B<to_RA_SCALE>
176  
177 Returns the pixel scale along the RA axis in arcseconds. If the pixel
178 scale is not defined in the PIXELSIZ or CDELT1 headers, then default
179 to -0.08144 arcseconds for data taken after 19990901, or -0.286
180 arcseconds for older data. The value will always be negative.
181  
182 =cut
183  
184 sub to_RA_SCALE {
185 4 ▶ my $self = shift;
Subroutine to_RA_SCALE: called CC=8 SCAR=26.9
Pod documented
186 4 my $FITS_headers = shift;
187 4 my $scale;
188 4 my $pixelsiz = $FITS_headers->{PIXELSIZ};
189 4 my $ctype1 = $FITS_headers->{CTYPE1};
190 4 my $cdelt1 = $FITS_headers->{CDELT1};
191 4 my $utdate = $self->to_UTDATE( $FITS_headers );
192  
193 # The CDELTn headers may be part of a WCS in expressed in the AIPS-convention
194 # measured in degrees (but protect against cases where it may have been in
195 # arcsec).
196 4 ▶ if ( defined( $cdelt1 ) && defined( $ctype1 ) && $ctype1 eq "RA---TAN" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cdelt1 and defined $ctype1 and $ctype1 eq 'RA---TAN') { } 0 4 4
Condition33%2/6
defined $cdelt1 and defined $ctype1 and $ctype1 eq "RA---TAN"
!ll&&!rl&&r
400
defined $cdelt1 and defined $ctype1
!ll&&!rl&&r
400
MC/DC0%0/3
defined $cdelt1 and defined $ctype1 and $ctype1 eq "RA---TAN"
defined $cdelt1 defined $ctype1 $ctype1 eq "RA---TAN"
Truth table25%1/4
A and B and C
A= defined $cdelt1B= defined $ctype1C= $ctype1 eq "RA---TAN"
ABCresult
0XX0
10X0
1100
1111
197 0 $scale = $cdelt1;
198 0 ▶ if ( abs( $scale ) < 1.0E-3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (abs $scale < "0.001") 0 0 0
199 0 $scale *= 3600.0;
200 }
201 } else {
202 4 $scale = $pixelsiz;
203 }
204  
205 # Use the default scales. The first IRCAM scale did vary with time,
206 # but the information is no longer on the UKIRT web site.
207 4 ▶ if ( ! defined( $scale ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scale) 0 4 4
208 0 ▶ if ( $utdate > 19990901 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate > 19990901) { } 0 0 0
209 0 $scale = -0.08144;
210 } else {
211 0 $scale = -0.286;
212 }
213 }
214  
215 # Headers may be in scientific notation, but with a 'D' instead of
216 # an 'E'. Translate to an 'E' so Perl doesn't fall over.
217 4 $scale =~ s/D/E/;
218  
219 # Correct erroneous positive RA scale in some headers.
220 4 ▶ if ( $scale > 0.0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scale > 0) 4 0 4
221 4 $scale *= -1.0;
222 }
223  
224 4 return $scale;
225 }
226  
227 =item B<from_RA_SCALE>
228  
229 Generates the PIXELSIZ or CDELT1 header for IRCAM2 or IRCAM3 data
230 respectively. The header will be returned in arcseconds, and will
231 always be negative.
232  
233 =cut
234  
235 sub from_RA_SCALE {
236 4 ▶ my $self = shift;
Subroutine from_RA_SCALE: called CC=1 SCAR=0.0
Pod documented
237 4 my $generic_headers = shift;
238 4 my $scale = abs( $generic_headers->{RA_SCALE} );
239  
240 # Need to find way to allow for new and old headers with differing units.
241 4 return ( "PIXELSIZ", $scale );
242 }
243  
244  
245 =item B<to_SPEED_GAIN>
246  
247 For data taken before 22 November 2000, the SPD_GAIN header was not
248 written. Obtain the SPEED_GAIN from the detector bias if the SPD_GAIN
249 header is not defined. If the detector bias is between 0.61 and 0.63,
250 then the SPEED_GAIN is Standard. Otherwise, it is Deepwell.
251  
252 =cut
253  
254 sub to_SPEED_GAIN {
255 4 ▶ my $self = shift;
Subroutine to_SPEED_GAIN: called CC=4 SCAR=14.4
Pod documented
256 4 my $FITS_headers = shift;
257  
258 4 my $return;
259 4 ▶ if ( defined( $FITS_headers->{SPD_GAIN} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'SPD_GAIN'}) { } 2 2 4
260 2 $return = $FITS_headers->{SPD_GAIN};
261 } else {
262 2 my $detector_bias = $self->to_DETECTOR_BIAS( $FITS_headers );
263 2 ▶ if ( $detector_bias > 0.61 && $detector_bias < 0.63 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($detector_bias > 0.61 and $detector_bias < 0.63) { } 0 2 2
Condition33%1/3
$detector_bias > "0.61" and $detector_bias < "0.63"
!ll&&!rl&&r
020
MC/DC0%0/2
$detector_bias > "0.61" and $detector_bias < "0.63"
$detector_bias > "0.61" $detector_bias < "0.63"
Truth table33%1/3
A and B
A= $detector_bias > "0.61"B= $detector_bias < "0.63"
ABresult
0X0
100
111
264 0 $return = "Standard";
265 } else {
266 2 $return = "Deepwell";
267 }
268 }
269 4 return $return;
270 }
271  
272 =item B<from_SPEED_GAIN>
273  
274 Translates the SPEED_GAIN generic header into the SPD_GAIN
275 IRCAM-specific header. Note that this will break bi-directional tests
276 as the SPD_GAIN header did not exist in data taken before 2000
277 November 22.
278  
279 =cut
280  
281 sub from_SPEED_GAIN {
282 4 ▶ my $self = shift;
Subroutine from_SPEED_GAIN: called CC=1 SCAR=0.0
Pod documented
283 4 my $generic_headers = shift;
284 4 return( "SPD_GAIN", $generic_headers->{"SPEED_GAIN"} )
285 }
286  
287 =item B<from_TELESCOPE>
288  
289 For data taken before 20000607, return 'UKIRT, Mauna Kea, HI'. For
290 data taken on and after 20000607, return
291 'UKIRT,Mauna_Kea,HI'. Returned header is C<TELESCOP>.
292  
293 =cut
294  
295 sub from_TELESCOPE {
296 4 ▶ my $self = shift;
Subroutine from_TELESCOPE: called CC=2 SCAR=7.2
Pod documented
297 4 my $generic_headers = shift;
298 4 my $utdate = $generic_headers->{'UTDATE'};
299 4 ▶ if ( $utdate < 20000607 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate < 20000607) { } 0 4 4
300 0 return( "TELESCOP", "UKIRT, Mauna Kea, HI" );
301 } else {
302 4 return( "TELESCOP", "UKIRT,Mauna_Kea,HI" );
303 }
304 }
305  
306 =item B<to_X_REFERENCE_PIXEL>
307  
308 Specify the reference pixel, which is normally near the frame centre.
309 Note that offsets for polarimetry are undefined.
310  
311 =cut
312  
313 sub to_X_REFERENCE_PIXEL{
314 4 ▶ my $self = shift;
Subroutine to_X_REFERENCE_PIXEL: called CC=3 SCAR=11.0
Pod documented
315 4 my $FITS_headers = shift;
316 4 my $xref;
317  
318 # Use the average of the bounds to define the centre.
319 4 ▶ if ( exists $FITS_headers->{RDOUT_X1} && exists $FITS_headers->{RDOUT_X2} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'RDOUT_X1'} and exists $FITS_headers->{'RDOUT_X2'}) { } 2 2 4
Condition66%2/3
exists $FITS_headers->{"RDOUT_X1"} and exists $FITS_headers->{"RDOUT_X2"}
!ll&&!rl&&r
202
MC/DC50%1/2
exists $FITS_headers->{"RDOUT_X1"} and exists $FITS_headers->{"RDOUT_X2"}
exists $FITS_headers->{"RDOUT_X1"} exists $FITS_headers->{"RDOUT_X2"}
Truth table66%2/3
A and B
A= exists $FITS_headers->{"RDOUT_X1"}B= exists $FITS_headers->{"RDOUT_X2"}
ABresult
0X0
100
111
320 2 my $xl = $FITS_headers->{RDOUT_X1};
321 2 my $xu = $FITS_headers->{RDOUT_X2};
322 2 $xref = $self->nint( ( $xl + $xu ) / 2 );
323  
324 # Use a default of the centre of the full array.
325 } else {
326 2 $xref = 129;
327 }
328 4 return $xref;
329 }
330  
331 =item B<from_X_REFERENCE_PIXEL>
332  
333 Returns CRPIX1.
334  
335 =cut
336  
337 sub from_X_REFERENCE_PIXEL {
338 4 ▶ my $self = shift;
Subroutine from_X_REFERENCE_PIXEL: called CC=1 SCAR=0.0
Pod documented
339 4 my $generic_headers = shift;
340 4 return ( "CRPIX1", $generic_headers->{"X_REFERENCE_PIXEL"} );
341 }
342  
343 =item B<to_Y_REFERENCE_PIXEL>
344  
345 Specify the reference pixel, which is normally near the frame centre.
346 Note that offsets for polarimetry are undefined.
347  
348 =cut
349  
350 sub to_Y_REFERENCE_PIXEL{
351 4 ▶ my $self = shift;
Subroutine to_Y_REFERENCE_PIXEL: called CC=3 SCAR=11.0
Pod documented
352 4 my $FITS_headers = shift;
353 4 my $yref;
354  
355 # Use the average of the bounds to define the centre.
356 4 ▶ if ( exists $FITS_headers->{RDOUT_Y1} && exists $FITS_headers->{RDOUT_Y2} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'RDOUT_Y1'} and exists $FITS_headers->{'RDOUT_Y2'}) { } 2 2 4
Condition66%2/3
exists $FITS_headers->{"RDOUT_Y1"} and exists $FITS_headers->{"RDOUT_Y2"}
!ll&&!rl&&r
202
MC/DC50%1/2
exists $FITS_headers->{"RDOUT_Y1"} and exists $FITS_headers->{"RDOUT_Y2"}
exists $FITS_headers->{"RDOUT_Y1"} exists $FITS_headers->{"RDOUT_Y2"}
Truth table66%2/3
A and B
A= exists $FITS_headers->{"RDOUT_Y1"}B= exists $FITS_headers->{"RDOUT_Y2"}
ABresult
0X0
100
111
357 2 my $yl = $FITS_headers->{RDOUT_Y1};
358 2 my $yu = $FITS_headers->{RDOUT_Y2};
359 2 $yref = $self->nint( ( $yl + $yu ) / 2 );
360  
361 # Use a default of the centre of the full array.
362 } else {
363 2 $yref = 129;
364 }
365 4 return $yref;
366 }
367  
368 =item B<from_X_REFERENCE_PIXEL>
369  
370 Returns CRPIX2.
371  
372 =cut
373  
374 sub from_Y_REFERENCE_PIXEL {
375 4 ▶ my $self = shift;
Subroutine from_Y_REFERENCE_PIXEL: called CC=1 SCAR=0.0
Pod undocumented
376 4 my $generic_headers = shift;
377 4 return ( "CRPIX2", $generic_headers->{"Y_REFERENCE_PIXEL"} );
378 }
379  
380 =item B<to_ROTATION>
381  
382 Returns fixed rotation values based on the UT date.
383  
384 =cut
385  
386 sub to_ROTATION {
387 4 ▶ my $self = shift;
Subroutine to_ROTATION: called CC=2 SCAR=7.2
Pod documented
388 4 my $FITS_headers = shift;
389 4 my $utdate = $self->to_UTDATE($FITS_headers);
390  
391 4 ▶ if ($utdate < 19990901) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate < 19990901) 0 4 4
392 0 return 1.5;
393 }
394  
395 # TODO: determine correct sense for later rotations given on the
396 # IRCAM website http://www.jach.hawaii.edu/UKIRT/instruments/ircam/scale.html
397 # Sept 99: -89.04
398 # June 01: -88.84
399  
400 4 return 0.0;
401 }
402  
403 =back
404  
405 =head1 SEE ALSO
406  
407 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>.
408  
409 =head1 AUTHOR
410  
411 Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt>
412 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
413 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
414  
415 =head1 COPYRIGHT
416  
417 Copyright (C) 2008 Science and Technology Facilities Council.
418 Copyright (C) 2003-2005 Particle Physics and Astronomy Research Council.
419 All Rights Reserved.
420  
421 This program is free software; you can redistribute it and/or modify it under
422 the terms of the GNU General Public License as published by the Free Software
423 Foundation; either Version 2 of the License, or (at your option) any later
424 version.
425  
426 This program is distributed in the hope that it will be useful,but WITHOUT ANY
427 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
428 PARTICULAR PURPOSE. See the GNU General Public License for more details.
429  
430 You should have received a copy of the GNU General Public License along with
431 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
432 Place, Suite 330, Boston, MA 02111-1307, USA.
433  
434 =cut
435  
436 10 1;
« blib/lib/Astro/FITS/HdrTrans/MICHELLE.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/JAC.pm »