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

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