File Coverage

blib/lib/Astro/FITS/HdrTrans/LCOSBIG_0m8.pm
Criterion Covered Total %
statement 18 93 19.3
branch 0 24 0.0
condition 0 9 0.0
subroutine 7 16 43.7
pod 9 10 90.0
total 34 152 22.3


line stmt bran cond sub pod time code
1             # -*-perl-*-
2              
3              
4             =head1 NAME
5              
6             Astro::FITS::HdrTrans::LCOSBIG_0m8 - LCO 0.8m SBIG translations
7              
8             =head1 SYNOPSIS
9              
10             use Astro::FITS::HdrTrans::LCOSBIG_0m8;
11              
12             %gen = Astro::FITS::HdrTrans::LCOSBIG_0m8->translate_from_FITS( %hdr );
13              
14             =head1 DESCRIPTION
15              
16             This class provides a generic set of translations that are specific to
17             0.8m SBIG on Sedgwick at LCO.
18              
19             =cut
20              
21             use 5.006;
22 10     10   32396690 use warnings;
  10         31  
23 10     10   117 use strict;
  10         18  
  10         291  
24 10     10   42 use Carp;
  10         17  
  10         185  
25 10     10   46  
  10         14  
  10         679  
26             # Inherit from LCO base class.
27             use base qw/ Astro::FITS::HdrTrans::LCO /;
28 10     10   59  
  10         28  
  10         1670  
29             use vars qw/ $VERSION /;
30 10     10   54  
  10         17  
  10         7599  
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/^kb16/i;
66              
67 20     20 1 79 }
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             my $self = shift;
94             my $FITS_headers = shift;
95             my $decscale = 0.280;
96 0     0 1    
97 0           # Assumes either x-y scales the same or the y corresponds to
98 0           # declination.
99             my $ccdscale = $self->via_subheader( $FITS_headers, "PIXSCALE" );
100             if ( defined $ccdscale ) {
101             $decscale = $ccdscale;
102 0           } else {
103 0 0         my $ccdsum = $self->via_subheader( $FITS_headers, "CCDSUM" );
104 0           if ( defined $ccdsum ) {
105             my @binning = split( / /, $ccdsum );
106 0           $decscale = $decscale * $binning[1];
107 0 0         }
108 0           }
109 0           return $decscale;
110             }
111              
112 0           =item B<to_DEC_TELESCOPE_OFFSET>
113              
114             Sets the declination telescope offset in arcseconds. It uses the
115             C<CAT-DEC> and C<DEC> keywords to derive the offset, and if either
116             does not exist, it returns a default of 0.0.
117              
118             =cut
119              
120             my $self = shift;
121             my $FITS_headers = shift;
122             my $decoffset = 0.0;
123             if ( exists $FITS_headers->{"CAT-DEC"} && exists $FITS_headers->{DEC} ) {
124 0     0 1    
125 0           # Obtain the reference and telescope declinations positions measured in degrees.
126 0           my $refdec = $self->dms_to_degrees( $FITS_headers->{"CAT-DEC"} );
127 0 0 0       my $dec = $self->dms_to_degrees( $FITS_headers->{DEC} );
128              
129             # Find the offsets between the positions in arcseconds on the sky.
130 0           $decoffset = 3600.0 * ( $dec - $refdec );
131 0           }
132              
133             # The sense is reversed compared with UKIRT, as these measure the
134 0           # places on the sky, not the motion of the telescope.
135             return -1.0 * $decoffset;
136             }
137              
138             =item B<to_RA_SCALE>
139 0            
140             Sets the RA scale in arcseconds per pixel. The C<PIXSCALE>
141             is used when it's defined. Otherwise it returns a default value of 0.280
142             arcsec/pixel, multiplied by the first entry of C<CCDSUM> assuming this is
143             defined (1.0 otherwise)
144              
145             =cut
146              
147             my $self = shift;
148             my $FITS_headers = shift;
149             my $rascale = 0.280;
150              
151             # Assumes either x-y scales the same or the x corresponds to
152 0     0 1   # ra.
153 0           my $ccdscale = $self->via_subheader( $FITS_headers, "PIXSCALE" );
154 0           if ( defined $ccdscale ) {
155             $rascale = $ccdscale;
156             } else {
157             my $ccdsum = $self->via_subheader( $FITS_headers, "CCDSUM" );
158 0           if ( defined $ccdsum ) {
159 0 0         my @binning = split( / /, $ccdsum );
160 0           $rascale = $rascale * $binning[0];
161             }
162 0           }
163 0 0         return $rascale;
164 0           }
165 0            
166              
167             =item B<to_RA_TELESCOPE_OFFSET>
168 0            
169             Sets the right-ascension telescope offset in arcseconds. It uses the
170             C<CAT-RA>, C<RA>, C<CAT-DEC> keywords to derive the offset, and if any
171             of these keywords does not exist, it returns a default of 0.0.
172              
173             =cut
174              
175             my $self = shift;
176             my $FITS_headers = shift;
177             my $raoffset = 0.0;
178              
179             if ( exists $FITS_headers->{"CAT-DEC"} &&
180             exists $FITS_headers->{"CAT-RA"} && exists $FITS_headers->{RA} ) {
181 0     0 1    
182 0           # Obtain the reference and telescope sky positions measured in degrees.
183 0           my $refra = $self->hms_to_degrees( $FITS_headers->{"CAT-RA"} );
184             my $ra = $self->hms_to_degrees( $FITS_headers->{RA} );
185 0 0 0       my $refdec = $self->dms_to_degrees( $FITS_headers->{"CAT-DEC"} );
      0        
186              
187             # Find the offset between the positions in arcseconds on the sky.
188             $raoffset = 3600.0 * ( $ra - $refra ) * $self->cosdeg( $refdec );
189 0           }
190 0            
191 0           # The sense is reversed compared with UKIRT, as these measure the
192             # place son the sky, not the motion of the telescope.
193             return -1.0 * $raoffset;
194 0           }
195              
196             =item B<to_X_LOWER_BOUND>
197              
198             Returns the lower bound along the X-axis of the area of the detector
199 0           as a pixel index.
200              
201             =cut
202              
203             my $self = shift;
204             my $FITS_headers = shift;
205             my @bounds = $self->getbounds( $FITS_headers );
206             return $bounds[ 0 ];
207             }
208              
209             =item B<to_X_UPPER_BOUND>
210 0     0 1    
211 0           Returns the upper bound along the X-axis of the area of the detector
212 0           as a pixel index.
213 0            
214             =cut
215              
216             my $self = shift;
217             my $FITS_headers = shift;
218             my @bounds = $self->getbounds( $FITS_headers );
219             return $bounds[ 1 ];
220             }
221              
222             =item B<to_Y_LOWER_BOUND>
223              
224 0     0 1   Returns the lower bound along the Y-axis of the area of the detector
225 0           as a pixel index.
226 0            
227 0           =cut
228              
229             my $self = shift;
230             my $FITS_headers = shift;
231             my @bounds = $self->getbounds( $FITS_headers );
232             return $bounds[ 2 ];
233             }
234              
235              
236             =item B<to_Y_UPPER_BOUND>
237              
238 0     0 1   Returns the upper bound along the Y-axis of the area of the detector
239 0           as a pixel index.
240 0            
241 0           =cut
242              
243             my $self = shift;
244             my $FITS_headers = shift;
245             my @bounds = $self->getbounds( $FITS_headers );
246             return $bounds[ 3 ];
247             }
248              
249             # Supplementary methods for the translations
250             # ------------------------------------------
251              
252             # Obtain the detector bounds from a section in [xl:xu,yl:yu] syntax.
253 0     0 1   # If the TRIMSEC header is absent, use a default which corresponds
254 0           # to the useful part of the array (minus bias strips).
255 0           my $self = shift;
256 0           my $FITS_headers = shift;
257             my @bounds = ( 11, 1536, 6, 1022 );
258             # if ( $FITS_headers->{INSTRUME} =~ /^kb16/i ) {
259             # @bounds = ( 11, 2037, 11, 2037 );
260             # }
261             if ( exists $FITS_headers->{CCDSUM} ) {
262             my $binning = $FITS_headers->{CCDSUM};
263             if ( $binning eq '1 1' ) {
264             @bounds = ( 22, 3072, 12, 2044 );
265             }
266 0     0 0   }
267 0           if ( exists $FITS_headers->{TRIMSEC} ) {
268 0           my $section = $FITS_headers->{TRIMSEC};
269             if ( $section !~ /UNKNOWN/i ) {
270             $section =~ s/\[//;
271             $section =~ s/\]//;
272 0 0         $section =~ s/,/:/g;
273 0           my @newbounds = split( /:/, $section );
274 0 0         if (@newbounds == grep { $_ == 0 } @newbounds) {
275 0           print "ERR: TRIMSEC all 0\n";
276             } else {
277             if ( $FITS_headers->{INSTRUME} !~ /^kbXX/i ) {
278 0 0         # Unless this is kb78 data (which has a bad TRIMSEC), update bounds array
279 0           @bounds = @newbounds;
280 0 0         }
281 0           }
282 0           }
283 0           }
284 0           # print("DBG: Bounds=@bounds\n");
285 0 0         return @bounds;
  0            
286 0           }
287              
288 0 0         =back
289              
290 0           =head1 SEE ALSO
291              
292             C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::LCO>.
293              
294             =head1 AUTHOR
295              
296 0           Tim Lister E<lt>tlister@lcogt.netE<gt>
297              
298             =head1 COPYRIGHT
299              
300             =cut
301              
302             1;