File Coverage

blib/lib/Astro/FITS/HdrTrans/LCOSBIG_0m4.pm
Criterion Covered Total %
statement 18 86 20.9
branch 0 20 0.0
condition 0 9 0.0
subroutine 7 16 43.7
pod 9 10 90.0
total 34 141 24.1


line stmt bran cond sub pod time code
1             # -*-perl-*-
2              
3              
4             =head1 NAME
5              
6             Astro::FITS::HdrTrans::LCOSBIG_0m4 - LCO 0.4m SBIG translations
7              
8             =head1 SYNOPSIS
9              
10             use Astro::FITS::HdrTrans::LCOSBIG_0m4;
11              
12             %gen = Astro::FITS::HdrTrans::LCOSBIG_0m4->translate_from_FITS( %hdr );
13              
14             =head1 DESCRIPTION
15              
16             This class provides a generic set of translations that are specific to
17             0.4m SBIGs at LCO.
18              
19             =cut
20              
21             use 5.006;
22 10     10   13893627 use warnings;
  10         31  
23 10     10   44 use strict;
  10         16  
  10         298  
24 10     10   51 use Carp;
  10         26  
  10         211  
25 10     10   39  
  10         21  
  10         605  
26             # Inherit from LCO base class.
27             use base qw/ Astro::FITS::HdrTrans::LCO /;
28 10     10   59  
  10         16  
  10         1419  
29             use vars qw/ $VERSION /;
30 10     10   53  
  10         17  
  10         6524  
31             $VERSION = "1.65";
32              
33             # for a constant mapping, there is no FITS header, just a generic
34             # header that is constant
35             my %CONST_MAP = (
36             );
37              
38             # NULL mappings used to override base-class implementations.
39             my @NULL_MAP = qw/ /;
40              
41             my %UNIT_MAP = (
42             );
43              
44              
45             # Create the translation methods
46             __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
47              
48             =head1 METHODS
49              
50             =over 4
51              
52             =item B<this_instrument>
53              
54             The name of the instrument required to match (case insensitively)
55             against the INSTRUME/INSTRUMENT keyword to allow this class to
56             translate the specified headers. Called by the default
57             C<can_translate> method.
58              
59             $inst = $class->this_instrument();
60              
61             Returns "LCOSBIG".
62              
63             =cut
64              
65             return qr/^kb8/i;
66             }
67 20     20 1 94  
68             =back
69              
70             =head1 COMPLEX CONVERSIONS
71              
72             These methods are more complicated than a simple mapping. We have to
73             provide both from- and to-FITS conversions All these routines are
74             methods and the to_ routines all take a reference to a hash and return
75             the translated value (a many-to-one mapping) The from_ methods take a
76             reference to a generic hash and return a translated hash (sometimes
77             these are many-to-many)
78              
79             =over 4
80              
81             =cut
82              
83             =item B<to_DEC_SCALE>
84              
85             Sets the declination scale in arcseconds per pixel. The C<PIXSCALE>
86             is used when it's defined. Otherwise it returns a default value of 0.5710
87             arcsec/pixel, multiplied by C<YBINNING> assuming this is defined
88              
89             =cut
90              
91             my $self = shift;
92             my $FITS_headers = shift;
93             my $decscale = 0.5710;
94 0     0 1    
95 0           # Assumes either x-y scales the same or the y corresponds to
96 0           # declination.
97             my $ccdscale = $self->via_subheader( $FITS_headers, "PIXSCALE" );
98             if ( defined $ccdscale ) {
99             $decscale = $ccdscale;
100 0           } else {
101 0 0         my $ybinning = $self->via_subheader( $FITS_headers, "YBINNING" );
102 0           if ( defined $ybinning ) {
103             $decscale = $decscale * $ybinning;
104 0           }
105 0 0         }
106 0           return $decscale;
107             }
108              
109 0           =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             my $self = shift;
118             my $FITS_headers = shift;
119             my $decoffset = 0.0;
120             if ( exists $FITS_headers->{"CAT-DEC"} && exists $FITS_headers->{DEC} ) {
121 0     0 1    
122 0           # Obtain the reference and telescope declinations positions measured in degrees.
123 0           my $refdec = $self->dms_to_degrees( $FITS_headers->{"CAT-DEC"} );
124 0 0 0       my $dec = $self->dms_to_degrees( $FITS_headers->{DEC} );
125              
126             # Find the offsets between the positions in arcseconds on the sky.
127 0           $decoffset = 3600.0 * ( $dec - $refdec );
128 0           }
129              
130             # The sense is reversed compared with UKIRT, as these measure the
131 0           # places on the sky, not the motion of the telescope.
132             return -1.0 * $decoffset;
133             }
134              
135             =item B<to_RA_SCALE>
136 0            
137             Sets the RA scale in arcseconds per pixel. The C<PIXSCALE>
138             is used when it's defined. Otherwise it returns a default value of 0.5710
139             arcsec/pixel, multiplied by C<XBINNING> assuming this is defined (1.0 otherwise)
140              
141             =cut
142              
143             my $self = shift;
144             my $FITS_headers = shift;
145             my $rascale = 0.5710;
146              
147             # Assumes either x-y scales the same or the x corresponds to
148 0     0 1   # ra.
149 0           my $ccdscale = $self->via_subheader( $FITS_headers, "PIXSCALE" );
150 0           if ( defined $ccdscale ) {
151             $rascale = $ccdscale;
152             } else {
153             my $xbinning = $self->via_subheader( $FITS_headers, "XBINNING" );
154 0           if ( defined $xbinning ) {
155 0 0         $rascale = $rascale * $xbinning;
156 0           }
157             }
158 0           return $rascale;
159 0 0         }
160 0            
161              
162             =item B<to_RA_TELESCOPE_OFFSET>
163 0            
164             Sets the right-ascension telescope offset in arcseconds. It uses the
165             C<CAT-RA>, C<RA>, C<CAT-DEC> keywords to derive the offset, and if any
166             of these keywords does not exist, it returns a default of 0.0.
167              
168             =cut
169              
170             my $self = shift;
171             my $FITS_headers = shift;
172             my $raoffset = 0.0;
173              
174             if ( exists $FITS_headers->{"CAT-DEC"} &&
175             exists $FITS_headers->{"CAT-RA"} && exists $FITS_headers->{RA} ) {
176 0     0 1    
177 0           # Obtain the reference and telescope sky positions measured in degrees.
178 0           my $refra = $self->hms_to_degrees( $FITS_headers->{"CAT-RA"} );
179             my $ra = $self->hms_to_degrees( $FITS_headers->{RA} );
180 0 0 0       my $refdec = $self->dms_to_degrees( $FITS_headers->{"CAT-DEC"} );
      0        
181              
182             # Find the offset between the positions in arcseconds on the sky.
183             $raoffset = 3600.0 * ( $ra - $refra ) * $self->cosdeg( $refdec );
184 0           }
185 0            
186 0           # The sense is reversed compared with UKIRT, as these measure the
187             # place son the sky, not the motion of the telescope.
188             return -1.0 * $raoffset;
189 0           }
190              
191             =item B<to_X_LOWER_BOUND>
192              
193             Returns the lower bound along the X-axis of the area of the detector
194 0           as a pixel index.
195              
196             =cut
197              
198             my $self = shift;
199             my $FITS_headers = shift;
200             my @bounds = $self->getbounds( $FITS_headers );
201             return $bounds[ 0 ];
202             }
203              
204             =item B<to_X_UPPER_BOUND>
205 0     0 1    
206 0           Returns the upper bound along the X-axis of the area of the detector
207 0           as a pixel index.
208 0            
209             =cut
210              
211             my $self = shift;
212             my $FITS_headers = shift;
213             my @bounds = $self->getbounds( $FITS_headers );
214             return $bounds[ 1 ];
215             }
216              
217             =item B<to_Y_LOWER_BOUND>
218              
219 0     0 1   Returns the lower bound along the Y-axis of the area of the detector
220 0           as a pixel index.
221 0            
222 0           =cut
223              
224             my $self = shift;
225             my $FITS_headers = shift;
226             my @bounds = $self->getbounds( $FITS_headers );
227             return $bounds[ 2 ];
228             }
229              
230             =item B<to_Y_UPPER_BOUND>
231              
232             Returns the upper bound along the Y-axis of the area of the detector
233 0     0 1   as a pixel index.
234 0            
235 0           =cut
236 0            
237             my $self = shift;
238             my $FITS_headers = shift;
239             my @bounds = $self->getbounds( $FITS_headers );
240             return $bounds[ 3 ];
241             }
242              
243             # Supplementary methods for the translations
244             # ------------------------------------------
245              
246              
247 0     0 1   # Obtain the detector bounds from a section in [xl:xu,yl:yu] syntax.
248 0           # If the TRIMSEC header is absent, use a default which corresponds
249 0           # to the useful part of the array (minus bias strips).
250 0           my $self = shift;
251             my $FITS_headers = shift;
252             my @bounds = ( 11, 1536, 4, 1024 );
253             if ( exists $FITS_headers->{CCDSUM} ) {
254             my $binning = $FITS_headers->{CCDSUM};
255             if ( $binning eq '1 1' ) {
256             @bounds = ( 22, 3072, 8, 2048 );
257             }
258             }
259             if ( exists $FITS_headers->{TRIMSEC} ) {
260             my $section = $FITS_headers->{TRIMSEC};
261 0     0 0   if ( $section !~ /UNKNOWN/i ) {
262 0           $section =~ s/\[//;
263 0           $section =~ s/\]//;
264 0 0         $section =~ s/,/:/g;
265 0           @bounds = split( /:/, $section );
266 0 0         }
267 0           }
268             # print("DBG: Bounds=@bounds\n");
269             return @bounds;
270 0 0         }
271 0            
272 0 0         =back
273 0            
274 0           =head1 SEE ALSO
275 0            
276 0           C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::LCO>.
277              
278             =head1 AUTHOR
279              
280 0           Tim Lister E<lt>tlister@lcogt.netE<gt>
281              
282             =head1 COPYRIGHT
283              
284             =cut
285              
286             1;