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