HdrTrans/SCUBA2.pm

filter: Statementstmt 95.8% 69 / 72 Branchbran 57.6% 15 / 26 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 14 / 14 Podpod 100% 8 / 8 totaltotal 83.0% 108 / 130 CC 16 SCAR 11.9
CC
16
Cov
83%
to_DR_RECIPE
5.6
to_OBSERVATION_MODE
5.3
_reconstruct_INBEAM
4.2
CRAP 3.3
« HdrTrans/UIST.pm ↑ Summary HdrTrans/UKIRT.pm »
1 package Astro::FITS::HdrTrans::SCUBA2;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::SCUBA2 - JCMT SCUBA-2 translations
6  
7 =head1 DESCRIPTION
8  
9 Converts information contained in SCUBA-2 FITS headers to and from
10 generic headers. See L<Astro::FITS::HdrTrans> for a list of generic
11 headers.
12  
13 =cut
14  
15 10 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 10 ▶use base qw/ Astro::FITS::HdrTrans::JCMT /;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 10 our $VERSION = "1.66";
23  
24 # For a constant mapping, there is no FITS header, just a generic
25 # header that is constant.
26 10 my %CONST_MAP = (
27 BACKEND => 'SCUBA-2',
28 DATA_UNITS => 'pW',
29 );
30  
31 # NULL mappings used to override base class implementations
32 10 my @NULL_MAP = ();
33  
34 # Unit mapping implies that the value propogates directly
35 # to the output with only a keyword name change.
36  
37 10 my %UNIT_MAP = (
38 FILTER => "FILTER",
39 INSTRUMENT => "INSTRUME",
40 DR_GROUP => "DRGROUP",
41 OBSERVATION_TYPE => "OBS_TYPE",
42 UTDATE => "UTDATE",
43 TELESCOPE => "TELESCOP",
44 AMBIENT_TEMPERATURE => 'ATSTART',
45 );
46  
47 # Values that are derived from the last subheader entry
48 10 my %ENDOBS_MAP = (
49 AIRMASS_END => 'AMEND',
50 AZIMUTH_END => 'AZEND',
51 ELEVATION_END => 'ELEND',
52 );
53  
54 # Create the translation methods
55 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP, \%ENDOBS_MAP );
56  
57 =head1 METHODS
58  
59 =over 4
60  
61 =item B<this_instrument>
62  
63 The name of the instrument required to match (case insensitively)
64 against the INSTRUME/INSTRUMENT keyword to allow this class to
65 translate the specified headers. Called by the default
66 C<can_translate> method.
67  
68 $inst = $class->this_instrument();
69  
70 Returns "SCUBA-2".
71  
72 =cut
73  
74 21 ▶sub this_instrument {
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
75 21 return "SCUBA-2";
76 }
77  
78 =back
79  
80 =head1 COMPLEX CONVERSIONS
81  
82 These methods are more complicated than a simple mapping. We have to
83 provide both from- and to-FITS conversions All these routines are
84 methods and the to_ routines all take a reference to a hash and return
85 the translated value (a many-to-one mapping) The from_ methods take a
86 reference to a generic hash and return a translated hash (sometimes
87 these are many-to-many)
88  
89 =over 4
90  
91 =item B<to_OBSERVATION_MODE>
92  
93 If Observation type is SCIENCE, return the sample mode, else
94 return the sample mode and observation type. For example, "STARE",
95 "SCAN", "SCAN_POINTING".
96  
97 Do not currently take into account polarimeter or FTS.
98  
99 =cut
100  
101 3 ▶sub to_OBSERVATION_MODE {
Subroutine to_OBSERVATION_MODE: called CC=5 SCAR=16.6
Pod documented
102 3 my $self = shift;
103 3 my $FITS_headers = shift;
104  
105 3 my $return;
106 3 ▶ if ( exists( $FITS_headers->{'SAM_MODE'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"SAM_MODE"} and exists $FITS_headers->{"OBS_TYPE"}) 3 0 3
Condition33%1/3
exists $FITS_headers->{"SAM_MODE"} and exists $FITS_headers->{"OBS_TYPE"}
!ll&&!rl&&r
003
MC/DC0%0/2
exists $FITS_headers->{"SAM_MODE"} and exists $FITS_headers->{"OBS_TYPE"}
exists $FITS_headers->{"SAM_MODE"} exists $FITS_headers->{"OBS_TYPE"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"SAM_MODE"}B= exists $FITS_headers->{"OBS_TYPE"}
ABresult
0X0
100
111
107 exists( $FITS_headers->{'OBS_TYPE'} ) ) {
108 3 my $sam_mode = $FITS_headers->{'SAM_MODE'};
109 3 $sam_mode =~ s/\s//g;
110 3 my $obs_type = $FITS_headers->{'OBS_TYPE'};
111 3 $obs_type =~ s/\s//g;
112  
113 3 $return = $sam_mode;
114 3 ▶ if ($obs_type !~ /science/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obs_type =~ /science/i) 2 1 3
115 2 ▶ if ($obs_type =~ /(setup)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obs_type =~ /(setup)/i) { } 0 2 2
116 0 $return = lc($1);
117 } else {
118 2 $return .= "_$obs_type";
119 }
120 }
121 }
122 3 return $return;
123 }
124  
125 =item B<to_SUBSYSTEM_IDKEY>
126  
127 =cut
128  
129 3 ▶sub to_SUBSYSTEM_IDKEY {
Subroutine to_SUBSYSTEM_IDKEY: called CC=2 SCAR=7.0
Pod documented
130 3 my $self = shift;
131 3 my $FITS_headers = shift;
132  
133 # Try the general headers first
134 3 my $general = $self->SUPER::to_SUBSYSTEM_IDKEY( $FITS_headers );
135 3 ▶ return ( defined $general ? $general : "FILTER" );
Branch: 1 branch
BranchTrueFalseTotal
defined $general ? : 3 0 3
136 }
137  
138 =item B<to_DR_RECIPE>
139  
140 Fix up recipes that were incorrect in the early years of the
141 observing tool.
142  
143 Converts SASSy survey data to use the SASSy recipe.
144  
145 =cut
146  
147 3 ▶sub to_DR_RECIPE {
Subroutine to_DR_RECIPE: called CC=4 SCAR=17.3
Pod documented
148 3 my $class = shift;
149 3 my $FITS_headers = shift;
150 3 my $dr = $FITS_headers->{RECIPE};
151 3 my $survey = $FITS_headers->{SURVEY};
152  
153 3 ▶ if (defined $survey && $survey =~ /sassy/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $survey and $survey =~ /sassy/i) 0 3 3
Condition33%1/3
defined $survey and $survey =~ /sassy/i
!ll&&!rl&&r
030
MC/DC0%0/2
defined $survey and $survey =~ /sassy/i
defined $survey $survey =~ /sassy/i
Truth table33%1/3
A and B
A= defined $surveyB= $survey =~ /sassy/i
ABresult
0X0
100
111
154 0 ▶ if ($dr !~ /sassy/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dr =~ /sassy/i) 0 0 0
155 0 $dr = "REDUCE_SASSY";
156 }
157 }
158 3 return $dr;
159 }
160  
161 =item B<to_POLARIMETER>
162  
163 Determine if POL-2 is in the beam, based on the INBEAM header.
164  
165 =cut
166  
167 3 ▶sub to_POLARIMETER {
Subroutine to_POLARIMETER: called CC=3 SCAR=11.0
Pod documented
168 3 my $class = shift;
169 3 my $FITS_headers = shift;
170  
171 3 my $inbeam = $FITS_headers->{'INBEAM'};
172  
173 3 ▶ return 0 unless defined $inbeam;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $inbeam 1 2 3
174  
175 2 ▶ return ($inbeam =~ /\bpol/i) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$inbeam =~ /\bpol/i ? : 2 0 2
176 }
177  
178 =item B<from_POLARIMETER>
179  
180 Attempt to recreate the INBEAM header. Since this also
181 depends on FTS-2, use the _reconstruct_INBEAM method.
182  
183 =cut
184  
185 1 ▶sub from_POLARIMETER {
Subroutine from_POLARIMETER: called CC=1 SCAR=0.0
Pod documented
186 1 my $class = shift;
187 1 my $generic_headers = shift;
188  
189 1 return $class->_reconstruct_INBEAM($generic_headers);
190 }
191  
192 =item B<to_FOURIER_TRANSFORM_SPECTROMETER>
193  
194 Determine if FTS-2 is in the beam, based on the INBEAM header.
195  
196 =cut
197  
198 3 ▶sub to_FOURIER_TRANSFORM_SPECTROMETER {
Subroutine to_FOURIER_TRANSFORM_SPECTROMETER: called CC=3 SCAR=11.0
Pod documented
199 3 my $class = shift;
200 3 my $FITS_headers = shift;
201  
202 3 my $inbeam = $FITS_headers->{'INBEAM'};
203  
204 3 ▶ return 0 unless defined $inbeam;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $inbeam 1 2 3
205  
206 2 ▶ return ($inbeam =~ /\bfts/i) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$inbeam =~ /\bfts/i ? : 2 0 2
207 }
208  
209 =item B<from_FOURIER_TRANSFORM_SPECTROMETER>
210  
211 Attempt to recreate the INBEAM header. Since this also
212 depends on POL-2, use the _reconstruct_INBEAM method.
213  
214 =cut
215  
216 1 ▶sub from_FOURIER_TRANSFORM_SPECTROMETER {
Subroutine from_FOURIER_TRANSFORM_SPECTROMETER: called CC=1 SCAR=0.0
Pod documented
217 1 my $class = shift;
218 1 my $generic_headers = shift;
219  
220 1 return $class->_reconstruct_INBEAM($generic_headers);
221 }
222  
223  
224 =item B<_reconstruct_INBEAM>
225  
226 Since the INBEAM header becomes multiple generic headers, we need to look at
227 them all to reconstruct it. In order to work within the confines of the
228 Astro::FITS::HdrTrans::Base::translate_to_FITS method, we need to work
229 on a per-generic header basis. This internal method can then be used for
230 the "from_" method for each of these. It will end up returning the same
231 INBEAM header each time -- the versions generated from different generic
232 headers will overwrite eachother in the Base translate_to_FITS method
233 but that shouldn't be a problem.
234  
235 Note that the INBEAM header may not be reconstructed exactly. For example
236 it will just include the short form "pol" even if it would originally have
237 included specific POL-2 components instead.
238  
239 =cut
240  
241 2 ▶sub _reconstruct_INBEAM {
Subroutine _reconstruct_INBEAM: called CC=4 SCAR=14.2
242 2 my $class = shift;
243 2 my $generic_headers = shift;
244  
245 2 my @components;
246  
247 2 ▶ push @components, 'fts2' if $generic_headers->{'FOURIER_TRANSFORM_SPECTROMETER'};
Branch: 1 branch
BranchTrueFalseTotal
if $generic_headers->{"FOURIER_TRANSFORM_SPECTROMETER"} 2 0 2
248  
249 2 ▶ push @components, 'pol' if $generic_headers->{'POLARIMETER'};
Branch: 1 branch
BranchTrueFalseTotal
if $generic_headers->{"POLARIMETER"} 2 0 2
250  
251 2 my $inbeam = undef;
252  
253 2 ▶ $inbeam = join(' ', @components) if scalar @components;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @components 2 0 2
254  
255 2 return (INBEAM => $inbeam);
256 }
257  
258 =back
259  
260 =head1 SEE ALSO
261  
262 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::Base>
263  
264 =head1 AUTHOR
265  
266 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>
267  
268 =head1 COPYRIGHT
269  
270 Copyright (C) 2007-2009,2011,2013 Science & Technology Facilities Council.
271 Copyright (C) 2003-2005 Particle Physics and Astronomy Research Council.
272 All Rights Reserved.
273  
274 This program is free software; you can redistribute it and/or modify it under
275 the terms of the GNU General Public License as published by the Free Software
276 Foundation; either Version 2 of the License, or (at your option) any later
277 version.
278  
279 This program is distributed in the hope that it will be useful,but WITHOUT ANY
280 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
281 PARTICULAR PURPOSE. See the GNU General Public License for more details.
282  
283 You should have received a copy of the GNU General Public License along with
284 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
285 Place, Suite 330, Boston, MA 02111-1307, USA.
286  
287 =cut
288  
289 10 1;
« HdrTrans/UIST.pm ↑ Summary HdrTrans/UKIRT.pm »