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

filter: Statementstmt 13.1% 27 / 205 Branchbran 1.5% 1 / 64 Conditioncond 13.3% 2 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 21.2% 7 / 33 Podpod 100% 27 / 27 totaltotal 18.1% 64 / 353 SCAR 69.8
CC
38
Cov
11%
get_speed_sec
42.0
to_DR_RECIPE
30.0
to_OBSERVATION_TYPE
20.0
CRAP 1071.0
« blib/lib/Astro/FITS/HdrTrans/INGRID.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/SPEX.pm »
1 package Astro::FITS::HdrTrans::ClassicCam;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::ClassicCam - Magellan ClassicCam translations
6  
7 =head1 SYNOPSIS
8  
9 use Astro::FITS::HdrTrans::ClassicCam;
10  
11 %gen = Astro::FITS::HdrTrans::ClassicCam->translate_from_FITS( %hdr );
12  
13 =head1 DESCRIPTION
14  
15 This class provides a generic set of translations that are specific to
16 Magellan ClassicCam observations.
17  
18 =cut
19  
20 10 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # Inherit from FITS.
26 10 ▶use base qw/ Astro::FITS::HdrTrans::FITS /;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 10 ▶use vars qw/ $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 10 $VERSION = "1.64";
31  
32 # For a constant mapping, there is no FITS header, just a generic
33 # header that is constant.
34 10 my %CONST_MAP = (
35 DETECTOR_READ_TYPE => "NDSTARE",
36 GAIN => 7.5,
37 INSTRUMENT => "ClassicCam",
38 NSCAN_POSITIONS => 1,
39 NUMBER_OF_EXPOSURES => 1,
40 OBSERVATION_MODE => 'imaging',
41 ROTATION => 0, # assume good alignment for now
42 );
43  
44 # NULL mappings used to override base-class implementations
45 10 my @NULL_MAP = qw/ /;
46  
47 # Unit mapping implies that the value propogates directly
48 # to the output with only a keyword name change.
49 10 my %UNIT_MAP = (
50 AIRMASS_END => "AIRMASS",
51 DEC_TELESCOPE_OFFSET => "DSECS",
52 EQUINOX => "EQUINOX",
53 EXPOSURE_TIME => "EXPTIME",
54 FILTER => "FILTER",
55 OBJECT => "OBJECT",
56 OBSERVATION_NUMBER => "IRPICNO",
57 RA_TELESCOPE_OFFSET => "ASECS",
58 SPEED_GAIN => "SPEED",
59 X_DIM => "NAXIS1",
60 Y_DIM => "NAXIS2"
61 );
62  
63  
64 # Create the translation methods.
65 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
66  
67 =head1 METHODS
68  
69 =over 4
70  
71 =item B<this_instrument>
72  
73 The name of the instrument required to match (case insensitively)
74 against the C<CHIP> keyword to allow this class to translate the
75 specified headers. Called by the default C<can_translate> method.
76  
77 $inst = $class->this_instrument();
78  
79 Returns "ClassicCam".
80  
81 =cut
82  
83 sub this_instrument {
84 0 ▶ return qr/^ClassicCam/i;
Subroutine this_instrument: not called CC=1 SCAR=6.9
Pod documented
85 }
86  
87 =item B<can_translate>
88  
89 Returns true if the supplied headers can be handled by this class.
90  
91 $cando = $class->can_translate( \%hdrs );
92  
93 For this class, in the absence of an C<INSTRUME> keyword, the method
94 will return true if the C<CHIP> header exists and matches 'C-CAM'.
95 It is not clear how robust this is, or over what range of epochs this
96 keyword was written.
97  
98 =cut
99  
100 sub can_translate {
101 20 ▶ my $self = shift;
Subroutine can_translate: called CC=4 SCAR=17.2
Pod documented
102 20 my $headers = shift;
103  
104 20 ▶ if ( exists $headers->{CHIP} &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $headers->{'CHIP'} and defined $headers->{'CHIP'} and $headers->{'CHIP'} =~ /^C-CAM/i) { } 0 20 20
Condition33%2/6
exists $headers->{"CHIP"} and defined $headers->{"CHIP"} and $headers->{"CHIP"} =~ /^C-CAM/i
!ll&&!rl&&r
2000
exists $headers->{"CHIP"} and defined $headers->{"CHIP"}
!ll&&!rl&&r
2000
MC/DC0%0/3
exists $headers->{"CHIP"} and defined $headers->{"CHIP"} and $headers->{"CHIP"} =~ /^C-CAM/i
exists $headers->{"CHIP"} defined $headers->{"CHIP"} $headers->{"CHIP"} =~ /^C-CAM/i
Truth table25%1/4
A and B and C
A= exists $headers->{"CHIP"}B= defined $headers->{"CHIP"}C= $headers->{"CHIP"} =~ /^C-CAM/i
ABCresult
0XX0
10X0
1100
1111
105 defined $headers->{CHIP} &&
106 $headers->{CHIP} =~ /^C-CAM/i ) {
107 0 return 1;
108 } else {
109 20 return 0;
110 }
111 }
112  
113 =back
114  
115 =head1 COMPLEX CONVERSIONS
116  
117 These methods are more complicated than a simple mapping. We have to
118 provide both from- and to-FITS conversions. All these routines are
119 methods and the to_ routines all take a reference to a hash and return
120 the translated value (a many-to-one mapping). The from_ methods take a
121 reference to a generic hash and return a translated hash (sometimes
122 these are many-to-many).
123  
124 =over 4
125  
126 =item B<to_AIRMASS_START>
127  
128 Sets a default airmass at the start of the observation if the C<AIRMASS>
129 keyword is not defined.
130  
131 =cut
132  
133 sub to_AIRMASS_START {
134 0 ▶ my $self = shift;
Subroutine to_AIRMASS_START: not called CC=2 SCAR=17.9
Pod documented
135 0 my $FITS_headers = shift;
136 0 my $airmass = 1.0;
137 0 ▶ if ( defined( $FITS_headers->{AIRMASS} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"AIRMASS"}) 0 0 0
138 0 $airmass = $FITS_headers->{AIRMASS};
139 }
140 0 return $airmass;
141 }
142  
143 =item B<to_DEC_BASE>
144  
145 Converts the base declination from sexagesimal d:m:s to decimal
146 degrees using the C<DEC> keyword, defaulting to 0.0.
147  
148 =cut
149  
150 sub to_DEC_BASE {
151 0 ▶ my $self = shift;
Subroutine to_DEC_BASE: not called CC=2 SCAR=17.9
Pod documented
152 0 my $FITS_headers = shift;
153 0 my $dec = 0.0;
154 0 my $sexa = $FITS_headers->{"DEC"};
155 0 ▶ if ( defined( $sexa ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sexa) 0 0 0
156 0 $dec = $self->dms_to_degrees( $sexa );
157 }
158 0 return $dec;
159 }
160  
161 =item B<to_DEC_SCALE>
162  
163 Sets the declination scale in arcseconds per pixel. It has a
164 fixed absolute value of 0.115 arcsec/pixel, but its sign depends on
165 the declination. The scale increases with pixel index, i.e. has north
166 to the top, for declinations south of -29 degrees. It is flipped
167 north of -29 degrees. The default scale assumes north is up.
168  
169 =cut
170  
171 sub to_DEC_SCALE {
172 0 ▶ my $self = shift;
Subroutine to_DEC_SCALE: not called CC=3 SCAR=24.8
Pod documented
173 0 my $FITS_headers = shift;
174 0 my $scale = 0.115;
175  
176 # Find the declination, converting from sexagesimal d:m:s.
177 0 my $sexa = $FITS_headers->{"DEC"};
178 0 ▶ if ( defined( $sexa ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sexa) 0 0 0
179 0 my $dec = $self->dms_to_degrees( $sexa );
180 0 ▶ if ( $dec > -29 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dec > -29) 0 0 0
181 0 $scale *= -1;
182 }
183 }
184 0 return $scale;
185 }
186  
187 =item B<to_DR_RECIPE>
188  
189 Returns the data-reduction recipe name. The selection depends on the
190 value of the C<OBJECT> keyword. The default is "QUICK_LOOK". A dark
191 returns "REDUCE_DARK", a sky flat "SKY_FLAT_MASKED", a dome flat
192 "SKY_FLAT", and an object's recipe is "JITTER_SELF_FLAT".
193  
194 =cut
195  
196 sub to_DR_RECIPE {
197 0 ▶ my $self = shift;
Subroutine to_DR_RECIPE: not called CC=5 SCAR=34.0
Pod documented
198 0 my $FITS_headers = shift;
199 0 my $type = "OBJECT";
200 0 my $recipe = "QUICK_LOOK";
201 0 ▶ if ( defined $FITS_headers->{OBJECT} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"OBJECT"}) 0 0 0
202 0 my $object = uc( $FITS_headers->{OBJECT} );
203 0 ▶ if ( $object eq "DARK" ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($object eq 'DARK') { } 0 0 0
elsif ($object =~ /SKY*FLAT/) { } 0 0 0
elsif ($object =~ /DOME*FLAT/) { } 0 0 0
204 0 $recipe = "REDUCE_DARK";
205 } elsif ( $object =~ /SKY*FLAT/ ) {
206 0 $recipe = "SKY_FLAT_MASKED";
207 } elsif ( $object =~ /DOME*FLAT/ ) {
208 0 $recipe = "SKY_FLAT";
209 } else {
210 0 $recipe = "JITTER_SELF_FLAT";
211 }
212 }
213 0 return $recipe;
214 }
215  
216 =item B<to_NUMBER_OF_OFFSETS>
217  
218 Stores the number of offsets using the UKIRT convention, i.e. adding
219 one to the number of dither positions, and a default dither pattern of
220 5.
221  
222 =cut
223  
224 sub to_NUMBER_OF_OFFSETS {
225 0 ▶ my $self = shift;
Subroutine to_NUMBER_OF_OFFSETS: not called CC=2 SCAR=17.9
Pod documented
226 0 my $FITS_headers = shift;
227  
228 # Allow for the UKIRT convention of the final offset to 0,0, and a
229 # default dither pattern of 5.
230 0 my $noffsets = 6;
231  
232 # The number of group members appears to be given by keyword NOFFSETS.
233 0 ▶ if ( defined $FITS_headers->{NOFFSETS} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"NOFFSETS"}) 0 0 0
234 0 $noffsets = $FITS_headers->{NOFFSETS};
235 }
236 0 return $noffsets;
237 }
238  
239 =item B<to_NUMBER_OF_READS>
240  
241 Stores the number of reads of the detector, with a default of 2, from
242 the sum of keywords C<REASDS_EP> and C<PRE_EP>.
243  
244 =cut
245  
246 sub to_NUMBER_OF_READS {
247 0 ▶ my $self = shift;
Subroutine to_NUMBER_OF_READS: not called CC=3 SCAR=24.8
Pod documented
248 0 my $FITS_headers = shift;
249 0 my $reads = 2;
250 0 ▶ if ( defined $FITS_headers->{READS_EP} && $FITS_headers->{PRE_EP} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"READS_EP"} and $FITS_headers->{"PRE_EP"}) 0 0 0
Condition0%0/3
defined $FITS_headers->{"READS_EP"} and $FITS_headers->{"PRE_EP"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $FITS_headers->{"READS_EP"} and $FITS_headers->{"PRE_EP"}
defined $FITS_headers->{"READS_EP"} $FITS_headers->{"PRE_EP"}
Truth table0%0/3
A and B
A= defined $FITS_headers->{"READS_EP"}B= $FITS_headers->{"PRE_EP"}
ABresult
0X0
100
111
251 0 $reads = $FITS_headers->{READS_EP} + $FITS_headers->{PRE_EP};
252 }
253 0 return $reads;
254 }
255  
256 =item B<to_OBSERVATION_TYPE>
257  
258 Determines the observation type from the C<OBJECT> keyword provided it is
259 "DARK" for a dark frame, or "FLAT" for a flat-field frame. All other
260 values of C<OBJECT> return a value of "OBJECT", i.e. of a source.
261  
262 =cut
263  
264 sub to_OBSERVATION_TYPE {
265 0 ▶ my $self = shift;
Subroutine to_OBSERVATION_TYPE: not called CC=4 SCAR=30.0
Pod documented
266 0 my $FITS_headers = shift;
267 0 my $type = "OBJECT";
268 0 ▶ if ( defined $FITS_headers->{OBJECT} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"OBJECT"}) 0 0 0
269 0 my $object = uc( $FITS_headers->{OBJECT} );
270 0 ▶ if ( $object eq "DARK" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($object eq 'DARK') { } 0 0 0
elsif ($object =~ /FLAT/) { } 0 0 0
271 0 $type = $object;
272 } elsif ( $object =~ /FLAT/ ) {
273 0 $type = "FLAT";
274 }
275 }
276 0 return $type;
277 }
278  
279 =item B<to_RA_BASE>
280  
281 Converts the base right ascension from sexagesimal h:m:s to decimal degrees
282 using the C<RA> keyword, defaulting to 0.0.
283  
284 =cut
285  
286 sub to_RA_BASE {
287 0 ▶ my $self = shift;
Subroutine to_RA_BASE: not called CC=2 SCAR=17.9
Pod documented
288 0 my $FITS_headers = shift;
289 0 my $ra = 0.0;
290 0 my $sexa = $FITS_headers->{"RA"};
291 0 ▶ if ( defined( $sexa ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sexa) 0 0 0
292 0 $ra = $self->hms_to_degrees( $sexa );
293 }
294 0 return $ra;
295 }
296  
297 =item B<to_RA_SCALE>
298  
299 Sets the right-ascension scale in arcseconds per pixel. It has a
300 fixed absolute value of 0.115 arcsec/pixel, but its sign depends on
301 the declination. The scale increases with pixel index, i.e. has east
302 to the right, for declinations south of -29 degrees. It is flipped
303 north of -29 degrees. The default scale assumes east is to the right.
304  
305 =cut
306  
307 sub to_RA_SCALE {
308 0 ▶ my $self = shift;
Subroutine to_RA_SCALE: not called CC=3 SCAR=24.8
Pod documented
309 0 my $FITS_headers = shift;
310 0 my $scale = 0.115;
311 0 my $sexa = $FITS_headers->{"DEC"};
312 0 ▶ if ( defined( $sexa ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sexa) 0 0 0
313 0 my $dec = $self->dms_to_degrees( $sexa );
314 0 ▶ if ( $dec > -29 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dec > -29) 0 0 0
315 0 $scale *= -1;
316 }
317 }
318 0 return $scale;
319 }
320  
321 =item B<to_UTDATE>
322  
323 Returns the UT date as C<Time::Piece> object. It copes with non-standard
324 format in C<DATE-OBS>.
325  
326 =cut
327  
328 sub to_UTDATE {
329 0 ▶ my $self = shift;
Subroutine to_UTDATE: not called CC=1 SCAR=6.9
Pod documented
330 0 my $FITS_headers = shift;
331  
332 # Guessing the format is ddmmmyy, which is not supported by
333 # Time::DateParse, so parse it.
334 0 return $self->get_UT_date( $FITS_headers );
335 }
336  
337 =item B<to_UTEND>
338  
339 Returns the UT time of the end of the observation as a C<Time::Piece> object.
340  
341 =cut
342  
343 # UT header gives end of observation in HH:MM:SS format.
344 sub to_UTEND {
345 0 ▶ my $self = shift;
Subroutine to_UTEND: not called CC=1 SCAR=6.9
Pod documented
346 0 my $FITS_headers = shift;
347  
348 # Get the UTDATE in YYYYMMDD format.
349 0 my $ymd = $self->to_UTDATE( $FITS_headers );
350 my $iso = sprintf( "%04d-%02d-%02dT%s",
351 substr( $ymd, 0, 4 ),
352 substr( $ymd, 4, 2 ),
353 substr( $ymd, 6, 2 ),
354 0 $FITS_headers->{UT} );
355 0 return $self->_parse_iso_date( $iso );
356 }
357  
358 =item B<from_UTEND>
359  
360 Returns the UT time of the end of the observation in HH:MM:SS format
361 and stores it in the C<UTEND> keyword.
362  
363 =cut
364  
365 sub from_UTEND {
366 0 ▶ my $self = shift;
Subroutine from_UTEND: not called CC=2 SCAR=17.9
Pod documented
367 0 my $generic_headers = shift;
368 0 my $utend = $generic_headers->{"UTEND"};
369 0 ▶ if (defined $utend) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $utend) 0 0 0
370 0 return $utend->strftime("%T");
371 }
372 0 return;
373 }
374  
375 =item B<to_UTSTART>
376  
377 Returns an estimated UT time of the start of the observation as a
378 C<Time::Piece> object. The start time is derived from the end time,
379 less the C<EXPTIME> exposure time and some allowance for the read time.
380  
381 =cut
382  
383 sub to_UTSTART {
384 0 ▶ my $self = shift;
Subroutine to_UTSTART: not called CC=2 SCAR=17.9
Pod documented
385 0 my $FITS_headers = shift;
386  
387 0 my $utend = $self->to_UTEND( $FITS_headers );
388  
389 0 my $nreads = $self->to_NUMBER_OF_READS( $FITS_headers );
390 0 my $speed = $self->get_speed_sec( $FITS_headers );
391 0 ▶ if ( defined $FITS_headers->{EXPTIME} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"EXPTIME"}) 0 0 0
392 0 my $offset = -1 * ( $FITS_headers->{EXPTIME} + $speed * $nreads );
393 0 $utend = $self->_add_seconds( $utend, $offset );
394 }
395 0 return $utend;
396 }
397  
398 =item B<to_X_LOWER_BOUND>
399  
400 Returns the lower bound along the X-axis of the area of the detector
401 as a pixel index.
402  
403 =cut
404  
405 sub to_X_LOWER_BOUND {
406 0 ▶ my $self = shift;
Subroutine to_X_LOWER_BOUND: not called CC=1 SCAR=6.9
Pod documented
407 0 my $FITS_headers = shift;
408 0 my @bounds = $self->quad_bounds( $FITS_headers );
409 0 return $bounds[ 0 ];
410 }
411  
412 =item B<to_X_REFERENCE_PIXEL>
413  
414 Specifies the X-axis reference pixel near the frame centre.
415  
416 =cut
417  
418 sub to_X_REFERENCE_PIXEL {
419 0 ▶ my $self = shift;
Subroutine to_X_REFERENCE_PIXEL: not called CC=1 SCAR=6.9
Pod documented
420 0 my $FITS_headers = shift;
421 0 my @bounds = $self->quad_bounds( $FITS_headers );
422 0 return int( ( $bounds[ 0 ] + $bounds[ 2 ] ) / 2 ) + 1;
423 }
424  
425 =item B<to_X_UPPER_BOUND>
426  
427 Returns the upper bound along the X-axis of the area of the detector
428 as a pixel index.
429  
430 =cut
431  
432 sub to_X_UPPER_BOUND {
433 0 ▶ my $self = shift;
Subroutine to_X_UPPER_BOUND: not called CC=1 SCAR=6.9
Pod documented
434 0 my $FITS_headers = shift;
435 0 my @bounds = $self->quad_bounds( $FITS_headers );
436 0 return $bounds[ 2 ];
437 }
438  
439 =item B<to_Y_LOWER_BOUND>
440  
441 Returns the lower bound along the Y-axis of the area of the detector
442 as a pixel index.
443  
444 =cut
445  
446 sub to_Y_LOWER_BOUND {
447 0 ▶ my $self = shift;
Subroutine to_Y_LOWER_BOUND: not called CC=1 SCAR=6.9
Pod documented
448 0 my $FITS_headers = shift;
449  
450 # Find the pixel bounds of the quadrant or whole detector.
451 0 my @bounds = $self->quad_bounds( $FITS_headers );
452 0 return $bounds[ 1 ];
453 }
454  
455 =item B<to_Y_REFERENCE_PIXEL>
456  
457 Specifies the Y-axis reference pixel near the frame centre.
458  
459 =cut
460  
461 sub to_Y_REFERENCE_PIXEL {
462 0 ▶ my $self = shift;
Subroutine to_Y_REFERENCE_PIXEL: not called CC=1 SCAR=6.9
Pod documented
463 0 my $FITS_headers = shift;
464 0 my @bounds = $self->quad_bounds($FITS_headers);
465 0 return int( ( $bounds[ 1 ] + $bounds[ 3 ] ) / 2 ) + 1;
466 }
467  
468 =item B<to_Y_UPPER_BOUND>
469  
470 Returns the upper bound along the Y-axis of the area of the detector
471 as a pixel index.
472  
473 =cut
474  
475 sub to_Y_UPPER_BOUND {
476 0 ▶ my $self = shift;
Subroutine to_Y_UPPER_BOUND: not called CC=1 SCAR=6.9
Pod documented
477 0 my $FITS_headers = shift;
478  
479 # Find the pixel bounds of the quadrant or whole detector.
480 0 my @bounds = $self->quad_bounds( $FITS_headers );
481 0 return $bounds[ 3 ];
482 }
483  
484 =back
485  
486 =cut
487  
488 # Supplementary methods for the translations
489 # ------------------------------------------
490  
491 =head1 HELPER ROUTINES
492  
493 These are ClassicCam-specific helper routines.
494  
495 =over 4
496  
497 =item B<dms_to_degrees>
498  
499 Converts a sky angle specified in d:m:s format into decimal degrees.
500 The argument is the sexagesimal-format angle.
501  
502 =cut
503  
504 sub dms_to_degrees {
505 0 ▶ my $self = shift;
Subroutine dms_to_degrees: not called CC=2 SCAR=17.9
Pod documented
506 0 my $sexa = shift;
507 0 my $dms;
508 0 ▶ if ( defined( $sexa ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sexa) 0 0 0
509 0 my @pos = split( /:/, $sexa );
510 0 $dms = $pos[ 0 ] + $pos[ 1 ] / 60.0 + $pos [ 2 ] / 3600.;
511 }
512 0 return $dms;
513 }
514  
515 =item B<get_speed_sec>
516  
517 Returns the detector speed in seconds. It uses the C<SPEED> to derive a
518 time in decimal seconds. The default is 0.743.
519  
520 =cut
521  
522 sub get_speed_sec {
523 0 ▶ my $self = shift;
Subroutine get_speed_sec: not called CC=6 SCAR=37.4
Pod documented
524 0 my $FITS_headers = shift;
525 0 my $speed = 0.743;
526 0 ▶ if ( exists $FITS_headers->{SPEED} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"SPEED"}) 0 0 0
527 0 my $s_speed = $FITS_headers->{SPEED};
528 0 ▶ $speed = 2.01 if ( $s_speed eq "2.0s" );
Branch: 1 branch
BranchTrueFalseTotal
if $s_speed eq "2.0s" 0 0 0
529 0 ▶ $speed = 1.005 if ( $s_speed eq "1.0s" );
Branch: 1 branch
BranchTrueFalseTotal
if $s_speed eq "1.0s" 0 0 0
530 0 ▶ $speed = 0.743 if ( $s_speed eq "743ms" );
Branch: 1 branch
BranchTrueFalseTotal
if $s_speed eq "743ms" 0 0 0
531 0 ▶ $speed = 0.405 if ( $s_speed eq "405ms" );
Branch: 1 branch
BranchTrueFalseTotal
if $s_speed eq "405ms" 0 0 0
532 }
533 0 return $speed;
534 }
535  
536 =item B<get_UT_date>
537  
538 Returns the UT date in YYYYMMDD format. It parses the non-standard
539 ddMmmyy C<DATE-OBS> keyword.
540  
541 =cut
542  
543 sub get_UT_date {
544 0 ▶ my $self = shift;
Subroutine get_UT_date: not called CC=4 SCAR=30.0
Pod documented
545 0 my $FITS_headers = shift;
546 0 my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
547 0 my $junk = $FITS_headers->{"DATE-OBS"};
548 0 my $day = substr( $junk, 0, 2 );
549 0 my $smonth = substr( $junk, 2, 3 );
550 0 my $mindex = 0;
551 0 ▶ while ( $mindex < 11 && uc( $smonth ) ne uc( $months[ $mindex ] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mindex < 11 and uc $smonth ne uc $months[$mindex]) 0 0 0
Condition0%0/3
$mindex < 11 and uc $smonth ne uc $months[$mindex]
!ll&&!rl&&r
000
MC/DC0%0/2
$mindex < 11 and uc $smonth ne uc $months[$mindex]
$mindex < 11 uc $smonth ne uc $months[$mindex]
Truth table0%0/3
A and B
A= $mindex < 11B= uc $smonth ne uc $months[$mindex]
ABresult
0X0
100
111
552 0 $mindex++;
553 }
554 0 $mindex++;
555 0 my $month = "0" x ( 2 - length( $mindex ) ) . $mindex;
556 0 my $year = substr( $junk, 5, 2 );
557 0 ▶ if ( $year > 90 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 90) { } 0 0 0
558 0 $year += 1900;
559 } else {
560 0 $year += 2000;
561 }
562 0 return join "", $year, $month, $day;
563 }
564  
565 =item B<get_UT_hours>
566  
567 Returns the UT time of the end of observation in decimal hours from
568 the C<UT> keyeword.
569  
570 =cut
571  
572 sub get_UT_hours {
573 0 ▶ my $self = shift;
Subroutine get_UT_hours: not called CC=3 SCAR=24.8
Pod documented
574 0 my $FITS_headers = shift;
575 0 ▶ if ( exists $FITS_headers->{UT} && $FITS_headers->{UT} =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'UT'} and $FITS_headers->{'UT'} =~ /:/) { } 0 0 0
Condition0%0/3
exists $FITS_headers->{"UT"} and $FITS_headers->{"UT"} =~ /:/
!ll&&!rl&&r
000
MC/DC0%0/2
exists $FITS_headers->{"UT"} and $FITS_headers->{"UT"} =~ /:/
exists $FITS_headers->{"UT"} $FITS_headers->{"UT"} =~ /:/
Truth table0%0/3
A and B
A= exists $FITS_headers->{"UT"}B= $FITS_headers->{"UT"} =~ /:/
ABresult
0X0
100
111
576 0 my ($hour, $minute, $second) = split( /:/, $FITS_headers->{UT} );
577 0 return $hour + ($minute / 60) + ($second / 3600);
578 } else {
579 0 return $FITS_headers->{UT};
580 }
581 }
582  
583 =item B<hms_to_degrees>
584  
585 Converts a sky angle specified in h:m:s format into decimal degrees.
586 It takes no account of latitude. The argument is the sexagesimal
587 format angle.
588  
589 =cut
590  
591 sub hms_to_degrees {
592 0 ▶ my $self = shift;
Subroutine hms_to_degrees: not called CC=2 SCAR=17.9
Pod documented
593 0 my $sexa = shift;
594 0 my $hms;
595 0 ▶ if ( defined( $sexa ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sexa) 0 0 0
596 0 my @pos = split( /:/, $sexa );
597 0 $hms = 15.0 * ( $pos[ 0 ] + $pos[ 1 ] / 60.0 + $pos [ 2 ] / 3600. );
598 }
599 0 return $hms;
600 }
601  
602 =item B<quad_bounds>
603  
604 Returns the detector bounds in pixels of the region of the detector
605 used. The region will be one of the four quadrants or the full
606 detector. We guess for the moment that keword C<QUAD> values of
607 1, 2, 3, 4 correspond to lower-left, lower-right, upper-left,
608 upper-right quadrants respectively, and 5 is the whole
609 256x256-pixel array.
610  
611 =cut
612  
613 sub quad_bounds {
614 0 ▶ my $self = shift;
Subroutine quad_bounds: not called CC=4 SCAR=30.0
Pod documented
615 0 my $FITS_headers = shift;
616 0 my @bounds = ( 1, 1, 256, 256 );
617 0 my $quad = $FITS_headers->{"QUAD"};
618 0 ▶ if ( defined( $quad ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $quad) 0 0 0
619 0 ▶ if ( $quad < 5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quad < 5) 0 0 0
620 0 $bounds[ 0 ] += 128 * ( $quad + 1 ) % 2;
621 0 $bounds[ 2 ] -= 128 * $quad % 2;
622 0 ▶ if ( $quad > 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quad > 2) { } 0 0 0
623 0 $bounds[ 1 ] += 128;
624 } else {
625 0 $bounds[ 3 ]-= 128;
626 }
627 }
628 }
629 0 return @bounds;
630 }
631  
632 =back
633  
634 =head1 SEE ALSO
635  
636 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>.
637  
638 =head1 AUTHOR
639  
640 Malcolm J. Currie E<lt>mjc@jach.hawaii.eduE<gt>
641 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
642  
643 =head1 COPYRIGHT
644  
645 Copyright (C) 2008 Science and Technology Facilities Council.
646 Copyright (C) 1998-2007 Particle Physics and Astronomy Research Council.
647 All Rights Reserved.
648  
649 This program is free software; you can redistribute it and/or modify it under
650 the terms of the GNU General Public License as published by the Free Software
651 Foundation; either Version 2 of the License, or (at your option) any later
652 version.
653  
654 This program is distributed in the hope that it will be useful,but WITHOUT ANY
655 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
656 PARTICULAR PURPOSE. See the GNU General Public License for more details.
657  
658 You should have received a copy of the GNU General Public License along with
659 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
660 Place, Suite 330, Boston, MA 02111-1307, USA.
661  
662 =cut
663  
664 10 1;
« blib/lib/Astro/FITS/HdrTrans/INGRID.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/SPEX.pm »