File Coverage

blib/lib/Astro/FITS/HdrTrans/UKIRTOld.pm
Criterion Covered Total %
statement 60 65 92.3
branch 6 12 50.0
condition 1 3 33.3
subroutine 13 13 100.0
pod 7 7 100.0
total 87 100 87.0


line stmt bran cond sub pod time code
1              
2             =head1 NAME
3              
4             Astro::FITS::HdrTrans::UKIRTOld - Base class for translation of old UKIRT instruments
5              
6             =head1 SYNOPSIS
7              
8             use Astro::FITS::HdrTrans::UKIRTOld;
9              
10             =head1 DESCRIPTION
11              
12             This class provides a generic set of translations that are common to
13             CGS4 and IRCAM from the United Kingdom Infrared Telescope. It should
14             not be used directly for translation of instrument FITS headers.
15              
16             =cut
17              
18             use 5.006;
19 12     12   22568374 use warnings;
  12         42  
20 12     12   50 use strict;
  12         23  
  12         289  
21 12     12   49 use Carp;
  12         29  
  12         267  
22 12     12   53  
  12         25  
  12         726  
23             # Inherit from UKIRT
24             use base qw/ Astro::FITS::HdrTrans::UKIRT /;
25 12     12   74  
  12         34  
  12         4277  
26             use vars qw/ $VERSION /;
27 12     12   70  
  12         35  
  12         5991  
28             $VERSION = "1.65";
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             DETECTOR_READ_TYPE => "MODE", # Also UFTI
40             DR_RECIPE => "DRRECIPE",
41             EXPOSURE_TIME => "DEXPTIME",
42             GAIN => "DEPERDN",
43             );
44              
45             # Create the translation methods.
46             __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP );
47              
48             =head1 COMPLEX CONVERSIONS
49              
50             These methods are more complicated than a simple mapping. We have to
51             provide both from- and to-FITS conversions. All these routines are
52             methods and the to_ routines all take a reference to a hash and return
53             the translated value (a many-to-one mapping). The from_ methods take
54             a reference to a generic hash and return a translated hash (sometimes
55             these are many-to-many).
56              
57             =over 4
58              
59             =item B<to_UTDATE>
60              
61             Converts IDATE into UTDATE without any modification. Flattens
62             duplicate headers into a single header.
63              
64             =cut
65              
66             my $self = shift;
67             my $FITS_headers = shift;
68 36     36 1 75 my $return;
69 36         43 my $utdate = ( exists $FITS_headers->{IDATE} ? $FITS_headers->{IDATE} : undef );
70 36         42 if ( defined( $utdate ) && ref( $utdate ) eq 'ARRAY' ) {
71 36 50       86 $return = $utdate->[0];
72 36 50 33     1627 } else {
73 0         0 $return = $utdate;
74             }
75 36         50 return $return;
76             }
77 36         64  
78             =item B<from_UTDATE>
79              
80             Converts UTDATE into IDATE without any modification.
81              
82             =cut
83              
84             return ( "IDATE", $_[1]->{'UTDATE'} );
85             }
86              
87 6     6 1 61 =item B<to_UTSTART>
88              
89             Converts FITS header UT date/time values for the start of the observation
90             into a C<Time::Piece> object.
91              
92             =cut
93              
94             my $self = shift;
95             my $FITS_headers = shift;
96              
97             my $utdate = $self->to_UTDATE( $FITS_headers );
98 12     12 1 20 my @rutstart = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "RUTSTART" );
99 12         19 my $utdechour = $rutstart[0];
100              
101 12         30 # We do not have a DATE-OBS.
102 12         35 return $self->_parse_date_info( undef, $utdate, $utdechour );
  0         0  
103 12         22 }
104              
105             =item B<from_UTSTART>
106 12         55  
107             Converts a C<Time::Piece> object into two FITS headers for IRCAM: IDATE
108             (in the format YYYYMMDD) and RUTSTART (decimal hours).
109              
110             =cut
111              
112             my $class = shift;
113             my $generic_headers = shift;
114             my %return_hash;
115             if ( exists($generic_headers->{UTSTART} ) ) {
116             my $date = $generic_headers->{UTSTART};
117 6     6 1 11 if ( ! UNIVERSAL::isa( $date, "Time::Piece" ) ) {
118 6         10 return;
119 6         10 }
120 6 50       15 $return_hash{IDATE} = sprintf( "%4d%02d%02d", $date->year, $date->mon, $date->mday );
121 6         12 $return_hash{RUTSTART} = $date->hour + ( $date->minute / 60 ) + ( $date->second / 3600 );
122 6 50       20 }
123 0         0 return %return_hash;
124             }
125 6         16  
126 6         61 =item B<to_UTEND>
127              
128 6         119 Converts FITS header UT date/time values for the end of the observation into
129             a C<Time::Piece> object.
130              
131             =cut
132              
133             my $self = shift;
134             my $FITS_headers = shift;
135             my $return;
136             my $utdate = $self->to_UTDATE( $FITS_headers );
137             my @rutend = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "RUTEND" );
138             my $utdechour = $rutend[-1];
139 6     6 1 13  
140 6         10 # We do not have a DATE-END.
141 6         8 return $self->_parse_date_info( undef, $utdate, $utdechour );
142 6         13 }
143 6         19  
  0         0  
144 6         12 =item B<from_UTEND>
145              
146             Converts a C<Time::Piece> object into two FITS headers for IRCAM: IDATE
147 6         23 (in the format YYYYMMDD) and RUTEND (decimal hours).
148              
149             =cut
150              
151             my $class = shift;
152             my $generic_headers = shift;
153             my %return_hash;
154             if ( exists($generic_headers->{UTEND} ) ) {
155             my $date = $generic_headers->{UTEND};
156             if ( ! UNIVERSAL::isa( $date, "Time::Piece" ) ) {
157             return;
158 6     6 1 10 }
159 6         10 $return_hash{IDATE} = sprintf( "%4d%02d%02d", $date->year, $date->mon, $date->mday );
160 6         10 $return_hash{RUTEND} = $date->hour + ( $date->minute / 60 ) + ( $date->second / 3600 );
161 6 50       17 }
162 6         12 return %return_hash;
163 6 50       41 }
164 0         0  
165             =item B<to_INST_DHS>
166 6         30  
167 6         93 Sets the instrument data handling system header. Note that for old
168             instruments there is no DHSVER header so this simply returns
169 6         148 the name of the instrument and a UKDHS suffix.
170              
171             =cut
172              
173             my $self = shift;
174             my $FITS_headers = shift;
175             my $inst = $self->to_INSTRUMENT( $FITS_headers );
176             return $inst . '_UKDHS';
177             }
178              
179             =back
180              
181 6     6 1 12 =head1 SEE ALSO
182 6         12  
183 6         114 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>
184 6         28  
185             =head1 AUTHOR
186              
187             Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
188             Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
189              
190             =head1 COPYRIGHT
191              
192             Copyright (C) 2007-2008 Science and Technology Facilities Council.
193             Copyright (C) 2003-2007 Particle Physics and Astronomy Research Council.
194             All Rights Reserved.
195              
196             This program is free software; you can redistribute it and/or modify it under
197             the terms of the GNU General Public License as published by the Free Software
198             Foundation; either Version 2 of the License, or (at your option) any later
199             version.
200              
201             This program is distributed in the hope that it will be useful,but WITHOUT ANY
202             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
203             PARTICULAR PURPOSE. See the GNU General Public License for more details.
204              
205             You should have received a copy of the GNU General Public License along with
206             this program; if not, write to the Free Software Foundation, Inc., 59 Temple
207             Place, Suite 330, Boston, MA 02111-1307, USA.
208              
209             =cut
210              
211             1;