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

filter: Statementstmt 81.9% 132 / 161 Branchbran 39.7% 27 / 68 Conditioncond 33.3% 17 / 51 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 100% 22 / 22 Podpod 93.7% 15 / 16 totaltotal 61.9% 213 / 344 CC 52 SCAR 24.9
CC
52
Cov
63%
to_RA_SCALE
31.0
to_DEC_SCALE
29.9
from_RA_BASE
11.2
CRAP 12.0
« blib/lib/Astro/FITS/HdrTrans/LCOSBIG_0m4.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/UKIRTDB.pm »
1 package Astro::FITS::HdrTrans::UFTI;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::UFTI - UKIRT UFTI translations
6  
7 =head1 SYNOPSIS
8  
9 use Astro::FITS::HdrTrans::UFTI;
10  
11 %gen = Astro::FITS::HdrTrans::UFTI->translate_from_FITS( %hdr );
12  
13 =head1 DESCRIPTION
14  
15 This class provides a generic set of translations that are specific to
16 the UFTI camera of the United Kingdom Infrared Telescope.
17  
18 =cut
19  
20 11 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # Inherit from UKIRTNew
26 11 ▶use base qw/ Astro::FITS::HdrTrans::UKIRTNew /;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 11 ▶use vars qw/ $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 11 $VERSION = "1.65";
31  
32 # for a constant mapping, there is no FITS header, just a generic
33 # header that is constant
34 11 my %CONST_MAP = (
35  
36 );
37  
38 # NULL mappings used to override base class implementations
39 11 my @NULL_MAP = qw/ DETECTOR_INDEX /;
40  
41 # unit mapping implies that the value propogates directly
42 # to the output with only a keyword name change
43  
44 11 my %UNIT_MAP = (
45 # CGS4 + IRCAM
46 DETECTOR_READ_TYPE => "MODE",
47  
48 # MICHELLE + IRCAM compatible
49 SPEED_GAIN => "SPD_GAIN",
50 );
51  
52  
53 # Create the translation methods
54 11 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
55  
56 =head1 METHODS
57  
58 =over 4
59  
60 =item B<this_instrument>
61  
62 The name of the instrument required to match (case insensitively)
63 against the INSTRUME/INSTRUMENT keyword to allow this class to
64 translate the specified headers. Called by the default
65 C<can_translate> method.
66  
67 $inst = $class->this_instrument();
68  
69 Returns "UFTI".
70  
71 =cut
72  
73 sub this_instrument {
74 20 ▶ return "UFTI";
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
75 }
76  
77 =back
78  
79 =head1 COMPLEX CONVERSIONS
80  
81 These methods are more complicated than a simple mapping. We have to
82 provide both from- and to-FITS conversions. All these routines are
83 methods and the to_ routines all take a reference to a hash and return
84 the translated value (a many-to-one mapping). The from_ methods take a
85 reference to a generic hash and return a translated hash (sometimes
86 these are many-to-many).
87  
88 =over 4
89  
90 =item B<to_DEC_SCALE>
91  
92 Sets the declination scale in arcseconds per pixel derived
93 from keyword C<CDELT2>. The default is time dependent, as tabulated
94 in the UFTI web page.
95 L<http://www.jach.hawaii.edu/UKIRT/instruments/ufti/PARAMETERS.html#1>
96 The default scale assumes north is to the top.
97  
98 The actual C<CDELT2> value is scaled if its unit is degree/pixel,
99 as suggested by its size, and the presence of header C<CTYPE2> set
100 to 'DEC--TAN' indicating that the WCS follows the AIPS convention.
101  
102 =cut
103  
104 sub to_DEC_SCALE {
105 1 ▶ my $self = shift;
Subroutine to_DEC_SCALE: called CC=9 SCAR=34.0
Pod documented
106 1 my $FITS_headers = shift;
107  
108 # Default from 20011115.
109 1 my $scale = 0.09085;
110  
111 # Note in the raw data these are in arcseconds, not degrees.
112 1 ▶ if ( defined( $FITS_headers->{CDELT2} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'CDELT2'}) { } 1 0 1
113 1 $scale = $FITS_headers->{CDELT2};
114  
115 # Allow for missing values using measured scales.
116 } else {
117 0 my $date = $self->to_UTDATE( $FITS_headers );
118 0 ▶ if ( defined( $date ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $date) 0 0 0
119 0 ▶ if ( $date < 19990701 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($date < 19990701) { } 0 0 0
elsif ($date < 20010401) { } 0 0 0
elsif ($date < 20011115) { } 0 0 0
120 0 $scale = 0.09075;
121 } elsif ( $date < 20010401 ) {
122 0 $scale = 0.09088;
123 } elsif ( $date < 20011115 ) {
124 0 $scale = 0.09060;
125 }
126 }
127 }
128  
129 # Allow for D notation, which is not recognised by Perl, so that
130 # supplied strings are valid numbers.
131 1 $scale =~ s/D/E/;
132  
133 # The CDELTn headers are either part of a WCS in expressed in the
134 # AIPS-convention, or the values we require. Angles for the former
135 # are measured in degrees. The sign of the scale may be negative.
136 1 ▶ if ( defined $FITS_headers->{CTYPE2} &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"CTYPE2"} and $FITS_headers->{"CTYPE2"} eq "DEC--TAN" and abs $scale < "0.001") 0 1 1
Condition33%2/6
defined $FITS_headers->{"CTYPE2"} and $FITS_headers->{"CTYPE2"} eq "DEC--TAN" and abs $scale < "0.001"
!ll&&!rl&&r
100
defined $FITS_headers->{"CTYPE2"} and $FITS_headers->{"CTYPE2"} eq "DEC--TAN"
!ll&&!rl&&r
010
MC/DC0%0/3
defined $FITS_headers->{"CTYPE2"} and $FITS_headers->{"CTYPE2"} eq "DEC--TAN" and abs $scale < "0.001"
defined $FITS_headers->{"CTYPE2"} $FITS_headers->{"CTYPE2"} eq "DEC--TAN" abs $scale < "0.001"
Truth table25%1/4
A and B and C
A= defined $FITS_headers->{"CTYPE2"}B= $FITS_headers->{"CTYPE2"} eq "DEC--TAN"C= abs $scale < "0.001"
ABCresult
0XX0
10X0
1100
1111
137 $FITS_headers->{CTYPE2} eq "DEC--TAN" &&
138 abs( $scale ) < 1.0E-3 ) {
139 0 $scale *= 3600.0;
140 }
141 1 return $scale;
142 }
143  
144 =item B<to_FILE_FORMAT>
145  
146 Determines the file format being used. It is either C<"HDS"> (meaning
147 an HDS container file of NDFs) or C<"FITS"> and is determined by the
148 presence of the DHSVER header.
149  
150 =cut
151  
152 sub to_FILE_FORMAT {
153 2 ▶ my $self = shift;
Subroutine to_FILE_FORMAT: called CC=2 SCAR=7.2
Pod documented
154 2 my $FITS_headers = shift;
155 2 my $format = "HDS";
156 2 ▶ if ( ! exists( $FITS_headers->{DHSVER} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $FITS_headers->{"DHSVER"}) 0 2 2
157 0 $format = "FITS";
158 }
159 2 return $format;
160 }
161  
162 =item B<to_POLARIMETRY>
163  
164 Checks the filter name.
165  
166 =cut
167  
168 sub to_POLARIMETRY {
169 1 ▶ my $self = shift;
Subroutine to_POLARIMETRY: called CC=3 SCAR=12.7
Pod documented
170 1 my $FITS_headers = shift;
171 1 ▶ if ( exists( $FITS_headers->{FILTER} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'FILTER'} and $FITS_headers->{'FILTER'} =~ /pol/i) { } 0 1 1
Condition33%1/3
exists $FITS_headers->{"FILTER"} and $FITS_headers->{"FILTER"} =~ /pol/i
!ll&&!rl&&r
010
MC/DC0%0/2
exists $FITS_headers->{"FILTER"} and $FITS_headers->{"FILTER"} =~ /pol/i
exists $FITS_headers->{"FILTER"} $FITS_headers->{"FILTER"} =~ /pol/i
Truth table33%1/3
A and B
A= exists $FITS_headers->{"FILTER"}B= $FITS_headers->{"FILTER"} =~ /pol/i
ABresult
0X0
100
111
172 $FITS_headers->{FILTER} =~ /pol/i ) {
173 0 return 1;
174 } else {
175 1 return 0;
176 }
177 }
178  
179 =item B<to_RA_BASE>
180  
181 Converts the decimal hours in the FITS header C<RABASE> into
182 decimal degrees for the generic header C<RA_BASE>.
183  
184 Note that this is different from the original translation within
185 ORAC-DR where it was to decimal hours.
186  
187 There was a period from 2000-05-07 to 2000-07-19 inclusive, where
188 degrees, not hours, were written whenever the data were stored as NDF
189 format. However, there wasn't a clean changover during ORAC-DR
190 commissioning. So use the FILE_FORMAT to discriminate between the two
191 formats.
192  
193 =cut
194  
195 sub to_RA_BASE {
196 1 ▶ my $self = shift;
Subroutine to_RA_BASE: called CC=7 SCAR=23.7
Pod documented
197 1 my $FITS_headers = shift;
198 1 my $return;
199 1 ▶ if ( exists($FITS_headers->{RABASE} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"RABASE"}) 1 0 1
200 1 my $date = $self->to_UTDATE( $FITS_headers );
201 1 my $format = $self->to_FILE_FORMAT( $FITS_headers );
202  
203 1 ▶ if ( defined( $format ) && $format eq "HDS" &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $format and $format eq 'HDS' and defined $date and $date > 20000507 and $date < 20000720) { } 0 1 1
Condition33%4/12
defined $format and $format eq "HDS" and defined $date and $date > 20000507 and $date < 20000720
!ll&&!rl&&r
010
defined $format and $format eq "HDS" and defined $date and $date > 20000507
!ll&&!rl&&r
001
defined $format and $format eq "HDS" and defined $date
!ll&&!rl&&r
001
defined $format and $format eq "HDS"
!ll&&!rl&&r
001
MC/DC0%0/5
defined $format and $format eq "HDS" and defined $date and $date > 20000507 and $date < 20000720
defined $format $format eq "HDS" defined $date $date > 20000507 $date < 20000720
Truth table16%1/6
A and B and C and D and E
A= defined $formatB= $format eq "HDS"C= defined $dateD= $date > 20000507E= $date < 20000720
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
204 defined( $date ) && $date > 20000507 && $date < 20000720 ) {
205 0 $return = $FITS_headers->{RABASE};
206 } else {
207 1 $return = $FITS_headers->{RABASE} * 15;
208 }
209 }
210 1 return $return;
211 }
212  
213 =item B<from_RA_BASE>
214  
215 Converts the decimal degrees in the generic header C<RA_BASE>
216 into decimal hours for the FITS header C<RABASE>.
217  
218 %fits = $class->from_RA_BASE( \%generic );
219  
220 There was a period from 2000-05-07 to 2000-07-19 inclusive, where
221 degrees, not hours, were written whenever the data were stored as NDF
222 format. However, there was not a clean changover during ORAC-DR
223 commissioning. So use the generic header FILE_FORMAT to discriminate
224 between the two formats. For symmetry and consistency, retain these
225 units during the problem period.
226  
227 =cut
228  
229 sub from_RA_BASE {
230 1 ▶ my $self = shift;
Subroutine from_RA_BASE: called CC=7 SCAR=24.1
Pod documented
231 1 my $generic_headers = shift;
232 1 my %return_hash;
233 1 ▶ if ( defined( $generic_headers->{RA_BASE} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $generic_headers->{"RA_BASE"}) 1 0 1
234 1 my $date = $self->to_UTDATE( $generic_headers );
235  
236 1 ▶ if ( defined( $generic_headers->{FILE_FORMAT} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $generic_headers->{'FILE_FORMAT'} and $generic_headers->{'FILE_FORMAT'} eq 'HDS' and defined $date and $date > 20000507 and $date < 20000720) { } 0 1 1
Condition33%4/12
defined $generic_headers->{"FILE_FORMAT"} and $generic_headers->{"FILE_FORMAT"} eq "HDS" and defined $date and $date > 20000507 and $date < 20000720
!ll&&!rl&&r
100
defined $generic_headers->{"FILE_FORMAT"} and $generic_headers->{"FILE_FORMAT"} eq "HDS" and defined $date and $date > 20000507
!ll&&!rl&&r
100
defined $generic_headers->{"FILE_FORMAT"} and $generic_headers->{"FILE_FORMAT"} eq "HDS" and defined $date
!ll&&!rl&&r
010
defined $generic_headers->{"FILE_FORMAT"} and $generic_headers->{"FILE_FORMAT"} eq "HDS"
!ll&&!rl&&r
001
MC/DC0%0/5
defined $generic_headers->{"FILE_FORMAT"} and $generic_headers->{"FILE_FORMAT"} eq "HDS" and defined $date and $date > 20000507 and $date < 20000720
defined $generic_headers->{"FILE_FORMAT"} $generic_headers->{"FILE_FORMAT"} eq "HDS" defined $date $date > 20000507 $date < 20000720
Truth table16%1/6
A and B and C and D and E
A= defined $generic_headers->{"FILE_FORMAT"}B= $generic_headers->{"FILE_FORMAT"} eq "HDS"C= defined $dateD= $date > 20000507E= $date < 20000720
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
237 $generic_headers->{FILE_FORMAT} eq "HDS" &&
238 defined( $date ) && $date > 20000507 && $date < 20000720 ) {
239 0 $return_hash{'RABASE'} = $generic_headers->{RA_BASE};
240 } else {
241 1 $return_hash{'RABASE'} = $generic_headers->{RA_BASE} / 15;
242 }
243 }
244 1 return %return_hash;
245 }
246  
247 =item B<to_RA_SCALE>
248  
249 Sets the right-ascension scale in arcseconds per pixel derived
250 from keyword C<CDELT1>. The default is time dependent, as tabulated
251 in the UFTI web page.
252 L<http://www.jach.hawaii.edu/UKIRT/instruments/ufti/PARAMETERS.html#1>
253 The default scale assumes east is to the left.
254  
255 It corrects for an erroneous sign in early data.
256  
257 The actual C<CDELT1> value is scaled if its unit is degree/pixel,
258 as suggested by its size, and the presence of header C<CTYPE1> set
259 to 'RA---TAN' indicating that the WCS follows the AIPS convention.
260  
261 =cut
262  
263 sub to_RA_SCALE {
264 1 ▶ my $self = shift;
Subroutine to_RA_SCALE: called CC=10 SCAR=34.3
Pod documented
265 1 my $FITS_headers = shift;
266  
267 # Default from 20011115.
268 1 my $scale = -0.09085;
269  
270 # Note in the raw data these are in arcseconds, not degrees.
271 1 ▶ if ( defined( $FITS_headers->{CDELT1} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{'CDELT1'}) { } 1 0 1
272 1 $scale = $FITS_headers->{CDELT1};
273  
274 # Allow for missing values using measured scales.
275 } else {
276 0 my $date = $self->to_UTDATE( $FITS_headers );
277 0 ▶ if ( defined( $date ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $date) 0 0 0
278 0 ▶ if ( $date < 19990701 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($date < 19990701) { } 0 0 0
elsif ($date < 20010401) { } 0 0 0
elsif ($date < 20011115) { } 0 0 0
279 0 $scale = -0.09075;
280 } elsif ( $date < 20010401 ) {
281 0 $scale = -0.09088;
282 } elsif ( $date < 20011115 ) {
283 0 $scale = -0.09060;
284 }
285 }
286 }
287  
288 # Allow for D notation, which is not recognised by Perl, so that
289 # supplied strings are valid numbers.
290 1 $scale =~ s/D/E/;
291  
292 # Correct the RA scale. The RA scale originates from the erroneous
293 # positive CDELT1. Reverse the sign to give the correct increment
294 # per pixel.
295 1 ▶ if ( $scale > 0.0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scale > 0) 1 0 1
296 1 $scale *= -1.0;
297 }
298  
299 # The CDELTn headers are either part of a WCS in expressed in the
300 # AIPS-convention, or the values we require. Angles for the former
301 # are measured in degrees. The sign of the scale may be negative.
302 1 ▶ if ( defined $FITS_headers->{CTYPE1} &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $FITS_headers->{"CTYPE1"} and $FITS_headers->{"CTYPE1"} eq "RA---TAN" and abs $scale < "0.001") 0 1 1
Condition33%2/6
defined $FITS_headers->{"CTYPE1"} and $FITS_headers->{"CTYPE1"} eq "RA---TAN" and abs $scale < "0.001"
!ll&&!rl&&r
100
defined $FITS_headers->{"CTYPE1"} and $FITS_headers->{"CTYPE1"} eq "RA---TAN"
!ll&&!rl&&r
010
MC/DC0%0/3
defined $FITS_headers->{"CTYPE1"} and $FITS_headers->{"CTYPE1"} eq "RA---TAN" and abs $scale < "0.001"
defined $FITS_headers->{"CTYPE1"} $FITS_headers->{"CTYPE1"} eq "RA---TAN" abs $scale < "0.001"
Truth table25%1/4
A and B and C
A= defined $FITS_headers->{"CTYPE1"}B= $FITS_headers->{"CTYPE1"} eq "RA---TAN"C= abs $scale < "0.001"
ABCresult
0XX0
10X0
1100
1111
303 $FITS_headers->{CTYPE1} eq "RA---TAN" &&
304 abs( $scale ) < 1.0E-3 ) {
305 0 $scale *= 3600.0;
306 }
307  
308 1 return $scale;
309 }
310  
311 =item B<from_RA_SCALE>
312  
313 Converts the generic header C<RA_SCALE> to the FITS header C<CDELT1>
314 by ensuring it has a positive sign as in the input data. This
315 sign is wrong because the right ascension increases with decreasing
316 pixel index, however this conversion permits a cycle from FITS to
317 generic and back to FITS to retain the original value.
318  
319 %fits = $class->from_RA_SCALE( \%generic );
320  
321 =cut
322  
323 sub from_RA_SCALE {
324 1 ▶ my $self = shift;
Subroutine from_RA_SCALE: called CC=2 SCAR=7.0
Pod documented
325 1 my $generic_headers = shift;
326 1 my %return_hash;
327 1 ▶ if ( defined( $generic_headers->{RA_SCALE} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $generic_headers->{"RA_SCALE"}) 1 0 1
328 1 $return_hash{'CDELT1'} = -1.0 * $generic_headers->{RA_SCALE};
329 }
330 1 return %return_hash;
331 }
332  
333 =item B<to_UTDATE>
334  
335 Converts FITS header values into C<Time::Piece> object. This differs
336 from the base class in the use of the C<DATE> rather than C<UTDATE>
337 header item and the formatting of the DATE keyword is not an integer.
338  
339 =cut
340  
341 sub to_UTDATE {
342 6 ▶ my $self = shift;
Subroutine to_UTDATE: called CC=3 SCAR=11.1
Pod documented
343 6 my $FITS_headers = shift;
344 6 my $return;
345 6 ▶ if ( exists( $FITS_headers->{DATE} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"DATE"}) 5 1 6
346 5 my $utdate = $FITS_headers->{DATE};
347  
348 # This is a kludge to work with old data which has multiple values of
349 # the DATE keyword with the last value being blank (these were early
350 # UFTI data). Return the first value, since the last value can be
351 # blank.
352 5 ▶ if ( ref( $utdate ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $utdate eq "ARRAY") 0 5 5
353 0 $utdate = $utdate->[0];
354 }
355 5 $return = $self->_parse_yyyymmdd_date( $utdate, "-" );
356 5 $return = $return->strftime( '%Y%m%d' );
357 }
358  
359 6 return $return;
360 }
361  
362 =item B<from_UTDATE>
363  
364 Converts UT date in C<Time::Piece> object into C<YYYY-MM-DD> format
365 for DATE header. This differs from the base class in the use of the
366 C<DATE> rather than C<UTDATE> header item.
367  
368 =cut
369  
370 sub from_UTDATE {
371 1 ▶ my $self = shift;
Subroutine from_UTDATE: called CC=3 SCAR=11.1
Pod documented
372 1 my $generic_headers = shift;
373 1 my %return_hash;
374 1 ▶ if ( exists( $generic_headers->{UTDATE} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $generic_headers->{"UTDATE"}) 1 0 1
375 1 my $date = $generic_headers->{UTDATE};
376 1 $date = $self->_parse_yyyymmdd_date( $date, '' );
377 1 ▶ return () unless defined $date;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $date 0 1 1
378 1 $return_hash{DATE} = sprintf( "%04d-%02d-%02d",
379 $date->year, $date->mon, $date->mday );
380 }
381 1 return %return_hash;
382 }
383  
384 =item B<to_UTEND>
385  
386 Converts UT date in C<DATE-END> header into C<Time::Piece> object.
387 Allows for blank C<DATE-END> string present in early UFTI data.
388  
389 =cut
390  
391 sub to_UTEND {
392 1 ▶ my $self = shift;
Subroutine to_UTEND: called CC=4 SCAR=15.8
Pod documented
393 1 my $FITS_headers = shift;
394 my $dateend = ( exists $FITS_headers->{"DATE-END"} ?
395 1 ▶ $FITS_headers->{"DATE-END"} : undef );
Branch: 1 branch
BranchTrueFalseTotal
exists $FITS_headers->{'DATE-END'} ? : 1 0 1
396  
397 # Some early data had blank DATE-OBS strings.
398 1 ▶ if ( defined( $dateend ) && $dateend !~ /\d/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dateend and not $dateend =~ /\d/) 0 1 1
Condition33%1/3
defined $dateend and not $dateend =~ /\d/
!ll&&!rl&&r
010
MC/DC0%0/2
defined $dateend and not $dateend =~ /\d/
defined $dateend not $dateend =~ /\d/
Truth table33%1/3
A and not(B)
A= defined $dateendB= not $dateend =~ /\d/
ABresult
0X0
100
111
399 0 $dateend = undef;
400 }
401  
402 1 my @rutend = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "UTEND" );
403 1 my $utend = $rutend[-1];
404 1 return $self->_parse_date_info( $dateend,
405 $self->to_UTDATE( $FITS_headers ),
406 $utend );
407 }
408  
409 =item B<to_UTSTART>
410  
411 Converts UT date in C<DATE-OBS> header into C<Time::Piece> object.
412 Allows for blank C<DATE-OBS> string present in early UFTI data.
413  
414 =cut
415  
416 sub to_UTSTART {
417 2 ▶ my $self = shift;
Subroutine to_UTSTART: called CC=4 SCAR=15.8
Pod documented
418 2 my $FITS_headers = shift;
419 my $dateobs = ( exists $FITS_headers->{"DATE-OBS"} ?
420 2 ▶ $FITS_headers->{"DATE-OBS"} : undef );
Branch: 1 branch
BranchTrueFalseTotal
exists $FITS_headers->{'DATE-OBS'} ? : 2 0 2
421  
422 # Some early data had blank DATE-OBS strings.
423 2 ▶ if ( defined( $dateobs ) && $dateobs !~ /\d/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dateobs and not $dateobs =~ /\d/) 0 2 2
Condition33%1/3
defined $dateobs and not $dateobs =~ /\d/
!ll&&!rl&&r
020
MC/DC0%0/2
defined $dateobs and not $dateobs =~ /\d/
defined $dateobs not $dateobs =~ /\d/
Truth table33%1/3
A and not(B)
A= defined $dateobsB= not $dateobs =~ /\d/
ABresult
0X0
100
111
424 0 $dateobs = undef;
425 }
426  
427 2 my @rutstart = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "UTSTART" );
428 2 my $utstart = $rutstart[0];
429 2 return $self->_parse_date_info( $dateobs,
430 $self->to_UTDATE( $FITS_headers ),
431 $utstart );
432 }
433  
434  
435 =item B<to_X_REFERENCE_PIXEL>
436  
437 Specify the reference pixel, which is normally near the frame centre.
438 There may be small displacements to avoid detector joins or for
439 polarimetry using a Wollaston prism.
440  
441 =cut
442  
443 sub to_X_REFERENCE_PIXEL{
444 1 ▶ my $self = shift;
Subroutine to_X_REFERENCE_PIXEL: called CC=5 SCAR=17.8
Pod documented
445 1 my $FITS_headers = shift;
446 1 my $xref;
447  
448 # Use the average of the bounds to define the centre and dimension.
449 1 ▶ if ( exists $FITS_headers->{RDOUT_X1} && exists $FITS_headers->{RDOUT_X2} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'RDOUT_X1'} and exists $FITS_headers->{'RDOUT_X2'}) { } 1 0 1
Condition33%1/3
exists $FITS_headers->{"RDOUT_X1"} and exists $FITS_headers->{"RDOUT_X2"}
!ll&&!rl&&r
001
MC/DC0%0/2
exists $FITS_headers->{"RDOUT_X1"} and exists $FITS_headers->{"RDOUT_X2"}
exists $FITS_headers->{"RDOUT_X1"} exists $FITS_headers->{"RDOUT_X2"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"RDOUT_X1"}B= exists $FITS_headers->{"RDOUT_X2"}
ABresult
0X0
100
111
450 1 my $xl = $FITS_headers->{RDOUT_X1};
451 1 my $xu = $FITS_headers->{RDOUT_X2};
452 1 my $xdim = $xu - $xl + 1;
453 1 my $xmid = $self->nint( ( $xl + $xu ) / 2 );
454  
455 # UFTI is at the centre for a sub-array along an axis but offset slightly
456 # for a sub-array to avoid the joins between the four sub-array sections
457 # of the frame. Ideally these should come through the headers...
458 1 ▶ if ( $xdim == 1024 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xdim == 1024) { } 1 0 1
459 1 $xref = $xmid + 20;
460 } else {
461 0 $xref = $xmid;
462 }
463  
464 # Correct for IRPOL beam splitting with a 6" E offset.
465 1 ▶ if ( $FITS_headers->{FILTER} =~ m/pol/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($FITS_headers->{"FILTER"} =~ /pol/) 0 1 1
466 0 $xref -= 65.5;
467 }
468  
469 # Use a default which assumes the full array (slightly offset from the
470 # centre).
471 } else {
472 0 $xref = 533;
473 }
474 1 return $xref;
475 }
476  
477 =item B<from_X_REFERENCE_PIXEL>
478  
479 Always returns CRPIX1 of "0.5".
480  
481 =cut
482  
483 sub from_X_REFERENCE_PIXEL {
484 1 ▶ return ( "CRPIX1" => 0.5 );
Subroutine from_X_REFERENCE_PIXEL: called CC=1 SCAR=0.0
Pod documented
485 }
486  
487 =item B<to_Y_REFERENCE_PIXEL>
488  
489 Specify the reference pixel, which is normally near the frame centre.
490 There may be small displacements to avoid detector joins or for
491 polarimetry using a Wollaston prism.
492  
493 =cut
494  
495 sub to_Y_REFERENCE_PIXEL{
496 1 ▶ my $self = shift;
Subroutine to_Y_REFERENCE_PIXEL: called CC=5 SCAR=17.8
Pod documented
497 1 my $FITS_headers = shift;
498 1 my $yref;
499  
500 # Use the average of the bounds to define the centre and dimension.
501 1 ▶ if ( exists $FITS_headers->{RDOUT_Y1} && exists $FITS_headers->{RDOUT_Y2} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'RDOUT_Y1'} and exists $FITS_headers->{'RDOUT_Y2'}) { } 1 0 1
Condition33%1/3
exists $FITS_headers->{"RDOUT_Y1"} and exists $FITS_headers->{"RDOUT_Y2"}
!ll&&!rl&&r
001
MC/DC0%0/2
exists $FITS_headers->{"RDOUT_Y1"} and exists $FITS_headers->{"RDOUT_Y2"}
exists $FITS_headers->{"RDOUT_Y1"} exists $FITS_headers->{"RDOUT_Y2"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"RDOUT_Y1"}B= exists $FITS_headers->{"RDOUT_Y2"}
ABresult
0X0
100
111
502 1 my $yl = $FITS_headers->{RDOUT_Y1};
503 1 my $yu = $FITS_headers->{RDOUT_Y2};
504 1 my $ydim = $yu - $yl + 1;
505 1 my $ymid = $self->nint( ( $yl + $yu ) / 2 );
506  
507 # UFTI is at the centre for a sub-array along an axis but offset slightly
508 # for a sub-array to avoid the joins between the four sub-array sections
509 # of the frame. Ideally these should come through the headers...
510 1 ▶ if ( $ydim == 1024 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ydim == 1024) { } 1 0 1
511 1 $yref = $ymid - 25;
512 } else {
513 0 $yref = $ymid;
514 }
515  
516 # Correct for IRPOL beam splitting with a " N offset.
517 1 ▶ if ( $FITS_headers->{FILTER} =~ m/pol/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($FITS_headers->{"FILTER"} =~ /pol/) 0 1 1
518 0 $yref += 253;
519 }
520  
521 # Use a default which assumes the full array (slightly offset from the
522 # centre).
523 } else {
524 0 $yref = 488;
525 }
526 1 return $yref;
527 }
528  
529 =item B<from_X_REFERENCE_PIXEL>
530  
531 Always returns CRPIX2 of "0.5".
532  
533 =cut
534  
535 sub from_Y_REFERENCE_PIXEL {
536 1 ▶ return ( "CRPIX2" => 0.5 );
Subroutine from_Y_REFERENCE_PIXEL: called CC=1 SCAR=0.0
Pod undocumented
537 }
538  
539  
540 =back
541  
542 =head1 SEE ALSO
543  
544 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>.
545  
546 =head1 AUTHOR
547  
548 Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt>
549 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
550 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
551  
552 =head1 COPYRIGHT
553  
554 Copyright (C) 2008 Science and Technology Facilities Council.
555 Copyright (C) 2003-2007 Particle Physics and Astronomy Research Council.
556 All Rights Reserved.
557  
558 This program is free software; you can redistribute it and/or modify it under
559 the terms of the GNU General Public License as published by the Free Software
560 Foundation; either Version 2 of the License, or (at your option) any later
561 version.
562  
563 This program is distributed in the hope that it will be useful,but WITHOUT ANY
564 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
565 PARTICULAR PURPOSE. See the GNU General Public License for more details.
566  
567 You should have received a copy of the GNU General Public License along with
568 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
569 Place, Suite 330, Boston, MA 02111-1307, USA.
570  
571 =cut
572  
573 11 1;
« blib/lib/Astro/FITS/HdrTrans/LCOSBIG_0m4.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/UKIRTDB.pm »