HdrTrans/LCOSPECTRAL.pm

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