HdrTrans/NIRI.pm

filter: Statementstmt 25.9% 21 / 81 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 46.1% 6 / 13 Podpod 25.0% 2 / 8 totaltotal 23.7% 29 / 122 CC 11 SCAR 26.3
CC
11
Cov
21%
to_ROTATION
42.0
to_OBSERVATION_NUMBER
6.0
to_X_LOWER_BOUND
6.0
CRAP 13.9
« HdrTrans.pm ↑ Summary HdrTrans/ClassicCam.pm »
1 package Astro::FITS::HdrTrans::NIRI;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::NIRI - Gemini NIRI translations
6  
7 =head1 SYNOPSIS
8  
9 use Astro::FITS::HdrTrans::NIRI;
10  
11 %gen = Astro::FITS::HdrTrans::NIRI->translate_from_FITS( %hdr );
12  
13 =head1 DESCRIPTION
14  
15 This class provides a generic set of translations that are specific to
16 NIRI on the Gemini Observatory.
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 GEMINI
26 10 ▶use base qw/ Astro::FITS::HdrTrans::GEMINI /;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 10 our $VERSION = "1.66";
29  
30 # for a constant mapping, there is no FITS header, just a generic
31 # header that is constant
32 10 my %CONST_MAP = (
33 GAIN => 12.3, # hardwire for now
34 OBSERVATION_MODE => 'imaging',
35 SPEED_GAIN => "NA",
36 STANDARD => 0, # hardwire for now as all objects not a standard.
37 WAVEPLATE_ANGLE => 0, # hardwire for now
38 );
39  
40 # NULL mappings used to override base class implementations
41 10 my @NULL_MAP = qw/ /;
42  
43 # unit mapping implies that the value propogates directly
44 # to the output with only a keyword name change
45  
46 10 my %UNIT_MAP = (
47 DETECTOR_READ_TYPE => "MODE",
48 );
49  
50  
51 # Create the translation methods
52 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
53  
54 =head1 METHODS
55  
56 =over 4
57  
58 =item B<this_instrument>
59  
60 The name of the instrument required to match (case insensitively)
61 against the INSTRUME/INSTRUMENT keyword to allow this class to
62 translate the specified headers. Called by the default
63 C<can_translate> method.
64  
65 $inst = $class->this_instrument();
66  
67 Returns "NIRI".
68  
69 =cut
70  
71 20 ▶sub this_instrument {
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
72 20 return qr/^NIRI/;
73 }
74  
75 =back
76  
77 =head1 COMPLEX CONVERSIONS
78  
79 =over 4
80  
81 =cut
82  
83 0 ▶sub to_EXPOSURE_TIME {
Subroutine to_EXPOSURE_TIME: not called CC=1 SCAR=6.9
Pod undocumented
84 0 my $self = shift;
85 0 my $FITS_headers = shift;
86 0 my $et = $FITS_headers->{EXPTIME};
87 0 my $co = $FITS_headers->{COADDS};
88 0 return $et *= $co;
89 }
90  
91 0 ▶sub to_OBSERVATION_NUMBER {
Subroutine to_OBSERVATION_NUMBER: not called CC=2 SCAR=17.9
Pod undocumented
92 0 my $self = shift;
93 0 my $FITS_headers = shift;
94 0 my $obsnum = 0;
95 0 ▶ if ( exists ( $FITS_headers->{FRMNAME} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"FRMNAME"}) 0 0 0
96 0 my $fname = $FITS_headers->{FRMNAME};
97 0 $obsnum = substr( $fname, index( $fname, ":" ) - 4, 4 );
98 }
99 0 return $obsnum;
100 }
101  
102 =item B<to_ROTATION>
103  
104 Converts a linear transformation CD matrix into a single rotation angle.
105 This angle is measured counter-clockwise from the positive x-axis.
106 It uses the SLALIB routine slaDcmpf obtain the rotation angle without
107 assuming perpendicular axes.
108  
109 This routine also copes with errors in the matrix that can generate angles
110 +/-90 degrees instead of near 0 that they should be.
111  
112 =cut
113  
114 0 ▶sub to_ROTATION {
Subroutine to_ROTATION: not called CC=6 SCAR=37.4
Pod documented
115 0 my $self = shift;
116 0 my $FITS_headers = shift;
117 0 my $rotation = 0.0;
118 0 ▶ if ( exists( $FITS_headers->{CD1_1} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"CD1_1"}) 0 0 0
119  
120 # Access the CD matrix.
121 0 my $cd11 = $FITS_headers->{"CD1_1"};
122 0 my $cd12 = $FITS_headers->{"CD1_2"};
123 0 my $cd21 = $FITS_headers->{"CD2_1"};
124 0 my $cd22 = $FITS_headers->{"CD2_2"};
125  
126 # Determine the orientation using PAL routine. This has the
127 # advantage of not assuming perpendicular axes (i.e. allows for
128 # shear).
129 0 my ( $xz, $yz, $xs, $ys, $perp );
130 0 my @coeffs = ( 0.0, $cd11, $cd21, 0.0, $cd12, $cd22 );
131 0 eval {
132 0 require Astro::PAL;
133 0 ( $xz, $yz, $xs, $ys, $perp, $rotation ) = Astro::PAL::palDcmpf( \@coeffs );
134 };
135 0 ▶ if (!defined $perp) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $perp) 0 0 0
136 0 croak "NIRI translations require Astro::PAL";
137 }
138  
139 # Convert from radians to degrees.
140 0 my $rtod = 45 / atan2( 1, 1 );
141 0 $rotation *= $rtod;
142  
143 # The actual WCS matrix has errors and sometimes the angle which
144 # should be near 0 degrees, can be out by 90 degrees. So for this
145 # case we hardwire the main rotation and merely apply the small
146 # deviation from the cardinal orientations.
147 0 ▶ if ( abs( abs( $rotation ) - 90 ) < 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (abs abs($rotation) - 90 < 2) 0 0 0
148 0 my $delta_rho = 0.0;
149  
150 0 $delta_rho = $rotation - ( 90 * int( $rotation / 90 ) );
151 0 ▶ $delta_rho -= 90 if ( $delta_rho > 45 );
Branch: 1 branch
BranchTrueFalseTotal
if $delta_rho > 45 0 0 0
152 0 ▶ $delta_rho += 90 if ( $delta_rho < -45 );
Branch: 1 branch
BranchTrueFalseTotal
if $delta_rho < -45 0 0 0
153  
154 # Setting to near 180 is a fudge because the CD matrix appears is wrong
155 # occasionally by 90 degrees, judging by the telescope offsets, CTYPEn, and
156 # the support astronomer.
157 0 $rotation = 180.0 + $delta_rho;
158 }
159  
160 }
161 0 return $rotation;
162 }
163  
164 # Shift the bounds to GRID co-ordinates.
165 0 ▶sub to_X_LOWER_BOUND {
Subroutine to_X_LOWER_BOUND: not called CC=2 SCAR=17.9
Pod undocumented
166 0 my $self = shift;
167 0 my $FITS_headers = shift;
168 0 my $bound = 1;
169 0 ▶ if ( exists( $FITS_headers->{LOWCOL} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"LOWCOL"}) 0 0 0
170 0 $bound = $self->nint( $FITS_headers->{LOWCOL} + 1 );
171 }
172 0 return $bound;
173 }
174  
175 0 ▶sub to_Y_LOWER_BOUND {
Subroutine to_Y_LOWER_BOUND: not called CC=2 SCAR=17.9
Pod undocumented
176 0 my $self = shift;
177 0 my $FITS_headers = shift;
178 0 my $bound = 1;
179 0 ▶ if ( exists( $FITS_headers->{LOWROW} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"LOWROW"}) 0 0 0
180 0 $bound = $self->nint( $FITS_headers->{LOWROW} + 1 );
181 }
182 0 return $bound;
183 }
184  
185 0 ▶sub to_X_UPPER_BOUND {
Subroutine to_X_UPPER_BOUND: not called CC=2 SCAR=17.9
Pod undocumented
186 0 my $self = shift;
187 0 my $FITS_headers = shift;
188 0 my $bound = 1024;
189 0 ▶ if ( exists( $FITS_headers->{HICOL} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"HICOL"}) 0 0 0
190 0 $bound = $self->nint( $FITS_headers->{HICOL} + 1 );
191 }
192 0 return $bound;
193 }
194  
195 0 ▶sub to_Y_UPPER_BOUND {
Subroutine to_Y_UPPER_BOUND: not called CC=2 SCAR=17.9
Pod undocumented
196 0 my $self = shift;
197 0 my $FITS_headers = shift;
198 0 my $bound = 1024;
199 0 ▶ if ( exists( $FITS_headers->{HIROW} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"HIROW"}) 0 0 0
200 0 $bound = $self->nint( $FITS_headers->{HIROW} + 1 );
201 }
202 0 return $bound;
203 }
204  
205  
206 =back
207  
208 =head1 SEE ALSO
209  
210 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT>.
211  
212 =head1 AUTHOR
213  
214 Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt>
215 Paul Hirst E<lt>p.hirst@jach.hawaii.eduE<gt>,
216 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>.
217  
218 =head1 COPYRIGHT
219  
220 Copyright (C) 2008 Science and Technology Facilities Council
221 Copyright (C) 1998-2005 Particle Physics and Astronomy Research Council.
222 All Rights Reserved.
223  
224 This program is free software; you can redistribute it and/or modify it under
225 the terms of the GNU General Public License as published by the Free Software
226 Foundation; either Version 2 of the License, or (at your option) any later
227 version.
228  
229 This program is distributed in the hope that it will be useful,but WITHOUT ANY
230 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
231 PARTICULAR PURPOSE. See the GNU General Public License for more details.
232  
233 You should have received a copy of the GNU General Public License along with
234 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
235 Place, Suite 330, Boston, MA 02111-1307, USA.
236  
237 =cut
238  
239 10 1;
« HdrTrans.pm ↑ Summary HdrTrans/ClassicCam.pm »