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

filter: Statementstmt 82.5% 90 / 109 Branchbran 41.6% 10 / 24 Conditioncond 22.2% 6 / 27 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 94.4% 17 / 18 Podpod 100% 11 / 11 totaltotal 66.0% 134 / 203 SCAR 38.3
CC
24
Cov
66%
_to_RA_TELESCOPE_OFFSET
42.0
to_DEC_TELESCOPE_OFFSET
8.0
to_NUMBER_OF_OFFSETS
4.3
CRAP 46.1
« blib/lib/Astro/FITS/HdrTrans/Base.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/IRCAM.pm »
1 package Astro::FITS::HdrTrans::MICHELLE;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::MICHELLE - UKIRT Michelle translations
6  
7 =head1 SYNOPSIS
8  
9 use Astro::FITS::HdrTrans::MICHELLE;
10  
11 %gen = Astro::FITS::HdrTrans::MICHELLE->translate_from_FITS( %hdr );
12  
13 =head1 DESCRIPTION
14  
15 This class provides a generic set of translations that are specific to
16 the MICHELLE camera and spectrometer of the United Kingdom Infrared
17 Telescope.
18  
19 =cut
20  
21 10 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # Inherit from UKIRT
27 # UKIRTNew must come first because of DATE-OBS handling
28 10 ▶use base qw/ Astro::FITS::HdrTrans::UKIRTNew /;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 10 ▶use vars qw/ $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 10 $VERSION = "1.64";
33  
34 # for a constant mapping, there is no FITS header, just a generic
35 # header that is constant
36 10 my %CONST_MAP = (
37  
38 );
39  
40 # unit mapping implies that the value propogates directly
41 # to the output with only a keyword name change
42  
43 10 my %UNIT_MAP = (
44 # Michelle Specific
45 CHOP_ANGLE => "CHPANGLE",
46 CHOP_THROW => "CHPTHROW",
47 GRATING_DISPERSION => "GRATDISP",
48 GRATING_NAME => "GRATNAME",
49 GRATING_ORDER => "GRATORD",
50 GRATING_WAVELENGTH => "GRATPOS",
51 SAMPLING => "SAMPLING",
52 SLIT_ANGLE => "SLITANG",
53  
54 # CGS4 compatible
55 NSCAN_POSITIONS => "DETNINCR",
56 SCAN_INCREMENT => "DETINCR",
57  
58 # UIST compatible
59 NUMBER_OF_READS => "NREADS",
60 POLARIMETRY => "POLARISE",
61 SLIT_NAME => "SLITNAME",
62  
63 # UIST + WFCAM compatible
64 EXPOSURE_TIME => "EXP_TIME",
65  
66 # UFTI + IRCAM compatible
67 SPEED_GAIN => "SPD_GAIN",
68  
69 # CGS4 + UIST + WFCAM
70 CONFIGURATION_INDEX => 'CNFINDEX',
71 );
72  
73 # Derived from end entry in subheader
74 10 my %ENDOBS_MAP = (
75 DETECTOR_INDEX => 'DINDEX',
76 );
77  
78  
79 # Create the translation methods
80 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, undef, \%ENDOBS_MAP );
81  
82 =head1 METHODS
83  
84 =over 4
85  
86 =item B<this_instrument>
87  
88 The name of the instrument required to match (case insensitively)
89 against the INSTRUME/INSTRUMENT keyword to allow this class to
90 translate the specified headers. Called by the default
91 C<can_translate> method.
92  
93 $inst = $class->this_instrument();
94  
95 Returns "MICHELLE".
96  
97 =cut
98  
99 sub this_instrument {
100 20 ▶ return "MICHELLE";
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
101 }
102  
103 =back
104  
105 =head1 COMPLEX CONVERSIONS
106  
107 =over 4
108  
109 =item B<to_DEC_TELESCOPE_OFFSET>
110  
111 Declination offsets need to be handled differently for spectroscopy
112 mode because of the new nod iterator.
113  
114 =cut
115  
116 sub to_DEC_TELESCOPE_OFFSET {
117 1 ▶ my $self = shift;
Subroutine to_DEC_TELESCOPE_OFFSET: called CC=6 SCAR=20.9
Pod documented
118 1 my $FITS_headers = shift;
119 1 my $decoff;
120  
121 # Determine the observation mode, e.g. spectroscopy or imaging.
122 1 my $mode = $self->to_OBSERVATION_MODE($FITS_headers);
123 1 ▶ if ( $mode eq 'spectroscopy' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq 'spectroscopy') { } 1 0 1
124  
125 # If the nod iterator is used, then telescope offsets always come out
126 # as 0,0. We need to check if we're in the B beam (the nodded
127 # position) to figure out what the offset is using the chop angle
128 # and throw.
129 1 ▶ if ( exists( $FITS_headers->{CHOPBEAM} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'CHOPBEAM'} and $FITS_headers->{'CHOPBEAM'} =~ /^B/ and exists $FITS_headers->{'CHPANGLE'} and exists $FITS_headers->{'CHPTHROW'}) { } 1 0 1
Condition33%3/9
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/ and exists $FITS_headers->{"CHPANGLE"} and exists $FITS_headers->{"CHPTHROW"}
!ll&&!rl&&r
001
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/ and exists $FITS_headers->{"CHPANGLE"}
!ll&&!rl&&r
001
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/
!ll&&!rl&&r
001
MC/DC0%0/4
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/ and exists $FITS_headers->{"CHPANGLE"} and exists $FITS_headers->{"CHPTHROW"}
exists $FITS_headers->{"CHOPBEAM"} $FITS_headers->{"CHOPBEAM"} =~ /^B/ exists $FITS_headers->{"CHPANGLE"} exists $FITS_headers->{"CHPTHROW"}
Truth table20%1/5
A and B and C and D
A= exists $FITS_headers->{"CHOPBEAM"}B= $FITS_headers->{"CHOPBEAM"} =~ /^B/C= exists $FITS_headers->{"CHPANGLE"}D= exists $FITS_headers->{"CHPTHROW"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
130 $FITS_headers->{CHOPBEAM} =~ /^B/ &&
131 exists( $FITS_headers->{CHPANGLE} ) &&
132 exists( $FITS_headers->{CHPTHROW} ) ) {
133  
134 1 my $pi = 4 * atan2( 1, 1 );
135 1 my $throw = $FITS_headers->{CHPTHROW};
136 1 my $angle = $FITS_headers->{CHPANGLE} * $pi / 180.0;
137 1 $decoff = $throw * cos( $angle );
138 } else {
139 0 $decoff = $FITS_headers->{TDECOFF};
140 }
141  
142 # Imaging.
143 } else {
144 0 $decoff = $FITS_headers->{TDECOFF};
145 }
146  
147 1 return $decoff;
148 }
149  
150 =item B<from_DEC_TELESCOPE_OFFSET>
151  
152 If we are nodding TDECOFF always comes out as 0.0. We always return
153 zero for spectroscopy and TDECOFF otherwise. It's possible that this
154 is incorrect and should only occur for the specific case of a B
155 chop beam. The chopbeam is not stored in the generic headers.
156  
157 =cut
158  
159 sub from_DEC_TELESCOPE_OFFSET {
160 1 ▶ my $self = shift;
Subroutine from_DEC_TELESCOPE_OFFSET: called CC=2 SCAR=7.1
Pod documented
161 1 my $generic_headers = shift;
162 1 my $tdecoff;
163 1 ▶ if ($generic_headers->{OBSERVATION_MODE} eq 'spectroscopy') {
Branch: 1 branch
BranchTrueFalseTotal
if ($generic_headers->{'OBSERVATION_MODE'} eq 'spectroscopy') { } 1 0 1
164 1 $tdecoff = 0.0;
165 } else {
166 0 $tdecoff = $generic_headers->{DEC_TELESCOPE_OFFSET};
167 }
168 1 return ("TDECOFF",$tdecoff);
169 }
170  
171 =item B<to_DETECTOR_READ_TYPE>
172  
173 Usually DET_MODE but in some older data it can be DETMODE.
174  
175 =cut
176  
177 sub to_DETECTOR_READ_TYPE {
178 1 ▶ my $self = shift;
Subroutine to_DETECTOR_READ_TYPE: called CC=3 SCAR=11.0
Pod documented
179 1 my $FITS_headers = shift;
180  
181 # cut off date is 20040206
182 1 my $read_type;
183 1 for my $k (qw/ DET_MODE DETMODE /) {
184 1 ▶ if (exists $FITS_headers->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{$k}) 1 0 1
185 1 $read_type = $FITS_headers->{$k};
186 1 last;
187 }
188 }
189 1 return $read_type;
190 }
191  
192 =item B<to_NUMBER_OF_OFFSETS>
193  
194 Cater for early data with missing headers. Normally the NOFFSETS
195 header is available.
196  
197 =cut
198  
199 sub to_NUMBER_OF_OFFSETS {
200 1 ▶ my $self = shift;
Subroutine to_NUMBER_OF_OFFSETS: called CC=4 SCAR=14.6
Pod documented
201 1 my $FITS_headers = shift;
202  
203 # It's normally a ABBA pattern. Add one for the final offset to 0,0.
204 1 my $noffsets = 5;
205  
206 # Look for a defined header containing integers.
207 1 ▶ if ( exists $FITS_headers->{NOFFSETS} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"NOFFSETS"}) 1 0 1
208 1 my $noff = $FITS_headers->{NOFFSETS};
209 1 ▶ if ( defined $noff && $noff =~ /\d+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $noff and $noff =~ /\d+/) 1 0 1
Condition33%1/3
defined $noff and $noff =~ /\d+/
!ll&&!rl&&r
001
MC/DC0%0/2
defined $noff and $noff =~ /\d+/
defined $noff $noff =~ /\d+/
Truth table33%1/3
A and B
A= defined $noffB= $noff =~ /\d+/
ABresult
0X0
100
111
210 1 $noffsets = $noff;
211 }
212 }
213 1 return $noffsets;
214 }
215  
216 =item B<to_OBSERVATION_MODE>
217  
218 Normally use INSTMODE header but for older data use CAMERA.
219  
220 =cut
221  
222 sub to_OBSERVATION_MODE {
223 2 ▶ my $self = shift;
Subroutine to_OBSERVATION_MODE: called CC=3 SCAR=11.0
Pod documented
224 2 my $FITS_headers = shift;
225  
226 2 my $mode;
227 # 20040206
228 2 for my $k (qw/ INSTMODE CAMERA /) {
229 2 ▶ if (exists $FITS_headers->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{$k}) 2 0 2
230 2 $mode = $FITS_headers->{$k};
231 2 last;
232 }
233 }
234 2 return $mode;
235 }
236  
237 =item B<to_RA_TELESCOPE_OFFSET>
238  
239 Right-ascension offsets need to be handled differently for spectroscopy
240 mode because of the new nod iterator.
241  
242 =cut
243  
244 sub _to_RA_TELESCOPE_OFFSET {
245 0 ▶ my $self = shift;
Subroutine _to_RA_TELESCOPE_OFFSET: not called CC=6 SCAR=37.4
246 0 my $FITS_headers = shift;
247 0 my $raoff;
248  
249 # Determine the observation mode, e.g. spectroscopy or imaging.
250 0 my $mode = $self->to_OBSERVATION_MODE($FITS_headers);
251 0 ▶ if ( $mode eq 'spectroscopy' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq 'spectroscopy') { } 0 0 0
252  
253 # If the nod iterator is used, then telescope offsets always come out
254 # as 0,0. We need to check if we're in the B beam (the nodded
255 # position) to figure out what the offset is using the chop angle
256 # and throw.
257 0 ▶ if ( exists( $FITS_headers->{CHOPBEAM} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'CHOPBEAM'} and $FITS_headers->{'CHOPBEAM'} =~ /^B/ and exists $FITS_headers->{'CHPANGLE'} and exists $FITS_headers->{'CHPTHROW'}) { } 0 0 0
Condition0%0/9
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/ and exists $FITS_headers->{"CHPANGLE"} and exists $FITS_headers->{"CHPTHROW"}
!ll&&!rl&&r
000
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/ and exists $FITS_headers->{"CHPANGLE"}
!ll&&!rl&&r
000
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/
!ll&&!rl&&r
000
MC/DC0%0/4
exists $FITS_headers->{"CHOPBEAM"} and $FITS_headers->{"CHOPBEAM"} =~ /^B/ and exists $FITS_headers->{"CHPANGLE"} and exists $FITS_headers->{"CHPTHROW"}
exists $FITS_headers->{"CHOPBEAM"} $FITS_headers->{"CHOPBEAM"} =~ /^B/ exists $FITS_headers->{"CHPANGLE"} exists $FITS_headers->{"CHPTHROW"}
Truth table0%0/5
A and B and C and D
A= exists $FITS_headers->{"CHOPBEAM"}B= $FITS_headers->{"CHOPBEAM"} =~ /^B/C= exists $FITS_headers->{"CHPANGLE"}D= exists $FITS_headers->{"CHPTHROW"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
258 $FITS_headers->{CHOPBEAM} =~ /^B/ &&
259 exists( $FITS_headers->{CHPANGLE} ) &&
260 exists( $FITS_headers->{CHPTHROW} ) ) {
261 0 my $pi = 4 * atan2( 1, 1 );
262 0 my $throw = $FITS_headers->{CHPTHROW};
263 0 my $angle = $FITS_headers->{CHPANGLE} * $pi / 180.0;
264 0 $raoff = $throw * sin( $angle );
265  
266 } else {
267 0 $raoff = $FITS_headers->{TRAOFF};
268 }
269  
270 # Imaging.
271 } else {
272 0 $raoff = $FITS_headers->{TRAOFF};
273 }
274 0 return $raoff;
275 }
276  
277 =item B<from_TELESCOPE>
278  
279 For data taken before 20010906, return 'UKATC'. For data taken on and
280 after 20010906, return 'UKIRT'. Returned header is C<TELESCOP>.
281  
282 =cut
283  
284 sub from_TELESCOPE {
285 1 ▶ my $self = shift;
Subroutine from_TELESCOPE: called CC=2 SCAR=7.2
Pod documented
286 1 my $generic_headers = shift;
287 1 my $utdate = $generic_headers->{'UTDATE'};
288 1 ▶ if ( $utdate < 20010906 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utdate < 20010906) { } 0 1 1
289 0 return( "TELESCOP", "UKATC" );
290 } else {
291 1 return( "TELESCOP", "UKIRT" );
292 }
293 }
294  
295 =item B<to_X_REFERENCE_PIXEL>
296  
297 Specify the reference pixel, which is normally near the frame centre.
298 Note that offsets for polarimetry are undefined.
299  
300 =cut
301  
302 sub to_X_REFERENCE_PIXEL{
303 1 ▶ my $self = shift;
Subroutine to_X_REFERENCE_PIXEL: called CC=3 SCAR=11.7
Pod documented
304 1 my $FITS_headers = shift;
305 1 my $xref;
306  
307 # Use the average of the bounds to define the centre.
308 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
309 1 my $xl = $FITS_headers->{RDOUT_X1};
310 1 my $xu = $FITS_headers->{RDOUT_X2};
311 1 $xref = $self->nint( ( $xl + $xu ) / 2 );
312  
313 # Use a default of the centre of the full array.
314 } else {
315 0 $xref = 161;
316 }
317 1 return $xref;
318 }
319  
320 =item B<from_X_REFERENCE_PIXEL>
321  
322 Always returns the value '1' as CRPIX1.
323  
324 =cut
325  
326 sub from_X_REFERENCE_PIXEL {
327 1 ▶ my $self = shift;
Subroutine from_X_REFERENCE_PIXEL: called CC=1 SCAR=0.0
Pod documented
328 1 return ("CRPIX1", 1.0);
329 }
330  
331 =item B<to_Y_REFERENCE_PIXEL>
332  
333 Specify the reference pixel, which is normally near the frame centre.
334 Note that offsets for polarimetry are undefined.
335  
336 =cut
337  
338 sub to_Y_REFERENCE_PIXEL{
339 1 ▶ my $self = shift;
Subroutine to_Y_REFERENCE_PIXEL: called CC=3 SCAR=11.7
Pod documented
340 1 my $FITS_headers = shift;
341 1 my $yref;
342  
343 # Use the average of the bounds to define the centre.
344 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
345 1 my $yl = $FITS_headers->{RDOUT_Y1};
346 1 my $yu = $FITS_headers->{RDOUT_Y2};
347 1 $yref = $self->nint( ( $yl + $yu ) / 2 );
348  
349 # Use a default of the centre of the full array.
350 } else {
351 0 $yref = 121;
352 }
353 1 return $yref;
354 }
355  
356 =item B<from_Y_REFERENCE_PIXEL>
357  
358 Always returns the value '1' as CRPIX2.
359  
360 =cut
361  
362 sub from_Y_REFERENCE_PIXEL {
363 1 ▶ my $self = shift;
Subroutine from_Y_REFERENCE_PIXEL: called CC=1 SCAR=0.0
Pod documented
364 1 return ("CRPIX2", 1.0);
365 }
366  
367 =back
368  
369 =head1 SEE ALSO
370  
371 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>.
372  
373 =head1 AUTHOR
374  
375 Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt>
376 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
377 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
378  
379 =head1 COPYRIGHT
380  
381 Copyright (C) 2008 Science and Technology Facilities Council.
382 Copyright (C) 2006-2007 Particle Physics and Astronomy Research Council.
383 ACopyright (C) 2003-2005 Particle Physics and Astronomy Research Council.
384 All Rights Reserved.
385  
386 This program is free software; you can redistribute it and/or modify it under
387 the terms of the GNU General Public License as published by the Free Software
388 Foundation; either Version 2 of the License, or (at your option) any later
389 version.
390  
391 This program is distributed in the hope that it will be useful,but WITHOUT ANY
392 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
393 PARTICULAR PURPOSE. See the GNU General Public License for more details.
394  
395 You should have received a copy of the GNU General Public License along with
396 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
397 Place, Suite 330, Boston, MA 02111-1307, USA.
398  
399 =cut
400  
401 10 1;
« blib/lib/Astro/FITS/HdrTrans/Base.pm ↑ Summary blib/lib/Astro/FITS/HdrTrans/IRCAM.pm »