HdrTrans/SCUBA.pm

filter: Statementstmt 84.3% 135 / 160 Branchbran 39.4% 30 / 76 Conditioncond 30.0% 18 / 60 MC/DCmcdc 0.0% 0 / 33 Subroutinesub 100% 21 / 21 Podpod 100% 16 / 16 totaltotal 60.1% 220 / 366 CC 59 SCAR 23.6
CC
59
Cov
62%
to_UTSTART
26.0
to_UTDATE
21.8
from_EQUINOX
15.2
CRAP 10.6
« HdrTrans/INGRID.pm ↑ Summary HdrTrans/MICHELLE.pm »
1 package Astro::FITS::HdrTrans::SCUBA;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::SCUBA - JCMT SCUBA translations
6  
7 =head1 DESCRIPTION
8  
9 Converts information contained in SCUBA FITS headers to and from
10 generic headers. See 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 # Inherit from Base
21 10 ▶use base qw/ Astro::FITS::HdrTrans::JAC /;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 10 our $VERSION = "1.66";
24  
25 # for a constant mapping, there is no FITS header, just a generic
26 # header that is constant
27 10 my %CONST_MAP = (
28 COORDINATE_UNITS => 'sexagesimal',
29 INSTRUMENT => "SCUBA",
30 INST_DHS => 'SCUBA_SCUBA',
31 NUMBER_OF_OFFSETS => 1,
32 ROTATION => 0,
33 SLIT_ANGLE => 0,
34 SPEED_GAIN => 'normal',
35 TELESCOPE => 'JCMT',
36 );
37  
38 # NULL mappings used to override base class implementations
39 10 my @NULL_MAP = qw/ DETECTOR_INDEX WAVEPLATE_ANGLE /;
40  
41 # unit mapping implies that the value propogates directly
42 # to the output with only a keyword name change
43  
44 10 my %UNIT_MAP = (
45 AIRMASS_START => "AMSTART",
46 AIRMASS_END => "AMEND",
47 BOLOMETERS => "BOLOMS",
48 CHOP_ANGLE => "CHOP_PA",
49 CHOP_THROW => "CHOP_THR",
50 DEC_BASE => "LAT",
51 DEC_TELESCOPE_OFFSET => "MAP_Y",
52 DETECTOR_READ_TYPE => "MODE",
53 DR_RECIPE => "DRRECIPE",
54 FILENAME => "SDFFILE",
55 FILTER => "FILTER",
56 GAIN => "GAIN",
57 NUMBER_OF_EXPOSURES => "EXP_NO",
58 OBJECT => "OBJECT",
59 OBSERVATION_NUMBER => "RUN",
60 POLARIMETER => "POL_CONN",
61 PROJECT => "PROJ_ID",
62 RA_TELESCOPE_OFFSET => "MAP_X",
63 SCAN_INCREMENT => "SAM_DX",
64 SEEING => "SEEING",
65 STANDARD => "STANDARD",
66 TAU => "TAU_225",
67 X_BASE => "LONG",
68 Y_BASE => "LAT",
69 X_OFFSET => "MAP_X",
70 Y_OFFSET => "MAP_Y"
71 );
72  
73  
74 # Create the translation methods
75 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
76  
77 =head1 METHODS
78  
79 =over 4
80  
81 =item B<this_instrument>
82  
83 The name of the instrument required to match (case insensitively)
84 against the INSTRUME/INSTRUMENT keyword to allow this class to
85 translate the specified headers. Called by the default
86 C<can_translate> method.
87  
88 $inst = $class->this_instrument();
89  
90 Returns "SCUBA".
91  
92 =cut
93  
94 21 ▶sub this_instrument {
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
95 21 return "SCUBA";
96 }
97  
98 =item B<can_translate>
99  
100 The database tables do not include an instrument field so we need to determine
101 suitability by looking at other fields instead of using the base implementation.
102  
103 $cando = $class->can_translate( \%hdrs );
104  
105 For SCUBA we first check for BOLOMS and SCU# headers and then use the base
106 implementation that will look at the INSTRUME field.
107  
108 =cut
109  
110 21 ▶sub can_translate {
Subroutine can_translate: called CC=5 SCAR=18.4
Pod documented
111 21 my $self = shift;
112 21 my $headers = shift;
113  
114 21 ▶ if (exists $headers->{BOLOMS} && defined $headers->{BOLOMS} &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $headers->{'BOLOMS'} and defined $headers->{'BOLOMS'} and exists $headers->{'SCU#'} and defined $headers->{'SCU#'}) { } 0 21 21
Condition55%5/9
exists $headers->{"BOLOMS"} and defined $headers->{"BOLOMS"} and exists $headers->{"SCU#"} and defined $headers->{"SCU#"}
!ll&&!rl&&r
2100
exists $headers->{"BOLOMS"} and defined $headers->{"BOLOMS"} and exists $headers->{"SCU#"}
!ll&&!rl&&r
1920
exists $headers->{"BOLOMS"} and defined $headers->{"BOLOMS"}
!ll&&!rl&&r
1902
MC/DC0%0/4
exists $headers->{"BOLOMS"} and defined $headers->{"BOLOMS"} and exists $headers->{"SCU#"} and defined $headers->{"SCU#"}
exists $headers->{"BOLOMS"} defined $headers->{"BOLOMS"} exists $headers->{"SCU#"} defined $headers->{"SCU#"}
Truth table40%2/5
A and B and C and D
A= exists $headers->{"BOLOMS"}B= defined $headers->{"BOLOMS"}C= exists $headers->{"SCU#"}D= defined $headers->{"SCU#"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
115 exists $headers->{"SCU#"} && defined $headers->{"SCU#"}) {
116 0 return 1;
117 } else {
118 21 return $self->SUPER::can_translate( $headers );
119 }
120 }
121  
122 =back
123  
124 =head1 COMPLEX CONVERSIONS
125  
126 These methods are more complicated than a simple mapping. We have to
127 provide both from- and to-FITS conversions All these routines are
128 methods and the to_ routines all take a reference to a hash and return
129 the translated value (a many-to-one mapping) The from_ methods take a
130 reference to a generic hash and return a translated hash (sometimes
131 these are many-to-many)
132  
133 =over 4
134  
135 =item B<to_CHOP_COORDINATE_SYSTEM>
136  
137 Uses the C<CHOP_CRD> FITS header to determine the chopper coordinate
138 system, and then places that coordinate type in the C<CHOP_COORDINATE_SYSTEM>
139 generic header.
140  
141 A FITS header value of 'LO' translates to 'Tracking', 'AZ' translates to
142 'Alt/Az', and 'NA' translates to 'Focal Plane'. Any other values will return
143 undef.
144  
145 =cut
146  
147 2 ▶sub to_CHOP_COORDINATE_SYSTEM {
Subroutine to_CHOP_COORDINATE_SYSTEM: called CC=5 SCAR=18.7
Pod documented
148 2 my $self = shift;
149 2 my $FITS_headers = shift;
150 2 my $return;
151  
152 2 ▶ if (exists($FITS_headers->{'CHOP_CRD'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"CHOP_CRD"}) 2 0 2
153 2 my $fits_eq = $FITS_headers->{'CHOP_CRD'};
154 2 ▶ if ( $fits_eq =~ /LO/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($fits_eq =~ /LO/i) { } 0 2 2
elsif ($fits_eq =~ /AZ/i) { } 2 0 2
elsif ($fits_eq =~ /NA/i) { } 0 0 0
155 0 $return = "Tracking";
156 } elsif ( $fits_eq =~ /AZ/i ) {
157 2 $return = "Alt/Az";
158 } elsif ( $fits_eq =~ /NA/i ) {
159 0 $return = "Focal Plane";
160 }
161 }
162 2 return $return;
163 }
164  
165 =item B<to_COORDINATE_TYPE>
166  
167 Uses the C<CENT_CRD> FITS header to determine the coordinate type
168 (galactic, B1950, J2000) and then places that coordinate type in
169 the C<COORDINATE_TYPE> generic header.
170  
171 =cut
172  
173 2 ▶sub to_COORDINATE_TYPE {
Subroutine to_COORDINATE_TYPE: called CC=6 SCAR=20.8
Pod documented
174 2 my $self = shift;
175 2 my $FITS_headers = shift;
176 2 my $return;
177 2 ▶ if (exists($FITS_headers->{'CENT_CRD'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"CENT_CRD"}) 2 0 2
178 2 my $fits_eq = $FITS_headers->{'CENT_CRD'};
179 2 ▶ if ( $fits_eq =~ /RB/i ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($fits_eq =~ /RB/i) { } 0 2 2
elsif ($fits_eq =~ /RJ/i) { } 0 2 2
elsif ($fits_eq =~ /AZ/i) { } 0 2 2
elsif ($fits_eq =~ /planet/i) { } 2 0 2
180 0 $return = "B1950";
181 } elsif ( $fits_eq =~ /RJ/i ) {
182 0 $return = "J2000";
183 } elsif ( $fits_eq =~ /AZ/i ) {
184 0 $return = "galactic";
185 } elsif ( $fits_eq =~ /planet/i ) {
186 2 $return = "planet";
187 }
188 }
189 2 return $return;
190 }
191  
192 =item B<to_EQUINOX>
193  
194 Translates EQUINOX header into valid equinox value. The following
195 translation is done:
196  
197 =over 4
198  
199 =item * RB => 1950
200  
201 =item * RJ => 2000
202  
203 =item * RD => current
204  
205 =item * AZ => AZ/EL
206  
207 =back
208  
209 =cut
210  
211 2 ▶sub to_EQUINOX {
Subroutine to_EQUINOX: called CC=7 SCAR=24.6
Pod documented
212 2 my $self = shift;
213 2 my $FITS_headers = shift;
214 2 my $return;
215 2 ▶ if (exists($FITS_headers->{'CENT_CRD'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"CENT_CRD"}) 2 0 2
216 2 my $fits_eq = $FITS_headers->{'CENT_CRD'};
217 2 ▶ if ( $fits_eq =~ /RB/i ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($fits_eq =~ /RB/i) { } 0 2 2
elsif ($fits_eq =~ /RJ/i) { } 0 2 2
elsif ($fits_eq =~ /RD/i) { } 0 2 2
elsif ($fits_eq =~ /PLANET/i) { } 2 0 2
elsif ($fits_eq =~ /AZ/i) { } 0 0 0
218 0 $return = "1950";
219 } elsif ( $fits_eq =~ /RJ/i ) {
220 0 $return = "2000";
221 } elsif ( $fits_eq =~ /RD/i ) {
222 0 $return = "current";
223 } elsif ( $fits_eq =~ /PLANET/i ) {
224 2 $return = "planet";
225 } elsif ( $fits_eq =~ /AZ/i ) {
226 0 $return = "AZ/EL";
227 }
228 }
229 2 return $return;
230 }
231  
232 =item B<from_EQUINOX>
233  
234 Translates generic C<EQUINOX> values into SCUBA FITS
235 equinox values for the C<CENT_CRD> header.
236  
237 =cut
238  
239 1 ▶sub from_EQUINOX {
Subroutine from_EQUINOX: called CC=8 SCAR=27.2
Pod documented
240 1 my $self = shift;
241 1 my $generic_headers = shift;
242 1 my %return_hash;
243 my $return;
244 1 ▶ if (exists($generic_headers->{EQUINOX}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $generic_headers->{"EQUINOX"} and defined $generic_headers->{"EQUINOX"}) 1 0 1
Condition33%1/3
exists $generic_headers->{"EQUINOX"} and defined $generic_headers->{"EQUINOX"}
!ll&&!rl&&r
001
MC/DC0%0/2
exists $generic_headers->{"EQUINOX"} and defined $generic_headers->{"EQUINOX"}
exists $generic_headers->{"EQUINOX"} defined $generic_headers->{"EQUINOX"}
Truth table33%1/3
A and B
A= exists $generic_headers->{"EQUINOX"}B= defined $generic_headers->{"EQUINOX"}
ABresult
0X0
100
111
245 defined $generic_headers->{EQUINOX}) {
246 1 my $equinox = $generic_headers->{EQUINOX};
247 1 ▶ if ( $equinox =~ /1950/ ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($equinox =~ /1950/) { } 0 1 1
elsif ($equinox =~ /2000/) { } 0 1 1
elsif ($equinox =~ /current/) { } 0 1 1
elsif ($equinox =~ /planet/) { } 1 0 1
elsif ($equinox =~ m[AZ/EL]) { } 0 0 0
248 0 $return = 'RB';
249 } elsif ( $equinox =~ /2000/ ) {
250 0 $return = 'RJ';
251 } elsif ( $equinox =~ /current/ ) {
252 0 $return = 'RD';
253 } elsif ( $equinox =~ /planet/ ) {
254 1 $return = 'PLANET';
255 } elsif ( $equinox =~ /AZ\/EL/ ) {
256 0 $return = 'AZ';
257 } else {
258 0 $return = $equinox;
259 }
260 }
261 1 $return_hash{'CENT_CRD'} = $return;
262 1 return %return_hash;
263 }
264  
265 =item B<to_OBSERVATION_MODE>
266  
267 Returns C<photometry> if the FITS header value for C<MODE>
268 is C<PHOTOM>, otherwise returns C<imaging>.
269  
270 =cut
271  
272 2 ▶sub to_OBSERVATION_MODE {
Subroutine to_OBSERVATION_MODE: called CC=3 SCAR=12.0
Pod documented
273 2 my $self = shift;
274 2 my $FITS_headers = shift;
275 2 my $return;
276 2 ▶ if ( defined( $FITS_headers->{'MODE'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'MODE'} and $FITS_headers->{'MODE'} =~ /PHOTOM/i) { } 0 2 2
Condition33%1/3
defined $FITS_headers->{"MODE"} and $FITS_headers->{"MODE"} =~ /PHOTOM/i
!ll&&!rl&&r
020
MC/DC0%0/2
defined $FITS_headers->{"MODE"} and $FITS_headers->{"MODE"} =~ /PHOTOM/i
defined $FITS_headers->{"MODE"} $FITS_headers->{"MODE"} =~ /PHOTOM/i
Truth table33%1/3
A and B
A= defined $FITS_headers->{"MODE"}B= $FITS_headers->{"MODE"} =~ /PHOTOM/i
ABresult
0X0
100
111
277 $FITS_headers->{'MODE'} =~ /PHOTOM/i ) {
278 0 $return = "photometry";
279 } else {
280 2 $return = "imaging";
281 }
282 2 return $return;
283 }
284  
285 =item B<to_OBSERVATION_TYPE>
286  
287 Converts the observation type. If the FITS header is equal to
288 C<PHOTOM>, C<MAP>, C<POLPHOT>, or C<POLMAP>, then the generic
289 header value is C<OBJECT>. Else, the FITS header value is
290 copied directly to the generic header value.
291  
292 =cut
293  
294 2 ▶sub to_OBSERVATION_TYPE {
Subroutine to_OBSERVATION_TYPE: called CC=3 SCAR=11.8
Pod documented
295 2 my $self = shift;
296 2 my $FITS_headers = shift;
297 2 my $return;
298 2 my $mode = $FITS_headers->{'MODE'};
299 2 ▶ if ( defined( $mode ) && $mode =~ /PHOTOM|MAP|POLPHOT|POLMAP/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mode and $mode =~ /PHOTOM|MAP|POLPHOT|POLMAP/i) { } 0 2 2
Condition33%1/3
defined $mode and $mode =~ /PHOTOM|MAP|POLPHOT|POLMAP/i
!ll&&!rl&&r
020
MC/DC0%0/2
defined $mode and $mode =~ /PHOTOM|MAP|POLPHOT|POLMAP/i
defined $mode $mode =~ /PHOTOM|MAP|POLPHOT|POLMAP/i
Truth table33%1/3
A and B
A= defined $modeB= $mode =~ /PHOTOM|MAP|POLPHOT|POLMAP/i
ABresult
0X0
100
111
300 0 $return = "OBJECT";
301 } else {
302 2 $return = $mode;
303 }
304 2 return $return;
305 }
306  
307 =item B<to_POLARIMETRY>
308  
309 Sets the C<POLARIMETRY> generic header to 'true' if the
310 value for the FITS header C<MODE> is 'POLMAP' or 'POLPHOT',
311 otherwise sets it to 'false'.
312  
313 =cut
314  
315 2 ▶sub to_POLARIMETRY {
Subroutine to_POLARIMETRY: called CC=3 SCAR=11.8
Pod documented
316 2 my $self = shift;
317 2 my $FITS_headers = shift;
318 2 my $return;
319 2 my $mode = $FITS_headers->{'MODE'};
320 2 ▶ if (defined( $mode ) && $mode =~ /POLMAP|POLPHOT/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mode and $mode =~ /POLMAP|POLPHOT/i) { } 0 2 2
Condition33%1/3
defined $mode and $mode =~ /POLMAP|POLPHOT/i
!ll&&!rl&&r
020
MC/DC0%0/2
defined $mode and $mode =~ /POLMAP|POLPHOT/i
defined $mode $mode =~ /POLMAP|POLPHOT/i
Truth table33%1/3
A and B
A= defined $modeB= $mode =~ /POLMAP|POLPHOT/i
ABresult
0X0
100
111
321 0 $return = 1;
322 } else {
323 2 $return = 0;
324 }
325 2 return $return;
326 }
327  
328 =item B<to_UTDATE>
329  
330 Converts either the C<UTDATE> or C<DATE> header into a C<Time::Piece> object.
331  
332 =cut
333  
334 2 ▶sub to_UTDATE {
Subroutine to_UTDATE: called CC=8 SCAR=30.8
Pod documented
335 2 my $self = shift;
336 2 my $FITS_headers = shift;
337 2 my $return;
338 2 ▶ if ( exists( $FITS_headers->{'UTDATE'} ) &&
Branch: 3 branches
BranchTrueFalseTotal
if (exists $FITS_headers->{'UTDATE'} and defined $FITS_headers->{'UTDATE'}) { } 2 0 2
elsif (exists $FITS_headers->{'DATE'} and defined $FITS_headers->{'DATE'}) { } 0 0 0
elsif (exists $FITS_headers->{'DATE-OBS'} and defined $FITS_headers->{'DATE-OBS'}) { } 0 0 0
Condition33%1/3
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"}
!ll&&!rl&&r
002
MC/DC0%0/2
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"}
exists $FITS_headers->{"UTDATE"} defined $FITS_headers->{"UTDATE"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"UTDATE"}B= defined $FITS_headers->{"UTDATE"}
ABresult
0X0
100
111
339 defined( $FITS_headers->{'UTDATE'} ) ) {
340 2 my $utdate = $FITS_headers->{'UTDATE'};
341 2 $return = $self->_parse_yyyymmdd_date( $utdate, ":" );
342 ▶ } elsif ( exists( $FITS_headers->{'DATE'} ) &&
Condition0%0/3
exists $FITS_headers->{"DATE"} and defined $FITS_headers->{"DATE"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $FITS_headers->{"DATE"} and defined $FITS_headers->{"DATE"}
exists $FITS_headers->{"DATE"} defined $FITS_headers->{"DATE"}
Truth table0%0/3
A and B
A= exists $FITS_headers->{"DATE"}B= defined $FITS_headers->{"DATE"}
ABresult
0X0
100
111
343 defined( $FITS_headers->{'DATE'} ) ) {
344 0 my $utdate = $FITS_headers->{'DATE'};
345 0 $return = $self->_parse_iso_date( $utdate );
346 ▶ } elsif ( exists( $FITS_headers->{'DATE-OBS'} ) &&
Condition0%0/3
exists $FITS_headers->{"DATE-OBS"} and defined $FITS_headers->{"DATE-OBS"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $FITS_headers->{"DATE-OBS"} and defined $FITS_headers->{"DATE-OBS"}
exists $FITS_headers->{"DATE-OBS"} defined $FITS_headers->{"DATE-OBS"}
Truth table0%0/3
A and B
A= exists $FITS_headers->{"DATE-OBS"}B= defined $FITS_headers->{"DATE-OBS"}
ABresult
0X0
100
111
347 defined( $FITS_headers->{'DATE-OBS'} ) ) {
348 0 my $utdate = $FITS_headers->{'DATE-OBS'};
349 0 $return = $self->_parse_iso_date( $utdate );
350 }
351 2 ▶ if (defined $return) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $return) 2 0 2
352 2 $return = sprintf('%04d%02d%02d',$return->year,
353 $return->mon, $return->mday);
354 }
355 2 return $return;
356 }
357  
358 =item B<from_UTDATE>
359  
360 Converts UT date in C<Time::Piece> object into C<YYYY:MM:DD> format
361 for C<UTDATE> header.
362  
363 =cut
364  
365 1 ▶sub from_UTDATE {
Subroutine from_UTDATE: called CC=2 SCAR=7.0
Pod documented
366 1 my $self = shift;
367 1 my $generic_headers = shift;
368 1 my %return_hash;
369 1 ▶ if (exists($generic_headers->{UTDATE}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $generic_headers->{"UTDATE"}) 1 0 1
370 1 my $date = $generic_headers->{UTDATE};
371 1 $return_hash{UTDATE} = join(':',
372 substr($date,0,4),
373 substr($date,4,2),
374 substr($date,6,2));
375 }
376 1 return %return_hash;
377 }
378  
379 =item B<to_UTSTART>
380  
381 Combines C<UTDATE> and C<UTSTART> into a unified C<UTSTART>
382 generic header. If those headers do not exist, uses C<DATE>.
383  
384 =cut
385  
386 4 ▶sub to_UTSTART {
Subroutine to_UTSTART: called CC=9 SCAR=32.6
Pod documented
387 4 my $self = shift;
388 4 my $FITS_headers = shift;
389 4 my $return;
390 4 ▶ if ( exists( $FITS_headers->{'UTDATE'} ) &&
Branch: 3 branches
BranchTrueFalseTotal
if (exists $FITS_headers->{'UTDATE'} and defined $FITS_headers->{'UTDATE'} and exists $FITS_headers->{'UTSTART'} and defined $FITS_headers->{'UTSTART'}) { } 4 0 4
elsif (exists $FITS_headers->{'DATE-OBS'}) { } 0 0 0
elsif (exists $FITS_headers->{'DATE'} and defined $FITS_headers->{'DATE'} and $FITS_headers->{'DATE'} =~ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d/) { } 0 0 0
Condition33%3/9
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"} and exists $FITS_headers->{"UTSTART"} and defined $FITS_headers->{"UTSTART"}
!ll&&!rl&&r
004
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"} and exists $FITS_headers->{"UTSTART"}
!ll&&!rl&&r
004
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"}
!ll&&!rl&&r
004
MC/DC0%0/4
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"} and exists $FITS_headers->{"UTSTART"} and defined $FITS_headers->{"UTSTART"}
exists $FITS_headers->{"UTDATE"} defined $FITS_headers->{"UTDATE"} exists $FITS_headers->{"UTSTART"} defined $FITS_headers->{"UTSTART"}
Truth table20%1/5
A and B and C and D
A= exists $FITS_headers->{"UTDATE"}B= defined $FITS_headers->{"UTDATE"}C= exists $FITS_headers->{"UTSTART"}D= defined $FITS_headers->{"UTSTART"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
391 defined( $FITS_headers->{'UTDATE'} ) &&
392 exists $FITS_headers->{UTSTART} &&
393 defined $FITS_headers->{UTSTART} ) {
394  
395 # To convert to ISO replace colons with dashes
396 4 my $utdate = $FITS_headers->{UTDATE};
397 4 $utdate =~ s/:/\-/g;
398  
399 4 my $ut = $utdate . "T" . $FITS_headers->{'UTSTART'};
400 4 $return = $self->_parse_iso_date( $ut );
401  
402 } elsif (exists $FITS_headers->{"DATE-OBS"}) {
403 # reduced data
404 0 $return = $self->_parse_iso_date( $FITS_headers->{"DATE-OBS"} );
405  
406 ▶ } elsif ( exists( $FITS_headers->{'DATE'} ) &&
Condition0%0/6
exists $FITS_headers->{"DATE"} and defined $FITS_headers->{"DATE"} and $FITS_headers->{"DATE"} =~ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d/
!ll&&!rl&&r
000
exists $FITS_headers->{"DATE"} and defined $FITS_headers->{"DATE"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $FITS_headers->{"DATE"} and defined $FITS_headers->{"DATE"} and $FITS_headers->{"DATE"} =~ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d/
exists $FITS_headers->{"DATE"} defined $FITS_headers->{"DATE"} $FITS_headers->{"DATE"} =~ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d/
Truth table0%0/4
A and B and C
A= exists $FITS_headers->{"DATE"}B= defined $FITS_headers->{"DATE"}C= $FITS_headers->{"DATE"} =~ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d/
ABCresult
0XX0
10X0
1100
1111
407 defined( $FITS_headers->{'DATE'} ) &&
408 $FITS_headers->{'DATE'} =~ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d/ ) {
409  
410 0 $return = $self->_parse_iso_date( $FITS_headers->{"DATE"} );
411  
412 }
413  
414 4 return $return;
415 }
416  
417 =item B<from_UTSTART>
418  
419 Converts the unified C<UTSTART> generic header into C<UTDATE>
420 and C<UTSTART> FITS headers of the form C<YYYY:MM:DD> and C<HH:MM:SS>.
421  
422 =cut
423  
424 1 ▶sub from_UTSTART {
Subroutine from_UTSTART: called CC=3 SCAR=11.3
Pod documented
425 1 my $self = shift;
426 1 my $generic_headers = shift;
427 1 my %return_hash;
428 1 ▶ if (exists($generic_headers->{UTSTART}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $generic_headers->{"UTSTART"} and UNIVERSAL::isa($generic_headers->{"UTSTART"}, "Time::Piece")) 1 0 1
Condition33%1/3
exists $generic_headers->{"UTSTART"} and UNIVERSAL::isa($generic_headers->{"UTSTART"}, "Time::Piece")
!ll&&!rl&&r
001
MC/DC0%0/2
exists $generic_headers->{"UTSTART"} and UNIVERSAL::isa($generic_headers->{"UTSTART"}, "Time::Piece")
exists $generic_headers->{"UTSTART"} UNIVERSAL::isa($generic_headers->{"UTSTART"}, "Time::Piece")
Truth table33%1/3
A and B
A= exists $generic_headers->{"UTSTART"}B= UNIVERSAL::isa($generic_headers->{"UTSTART"}, "Time::Piece")
ABresult
0X0
100
111
429 UNIVERSAL::isa( $generic_headers->{UTSTART}, "Time::Piece" ) ) {
430 1 my $ut = $generic_headers->{UTSTART};
431 1 $return_hash{'UTDATE'} = join ':', $ut->year, $ut->mon, $ut->mday;
432 1 $return_hash{'UTSTART'} = join ':', $ut->hour, $ut->minute, $ut->second;
433 1 $return_hash{'DATE'} = $ut->datetime;
434 }
435 1 return %return_hash;
436 }
437  
438 =item B<to_UTEND>
439  
440 Converts the <UTDATE> and C<UTEND> headers into a combined
441 C<Time::Piece> object.
442  
443 =cut
444  
445 2 ▶sub to_UTEND {
Subroutine to_UTEND: called CC=6 SCAR=21.9
Pod documented
446 2 my $self = shift;
447 2 my $FITS_headers = shift;
448 2 my $return;
449  
450 2 ▶ if ( exists( $FITS_headers->{'UTDATE'} ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (exists $FITS_headers->{'UTDATE'} and defined $FITS_headers->{'UTDATE'} and exists $FITS_headers->{'UTEND'} and defined $FITS_headers->{'UTEND'}) { } 2 0 2
elsif (exists $FITS_headers->{'DATE-END'}) { } 0 0 0
Condition33%3/9
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"} and exists $FITS_headers->{"UTEND"} and defined $FITS_headers->{"UTEND"}
!ll&&!rl&&r
002
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"} and exists $FITS_headers->{"UTEND"}
!ll&&!rl&&r
002
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"}
!ll&&!rl&&r
002
MC/DC0%0/4
exists $FITS_headers->{"UTDATE"} and defined $FITS_headers->{"UTDATE"} and exists $FITS_headers->{"UTEND"} and defined $FITS_headers->{"UTEND"}
exists $FITS_headers->{"UTDATE"} defined $FITS_headers->{"UTDATE"} exists $FITS_headers->{"UTEND"} defined $FITS_headers->{"UTEND"}
Truth table20%1/5
A and B and C and D
A= exists $FITS_headers->{"UTDATE"}B= defined $FITS_headers->{"UTDATE"}C= exists $FITS_headers->{"UTEND"}D= defined $FITS_headers->{"UTEND"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
451 defined( $FITS_headers->{'UTDATE'} ) &&
452 exists $FITS_headers->{UTEND} &&
453 defined $FITS_headers->{UTEND} ) {
454  
455 # need to replace colons with -
456 2 my $utdate = $FITS_headers->{"UTDATE"};
457 2 $utdate =~ s/:/\-/g;
458  
459 2 my $ut = $utdate . "T" . $FITS_headers->{'UTEND'};
460  
461 2 $return = $self->_parse_iso_date( $ut );
462  
463 } elsif (exists $FITS_headers->{"DATE-END"}) {
464 # reduced data
465 0 $return = $self->_parse_iso_date( $FITS_headers->{"DATE-END"} );
466 }
467 2 return $return;
468 }
469  
470 =item B<from_UTEND>
471  
472 Converts the unified C<UTEND> generic header into C<UTDATE> and
473 C<UTEND> FITS headers of the form C<YYYY:MM:DD> and C<HH:MM:SS>.
474  
475 =cut
476  
477 1 ▶sub from_UTEND {
Subroutine from_UTEND: called CC=3 SCAR=11.3
Pod documented
478 1 my $self = shift;
479 1 my $generic_headers = shift;
480 1 my %return_hash;
481 1 ▶ if (exists($generic_headers->{UTEND}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $generic_headers->{"UTEND"} and UNIVERSAL::isa($generic_headers->{"UTEND"}, "Time::Piece")) 1 0 1
Condition33%1/3
exists $generic_headers->{"UTEND"} and UNIVERSAL::isa($generic_headers->{"UTEND"}, "Time::Piece")
!ll&&!rl&&r
001
MC/DC0%0/2
exists $generic_headers->{"UTEND"} and UNIVERSAL::isa($generic_headers->{"UTEND"}, "Time::Piece")
exists $generic_headers->{"UTEND"} UNIVERSAL::isa($generic_headers->{"UTEND"}, "Time::Piece")
Truth table33%1/3
A and B
A= exists $generic_headers->{"UTEND"}B= UNIVERSAL::isa($generic_headers->{"UTEND"}, "Time::Piece")
ABresult
0X0
100
111
482 UNIVERSAL::isa( $generic_headers->{UTEND}, "Time::Piece" ) ) {
483 1 my $ut = $generic_headers->{UTEND};
484 1 $generic_headers->{UTEND} =~ /(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)/;
485 1 $return_hash{'UTDATE'} = join ':', $ut->year, $ut->mon, $ut->mday;
486 1 $return_hash{'UTEND'} = join ':', $ut->hour, $ut->minute, $ut->second;
487 }
488 1 return %return_hash;
489 }
490  
491 =item B<to_MSBID>
492  
493 Converts the MSBID field to an MSBID. Complication is that the SCUBA
494 header and database store a blank MSBID as a single space rather than
495 an empty string and this causes difficulty in some subsystems.
496  
497 This routine replaces a single space with a null string.
498  
499 =cut
500  
501 2 ▶sub to_MSBID {
Subroutine to_MSBID: called CC=2 SCAR=7.0
Pod documented
502 2 my $self = shift;
503 2 my $FITS_headers = shift;
504 2 my $msbid = $FITS_headers->{MSBID};
505 2 ▶ $msbid =~ s/\s+$// if defined $msbid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $msbid 2 0 2
506 2 return $msbid;
507 }
508  
509 =back
510  
511 =head1 SEE ALSO
512  
513 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::Base>
514  
515 =head1 AUTHOR
516  
517 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
518 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>
519  
520 =head1 COPYRIGHT
521  
522 Copyright (C) 2007 Science and Technology Facilities Council.
523 Copyright (C) 2003-2005 Particle Physics and Astronomy Research Council.
524 All Rights Reserved.
525  
526 This program is free software; you can redistribute it and/or modify it under
527 the terms of the GNU General Public License as published by the Free Software
528 Foundation; either version 2 of the License, or (at your option) any later
529 version.
530  
531 This program is distributed in the hope that it will be useful,but WITHOUT ANY
532 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
533 PARTICULAR PURPOSE. See the GNU General Public License for more details.
534  
535 You should have received a copy of the GNU General Public License along with
536 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
537 Place,Suite 330, Boston, MA 02111-1307, USA
538  
539 =cut
540  
541 10 1;
« HdrTrans/INGRID.pm ↑ Summary HdrTrans/MICHELLE.pm »