File Coverage

blib/lib/Astro/FITS/HdrTrans/LCOSINISTRO_1m0.pm
Criterion Covered Total %
statement 18 91 19.7
branch 0 24 0.0
condition 0 18 0.0
subroutine 7 16 43.7
pod 9 10 90.0
total 34 159 21.3


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