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

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