File Coverage

blib/lib/Astro/FITS/HdrTrans/UKIRTNew.pm
Criterion Covered Total %
statement 46 48 95.8
branch 7 14 50.0
condition n/a
subroutine 10 10 100.0
pod 5 5 100.0
total 68 77 88.3


line stmt bran cond sub pod time code
1             package Astro::FITS::HdrTrans::UKIRTNew;
2              
3             =head1 NAME
4              
5             Astro::FITS::HdrTrans::UKIRTNew - Base class for translation of new UKIRT instruments
6              
7             =head1 SYNOPSIS
8              
9             use Astro::FITS::HdrTrans::UKIRTNew;
10              
11             =head1 DESCRIPTION
12              
13             This class provides a generic set of translations that are common to
14             the newer generation of instruments from the United Kingdom Infrared
15             Telescope. This includes MICHELLE, UIST, UFTI and WFCAM. It should
16             not be used directly for translation of instrument FITS headers.
17              
18             =cut
19              
20 16     16   55577277 use 5.006;
  16         109  
21 16     16   93 use warnings;
  16         62  
  16         1521  
22 16     16   142 use strict;
  16         46  
  16         465  
23 16     16   102 use Carp;
  16         32  
  16         1654  
24              
25             # Inherit from UKIRT
26 16     16   157 use base qw/ Astro::FITS::HdrTrans::UKIRT /;
  16         46  
  16         14049  
27              
28             our $VERSION = "1.66";
29              
30             # For a constant mapping, there is no FITS header, just a generic
31             # header that is constant.
32             my %CONST_MAP = (
33              
34             );
35              
36             # Unit mapping implies that the value propogates directly
37             # to the output with only a keyword name change.
38             my %UNIT_MAP = (
39             DEC_TELESCOPE_OFFSET => "TDECOFF",
40             DR_RECIPE => "RECIPE",
41             EXPOSURE_TIME => "EXP_TIME",
42             GAIN => "GAIN",
43             RA_TELESCOPE_OFFSET => "TRAOFF",
44             UTDATE => "UTDATE",
45             );
46              
47             # Create the translation methods.
48             __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP );
49              
50             =head1 COMPLEX CONVERSIONS
51              
52             These methods are more complicated than a simple mapping. We have to
53             provide both from- and to-FITS conversions. All these routines are
54             methods and the to_ routines all take a reference to a hash and return
55             the translated value (a many-to-one mapping). The from_ methods take
56             a reference to a generic hash and return a translated hash (sometimes
57             these are many-to-many).
58              
59             =over 4
60              
61             =item B<to_INST_DHS>
62              
63             Sets the instrument data-handling-system header.
64              
65             =cut
66              
67             sub to_INST_DHS {
68 6     6 1 14 my $self = shift;
69 6         14 my $FITS_headers = shift;
70 6         13 my $return;
71              
72 6 50       45 if ( exists( $FITS_headers->{DHSVER} ) ) {
73 6         196 $FITS_headers->{DHSVER} =~ /^(\w+)/;
74 6         507 my $dhs = uc( $1 );
75 6         24 $return = $FITS_headers->{INSTRUME} . "_$dhs";
76             }
77              
78 6         512 return $return;
79             }
80              
81             =item B<to_UTSTART>
82              
83             Converts UT date in C<DATE-OBS> header into C<Time::Piece> object.
84              
85             =cut
86              
87             sub to_UTSTART {
88 8     8 1 19 my $self = shift;
89 8         19 my $FITS_headers = shift;
90             my $dateobs = (exists $FITS_headers->{"DATE-OBS"} ?
91 8 50       37 $FITS_headers->{"DATE-OBS"} : undef );
92 8         1160 my @rutstart = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "UTSTART" );
  0         0  
93 8         23 my $utstart = $rutstart[0];
94 8         379 return $self->_parse_date_info( $dateobs,
95             $self->to_UTDATE( $FITS_headers ),
96             $utstart );
97             }
98              
99             =item B<from_UTSTART>
100              
101             Returns the starting observation time in ISO8601 format:
102             YYYY-MM-DDThh:mm:ss.
103              
104             =cut
105              
106             sub from_UTSTART {
107 5     5 1 15 my $self = shift;
108 5         12 my $generic_headers = shift;
109              
110             # Use the FITS standard parser.
111 5         24 my %return_hash = Astro::FITS::HdrTrans::FITS->from_UTSTART( $generic_headers );
112              
113 5 50       24 if ( exists $return_hash{'DATE-OBS'} ) {
114              
115             # Prior to April 2005 the UKIRT FITS headers had a trailing Z.
116             # This is part of the ISO8601 standard but not part of the FITS
117             # standard (which always assumes UTC), although it was in the
118             # draft FITS agreement.
119             $return_hash{'DATE-OBS'} .= "Z"
120 5 50       18 if $generic_headers->{UTSTART}->epoch < 1112662116;
121             }
122 5         391 return %return_hash;
123             }
124              
125             =item B<to_UTEND>
126              
127             Converts UT date in C<DATE-END> header into C<Time::Piece> object.
128              
129             =cut
130              
131             sub to_UTEND {
132 4     4 1 11 my $self = shift;
133 4         8 my $FITS_headers = shift;
134             my $dateend = (exists $FITS_headers->{"DATE-END"} ?
135 4 50       19 $FITS_headers->{"DATE-END"} : undef );
136              
137 4         548 my @rutend = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "UTEND" );
  0         0  
138 4         13 my $utend = $rutend[-1];
139 4         166 return $self->_parse_date_info( $dateend,
140             $self->to_UTDATE( $FITS_headers ),
141             $utend );
142             }
143              
144             =item B<from_UTEND>
145              
146             Returns the starting observation time in ISO8601 format:
147             YYYY-MM-DDThh:mm:ss.
148              
149             =cut
150              
151             sub from_UTEND {
152 5     5 1 15 my $self = shift;
153 5         11 my $generic_headers = shift;
154              
155             # Use the FITS standard parser.
156 5         41 my %return_hash = Astro::FITS::HdrTrans::FITS->from_UTEND( $generic_headers);
157              
158 5 50       31 if ( exists $return_hash{'DATE-END'} ) {
159              
160             # Prior to April 2005 the UKIRT FITS headers had a trailing Z.
161             # This is part of the ISO8601 standard but not part of the FITS
162             # standard (which always assumes UTC), although it was in the
163             # draft FITS agreement.
164             $return_hash{'DATE-END'} .= "Z"
165 5 50       24 if $generic_headers->{UTEND}->epoch < 1112662116;
166             }
167 5         537 return %return_hash;
168             }
169              
170             =back
171              
172             =head1 SEE ALSO
173              
174             C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>
175              
176             =head1 AUTHOR
177              
178             Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
179             Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
180             Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt>
181              
182             =head1 COPYRIGHT
183              
184             Copyright (C) 2007-2008 Science and Technology Facilities Council.
185             Copyright (C) 2003-2007 Particle Physics and Astronomy Research Council.
186             All Rights Reserved.
187              
188             This program is free software; you can redistribute it and/or modify it under
189             the terms of the GNU General Public License as published by the Free Software
190             Foundation; either Version 2 of the License, or (at your option) any later
191             version.
192              
193             This program is distributed in the hope that it will be useful,but WITHOUT ANY
194             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
195             PARTICULAR PURPOSE. See the GNU General Public License for more details.
196              
197             You should have received a copy of the GNU General Public License along with
198             this program; if not, write to the Free Software Foundation, Inc., 59 Temple
199             Place, Suite 330, Boston, MA 02111-1307, USA.
200              
201             =cut
202              
203             1;