HdrTrans/ACSIS.pm

filter: Statementstmt 70.0% 192 / 274 Branchbran 31.7% 47 / 148 Conditioncond 35.7% 44 / 123 MC/DCmcdc 2.9% 2 / 68 Subroutinesub 100% 30 / 30 Podpod 100% 19 / 19 totaltotal 50.4% 334 / 662 CC 116 SCAR 34.5
CC
116
Cov
52%
to_VELOCITY
101.6
to_DR_RECIPE
53.1
to_SYSTEM_VELOCITY
48.9
CRAP 31.4
« HdrTrans/LCOSBIG_CC.pm ↑ Summary HdrTrans/LCO.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 our $VERSION = "1.66";
38  
39 # Cache UTC definition
40 10 our $UTC = DateTime::TimeZone->new( name => 'UTC' );
41  
42 # in each class we have three sets of data.
43 # - constant mappings
44 # - unit mappings
45 # - complex mappings
46  
47 # for a constant mapping, there is no FITS header, just a generic
48 # header that is constant
49 10 my %CONST_MAP = (
50 INST_DHS => 'ACSIS',
51 );
52  
53 # unit mapping implies that the value propagates directly
54 # to the output with only a keyword name change
55  
56 10 my %UNIT_MAP = (
57 AIRMASS_END => 'AMEND',
58 AMBIENT_TEMPERATURE=> 'ATSTART',
59 AZIMUTH_END => 'AZEND',
60 BACKEND => 'BACKEND',
61 BANDWIDTH_MODE => 'BWMODE',
62 CHOP_ANGLE => 'CHOP_PA',
63 CHOP_COORDINATE_SYSTEM => 'CHOP_CRD',
64 CHOP_FREQUENCY => 'CHOP_FRQ',
65 CHOP_THROW => 'CHOP_THR',
66 ELEVATION_END => 'ELEND',
67 FRONTEND => 'INSTRUME',
68 NUMBER_OF_CYCLES => 'NUM_CYC',
69 SWITCH_MODE => 'SW_MODE',
70 SPECIES => 'MOLECULE',
71 VELOCITY_TYPE => 'DOPPLER',
72 SIDEBAND_MODE => 'SB_MODE',
73 SPECTRUM_NUMBER => 'SPECID',
74 SUBSYSTEM_NUMBER => 'SUBSYSNR',
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 21 ▶sub can_translate {
Subroutine can_translate: called CC=12 SCAR=29.9
Pod documented
100 21 my $self = shift;
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 1 ▶sub to_DR_RECIPE {
Subroutine to_DR_RECIPE: called CC=17 SCAR=39.7
Pod documented
156 1 my $class = shift;
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 = $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 ((defined $utdate) and $utdate < 20080701) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $utdate and $utdate < 20080701) 1 0 1
Condition33%1/3
defined $utdate and $utdate < 20080701
!ll&&!rl&&r
001
MC/DC0%0/2
defined $utdate and $utdate < 20080701
defined $utdate $utdate < 20080701
Truth table33%1/3
A and B
A= defined $utdateB= $utdate < 20080701
ABresult
0X0
100
111
173 1 ▶ if ((defined $obstype) && $obstype =~ /skydip/i && $dr eq 'REDUCE_SCIENCE') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $obstype and $obstype =~ /skydip/i and $dr eq "REDUCE_SCIENCE") 0 1 1
Condition33%2/6
defined $obstype and $obstype =~ /skydip/i and $dr eq "REDUCE_SCIENCE"
!ll&&!rl&&r
100
defined $obstype and $obstype =~ /skydip/i
!ll&&!rl&&r
010
MC/DC0%0/3
defined $obstype and $obstype =~ /skydip/i and $dr eq "REDUCE_SCIENCE"
defined $obstype $obstype =~ /skydip/i $dr eq "REDUCE_SCIENCE"
Truth table25%1/4
A and B and C
A= defined $obstypeB= $obstype =~ /skydip/iC= $dr eq "REDUCE_SCIENCE"
ABCresult
0XX0
10X0
1100
1111
174 0 $dr = "REDUCE_SKYDIP";
175 }
176 }
177  
178 1 ▶ my $is_sci = ( (defined $obstype) and $obstype =~ /science|raster|scan|grid|jiggle/i );
Condition33%1/3
defined $obstype && $obstype =~ /science|raster|scan|grid|jiggle/i
!ll&&!rl&&r
010
MC/DC0%0/2
defined $obstype && $obstype =~ /science|raster|scan|grid|jiggle/i
defined $obstype $obstype =~ /science|raster|scan|grid|jiggle/i
Truth table33%1/3
A && B
A= defined $obstypeB= $obstype =~ /science|raster|scan|grid|jiggle/i
ABresult
0X0
100
111
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 ((defined $utdate) && $utdate > 20081115 && $pol && $is_sci ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $utdate and $utdate > 20081115 and $pol and $is_sci) 0 1 1
Condition33%3/9
defined $utdate and $utdate > 20081115 and $pol and $is_sci
!ll&&!rl&&r
100
defined $utdate and $utdate > 20081115 and $pol
!ll&&!rl&&r
100
defined $utdate and $utdate > 20081115
!ll&&!rl&&r
010
MC/DC0%0/4
defined $utdate and $utdate > 20081115 and $pol and $is_sci
defined $utdate $utdate > 20081115 $pol $is_sci
Truth table20%1/5
A and B and C and D
A= defined $utdateB= $utdate > 20081115C= $polD= $is_sci
ABCDresult
0XXX0
10XX0
110X0
11100
11111
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 1 ▶sub from_DR_RECIPE {
Subroutine from_DR_RECIPE: called CC=5 SCAR=18.7
Pod documented
203 1 my $class = shift;
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 2 ▶sub to_POLARIMETER {
Subroutine to_POLARIMETER: called CC=5 SCAR=19.7
Pod documented
223 2 my $class = shift;
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 ( (defined $utdate) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $utdate and $utdate > 20081115 and defined $inbeam and $inbeam =~ /pol/i) 0 2 2
Condition33%3/9
defined $utdate and $utdate > 20081115 and defined $inbeam and $inbeam =~ /pol/i
!ll&&!rl&&r
200
defined $utdate and $utdate > 20081115 and defined $inbeam
!ll&&!rl&&r
200
defined $utdate and $utdate > 20081115
!ll&&!rl&&r
020
MC/DC0%0/4
defined $utdate and $utdate > 20081115 and defined $inbeam and $inbeam =~ /pol/i
defined $utdate $utdate > 20081115 defined $inbeam $inbeam =~ /pol/i
Truth table20%1/5
A and B and C and D
A= defined $utdateB= $utdate > 20081115C= defined $inbeamD= $inbeam =~ /pol/i
ABCDresult
0XXX0
10XX0
110X0
11100
11111
230 $utdate > 20081115 &&
231 defined( $inbeam ) &&
232 $inbeam =~ /pol/i ) {
233 0 return 1;
234 }
235 2 return 0;
236 }
237  
238 =item B<from_POLARIMETER>
239  
240 If the POLARIMETER header is true, then return "POL" for the INBEAM
241 header. Otherwise, return undef.
242  
243 =cut
244  
245 1 ▶sub from_POLARIMETER {
Subroutine from_POLARIMETER: called CC=2 SCAR=7.2
Pod documented
246 1 my $class = shift;
247 1 my $generic_headers = shift;
248  
249 1 my $pol = $generic_headers->{POLARIMETER};
250  
251 1 ▶ if ( $pol ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pol) 0 1 1
252 0 return ( "INBEAM" => "POL" );
253 }
254  
255 1 return ( "INBEAM" => undef );
256 }
257  
258 =item B<to_REFERENCE_LOCATION>
259  
260 Creates a string representing the location of the reference spectrum
261 to the nearest hundredth of a degree. It takes the form
262 system_longitude_latitude where system will normally be J2000 or GAL.
263 If the string cannot be evaluated (such as missing headers), the
264 returned value is undefined.
265  
266 =cut
267  
268 1 ▶sub to_REFERENCE_LOCATION {
Subroutine to_REFERENCE_LOCATION: called CC=13 SCAR=36.7
Pod documented
269 1 my $self = shift;
270 1 my $FITS_headers = shift;
271  
272 # Set the returned value in case something goes awry.
273 1 my $ref_location = undef;
274  
275 # Assume that the co-ordinate system is the same for the BASE
276 # co-ordinates as the offset to the reference spectrum.
277 1 my ( $system, $base_lon, $base_lat );
278  
279 $system = defined( $FITS_headers->{'TRACKSYS'} ) ?
280 1 ▶ $FITS_headers->{'TRACKSYS'} :
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'TRACKSYS'} ? : 0 1 1
281 undef;
282 1 ▶ $system =~ s/\s+$// if defined( $system );
Branch: 1 branch
BranchTrueFalseTotal
if defined $system 0 1 1
283  
284 # Obtain the base location's longitude in decimal degrees.
285 $base_lon = defined( $FITS_headers->{'BASEC1'} ) ?
286 1 ▶ $FITS_headers->{'BASEC1'} :
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'BASEC1'} ? : 0 1 1
287 undef;
288  
289 # Obtain the base location's latitude in decimal degrees.
290 $base_lat = defined( $FITS_headers->{'BASEC2'} ) ?
291 1 ▶ $FITS_headers->{'BASEC2'} :
Branch: 1 branch
BranchTrueFalseTotal
defined $FITS_headers->{'BASEC2'} ? : 0 1 1
292 undef;
293  
294 # Derive the reference position's longitude.
295 1 my $ref_lon = undef;
296 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
297  
298 # The value of SKYREFX has the form
299 # [OFFSET] <longitude_offset_in_arcsec> [<co-ordinate system>]
300 #
301 # Assume for now that the TRACKSYS and co-ordinate system are the
302 # same.
303 0 ▶ if ( defined( $FITS_headers->{'SKYREFX'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"SKYREFX"}) 0 0 0
304 0 my $ref_x = $FITS_headers->{'SKYREFX'};
305 0 my @comps = split( /\s+/, $ref_x );
306 0 my $offset_lon = $comps[1] / 3600.0;
307  
308 # Two decimal places should permit sufficient fuzziness.
309 0 $ref_lon = sprintf( "%.2f", $base_lon + $offset_lon );
310 }
311 }
312  
313 # Derive the reference position's latitude.
314 1 my $ref_lat = undef;
315 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
316  
317 # The value of SKYREFY has the form
318 # [OFFSET] <latitude_offset_in_arcsec> [<co-ordinate system>]
319 #
320 # Assume for now that the TRACKSYS and co-ordinate system are the
321 # same.
322 0 ▶ if ( defined( $FITS_headers->{'SKYREFY'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"SKYREFY"}) 0 0 0
323 0 my $ref_y = $FITS_headers->{'SKYREFY'};
324 0 my @comps = split( /\s+/, $ref_y );
325 0 my $offset_lat = $comps[1] / 3600.0;
326 0 $ref_lat = sprintf( "%.2f", $base_lat + $offset_lat );
327 }
328 }
329  
330 # Form the string comprising the three elements.
331 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
332 0 $ref_location = $system . "_" . $ref_lon . "_" . $ref_lat;
333 }
334  
335 1 return $ref_location;
336 }
337  
338  
339 =item B<to_SAMPLE_MODE>
340  
341 If the SAM_MODE value is either 'raster' or 'scan', return
342 'scan'. Otherwise, return the value in lowercase.
343  
344 =cut
345  
346 1 ▶sub to_SAMPLE_MODE {
Subroutine to_SAMPLE_MODE: called CC=3 SCAR=11.4
Pod documented
347 1 my $self = shift;
348 1 my $FITS_headers = shift;
349  
350 1 my $sam_mode;
351 1 ▶ if( defined $FITS_headers->{'SAM_MODE'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"SAM_MODE"}) 1 0 1
352 1 ▶ if (( uc $FITS_headers->{'SAM_MODE'} ) eq 'RASTER' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $FITS_headers->{'SAM_MODE'} eq 'RASTER') { } 0 1 1
353 0 $sam_mode = 'scan';
354 } else {
355 1 $sam_mode = lc( $FITS_headers->{'SAM_MODE'} );
356 }
357 }
358 1 return $sam_mode;
359 }
360  
361 =item B<to_SURVEY>
362  
363 Checks the value of the SURVEY header and uses that. If it's
364 undefined, then use the PROJECT header to determine an appropriate
365 survey.
366  
367 =cut
368  
369 1 ▶sub to_SURVEY {
Subroutine to_SURVEY: called CC=7 SCAR=27.5
Pod documented
370 1 my $self = shift;
371 1 my $FITS_headers = shift;
372  
373 1 my $survey;
374  
375 1 ▶ if( defined( $FITS_headers->{'SURVEY'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'SURVEY'}) { } 0 1 1
376 0 $survey = $FITS_headers->{'SURVEY'};
377 } else {
378  
379 1 my $project = $FITS_headers->{'PROJECT'};
380 1 ▶ if( defined( $project ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $project) 1 0 1
381 1 ▶ if( $project =~ /JLS([GNS])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($project =~ /JLS([GNS])/) 0 1 1
382 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
383 0 $survey = 'GBS';
384 } elsif( $1 eq 'N' ) {
385 0 $survey = 'NGS';
386 } elsif( $1 eq 'S' ) {
387 0 $survey = 'SLS';
388 }
389 }
390 }
391 }
392  
393 1 return $survey;
394  
395 }
396  
397 =item B<to_EXPOSURE_TIME>
398  
399 Uses the to_UTSTART and to_UTEND functions to calculate the exposure
400 time. Returns the exposure time as a scalar, not as a Time::Seconds
401 object.
402  
403 =cut
404  
405 1 ▶sub to_EXPOSURE_TIME {
Subroutine to_EXPOSURE_TIME: called CC=5 SCAR=17.2
Pod documented
406 1 my $self = shift;
407 1 my $FITS_headers = shift;
408  
409 # force date headers to be standardized
410 1 $self->_fix_dates( $FITS_headers );
411  
412 1 my $return;
413 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
414 exists( $FITS_headers->{'DATE-END'} ) ) {
415 1 my $start = $self->to_UTSTART( $FITS_headers );
416 1 my $end = $self->to_UTEND( $FITS_headers );
417 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
418 1 my $duration = $end - $start;
419 1 $return = $duration->seconds;
420 }
421 }
422 1 return $return;
423 }
424  
425 =item B<to_INSTRUMENT>
426  
427 Converts the C<INSTRUME> header into the C<INSTRUMENT> header. If the
428 C<INSTRUME> header begins with "HARP" or "FE_HARP", then the
429 C<INSTRUMENT> header will be set to "HARP".
430  
431 =cut
432  
433 1 ▶sub to_INSTRUMENT {
Subroutine to_INSTRUMENT: called CC=4 SCAR=15.2
Pod documented
434 1 my $self = shift;
435 1 my $FITS_headers = shift;
436 1 my $return;
437 1 ▶ if ( exists( $FITS_headers->{'INSTRUME'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"INSTRUME"}) 1 0 1
438 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
439 $FITS_headers->{'INSTRUME'} =~ /^FE_HARP/ ) {
440 0 $return = "HARP";
441 } else {
442 1 $return = $FITS_headers->{'INSTRUME'};
443 }
444 }
445 1 return $return;
446 }
447  
448 =item B<to_OBSERVATION_ID>
449  
450 Converts the C<OBSID> header directly into the C<OBSERVATION_ID>
451 generic header, or if that header does not exist, converts the
452 C<BACKEND>, C<OBSNUM>, and C<DATE-OBS> headers into C<OBSERVATION_ID>.
453  
454 =cut
455  
456 1 ▶sub to_OBSERVATION_ID {
Subroutine to_OBSERVATION_ID: called CC=6 SCAR=29.5
Pod documented
457 1 my $self = shift;
458 1 my $FITS_headers = shift;
459 1 my $return;
460 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
461 defined( $FITS_headers->{'OBSID'} ) ) {
462 1 $return = $FITS_headers->{'OBSID'};
463 } else {
464 0 $self->_fix_dates( $FITS_headers );
465  
466 0 my $backend = $self->to_BACKEND( $FITS_headers );
467 0 my $obsnum = $self->to_OBSERVATION_NUMBER( $FITS_headers );
468 0 my $dateobs = $self->to_UTSTART( $FITS_headers );
469  
470 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
471 defined( $obsnum ) &&
472 defined( $dateobs ) ) {
473 0 my $datetime = $dateobs->datetime;
474 0 $datetime =~ s/-//g;
475 0 $datetime =~ s/://g;
476  
477 0 $return = join '_', (lc $backend), $obsnum, $datetime;
478 }
479 }
480  
481 1 return $return;
482 }
483  
484 =item B<to_OBSERVATION_MODE>
485  
486 Concatenates the SAM_MODE, SW_MODE, and OBS_TYPE header keywords into
487 the OBSERVATION_MODE generic header, with spaces removed and joined
488 with underscores. For example, if SAM_MODE is 'jiggle ', SW_MODE is
489 'chop ', and OBS_TYPE is 'science ', then the OBSERVATION_MODE generic
490 header will be 'jiggle_chop_science'.
491  
492 =cut
493  
494 1 ▶sub to_OBSERVATION_MODE {
Subroutine to_OBSERVATION_MODE: called CC=7 SCAR=21.0
Pod documented
495 1 my $self = shift;
496 1 my $FITS_headers = shift;
497  
498 1 my $return;
499 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
500 exists( $FITS_headers->{'SW_MODE'} ) &&
501 exists( $FITS_headers->{'OBS_TYPE'} ) ) {
502 1 my $sam_mode = $FITS_headers->{'SAM_MODE'};
503 1 $sam_mode =~ s/\s//g;
504 1 ▶ $sam_mode = "raster" if $sam_mode eq "scan";
Branch: 1 branch
BranchTrueFalseTotal
if $sam_mode eq "scan" 0 1 1
505 1 my $sw_mode = $FITS_headers->{'SW_MODE'};
506 1 $sw_mode =~ s/\s//g;
507  
508 # handle OBS_TYPE missing
509 1 my $obs_type = $FITS_headers->{'OBS_TYPE'};
510 1 ▶ $obs_type = "science" unless $obs_type;
Branch: 1 branch
BranchTrueFalseTotal
unless $obs_type 0 1 1
511 1 $obs_type =~ s/\s//g;
512  
513 1 ▶ $return = ( ( $obs_type =~ /science/i )
Branch: 1 branch
BranchTrueFalseTotal
$obs_type =~ /science/i ? : 0 1 1
514 ? join '_', $sam_mode, $sw_mode
515 : join '_', $sam_mode, $sw_mode, $obs_type );
516 }
517 1 return $return;
518 }
519  
520 =item B<to_OBSERVATION_TYPE>
521  
522 Returns the type of observation that was done. If the OBS_TYPE header
523 matches /science/, the SAM_MODE header is used: if SAM_MODE matches
524 /raster/, then return 'raster'. If SAM_MODE matches /grid/, then
525 return 'grid'. If SAM_MODE matches /jiggle/, then return 'jiggle'.
526  
527 If the OBS_TYPE header matches /focus/, then return 'focus'. If the
528 OBS_TYPE header matches /pointing/, then return 'pointing'.
529  
530 If none of the above options hold, then return undef.
531  
532 =cut
533  
534 2 ▶sub to_OBSERVATION_TYPE {
Subroutine to_OBSERVATION_TYPE: called CC=11 SCAR=37.9
Pod documented
535 2 my $self = shift;
536 2 my $FITS_headers = shift;
537  
538 2 my $return;
539 2 my $ot = $FITS_headers->{OBS_TYPE};
540  
541 # Sometimes we lack OBS_TYPE. In that case we have to assume SCIENCE
542 # even though the headers are broken. (eg 20080509#18 RxWD)
543 2 ▶ $ot = "science" unless $ot;
Branch: 1 branch
BranchTrueFalseTotal
unless $ot 0 2 2
544  
545 2 ▶ if ( $ot ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ot) 2 0 2
546 2 my $obs_type = lc( $ot );
547  
548 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
549  
550 0 ▶ if ( defined( $FITS_headers->{'SAM_MODE'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"SAM_MODE"}) 0 0 0
551  
552 0 my $sam_mode = $FITS_headers->{'SAM_MODE'};
553  
554 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
555 0 $return = "raster";
556 } elsif ( $sam_mode =~ /grid/ ) {
557 0 $return = "grid";
558 } elsif ( $sam_mode =~ /jiggle/ ) {
559 0 $return = "jiggle";
560 } else {
561 0 croak "Unexpected sample mode: '$sam_mode'";
562 }
563 }
564 } elsif ( $obs_type =~ /focus/ ) {
565 2 $return = "focus";
566 } elsif ( $obs_type =~ /pointing/ ) {
567 0 $return = "pointing";
568 } elsif ( $obs_type =~ /skydip/) {
569 0 $return = "skydip";
570 } else {
571 0 croak "Unexpected OBS_TYPE of '$obs_type'\n";
572 }
573 }
574  
575 2 return $return;
576 }
577  
578  
579 =item B<to_REST_FREQUENCY>
580  
581 Uses an C<Starlink::AST::FrameSet> object to determine the
582 frequency. If such an object is not passed in, then the rest frequency
583 is set to zero.
584  
585 Returns the rest frequency in Hz.
586  
587 =cut
588  
589 1 ▶sub to_REST_FREQUENCY {
Subroutine to_REST_FREQUENCY: called CC=7 SCAR=28.0
Pod documented
590 1 my $self = shift;
591 1 my $FITS_headers = shift;
592 1 my $frameset = shift;
593  
594 1 my $return;
595  
596 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
597 UNIVERSAL::isa( $frameset, "Starlink::AST::FrameSet" ) ) {
598 # in some rare cases restfreq is not set in the frameset
599 0 eval {
600 0 my $frequency = $frameset->Get( "restfreq" );
601 0 $return = $frequency * 1_000_000_000;
602 };
603 ▶ } 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
604 ( exists( $FITS_headers->{'SUBHEADERS'} ) &&
605 exists( $FITS_headers->{'SUBHEADERS'}->[0]->{'RESTFREQ'} ) ) ) {
606  
607 $return = exists( $FITS_headers->{'RESTFREQ'} ) ?
608 $FITS_headers->{'RESTFREQ'} :
609 0 ▶ $FITS_headers->{'SUBHEADERS'}->[0]->{'RESTFREQ'};
Branch: 1 branch
BranchTrueFalseTotal
exists $FITS_headers->{'RESTFREQ'} ? : 0 0 0
610 0 $return *= 1_000_000_000;
611 }
612  
613 1 return $return;
614 }
615  
616 =item B<to_SYSTEM_VELOCITY>
617  
618 Converts the DOPPLER and SPECSYS headers into one combined
619 SYSTEM_VELOCITY header. The first three characters of each specific
620 header are used and concatenated. For example, if DOPPLER is 'radio'
621 and SPECSYS is 'LSR', then the resulting SYSTEM_VELOCITY generic
622 header will be 'RADLSR'. The results are always returned in capital
623 letters.
624  
625 =cut
626  
627 1 ▶sub to_SYSTEM_VELOCITY {
Subroutine to_SYSTEM_VELOCITY: called CC=9 SCAR=38.9
Pod documented
628 1 my $self = shift;
629 1 my $FITS_headers = shift;
630 1 my $frameset = shift;
631  
632 1 my $return;
633 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
634 0 my $doppler = uc( $FITS_headers->{'DOPPLER'} );
635  
636 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
637 UNIVERSAL::isa( $frameset, "Starlink::AST::FrameSet" ) ) {
638 # Sometimes we have frequency axis (rare)
639 0 eval {
640 0 my $sourcevrf = uc( $frameset->Get( "sourcevrf" ) );
641 0 $return = substr( $doppler, 0, 3 ) . substr( $sourcevrf, 0, 3 );
642 };
643 }
644 0 ▶ if (!defined $return) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $return) 0 0 0
645 0 ▶ if ( exists( $FITS_headers->{'SPECSYS'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'SPECSYS'}) { } 0 0 0
646 0 my $specsys = uc( $FITS_headers->{'SPECSYS'} );
647 0 $return = substr( $doppler, 0, 3 ) . substr( $specsys, 0, 3 );
648 } else {
649 0 my $specsys = '';
650 0 ▶ if ( $doppler eq 'RADIO' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($doppler eq 'RADIO') { } 0 0 0
elsif ($doppler eq 'OPTICAL') { } 0 0 0
651 0 $specsys = 'LSRK';
652 } elsif ( $doppler eq 'OPTICAL' ) {
653 0 $specsys = 'HELIOCENTRIC';
654 }
655 0 $return = substr( $doppler, 0, 3 ) . substr( $specsys, 0, 3 );
656 }
657 }
658 }
659 1 return $return;
660 }
661  
662 =item B<to_TRANSITION>
663  
664 Converts the TRANSITI header to the TRANSITION generic header.
665  
666 This would be a unit mapping except that we would like to tidy up
667 some whitespace issues.
668  
669 =cut
670  
671 1 ▶sub to_TRANSITION {
Subroutine to_TRANSITION: called CC=2 SCAR=7.0
Pod documented
672 1 my $self = shift;
673 1 my $FITS_headers = shift;
674  
675 1 my $transition = $FITS_headers->{'TRANSITI'};
676  
677 1 ▶ return undef unless defined $transition;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $transition 0 1 1
678  
679 # Remove leading and trailing spaces.
680 1 $transition =~ s/^ *//;
681 1 $transition =~ s/ *$//;
682 # Remove duplicated spaces.
683 1 $transition =~ s/ +/ /g;
684  
685 1 return $transition;
686 }
687  
688 =item B<from_TRANSITION>
689  
690 Converts TRANSITION back to TRANSITI.
691  
692 =cut
693  
694 1 ▶sub from_TRANSITION {
Subroutine from_TRANSITION: called CC=1 SCAR=0.0
Pod documented
695 1 my $self = shift;
696 1 my $generic_headers = shift;
697  
698 1 my $transition = $generic_headers->{'TRANSITION'};
699  
700 1 return (TRANSITI => $transition);
701 }
702  
703 =item B<to_VELOCITY>
704  
705 Converts the ZSOURCE header into an appropriate system velocity,
706 depending on the value of the DOPPLER header. If the DOPPLER header is
707 'redshift', then the VELOCITY generic header will be returned
708 as a redshift. If the DOPPLER header is 'optical', then the
709 VELOCITY generic header will be returned as an optical
710 velocity. If the DOPPLER header is 'radio', then the VELOCITY
711 generic header will be returned as a radio velocity. Note that
712 calculating the radio velocity from the zeropoint (which is the
713 ZSOURCE header) gives accurates results only if the radio velocity is
714 a small fraction (~0.01) of the speed of light.
715  
716 =cut
717  
718 1 ▶sub to_VELOCITY {
Subroutine to_VELOCITY: called CC=14 SCAR=46.2
Pod documented
719 1 my $self = shift;
720 1 my $FITS_headers = shift;
721 1 my $frameset = shift;
722  
723 1 my $velocity = undef;
724 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
725 UNIVERSAL::isa( $frameset, "Starlink::AST::FrameSet" ) ) {
726  
727 0 my $sourcesys = "VRAD";
728 0 ▶ if ( defined( $FITS_headers->{'DOPPLER'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"DOPPLER"}) 0 0 0
729 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
730 0 $sourcesys = "VRAD";
731 } elsif ( $FITS_headers->{'DOPPLER'} =~ /opt/i ) {
732 0 $sourcesys = "VOPT";
733 } elsif ( $FITS_headers->{'DOPPLER'} =~ /red/i ) {
734 0 $sourcesys = "REDSHIFT";
735 }
736 }
737 # Sometimes we do not have a spec frame (broken files)
738 0 eval {
739 0 $frameset->Set( sourcesys => $sourcesys );
740 0 $velocity = $frameset->Get( "sourcevel" );
741 };
742 } else {
743  
744 # We weren't passed a frameset, so try using other headers.
745 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
746 ( exists( $FITS_headers->{'ZSOURCE'} ) ||
747 exists( $FITS_headers->{'SUBHEADERS'}->[0]->{'ZSOURCE'} ) ) ) {
748 0 my $doppler = uc( $FITS_headers->{'DOPPLER'} );
749 my $zsource = exists( $FITS_headers->{'ZSOURCE'} ) ?
750 $FITS_headers->{'ZSOURCE'} :
751 0 ▶ $FITS_headers->{'SUBHEADERS'}->[0]->{'ZSOURCE'};
Branch: 1 branch
BranchTrueFalseTotal
exists $FITS_headers->{'ZSOURCE'} ? : 0 0 0
752  
753 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
754 0 $velocity = $zsource;
755 } elsif ( $doppler eq 'OPTICAL' ) {
756 0 $velocity = $zsource * CLIGHT;
757 } elsif ( $doppler eq 'RADIO' ) {
758 0 $velocity = ( CLIGHT * $zsource ) / ( 1 + $zsource );
759 }
760 }
761 }
762  
763 1 return $velocity;
764 }
765  
766 =item B<to_SUBSYSTEM_IDKEY>
767  
768 =cut
769  
770 1 ▶sub to_SUBSYSTEM_IDKEY {
Subroutine to_SUBSYSTEM_IDKEY: called CC=2 SCAR=7.0
Pod documented
771 1 my $self = shift;
772 1 my $FITS_headers = shift;
773  
774 # Try the general headers first
775 1 my $general = $self->SUPER::to_SUBSYSTEM_IDKEY( $FITS_headers );
776 1 ▶ return ( defined $general ? $general : "SUBSYSNR" );
Branch: 1 branch
BranchTrueFalseTotal
defined $general ? : 0 1 1
777 }
778  
779  
780 =item B<_is_FSW>
781  
782 Helper function to determine if we are doing frequency switch.
783  
784 =cut
785  
786 1 ▶sub _is_FSW {
Subroutine _is_FSW: called CC=3 SCAR=12.3
787 1 my $class = shift;
788 1 my $FITS_headers = shift;
789  
790 1 my $fsw = $FITS_headers->{SW_MODE};
791  
792 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
793 $fsw =~ /freqsw/i ) {
794 0 return 1;
795 }
796 1 return 0;
797 }
798  
799 =back
800  
801 =head1 SEE ALSO
802  
803 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::Base>
804  
805 =head1 AUTHORS
806  
807 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>,
808 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>.
809  
810 =head1 COPYRIGHT
811  
812 Copyright (C) 2016 East Asian Observatory.
813 Copyright (C) 2007-2013, 2016 Science and Technology Facilities Council.
814 Copyright (C) 2005-2007 Particle Physics and Astronomy Research Council.
815 All Rights Reserved.
816  
817 This program is free software; you can redistribute it and/or modify it under
818 the terms of the GNU General Public License as published by the Free Software
819 Foundation; either version 2 of the License, or (at your option) any later
820 version.
821  
822 This program is distributed in the hope that it will be useful,but WITHOUT ANY
823 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
824 PARTICULAR PURPOSE. See the GNU General Public License for more details.
825  
826 You should have received a copy of the GNU General Public License along with
827 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
828 Place,Suite 330, Boston, MA 02111-1307, USA
829  
830 =cut
831  
832 10 1;
« HdrTrans/LCOSBIG_CC.pm ↑ Summary HdrTrans/LCO.pm »