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

filter: Statementstmt 70.5% 196 / 278 Branchbran 31.7% 47 / 148 Conditioncond 36.0% 40 / 111 MC/DCmcdc 3.1% 2 / 63 Subroutinesub 100% 31 / 31 Podpod 100% 19 / 19 totaltotal 51.5% 335 / 650 CC 112 SCAR 33.4
CC
112
Cov
53%
to_VELOCITY
101.6
to_SYSTEM_VELOCITY
48.9
to_OBSERVATION_TYPE
44.2
CRAP 28.3
« blib/lib/Astro/FITS/HdrTrans/LCOFLOYDS.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/ESO.pm »
1 package Astro::FITS::HdrTrans::ACSIS;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::ACSIS - class for translation of JCMT ACSIS headers
6  
7 =head1 SYNOPSIS
8  
9 use Astro::FITS::HdrTrans::ACSIS;
10  
11 =head1 DESCRIPTION
12  
13 This class provides a set of translations for ACSIS at JCMT.
14  
15 =cut
16  
17 10 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 10 ▶use Astro::Coords;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 10 ▶use Astro::Telescope;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 10 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 10 ▶use DateTime::TimeZone;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 # inherit from the Base translation class and not HdrTrans
28 # itself (which is just a class-less wrapper)
29 10 ▶use base qw/ Astro::FITS::HdrTrans::JCMT /;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 # Use the FITS standard DATE-OBS handling
32 #use Astro::FITS::HdrTrans::FITS;
33  
34 # Speed of light in km/s.
35 10 ▶use constant CLIGHT => 2.99792458e5;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 10 ▶use vars qw/ $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 10 $VERSION = "1.65";
40  
41 # Cache UTC definition
42 10 our $UTC = DateTime::TimeZone->new( name => 'UTC' );
43  
44 # in each class we have three sets of data.
45 # - constant mappings
46 # - unit mappings
47 # - complex mappings
48  
49 # for a constant mapping, there is no FITS header, just a generic
50 # header that is constant
51 10 my %CONST_MAP = (
52 INST_DHS => 'ACSIS',
53 );
54  
55 # unit mapping implies that the value propagates directly
56 # to the output with only a keyword name change
57  
58 10 my %UNIT_MAP = (
59 AIRMASS_END => 'AMEND',
60 AMBIENT_TEMPERATURE=> 'ATSTART',
61 AZIMUTH_END => 'AZEND',
62 BACKEND => 'BACKEND',
63 BANDWIDTH_MODE => 'BWMODE',
64 CHOP_ANGLE => 'CHOP_PA',
65 CHOP_COORDINATE_SYSTEM => 'CHOP_CRD',
66 CHOP_FREQUENCY => 'CHOP_FRQ',
67 CHOP_THROW => 'CHOP_THR',
68 ELEVATION_END => 'ELEND',
69 FRONTEND => 'INSTRUME',
70 NUMBER_OF_CYCLES => 'NUM_CYC',
71 SWITCH_MODE => 'SW_MODE',
72 SPECIES => 'MOLECULE',
73 VELOCITY_TYPE => 'DOPPLER',
74 SIDEBAND_MODE => 'SB_MODE',
75 OBSERVED_SIDEBAND => 'OBS_SB',
76 TRACKING_SIDEBAND => 'TRACK_SB',
77 );
78  
79 # Create the translation methods
80 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP );
81  
82 =head1 METHODS
83  
84 =over 4
85  
86 =item B<can_translate>
87  
88 Returns true if the supplied headers can be handled by this class.
89  
90 $cando = $class->can_translate( \%hdrs );
91  
92 For this class, the method will return true if the B<BACKEND> header exists
93 and matches 'ACSIS'.
94  
95 Can also match translated GSD files.
96  
97 =cut
98  
99 sub can_translate {
100 21 ▶ my $self = shift;
Subroutine can_translate: called CC=12 SCAR=29.9
Pod documented
101 21 my $headers = shift;
102  
103 21 ▶ if ( exists $headers->{BACKEND} &&
Branch: 3 branches
BranchTrueFalseTotal
if (exists $headers->{'BACKEND'} and defined $headers->{'BACKEND'} and $headers->{'BACKEND'} =~ /^ACSIS/i) { } 2 19 21
elsif (exists $headers->{'BACKEND'} and defined $headers->{'BACKEND'} and $headers->{'BACKEND'} =~ /^DAS/i and not exists $headers->{'GSDFILE'} && exists $headers->{'SCA#'}) { } 0 19 19
elsif (exists $headers->{'INST_DHS'} and defined $headers->{'INST_DHS'} and $headers->{'INST_DHS'} eq 'ACSIS') { } 0 19 19
Condition83%5/6
exists $headers->{"BACKEND"} and defined $headers->{"BACKEND"} and $headers->{"BACKEND"} =~ /^ACSIS/i
!ll&&!rl&&r
1812
exists $headers->{"BACKEND"} and defined $headers->{"BACKEND"}
!ll&&!rl&&r
1803
MC/DC66%2/3
exists $headers->{"BACKEND"} and defined $headers->{"BACKEND"} and $headers->{"BACKEND"} =~ /^ACSIS/i
exists $headers->{"BACKEND"} defined $headers->{"BACKEND"} $headers->{"BACKEND"} =~ /^ACSIS/i
Truth table75%3/4
A and B and C
A= exists $headers->{"BACKEND"}B= defined $headers->{"BACKEND"}C= $headers->{"BACKEND"} =~ /^ACSIS/i
ABCresult
0XX0
10X0
1100
1111
104 defined $headers->{BACKEND} &&
105 $headers->{BACKEND} =~ /^ACSIS/i
106 ) {
107 2 return 1;
108  
109 # BACKEND will discriminate between DAS files converted to ACSIS format
110 # from GSD format directly (handled by Astro::FITS::HdrTrans::JCMT_GSD).
111 ▶ } elsif ( exists $headers->{BACKEND} &&
Condition58%7/12
exists $headers->{"BACKEND"} and defined $headers->{"BACKEND"} and $headers->{"BACKEND"} =~ /^DAS/i and not exists $headers->{"GSDFILE"} && exists $headers->{"SCA#"}
!ll&&!rl&&r
1810
exists $headers->{"BACKEND"} and defined $headers->{"BACKEND"} and $headers->{"BACKEND"} =~ /^DAS/i
!ll&&!rl&&r
1801
exists $headers->{"BACKEND"} and defined $headers->{"BACKEND"}
!ll&&!rl&&r
1801
exists $headers->{'GSDFILE'} && exists $headers->{'SCA#'}
!ll&&!rl&&r
001
MC/DC0%0/5
exists $headers->{"BACKEND"} and defined $headers->{"BACKEND"} and $headers->{"BACKEND"} =~ /^DAS/i and not exists $headers->{"GSDFILE"} && exists $headers->{"SCA#"}
exists $headers->{"BACKEND"} defined $headers->{"BACKEND"} $headers->{"BACKEND"} =~ /^DAS/i exists $headers->{'GSDFILE'} exists $headers->{'SCA#'}
Truth table33%2/6
A and B and C and not(D && E)
A= exists $headers->{"BACKEND"}B= defined $headers->{"BACKEND"}C= $headers->{"BACKEND"} =~ /^DAS/iD= exists $headers->{'GSDFILE'}E= exists $headers->{'SCA#'}
ABCDEresult
0XXXX0
10XXX0
110XX0
111110
1110X1
111101
112 defined $headers->{BACKEND} &&
113 $headers->{BACKEND} =~ /^DAS/i &&
114 ! (exists $headers->{'GSDFILE'} && exists $headers->{'SCA#'})) {
115 # Do not want to confuse with reverse conversion
116 # of JCMT_GSD data headers which will have a defined
117 # BACKEND header of DAS.
118 0 return 1;
119 ▶ } elsif ( exists $headers->{INST_DHS} &&
Condition33%2/6
exists $headers->{"INST_DHS"} and defined $headers->{"INST_DHS"} and $headers->{"INST_DHS"} eq "ACSIS"
!ll&&!rl&&r
1900
exists $headers->{"INST_DHS"} and defined $headers->{"INST_DHS"}
!ll&&!rl&&r
1900
MC/DC0%0/3
exists $headers->{"INST_DHS"} and defined $headers->{"INST_DHS"} and $headers->{"INST_DHS"} eq "ACSIS"
exists $headers->{"INST_DHS"} defined $headers->{"INST_DHS"} $headers->{"INST_DHS"} eq "ACSIS"
Truth table25%1/4
A and B and C
A= exists $headers->{"INST_DHS"}B= defined $headers->{"INST_DHS"}C= $headers->{"INST_DHS"} eq "ACSIS"
ABCresult
0XX0
10X0
1100
1111
120 defined $headers->{INST_DHS} &&
121 $headers->{INST_DHS} eq 'ACSIS') {
122 # This is for the reverse conversion of DAS data
123 0 return 1;
124 } else {
125 19 return 0;
126 }
127 }
128  
129 =back
130  
131 =head1 COMPLEX CONVERSIONS
132  
133 These methods are more complicated than a simple mapping. We have to
134 provide both from- and to-FITS conversions All these routines are
135 methods and the to_ routines all take a reference to a hash and return
136 the translated value (a many-to-one mapping) The from_ methods take a
137 reference to a generic hash and return a translated hash (sometimes
138 these are many-to-many)
139  
140 =over 4
141  
142 =item B<to_DR_RECIPE>
143  
144 Usually simply copies the RECIPE header. If the header is undefined,
145 initially set the recipe to REDUCE_SCIENCE. If the observation type
146 is skydip and the RECIPE header is "REDUCE_SCIENCE", actually use
147 REDUCE_SKYDIP. If a skydip is not being done and the STANDARD header
148 is true, then the recipe is set to REDUCE_STANDARD. If the INBEAM
149 header is "POL", the recipe name has "_POL" appended if it is a
150 science observation. "REDUCE_SCIENCE" is translated to
151 "REDUCE_SCIENCE_GRADIENT".
152  
153 =cut
154  
155 sub to_DR_RECIPE {
156 1 ▶ my $class = shift;
Subroutine to_DR_RECIPE: called CC=13 SCAR=33.8
Pod documented
157 1 my $FITS_headers = shift;
158  
159 1 my $dr = $FITS_headers->{RECIPE};
160 1 ▶ if ( defined( $dr ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dr) { } 1 0 1
161 1 $dr = uc( $dr );
162 } else {
163 0 $dr = 'REDUCE_SCIENCE';
164 }
165  
166 1 my $obstype = lc( $class->to_OBSERVATION_TYPE( $FITS_headers ) );
167 1 my $pol = $class->to_POLARIMETER( $FITS_headers );
168 1 my $standard = $class->to_STANDARD( $FITS_headers );
169 1 my $utdate = $class->to_UTDATE( $FITS_headers );
170 1 my $freq_sw = $class->_is_FSW( $FITS_headers );
171  
172 1 ▶ if ($utdate < 20080701) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate < 20080701) 1 0 1
173 1 ▶ if ($obstype eq 'skydip' && $dr eq 'REDUCE_SCIENCE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($obstype eq "skydip" and $dr eq "REDUCE_SCIENCE") 0 1 1
Condition33%1/3
$obstype eq "skydip" and $dr eq "REDUCE_SCIENCE"
!ll&&!rl&&r
100
MC/DC0%0/2
$obstype eq "skydip" and $dr eq "REDUCE_SCIENCE"
$obstype eq "skydip" $dr eq "REDUCE_SCIENCE"
Truth table33%1/3
A and B
A= $obstype eq "skydip"B= $dr eq "REDUCE_SCIENCE"
ABresult
0X0
100
111
174 0 $dr = "REDUCE_SKYDIP";
175 }
176 }
177  
178 1 my $is_sci = ( $obstype =~ /science|raster|scan|grid|jiggle/ );
179  
180 1 ▶ if ( $standard && $is_sci ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($standard and $is_sci) 0 1 1
Condition33%1/3
$standard and $is_sci
!ll&&!rl&&r
100
MC/DC0%0/2
$standard and $is_sci
$standard $is_sci
Truth table33%1/3
A and B
A= $standardB= $is_sci
ABresult
0X0
100
111
181 0 $dr = "REDUCE_STANDARD";
182 }
183  
184 # Append unless we have already appended
185 1 ▶ if ( $utdate > 20081115 && $pol && $is_sci ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate > 20081115 and $pol and $is_sci) 0 1 1
Condition33%2/6
$utdate > 20081115 and $pol and $is_sci
!ll&&!rl&&r
100
$utdate > 20081115 and $pol
!ll&&!rl&&r
100
MC/DC0%0/3
$utdate > 20081115 and $pol and $is_sci
$utdate > 20081115 $pol $is_sci
Truth table25%1/4
A and B and C
A= $utdate > 20081115B= $polC= $is_sci
ABCresult
0XX0
10X0
1100
1111
186 0 ▶ $dr .= "_POL" unless $dr =~ /_POL$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $dr =~ /_POL$/ 0 0 0
187 }
188  
189 1 ▶ if ( $dr eq 'REDUCE_SCIENCE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dr eq "REDUCE_SCIENCE") 0 1 1
190 0 ▶ $dr .= '_' . ($freq_sw ? 'FSW' : 'GRADIENT');
Branch: 1 branch
BranchTrueFalseTotal
$freq_sw ? : 0 0 0
191 }
192  
193 1 return $dr;
194 }
195  
196 =item B<from_DR_RECIPE>
197  
198 Returns DR_RECIPE unless we have a skydip.
199  
200 =cut
201  
202 sub from_DR_RECIPE {
203 1 ▶ my $class = shift;
Subroutine from_DR_RECIPE: called CC=5 SCAR=18.7
Pod documented
204 1 my $generic_headers = shift;
205 1 my $dr = $generic_headers->{DR_RECIPE};
206 1 my $ut = $generic_headers->{UTDATE};
207 1 ▶ if (defined $ut && $ut < 20080615) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ut and $ut < 20080615) 1 0 1
Condition33%1/3
defined $ut and $ut < 20080615
!ll&&!rl&&r
001
MC/DC0%0/2
defined $ut and $ut < 20080615
defined $ut $ut < 20080615
Truth table33%1/3
A and B
A= defined $utB= $ut < 20080615
ABresult
0X0
100
111
208 1 ▶ if (defined $dr && $dr eq 'REDUCE_SKYDIP') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dr and $dr eq "REDUCE_SKYDIP") 0 1 1
Condition33%1/3
defined $dr and $dr eq "REDUCE_SKYDIP"
!ll&&!rl&&r
010
MC/DC0%0/2
defined $dr and $dr eq "REDUCE_SKYDIP"
defined $dr $dr eq "REDUCE_SKYDIP"
Truth table33%1/3
A and B
A= defined $drB= $dr eq "REDUCE_SKYDIP"
ABresult
0X0
100
111
209 0 $dr = 'REDUCE_SCIENCE';
210 }
211 }
212 1 return ("RECIPE" => $dr);
213 }
214  
215 =item B<to_POLARIMETER>
216  
217 If the polarimeter is in the beam, as denoted by the INBEAM header
218 containing "POL", then this returns true. Otherwise, return false.
219  
220 =cut
221  
222 sub to_POLARIMETER {
223 2 ▶ my $class = shift;
Subroutine to_POLARIMETER: called CC=4 SCAR=16.1
Pod documented
224 2 my $FITS_headers = shift;
225  
226 2 my $inbeam = $FITS_headers->{INBEAM};
227 2 my $utdate = $class->to_UTDATE( $FITS_headers );
228  
229 2 ▶ if ( $utdate > 20081115 &&
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate > 20081115 and defined $inbeam and $inbeam =~ /pol/i) 0 2 2
Condition33%2/6
$utdate > 20081115 and defined $inbeam and $inbeam =~ /pol/i
!ll&&!rl&&r
200
$utdate > 20081115 and defined $inbeam
!ll&&!rl&&r
200
MC/DC0%0/3
$utdate > 20081115 and defined $inbeam and $inbeam =~ /pol/i
$utdate > 20081115 defined $inbeam $inbeam =~ /pol/i
Truth table25%1/4
A and B and C
A= $utdate > 20081115B= defined $inbeamC= $inbeam =~ /pol/i
ABCresult
0XX0
10X0
1100
1111
230 defined( $inbeam ) &&
231 $inbeam =~ /pol/i ) {
232 0 return 1;
233 }
234 2 return 0;
235 }
236  
237 =item B<from_POLARIMETER>
238  
239 If the POLARIMETER header is true, then return "POL" for the INBEAM
240 header. Otherwise, return undef.
241  
242 =cut
243  
244 sub from_POLARIMETER {
245 1 ▶ my $class = shift;
Subroutine from_POLARIMETER: called CC=2 SCAR=7.2
Pod documented
246 1 my $generic_headers = shift;
247  
248 1 my $pol = $generic_headers->{POLARIMETER};
249  
250 1 ▶ if ( $pol ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pol) 0 1 1
251 0 return ( "INBEAM" => "POL" );
252 }
253  
254 1 return ( "INBEAM" => undef );
255 }
256  
257 =item B<to_REFERENCE_LOCATION>
258  
259 Creates a string representing the location of the reference spectrum
260 to the nearest hundredth of a degree. It takes the form
261 system_longitude_latitude where system will normally be J2000 or GAL.
262 If the string cannot be evaluated (such as missing headers), the
263 returned value is undefined.
264  
265 =cut
266  
267 sub to_REFERENCE_LOCATION {
268 1 ▶ my $self = shift;
Subroutine to_REFERENCE_LOCATION: called CC=13 SCAR=36.7
Pod documented
269 1 my $FITS_headers = shift;
270  
271 # Set the returned value in case something goes awry.
272 1 my $ref_location = undef;
273  
274 # Assume that the co-ordinate system is the same for the BASE
275 # co-ordinates as the offset to the reference spectrum.
276 1 my ( $system, $base_lon, $base_lat );
277  
278 $system = defined( $FITS_headers->{'TRACKSYS'} ) ?
279 1 ▶ $FITS_headers->{'TRACKSYS'} :
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'TRACKSYS'} ? : 0 1 1
280 undef;
281 1 ▶ $system =~ s/\s+$// if defined( $system );
Branch: 1 branch
BranchTrueFalseTotal
if defined $system 0 1 1
282  
283 # Obtain the base location's longitude in decimal degrees.
284 $base_lon = defined( $FITS_headers->{'BASEC1'} ) ?
285 1 ▶ $FITS_headers->{'BASEC1'} :
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'BASEC1'} ? : 0 1 1
286 undef;
287  
288 # Obtain the base location's latitude in decimal degrees.
289 $base_lat = defined( $FITS_headers->{'BASEC2'} ) ?
290 1 ▶ $FITS_headers->{'BASEC2'} :
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'BASEC2'} ? : 0 1 1
291 undef;
292  
293 # Derive the reference position's longitude.
294 1 my $ref_lon = undef;
295 1 ▶ if ( defined( $system ) && defined( $base_lon ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $system and defined $base_lon) 0 1 1
Condition33%1/3
defined $system and defined $base_lon
!ll&&!rl&&r
100
MC/DC0%0/2
defined $system and defined $base_lon
defined $system defined $base_lon
Truth table33%1/3
A and B
A= defined $systemB= defined $base_lon
ABresult
0X0
100
111
296  
297 # The value of SKYREFX has the form
298 # [OFFSET] <longitude_offset_in_arcsec> [<co-ordinate system>]
299 #
300 # Assume for now that the TRACKSYS and co-ordinate system are the
301 # same.
302 0 ▶ if ( defined( $FITS_headers->{'SKYREFX'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"SKYREFX"}) 0 0 0
303 0 my $ref_x = $FITS_headers->{'SKYREFX'};
304 0 my @comps = split( /\s+/, $ref_x );
305 0 my $offset_lon = $comps[1] / 3600.0;
306  
307 # Two decimal places should permit sufficient fuzziness.
308 0 $ref_lon = sprintf( "%.2f", $base_lon + $offset_lon );
309 }
310 }
311  
312 # Derive the reference position's latitude.
313 1 my $ref_lat = undef;
314 1 ▶ if ( defined( $system ) && defined( $base_lat ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $system and defined $base_lat) 0 1 1
Condition33%1/3
defined $system and defined $base_lat
!ll&&!rl&&r
100
MC/DC0%0/2
defined $system and defined $base_lat
defined $system defined $base_lat
Truth table33%1/3
A and B
A= defined $systemB= defined $base_lat
ABresult
0X0
100
111
315  
316 # The value of SKYREFY has the form
317 # [OFFSET] <latitude_offset_in_arcsec> [<co-ordinate system>]
318 #
319 # Assume for now that the TRACKSYS and co-ordinate system are the
320 # same.
321 0 ▶ if ( defined( $FITS_headers->{'SKYREFY'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"SKYREFY"}) 0 0 0
322 0 my $ref_y = $FITS_headers->{'SKYREFY'};
323 0 my @comps = split( /\s+/, $ref_y );
324 0 my $offset_lat = $comps[1] / 3600.0;
325 0 $ref_lat = sprintf( "%.2f", $base_lat + $offset_lat );
326 }
327 }
328  
329 # Form the string comprising the three elements.
330 1 ▶ if ( defined( $ref_lon ) && defined( $ref_lat ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ref_lon and defined $ref_lat) 0 1 1
Condition33%1/3
defined $ref_lon and defined $ref_lat
!ll&&!rl&&r
100
MC/DC0%0/2
defined $ref_lon and defined $ref_lat
defined $ref_lon defined $ref_lat
Truth table33%1/3
A and B
A= defined $ref_lonB= defined $ref_lat
ABresult
0X0
100
111
331 0 $ref_location = $system . "_" . $ref_lon . "_" . $ref_lat;
332 }
333  
334 1 return $ref_location;
335 }
336  
337  
338 =item B<to_SAMPLE_MODE>
339  
340 If the SAM_MODE value is either 'raster' or 'scan', return
341 'scan'. Otherwise, return the value in lowercase.
342  
343 =cut
344  
345 sub to_SAMPLE_MODE {
346 1 ▶ my $self = shift;
Subroutine to_SAMPLE_MODE: called CC=3 SCAR=12.0
Pod documented
347 1 my $FITS_headers = shift;
348  
349 1 my $sam_mode;
350 1 ▶ if( defined( $FITS_headers->{'SAM_MODE'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'SAM_MODE'} and uc $FITS_headers->{'SAM_MODE'} eq 'RASTER') { } 0 1 1
Condition33%1/3
defined $FITS_headers->{"SAM_MODE"} and uc $FITS_headers->{"SAM_MODE"} eq "RASTER"
!ll&&!rl&&r
010
MC/DC0%0/2
defined $FITS_headers->{"SAM_MODE"} and uc $FITS_headers->{"SAM_MODE"} eq "RASTER"
defined $FITS_headers->{"SAM_MODE"} uc $FITS_headers->{"SAM_MODE"} eq "RASTER"
Truth table33%1/3
A and B
A= defined $FITS_headers->{"SAM_MODE"}B= uc $FITS_headers->{"SAM_MODE"} eq "RASTER"
ABresult
0X0
100
111
351 uc( $FITS_headers->{'SAM_MODE'} ) eq 'RASTER' ) {
352 0 $sam_mode = 'scan';
353 } else {
354 1 $sam_mode = lc( $FITS_headers->{'SAM_MODE'} );
355 }
356 1 return $sam_mode;
357 }
358  
359 =item B<to_SURVEY>
360  
361 Checks the value of the SURVEY header and uses that. If it's
362 undefined, then use the PROJECT header to determine an appropriate
363 survey.
364  
365 =cut
366  
367 sub to_SURVEY {
368 1 ▶ my $self = shift;
Subroutine to_SURVEY: called CC=7 SCAR=27.5
Pod documented
369 1 my $FITS_headers = shift;
370  
371 1 my $survey;
372  
373 1 ▶ if( defined( $FITS_headers->{'SURVEY'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'SURVEY'}) { } 0 1 1
374 0 $survey = $FITS_headers->{'SURVEY'};
375 } else {
376  
377 1 my $project = $FITS_headers->{'PROJECT'};
378 1 ▶ if( defined( $project ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $project) 1 0 1
379 1 ▶ if( $project =~ /JLS([GNS])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($project =~ /JLS([GNS])/) 0 1 1
380 0 ▶ if( $1 eq 'G' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($1 eq 'G') { } 0 0 0
elsif ($1 eq 'N') { } 0 0 0
elsif ($1 eq 'S') { } 0 0 0
381 0 $survey = 'GBS';
382 } elsif( $1 eq 'N' ) {
383 0 $survey = 'NGS';
384 } elsif( $1 eq 'S' ) {
385 0 $survey = 'SLS';
386 }
387 }
388 }
389 }
390  
391 1 return $survey;
392  
393 }
394  
395 =item B<to_EXPOSURE_TIME>
396  
397 Uses the to_UTSTART and to_UTEND functions to calculate the exposure
398 time. Returns the exposure time as a scalar, not as a Time::Seconds
399 object.
400  
401 =cut
402  
403 sub to_EXPOSURE_TIME {
404 1 ▶ my $self = shift;
Subroutine to_EXPOSURE_TIME: called CC=5 SCAR=17.2
Pod documented
405 1 my $FITS_headers = shift;
406  
407 # force date headers to be standardized
408 1 $self->_fix_dates( $FITS_headers );
409  
410 1 my $return;
411 1 ▶ if ( exists( $FITS_headers->{'DATE-OBS'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"DATE-OBS"} and exists $FITS_headers->{"DATE-END"}) 1 0 1
Condition33%1/3
exists $FITS_headers->{"DATE-OBS"} and exists $FITS_headers->{"DATE-END"}
!ll&&!rl&&r
001
MC/DC0%0/2
exists $FITS_headers->{"DATE-OBS"} and exists $FITS_headers->{"DATE-END"}
exists $FITS_headers->{"DATE-OBS"} exists $FITS_headers->{"DATE-END"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"DATE-OBS"}B= exists $FITS_headers->{"DATE-END"}
ABresult
0X0
100
111
412 exists( $FITS_headers->{'DATE-END'} ) ) {
413 1 my $start = $self->to_UTSTART( $FITS_headers );
414 1 my $end = $self->to_UTEND( $FITS_headers );
415 1 ▶ if (defined $start and defined $end) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $start and defined $end) 1 0 1
Condition33%1/3
defined $start and defined $end
!ll&&!rl&&r
001
MC/DC0%0/2
defined $start and defined $end
defined $start defined $end
Truth table33%1/3
A and B
A= defined $startB= defined $end
ABresult
0X0
100
111
416 1 my $duration = $end - $start;
417 1 $return = $duration->seconds;
418 }
419 }
420 1 return $return;
421 }
422  
423 =item B<to_INSTRUMENT>
424  
425 Converts the C<INSTRUME> header into the C<INSTRUMENT> header. If the
426 C<INSTRUME> header begins with "HARP" or "FE_HARP", then the
427 C<INSTRUMENT> header will be set to "HARP".
428  
429 =cut
430  
431 sub to_INSTRUMENT {
432 1 ▶ my $self = shift;
Subroutine to_INSTRUMENT: called CC=4 SCAR=15.2
Pod documented
433 1 my $FITS_headers = shift;
434 1 my $return;
435 1 ▶ if ( exists( $FITS_headers->{'INSTRUME'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"INSTRUME"}) 1 0 1
436 1 ▶ if ( $FITS_headers->{'INSTRUME'} =~ /^HARP/ ||
Branch: 1 branch
BranchTrueFalseTotal
if ($FITS_headers->{'INSTRUME'} =~ /^HARP/ or $FITS_headers->{'INSTRUME'} =~ /^FE_HARP/) { } 0 1 1
Condition33%1/3
$FITS_headers->{"INSTRUME"} =~ /^HARP/ or $FITS_headers->{"INSTRUME"} =~ /^FE_HARP/
l!l&&r!l&&!r
001
MC/DC0%0/2
$FITS_headers->{"INSTRUME"} =~ /^HARP/ or $FITS_headers->{"INSTRUME"} =~ /^FE_HARP/
$FITS_headers->{"INSTRUME"} =~ /^HARP/ $FITS_headers->{"INSTRUME"} =~ /^FE_HARP/
Truth table33%1/3
A or B
A= $FITS_headers->{"INSTRUME"} =~ /^HARP/B= $FITS_headers->{"INSTRUME"} =~ /^FE_HARP/
ABresult
1X1
011
000
437 $FITS_headers->{'INSTRUME'} =~ /^FE_HARP/ ) {
438 0 $return = "HARP";
439 } else {
440 1 $return = $FITS_headers->{'INSTRUME'};
441 }
442 }
443 1 return $return;
444 }
445  
446 =item B<to_OBSERVATION_ID>
447  
448 Converts the C<OBSID> header directly into the C<OBSERVATION_ID>
449 generic header, or if that header does not exist, converts the
450 C<BACKEND>, C<OBSNUM>, and C<DATE-OBS> headers into C<OBSERVATION_ID>.
451  
452 =cut
453  
454 sub to_OBSERVATION_ID {
455 1 ▶ my $self = shift;
Subroutine to_OBSERVATION_ID: called CC=6 SCAR=29.5
Pod documented
456 1 my $FITS_headers = shift;
457 1 my $return;
458 1 ▶ if ( exists( $FITS_headers->{'OBSID'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'OBSID'} and defined $FITS_headers->{'OBSID'}) { } 1 0 1
Condition33%1/3
exists $FITS_headers->{"OBSID"} and defined $FITS_headers->{"OBSID"}
!ll&&!rl&&r
001
MC/DC0%0/2
exists $FITS_headers->{"OBSID"} and defined $FITS_headers->{"OBSID"}
exists $FITS_headers->{"OBSID"} defined $FITS_headers->{"OBSID"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"OBSID"}B= defined $FITS_headers->{"OBSID"}
ABresult
0X0
100
111
459 defined( $FITS_headers->{'OBSID'} ) ) {
460 1 $return = $FITS_headers->{'OBSID'};
461 } else {
462 0 $self->_fix_dates( $FITS_headers );
463  
464 0 my $backend = lc( $self->to_BACKEND( $FITS_headers ) );
465 0 my $obsnum = $self->to_OBSERVATION_NUMBER( $FITS_headers );
466 0 my $dateobs = $self->to_UTSTART( $FITS_headers );
467  
468 0 ▶ if ( defined( $backend ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $backend and defined $obsnum and defined $dateobs) 0 0 0
Condition0%0/6
defined $backend and defined $obsnum and defined $dateobs
!ll&&!rl&&r
000
defined $backend and defined $obsnum
!ll&&!rl&&r
000
MC/DC0%0/3
defined $backend and defined $obsnum and defined $dateobs
defined $backend defined $obsnum defined $dateobs
Truth table0%0/4
A and B and C
A= defined $backendB= defined $obsnumC= defined $dateobs
ABCresult
0XX0
10X0
1100
1111
469 defined( $obsnum ) &&
470 defined( $dateobs ) ) {
471 0 my $datetime = $dateobs->datetime;
472 0 $datetime =~ s/-//g;
473 0 $datetime =~ s/://g;
474  
475 0 $return = join '_', $backend, $obsnum, $datetime;
476 }
477 }
478  
479 1 return $return;
480 }
481  
482 =item B<to_OBSERVATION_MODE>
483  
484 Concatenates the SAM_MODE, SW_MODE, and OBS_TYPE header keywords into
485 the OBSERVATION_MODE generic header, with spaces removed and joined
486 with underscores. For example, if SAM_MODE is 'jiggle ', SW_MODE is
487 'chop ', and OBS_TYPE is 'science ', then the OBSERVATION_MODE generic
488 header will be 'jiggle_chop_science'.
489  
490 =cut
491  
492 sub to_OBSERVATION_MODE {
493 1 ▶ my $self = shift;
Subroutine to_OBSERVATION_MODE: called CC=7 SCAR=21.0
Pod documented
494 1 my $FITS_headers = shift;
495  
496 1 my $return;
497 1 ▶ if ( exists( $FITS_headers->{'SAM_MODE'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"SAM_MODE"} and exists $FITS_headers->{"SW_MODE"} and exists $FITS_headers->{"OBS_TYPE"}) 1 0 1
Condition33%2/6
exists $FITS_headers->{"SAM_MODE"} and exists $FITS_headers->{"SW_MODE"} and exists $FITS_headers->{"OBS_TYPE"}
!ll&&!rl&&r
001
exists $FITS_headers->{"SAM_MODE"} and exists $FITS_headers->{"SW_MODE"}
!ll&&!rl&&r
001
MC/DC0%0/3
exists $FITS_headers->{"SAM_MODE"} and exists $FITS_headers->{"SW_MODE"} and exists $FITS_headers->{"OBS_TYPE"}
exists $FITS_headers->{"SAM_MODE"} exists $FITS_headers->{"SW_MODE"} exists $FITS_headers->{"OBS_TYPE"}
Truth table25%1/4
A and B and C
A= exists $FITS_headers->{"SAM_MODE"}B= exists $FITS_headers->{"SW_MODE"}C= exists $FITS_headers->{"OBS_TYPE"}
ABCresult
0XX0
10X0
1100
1111
498 exists( $FITS_headers->{'SW_MODE'} ) &&
499 exists( $FITS_headers->{'OBS_TYPE'} ) ) {
500 1 my $sam_mode = $FITS_headers->{'SAM_MODE'};
501 1 $sam_mode =~ s/\s//g;
502 1 ▶ $sam_mode = "raster" if $sam_mode eq "scan";
Branch: 1 branch
BranchTrueFalseTotal
if $sam_mode eq "scan" 0 1 1
503 1 my $sw_mode = $FITS_headers->{'SW_MODE'};
504 1 $sw_mode =~ s/\s//g;
505  
506 # handle OBS_TYPE missing
507 1 my $obs_type = $FITS_headers->{'OBS_TYPE'};
508 1 ▶ $obs_type = "science" unless $obs_type;
Branch: 1 branch
BranchTrueFalseTotal
unless $obs_type 0 1 1
509 1 $obs_type =~ s/\s//g;
510  
511 1 ▶ $return = ( ( $obs_type =~ /science/i )
Branch: 1 branch
BranchTrueFalseTotal
$obs_type =~ /science/i ? : 0 1 1
512 ? join '_', $sam_mode, $sw_mode
513 : join '_', $sam_mode, $sw_mode, $obs_type );
514 }
515 1 return $return;
516 }
517  
518 =item B<to_OBSERVATION_TYPE>
519  
520 Returns the type of observation that was done. If the OBS_TYPE header
521 matches /science/, the SAM_MODE header is used: if SAM_MODE matches
522 /raster/, then return 'raster'. If SAM_MODE matches /grid/, then
523 return 'grid'. If SAM_MODE matches /jiggle/, then return 'jiggle'.
524  
525 If the OBS_TYPE header matches /focus/, then return 'focus'. If the
526 OBS_TYPE header matches /pointing/, then return 'pointing'.
527  
528 If none of the above options hold, then return undef.
529  
530 =cut
531  
532 sub to_OBSERVATION_TYPE {
533 2 ▶ my $self = shift;
Subroutine to_OBSERVATION_TYPE: called CC=11 SCAR=37.9
Pod documented
534 2 my $FITS_headers = shift;
535  
536 2 my $return;
537 2 my $ot = $FITS_headers->{OBS_TYPE};
538  
539 # Sometimes we lack OBS_TYPE. In that case we have to assume SCIENCE
540 # even though the headers are broken. (eg 20080509#18 RxWD)
541 2 ▶ $ot = "science" unless $ot;
Branch: 1 branch
BranchTrueFalseTotal
unless $ot 0 2 2
542  
543 2 ▶ if ( $ot ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ot) 2 0 2
544 2 my $obs_type = lc( $ot );
545  
546 2 ▶ if ( $obs_type =~ /science/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($obs_type =~ /science/) { } 0 2 2
elsif ($obs_type =~ /focus/) { } 2 0 2
elsif ($obs_type =~ /pointing/) { } 0 0 0
elsif ($obs_type =~ /skydip/) { } 0 0 0
547  
548 0 ▶ if ( defined( $FITS_headers->{'SAM_MODE'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"SAM_MODE"}) 0 0 0
549  
550 0 my $sam_mode = $FITS_headers->{'SAM_MODE'};
551  
552 0 ▶ if ( $sam_mode =~ /raster|scan/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($sam_mode =~ /raster|scan/) { } 0 0 0
elsif ($sam_mode =~ /grid/) { } 0 0 0
elsif ($sam_mode =~ /jiggle/) { } 0 0 0
553 0 $return = "raster";
554 } elsif ( $sam_mode =~ /grid/ ) {
555 0 $return = "grid";
556 } elsif ( $sam_mode =~ /jiggle/ ) {
557 0 $return = "jiggle";
558 } else {
559 0 croak "Unexpected sample mode: '$sam_mode'";
560 }
561 }
562 } elsif ( $obs_type =~ /focus/ ) {
563 2 $return = "focus";
564 } elsif ( $obs_type =~ /pointing/ ) {
565 0 $return = "pointing";
566 } elsif ( $obs_type =~ /skydip/) {
567 0 $return = "skydip";
568 } else {
569 0 croak "Unexpected OBS_TYPE of '$obs_type'\n";
570 }
571 }
572  
573 2 return $return;
574 }
575  
576  
577 =item B<to_REST_FREQUENCY>
578  
579 Uses an C<Starlink::AST::FrameSet> object to determine the
580 frequency. If such an object is not passed in, then the rest frequency
581 is set to zero.
582  
583 Returns the rest frequency in Hz.
584  
585 =cut
586  
587 sub to_REST_FREQUENCY {
588 1 ▶ my $self = shift;
Subroutine to_REST_FREQUENCY: called CC=7 SCAR=28.0
Pod documented
589 1 my $FITS_headers = shift;
590 1 my $frameset = shift;
591  
592 1 my $return;
593  
594 1 ▶ if ( defined( $frameset ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $frameset and UNIVERSAL::isa($frameset, 'Starlink::AST::FrameSet')) { } 0 1 1
elsif (exists $FITS_headers->{'RESTFREQ'} or exists $FITS_headers->{'SUBHEADERS'} and exists $FITS_headers->{'SUBHEADERS'}[0]{'RESTFREQ'}) { } 0 1 1
Condition33%1/3
defined $frameset and UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
!ll&&!rl&&r
100
MC/DC0%0/2
defined $frameset and UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
defined $frameset UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
Truth table33%1/3
A and B
A= defined $framesetB= UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
ABresult
0X0
100
111
595 UNIVERSAL::isa( $frameset, "Starlink::AST::FrameSet" ) ) {
596 # in some rare cases restfreq is not set in the frameset
597 0 eval {
598 0 my $frequency = $frameset->Get( "restfreq" );
599 0 $return = $frequency * 1_000_000_000;
600 };
601 ▶ } elsif ( exists( $FITS_headers->{'RESTFREQ'} ) ||
Condition33%2/6
exists $FITS_headers->{"RESTFREQ"} or exists $FITS_headers->{"SUBHEADERS"} and exists $FITS_headers->{"SUBHEADERS"}[0]{"RESTFREQ"}
l!l&&r!l&&!r
001
exists $FITS_headers->{"SUBHEADERS"} and exists $FITS_headers->{"SUBHEADERS"}[0]{"RESTFREQ"}
!ll&&!rl&&r
010
MC/DC0%0/3
exists $FITS_headers->{"RESTFREQ"} or exists $FITS_headers->{"SUBHEADERS"} and exists $FITS_headers->{"SUBHEADERS"}[0]{"RESTFREQ"}
exists $FITS_headers->{"RESTFREQ"} exists $FITS_headers->{"SUBHEADERS"} exists $FITS_headers->{"SUBHEADERS"}[0]{"RESTFREQ"}
Truth table25%1/4
A or B and C
A= exists $FITS_headers->{"RESTFREQ"}B= exists $FITS_headers->{"SUBHEADERS"}C= exists $FITS_headers->{"SUBHEADERS"}[0]{"RESTFREQ"}
ABCresult
1XX1
0111
00X0
0100
602 ( exists( $FITS_headers->{'SUBHEADERS'} ) &&
603 exists( $FITS_headers->{'SUBHEADERS'}->[0]->{'RESTFREQ'} ) ) ) {
604  
605 $return = exists( $FITS_headers->{'RESTFREQ'} ) ?
606 $FITS_headers->{'RESTFREQ'} :
607 0 ▶ $FITS_headers->{'SUBHEADERS'}->[0]->{'RESTFREQ'};
Branch: 1 branch
BranchTrueFalseTotal
exists $FITS_headers->{'RESTFREQ'} ? : 0 0 0
608 0 $return *= 1_000_000_000;
609 }
610  
611 1 return $return;
612 }
613  
614 =item B<to_SYSTEM_VELOCITY>
615  
616 Converts the DOPPLER and SPECSYS headers into one combined
617 SYSTEM_VELOCITY header. The first three characters of each specific
618 header are used and concatenated. For example, if DOPPLER is 'radio'
619 and SPECSYS is 'LSR', then the resulting SYSTEM_VELOCITY generic
620 header will be 'RADLSR'. The results are always returned in capital
621 letters.
622  
623 =cut
624  
625 sub to_SYSTEM_VELOCITY {
626 1 ▶ my $self = shift;
Subroutine to_SYSTEM_VELOCITY: called CC=9 SCAR=38.9
Pod documented
627 1 my $FITS_headers = shift;
628 1 my $frameset = shift;
629  
630 1 my $return;
631 1 ▶ if ( exists( $FITS_headers->{'DOPPLER'} ) && defined $FITS_headers->{DOPPLER} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"DOPPLER"} and defined $FITS_headers->{"DOPPLER"}) 0 1 1
Condition33%1/3
exists $FITS_headers->{"DOPPLER"} and defined $FITS_headers->{"DOPPLER"}
!ll&&!rl&&r
010
MC/DC0%0/2
exists $FITS_headers->{"DOPPLER"} and defined $FITS_headers->{"DOPPLER"}
exists $FITS_headers->{"DOPPLER"} defined $FITS_headers->{"DOPPLER"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"DOPPLER"}B= defined $FITS_headers->{"DOPPLER"}
ABresult
0X0
100
111
632 0 my $doppler = uc( $FITS_headers->{'DOPPLER'} );
633  
634 0 ▶ if ( defined( $frameset ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $frameset and UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")) 0 0 0
Condition0%0/3
defined $frameset and UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $frameset and UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
defined $frameset UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
Truth table0%0/3
A and B
A= defined $framesetB= UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
ABresult
0X0
100
111
635 UNIVERSAL::isa( $frameset, "Starlink::AST::FrameSet" ) ) {
636 # Sometimes we have frequency axis (rare)
637 0 eval {
638 0 my $sourcevrf = uc( $frameset->Get( "sourcevrf" ) );
639 0 $return = substr( $doppler, 0, 3 ) . substr( $sourcevrf, 0, 3 );
640 };
641 }
642 0 ▶ if (!defined $return) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $return) 0 0 0
643 0 ▶ if ( exists( $FITS_headers->{'SPECSYS'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'SPECSYS'}) { } 0 0 0
644 0 my $specsys = uc( $FITS_headers->{'SPECSYS'} );
645 0 $return = substr( $doppler, 0, 3 ) . substr( $specsys, 0, 3 );
646 } else {
647 0 my $specsys = '';
648 0 ▶ if ( $doppler eq 'RADIO' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($doppler eq 'RADIO') { } 0 0 0
elsif ($doppler eq 'OPTICAL') { } 0 0 0
649 0 $specsys = 'LSRK';
650 } elsif ( $doppler eq 'OPTICAL' ) {
651 0 $specsys = 'HELIOCENTRIC';
652 }
653 0 $return = substr( $doppler, 0, 3 ) . substr( $specsys, 0, 3 );
654 }
655 }
656 }
657 1 return $return;
658 }
659  
660 =item B<to_TRANSITION>
661  
662 Converts the TRANSITI header to the TRANSITION generic header.
663  
664 This would be a unit mapping except that we would like to tidy up
665 some whitespace issues.
666  
667 =cut
668  
669 sub to_TRANSITION {
670 1 ▶ my $self = shift;
Subroutine to_TRANSITION: called CC=2 SCAR=7.0
Pod documented
671 1 my $FITS_headers = shift;
672  
673 1 my $transition = $FITS_headers->{'TRANSITI'};
674  
675 1 ▶ return undef unless defined $transition;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $transition 0 1 1
676  
677 # Remove leading and trailing spaces.
678 1 $transition =~ s/^ *//;
679 1 $transition =~ s/ *$//;
680 # Remove duplicated spaces.
681 1 $transition =~ s/ +/ /g;
682  
683 1 return $transition;
684 }
685  
686 =item B<from_TRANSITION>
687  
688 Converts TRANSITION back to TRANSITI.
689  
690 =cut
691  
692 sub from_TRANSITION {
693 1 ▶ my $self = shift;
Subroutine from_TRANSITION: called CC=2 SCAR=7.0
Pod documented
694 1 my $generic_headers = shift;
695  
696 1 my $transition = $generic_headers->{'TRANSITION'};
697  
698 1 ▶ if (defined $transition) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $transition) 1 0 1
699 # Restore whitespace issue to allow comparison of untranslated header.
700 1 $transition =~ s/ - / - /;
701 }
702  
703 1 return (TRANSITI => $transition);
704 }
705  
706 =item B<to_VELOCITY>
707  
708 Converts the ZSOURCE header into an appropriate system velocity,
709 depending on the value of the DOPPLER header. If the DOPPLER header is
710 'redshift', then the VELOCITY generic header will be returned
711 as a redshift. If the DOPPLER header is 'optical', then the
712 VELOCITY generic header will be returned as an optical
713 velocity. If the DOPPLER header is 'radio', then the VELOCITY
714 generic header will be returned as a radio velocity. Note that
715 calculating the radio velocity from the zeropoint (which is the
716 ZSOURCE header) gives accurates results only if the radio velocity is
717 a small fraction (~0.01) of the speed of light.
718  
719 =cut
720  
721 sub to_VELOCITY {
722 1 ▶ my $self = shift;
Subroutine to_VELOCITY: called CC=14 SCAR=46.2
Pod documented
723 1 my $FITS_headers = shift;
724 1 my $frameset = shift;
725  
726 1 my $velocity = 0;
727 1 ▶ if ( defined( $frameset ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $frameset and UNIVERSAL::isa($frameset, 'Starlink::AST::FrameSet')) { } 0 1 1
Condition33%1/3
defined $frameset and UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
!ll&&!rl&&r
100
MC/DC0%0/2
defined $frameset and UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
defined $frameset UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
Truth table33%1/3
A and B
A= defined $framesetB= UNIVERSAL::isa($frameset, "Starlink::AST::FrameSet")
ABresult
0X0
100
111
728 UNIVERSAL::isa( $frameset, "Starlink::AST::FrameSet" ) ) {
729  
730 0 my $sourcesys = "VRAD";
731 0 ▶ if ( defined( $FITS_headers->{'DOPPLER'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"DOPPLER"}) 0 0 0
732 0 ▶ if ( $FITS_headers->{'DOPPLER'} =~ /rad/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($FITS_headers->{'DOPPLER'} =~ /rad/i) { } 0 0 0
elsif ($FITS_headers->{'DOPPLER'} =~ /opt/i) { } 0 0 0
elsif ($FITS_headers->{'DOPPLER'} =~ /red/i) { } 0 0 0
733 0 $sourcesys = "VRAD";
734 } elsif ( $FITS_headers->{'DOPPLER'} =~ /opt/i ) {
735 0 $sourcesys = "VOPT";
736 } elsif ( $FITS_headers->{'DOPPLER'} =~ /red/i ) {
737 0 $sourcesys = "REDSHIFT";
738 }
739 }
740 # Sometimes we do not have a spec frame (broken files)
741 0 eval {
742 0 $frameset->Set( sourcesys => $sourcesys );
743 0 $velocity = $frameset->Get( "sourcevel" );
744 };
745 } else {
746  
747 # We weren't passed a frameset, so try using other headers.
748 1 ▶ if ( exists( $FITS_headers->{'DOPPLER'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"DOPPLER"} and exists $FITS_headers->{"ZSOURCE"} || exists $FITS_headers->{"SUBHEADERS"}[0]{"ZSOURCE"}) 0 1 1
Condition33%2/6
exists $FITS_headers->{"DOPPLER"} and exists $FITS_headers->{"ZSOURCE"} || exists $FITS_headers->{"SUBHEADERS"}[0]{"ZSOURCE"}
!ll&&!rl&&r
010
exists $FITS_headers->{"ZSOURCE"} or exists $FITS_headers->{"SUBHEADERS"}[0]{"ZSOURCE"}
l!l&&r!l&&!r
001
MC/DC0%0/3
exists $FITS_headers->{"DOPPLER"} and exists $FITS_headers->{"ZSOURCE"} || exists $FITS_headers->{"SUBHEADERS"}[0]{"ZSOURCE"}
exists $FITS_headers->{"DOPPLER"} exists $FITS_headers->{"ZSOURCE"} exists $FITS_headers->{"SUBHEADERS"}[0]{"ZSOURCE"}
Truth table25%1/4
A and B or C
A= exists $FITS_headers->{"DOPPLER"}B= exists $FITS_headers->{"ZSOURCE"}C= exists $FITS_headers->{"SUBHEADERS"}[0]{"ZSOURCE"}
ABCresult
0XX0
1000
11X1
1011
749 ( exists( $FITS_headers->{'ZSOURCE'} ) ||
750 exists( $FITS_headers->{'SUBHEADERS'}->[0]->{'ZSOURCE'} ) ) ) {
751 0 my $doppler = uc( $FITS_headers->{'DOPPLER'} );
752 my $zsource = exists( $FITS_headers->{'ZSOURCE'} ) ?
753 $FITS_headers->{'ZSOURCE'} :
754 0 ▶ $FITS_headers->{'SUBHEADERS'}->[0]->{'ZSOURCE'};
Branch: 1 branch
BranchTrueFalseTotal
exists $FITS_headers->{'ZSOURCE'} ? : 0 0 0
755  
756 0 ▶ if ( $doppler eq 'REDSHIFT' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($doppler eq 'REDSHIFT') { } 0 0 0
elsif ($doppler eq 'OPTICAL') { } 0 0 0
elsif ($doppler eq 'RADIO') { } 0 0 0
757 0 $velocity = $zsource;
758 } elsif ( $doppler eq 'OPTICAL' ) {
759 0 $velocity = $zsource * CLIGHT;
760 } elsif ( $doppler eq 'RADIO' ) {
761 0 $velocity = ( CLIGHT * $zsource ) / ( 1 + $zsource );
762 }
763 }
764 }
765  
766 1 return $velocity;
767 }
768  
769 =item B<to_SUBSYSTEM_IDKEY>
770  
771 =cut
772  
773 sub to_SUBSYSTEM_IDKEY {
774 1 ▶ my $self = shift;
Subroutine to_SUBSYSTEM_IDKEY: called CC=2 SCAR=7.0
Pod documented
775 1 my $FITS_headers = shift;
776  
777 # Try the general headers first
778 1 my $general = $self->SUPER::to_SUBSYSTEM_IDKEY( $FITS_headers );
779 1 ▶ return ( defined $general ? $general : "SUBSYSNR" );
Branch: 1 branch
BranchTrueFalseTotal
defined $general ? : 0 1 1
780 }
781  
782  
783 =item B<_is_FSW>
784  
785 Helper function to determine if we are doing frequency switch.
786  
787 =cut
788  
789 sub _is_FSW {
790 1 ▶ my $class = shift;
Subroutine _is_FSW: called CC=3 SCAR=12.3
791 1 my $FITS_headers = shift;
792  
793 1 my $fsw = $FITS_headers->{SW_MODE};
794  
795 1 ▶ if ( defined( $fsw ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fsw and $fsw =~ /freqsw/i) 0 1 1
Condition33%1/3
defined $fsw and $fsw =~ /freqsw/i
!ll&&!rl&&r
010
MC/DC0%0/2
defined $fsw and $fsw =~ /freqsw/i
defined $fsw $fsw =~ /freqsw/i
Truth table33%1/3
A and B
A= defined $fswB= $fsw =~ /freqsw/i
ABresult
0X0
100
111
796 $fsw =~ /freqsw/i ) {
797 0 return 1;
798 }
799 1 return 0;
800 }
801  
802 =back
803  
804 =head1 SEE ALSO
805  
806 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::Base>
807  
808 =head1 AUTHORS
809  
810 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>,
811 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>.
812  
813 =head1 COPYRIGHT
814  
815 Copyright (C) 2016 East Asian Observatory.
816 Copyright (C) 2007-2013, 2016 Science and Technology Facilities Council.
817 Copyright (C) 2005-2007 Particle Physics and Astronomy Research Council.
818 All Rights Reserved.
819  
820 This program is free software; you can redistribute it and/or modify it under
821 the terms of the GNU General Public License as published by the Free Software
822 Foundation; either version 2 of the License, or (at your option) any later
823 version.
824  
825 This program is distributed in the hope that it will be useful,but WITHOUT ANY
826 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
827 PARTICULAR PURPOSE. See the GNU General Public License for more details.
828  
829 You should have received a copy of the GNU General Public License along with
830 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
831 Place,Suite 330, Boston, MA 02111-1307, USA
832  
833 =cut
834  
835 10 1;
« blib/lib/Astro/FITS/HdrTrans/LCOFLOYDS.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/ESO.pm »