File Coverage

blib/lib/Astro/FITS/HdrTrans/UKIRTNew.pm
Criterion Covered Total %
statement 49 51 96.0
branch 7 14 50.0
condition n/a
subroutine 11 11 100.0
pod 5 5 100.0
total 72 81 88.8


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