HdrTrans/MICHELLE.pm

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