HdrTrans/LCOSBIG_0m8.pm

filter: Statementstmt 21.8% 21 / 96 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 40.0% 6 / 15 Podpod 90.0% 9 / 10 totaltotal 22.6% 36 / 159 CC 16 SCAR 29.9
CC
16
Cov
16%
getbounds
56.0
to_RA_TELESCOPE_OFFSET
20.0
to_DEC_SCALE
12.0
CRAP 19.8
« HdrTrans/GEMINI.pm ↑ Summary HdrTrans/LCOMEROPE.pm »
1 # -*-perl-*-
2  
3 package Astro::FITS::HdrTrans::LCOSBIG_0m8;
4  
5 =head1 NAME
6  
7 Astro::FITS::HdrTrans::LCOSBIG_0m8 - LCO 0.8m SBIG translations
8  
9 =head1 SYNOPSIS
10  
11 use Astro::FITS::HdrTrans::LCOSBIG_0m8;
12  
13 %gen = Astro::FITS::HdrTrans::LCOSBIG_0m8->translate_from_FITS( %hdr );
14  
15 =head1 DESCRIPTION
16  
17 This class provides a generic set of translations that are specific to
18 0.8m SBIG on Sedgwick at LCO.
19  
20 =cut
21  
22 10 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 # Inherit from LCO base class.
28 10 ▶use base qw/ Astro::FITS::HdrTrans::LCO /;
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 # NULL mappings used to override base-class implementations.
38 10 my @NULL_MAP = qw/ /;
39  
40 10 my %UNIT_MAP = (
41 );
42  
43  
44 # Create the translation methods
45 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
46  
47 =head1 METHODS
48  
49 =over 4
50  
51 =item B<this_instrument>
52  
53 The name of the instrument required to match (case insensitively)
54 against the INSTRUME/INSTRUMENT keyword to allow this class to
55 translate the specified headers. Called by the default
56 C<can_translate> method.
57  
58 $inst = $class->this_instrument();
59  
60 Returns "LCOSBIG".
61  
62 =cut
63  
64 20 ▶sub this_instrument {
Subroutine this_instrument: called CC=1 SCAR=0.0
Pod documented
65 20 return qr/^kb16/i;
66  
67 }
68  
69 =back
70  
71 =head1 COMPLEX CONVERSIONS
72  
73 These methods are more complicated than a simple mapping. We have to
74 provide both from- and to-FITS conversions All these routines are
75 methods and the to_ routines all take a reference to a hash and return
76 the translated value (a many-to-one mapping) The from_ methods take a
77 reference to a generic hash and return a translated hash (sometimes
78 these are many-to-many)
79  
80 =over 4
81  
82 =cut
83  
84 =item B<to_DEC_SCALE>
85  
86 Sets the declination scale in arcseconds per pixel. The C<PIXSCALE>
87 is used when it's defined. Otherwise it returns a default value of 0.280
88 arcsec/pixel, multiplied by second entry of C<CCDSUM> assuming this is
89 defined (1.0 otherwise)
90  
91 =cut
92  
93 0 ▶sub to_DEC_SCALE {
Subroutine to_DEC_SCALE: not called CC=3 SCAR=24.8
Pod documented
94 0 my $self = shift;
95 0 my $FITS_headers = shift;
96 0 my $decscale = 0.280;
97  
98 # Assumes either x-y scales the same or the y corresponds to
99 # declination.
100 0 my $ccdscale = $self->via_subheader( $FITS_headers, "PIXSCALE" );
101 0 ▶ if ( defined $ccdscale ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ccdscale) { } 0 0 0
102 0 $decscale = $ccdscale;
103 } else {
104 0 my $ccdsum = $self->via_subheader( $FITS_headers, "CCDSUM" );
105 0 ▶ if ( defined $ccdsum ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ccdsum) 0 0 0
106 0 my @binning = split( / /, $ccdsum );
107 0 $decscale = $decscale * $binning[1];
108 }
109 }
110 0 return $decscale;
111 }
112  
113 =item B<to_DEC_TELESCOPE_OFFSET>
114  
115 Sets the declination telescope offset in arcseconds. It uses the
116 C<CAT-DEC> and C<DEC> keywords to derive the offset, and if either
117 does not exist, it returns a default of 0.0.
118  
119 =cut
120  
121 0 ▶sub to_DEC_TELESCOPE_OFFSET {
Subroutine to_DEC_TELESCOPE_OFFSET: not called CC=3 SCAR=24.8
Pod documented
122 0 my $self = shift;
123 0 my $FITS_headers = shift;
124 0 my $decoffset = 0.0;
125 0 ▶ if ( exists $FITS_headers->{"CAT-DEC"} && exists $FITS_headers->{DEC} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"CAT-DEC"} and exists $FITS_headers->{"DEC"}) 0 0 0
Condition0%0/3
exists $FITS_headers->{"CAT-DEC"} and exists $FITS_headers->{"DEC"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $FITS_headers->{"CAT-DEC"} and exists $FITS_headers->{"DEC"}
exists $FITS_headers->{"CAT-DEC"} exists $FITS_headers->{"DEC"}
Truth table0%0/3
A and B
A= exists $FITS_headers->{"CAT-DEC"}B= exists $FITS_headers->{"DEC"}
ABresult
0X0
100
111
126  
127 # Obtain the reference and telescope declinations positions measured in degrees.
128 0 my $refdec = $self->dms_to_degrees( $FITS_headers->{"CAT-DEC"} );
129 0 my $dec = $self->dms_to_degrees( $FITS_headers->{DEC} );
130  
131 # Find the offsets between the positions in arcseconds on the sky.
132 0 $decoffset = 3600.0 * ( $dec - $refdec );
133 }
134  
135 # The sense is reversed compared with UKIRT, as these measure the
136 # places on the sky, not the motion of the telescope.
137 0 return -1.0 * $decoffset;
138 }
139  
140 =item B<to_RA_SCALE>
141  
142 Sets the RA scale in arcseconds per pixel. The C<PIXSCALE>
143 is used when it's defined. Otherwise it returns a default value of 0.280
144 arcsec/pixel, multiplied by the first entry of C<CCDSUM> assuming this is
145 defined (1.0 otherwise)
146  
147 =cut
148  
149 0 ▶sub to_RA_SCALE {
Subroutine to_RA_SCALE: not called CC=3 SCAR=24.8
Pod documented
150 0 my $self = shift;
151 0 my $FITS_headers = shift;
152 0 my $rascale = 0.280;
153  
154 # Assumes either x-y scales the same or the x corresponds to
155 # ra.
156 0 my $ccdscale = $self->via_subheader( $FITS_headers, "PIXSCALE" );
157 0 ▶ if ( defined $ccdscale ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ccdscale) { } 0 0 0
158 0 $rascale = $ccdscale;
159 } else {
160 0 my $ccdsum = $self->via_subheader( $FITS_headers, "CCDSUM" );
161 0 ▶ if ( defined $ccdsum ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ccdsum) 0 0 0
162 0 my @binning = split( / /, $ccdsum );
163 0 $rascale = $rascale * $binning[0];
164 }
165 }
166 0 return $rascale;
167 }
168  
169  
170 =item B<to_RA_TELESCOPE_OFFSET>
171  
172 Sets the right-ascension telescope offset in arcseconds. It uses the
173 C<CAT-RA>, C<RA>, C<CAT-DEC> keywords to derive the offset, and if any
174 of these keywords does not exist, it returns a default of 0.0.
175  
176 =cut
177  
178 0 ▶sub to_RA_TELESCOPE_OFFSET {
Subroutine to_RA_TELESCOPE_OFFSET: not called CC=4 SCAR=30.0
Pod documented
179 0 my $self = shift;
180 0 my $FITS_headers = shift;
181 0 my $raoffset = 0.0;
182  
183 0 ▶ if ( exists $FITS_headers->{"CAT-DEC"} &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"CAT-DEC"} and exists $FITS_headers->{"CAT-RA"} and exists $FITS_headers->{"RA"}) 0 0 0
Condition0%0/6
exists $FITS_headers->{"CAT-DEC"} and exists $FITS_headers->{"CAT-RA"} and exists $FITS_headers->{"RA"}
!ll&&!rl&&r
000
exists $FITS_headers->{"CAT-DEC"} and exists $FITS_headers->{"CAT-RA"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $FITS_headers->{"CAT-DEC"} and exists $FITS_headers->{"CAT-RA"} and exists $FITS_headers->{"RA"}
exists $FITS_headers->{"CAT-DEC"} exists $FITS_headers->{"CAT-RA"} exists $FITS_headers->{"RA"}
Truth table0%0/4
A and B and C
A= exists $FITS_headers->{"CAT-DEC"}B= exists $FITS_headers->{"CAT-RA"}C= exists $FITS_headers->{"RA"}
ABCresult
0XX0
10X0
1100
1111
184 exists $FITS_headers->{"CAT-RA"} && exists $FITS_headers->{RA} ) {
185  
186 # Obtain the reference and telescope sky positions measured in degrees.
187 0 my $refra = $self->hms_to_degrees( $FITS_headers->{"CAT-RA"} );
188 0 my $ra = $self->hms_to_degrees( $FITS_headers->{RA} );
189 0 my $refdec = $self->dms_to_degrees( $FITS_headers->{"CAT-DEC"} );
190  
191 # Find the offset between the positions in arcseconds on the sky.
192 0 $raoffset = 3600.0 * ( $ra - $refra ) * $self->cosdeg( $refdec );
193 }
194  
195 # The sense is reversed compared with UKIRT, as these measure the
196 # place son the sky, not the motion of the telescope.
197 0 return -1.0 * $raoffset;
198 }
199  
200 =item B<to_X_LOWER_BOUND>
201  
202 Returns the lower bound along the X-axis of the area of the detector
203 as a pixel index.
204  
205 =cut
206  
207 0 ▶sub to_X_LOWER_BOUND {
Subroutine to_X_LOWER_BOUND: not called CC=1 SCAR=6.9
Pod documented
208 0 my $self = shift;
209 0 my $FITS_headers = shift;
210 0 my @bounds = $self->getbounds( $FITS_headers );
211 0 return $bounds[ 0 ];
212 }
213  
214 =item B<to_X_UPPER_BOUND>
215  
216 Returns the upper bound along the X-axis of the area of the detector
217 as a pixel index.
218  
219 =cut
220  
221 0 ▶sub to_X_UPPER_BOUND {
Subroutine to_X_UPPER_BOUND: not called CC=1 SCAR=6.9
Pod documented
222 0 my $self = shift;
223 0 my $FITS_headers = shift;
224 0 my @bounds = $self->getbounds( $FITS_headers );
225 0 return $bounds[ 1 ];
226 }
227  
228 =item B<to_Y_LOWER_BOUND>
229  
230 Returns the lower bound along the Y-axis of the area of the detector
231 as a pixel index.
232  
233 =cut
234  
235 0 ▶sub to_Y_LOWER_BOUND {
Subroutine to_Y_LOWER_BOUND: not called CC=1 SCAR=6.9
Pod documented
236 0 my $self = shift;
237 0 my $FITS_headers = shift;
238 0 my @bounds = $self->getbounds( $FITS_headers );
239 0 return $bounds[ 2 ];
240 }
241  
242  
243 =item B<to_Y_UPPER_BOUND>
244  
245 Returns the upper bound along the Y-axis of the area of the detector
246 as a pixel index.
247  
248 =cut
249  
250 0 ▶sub to_Y_UPPER_BOUND {
Subroutine to_Y_UPPER_BOUND: not called CC=1 SCAR=6.9
Pod documented
251 0 my $self = shift;
252 0 my $FITS_headers = shift;
253 0 my @bounds = $self->getbounds( $FITS_headers );
254 0 return $bounds[ 3 ];
255 }
256  
257 # Supplementary methods for the translations
258 # ------------------------------------------
259  
260 # Obtain the detector bounds from a section in [xl:xu,yl:yu] syntax.
261 # If the TRIMSEC header is absent, use a default which corresponds
262 # to the useful part of the array (minus bias strips).
263 0 ▶sub getbounds{
Subroutine getbounds: not called CC=7 SCAR=40.3
Pod undocumented
264 0 my $self = shift;
265 0 my $FITS_headers = shift;
266 0 my @bounds = ( 11, 1536, 6, 1022 );
267 # if ( $FITS_headers->{INSTRUME} =~ /^kb16/i ) {
268 # @bounds = ( 11, 2037, 11, 2037 );
269 # }
270 0 ▶ if ( exists $FITS_headers->{CCDSUM} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"CCDSUM"}) 0 0 0
271 0 my $binning = $FITS_headers->{CCDSUM};
272 0 ▶ if ( $binning eq '1 1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($binning eq "1 1") 0 0 0
273 0 @bounds = ( 22, 3072, 12, 2044 );
274 }
275 }
276 0 ▶ if ( exists $FITS_headers->{TRIMSEC} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"TRIMSEC"}) 0 0 0
277 0 my $section = $FITS_headers->{TRIMSEC};
278 0 ▶ if ( $section !~ /UNKNOWN/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($section =~ /UNKNOWN/i) 0 0 0
279 0 $section =~ s/\[//;
280 0 $section =~ s/\]//;
281 0 $section =~ s/,/:/g;
282 0 my @newbounds = split( /:/, $section );
283 0 ▶ if (@newbounds == grep { $_ == 0 } @newbounds) {
Branch: 1 branch
BranchTrueFalseTotal
if (@newbounds == grep({$_ == 0;} @newbounds)) { } 0 0 0
284 0 print "ERR: TRIMSEC all 0\n";
285 } else {
286 0 ▶ if ( $FITS_headers->{INSTRUME} !~ /^kbXX/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($FITS_headers->{"INSTRUME"} =~ /^kbXX/i) 0 0 0
287 # Unless this is kb78 data (which has a bad TRIMSEC), update bounds array
288 0 @bounds = @newbounds;
289 }
290 }
291 }
292 }
293 # print("DBG: Bounds=@bounds\n");
294 0 return @bounds;
295 }
296  
297 =back
298  
299 =head1 SEE ALSO
300  
301 C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::LCO>.
302  
303 =head1 AUTHOR
304  
305 Tim Lister E<lt>tlister@lcogt.netE<gt>
306  
307 =head1 COPYRIGHT
308  
309 =cut
310  
311 10 1;
« HdrTrans/GEMINI.pm ↑ Summary HdrTrans/LCOMEROPE.pm »