File Coverage

blib/lib/Astro/FITS/HdrTrans/LCOMEROPE.pm
Criterion Covered Total %
statement 15 88 17.0
branch 0 24 0.0
condition 0 9 0.0
subroutine 6 15 40.0
pod 9 10 90.0
total 30 146 20.5


line stmt bran cond sub pod time code
1             # -*-perl-*-
2              
3             package Astro::FITS::HdrTrans::LCOMEROPE;
4              
5             =head1 NAME
6              
7             Astro::FITS::HdrTrans::LCOMEROPE - LCO 2.0m Merope translations
8              
9             =head1 SYNOPSIS
10              
11             use Astro::FITS::HdrTrans::LCOMEROPE;
12              
13             %gen = Astro::FITS::HdrTrans::LCOMEROPE->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 Meropes at LCO.
19              
20             =cut
21              
22 10     10   27072944 use 5.006;
  10         67  
23 10     10   78 use warnings;
  10         33  
  10         773  
24 10     10   100 use strict;
  10         34  
  10         381  
25 10     10   70 use Carp;
  10         30  
  10         1210  
26              
27             # Inherit from LCO base class.
28 10     10   71 use base qw/ Astro::FITS::HdrTrans::LCO /;
  10         39  
  10         14260  
29              
30             our $VERSION = "1.66";
31              
32             # for a constant mapping, there is no FITS header, just a generic
33             # header that is constant
34             my %CONST_MAP = (
35             );
36              
37             # NULL mappings used to override base-class implementations.
38             my @NULL_MAP = qw/ /;
39              
40             my %UNIT_MAP = (
41             );
42              
43              
44             # Create the translation methods
45             __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             sub this_instrument {
63 20     20 1 114 return qr/^em0/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.1390
86             arcsec/pixel, multiplied by C<YBINNING> assuming this is defined
87              
88             =cut
89              
90             sub to_DEC_SCALE {
91 0     0 1   my $self = shift;
92 0           my $FITS_headers = shift;
93 0           my $decscale = 0.1390;
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 0         if ( defined $ccdscale ) {
99 0           $decscale = $ccdscale;
100             } else {
101 0           my $ybinning = $self->via_subheader( $FITS_headers, "YBINNING" );
102 0 0         if ( defined $ybinning ) {
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             sub to_DEC_TELESCOPE_OFFSET {
118 0     0 1   my $self = shift;
119 0           my $FITS_headers = shift;
120 0           my $decoffset = 0.0;
121 0 0 0       if ( exists $FITS_headers->{"CAT-DEC"} && exists $FITS_headers->{DEC} ) {
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.1390
140             arcsec/pixel, multiplied by C<XBINNING> assuming this is defined (1.0 otherwise)
141              
142             =cut
143              
144             sub to_RA_SCALE {
145 0     0 1   my $self = shift;
146 0           my $FITS_headers = shift;
147 0           my $rascale = 0.1390;
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 0         if ( defined $ccdscale ) {
153 0           $rascale = $ccdscale;
154             } else {
155 0           my $xbinning = $self->via_subheader( $FITS_headers, "XBINNING" );
156 0 0         if ( defined $xbinning ) {
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             sub to_RA_TELESCOPE_OFFSET {
173 0     0 1   my $self = shift;
174 0           my $FITS_headers = shift;
175 0           my $raoffset = 0.0;
176              
177 0 0 0       if ( exists $FITS_headers->{"CAT-DEC"} &&
      0        
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             sub to_X_LOWER_BOUND {
202 0     0 1   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             sub to_X_UPPER_BOUND {
216 0     0 1   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             sub to_Y_LOWER_BOUND {
230 0     0 1   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             sub to_Y_UPPER_BOUND {
245 0     0 1   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             sub getbounds{
258 0     0 0   my $self = shift;
259 0           my $FITS_headers = shift;
260 0           my @bounds = ( 1, 1024, 1, 1024 );
261             # if ( $FITS_headers->{INSTRUME} =~ /^em0X/i ) {
262             # @bounds = ( 11, 2037, 11, 2037 );
263             # }
264 0 0         if ( exists $FITS_headers->{CCDSUM} ) {
265 0           my $binning = $FITS_headers->{CCDSUM};
266 0 0         if ( $binning eq '1 1' ) {
267 0           @bounds = ( 1, 2048, 1, 2048 );
268             # if ( $FITS_headers->{INSTRUME} =~ /^em0X/i ) {
269             # @bounds = ( 1, 2048, 1, 2048 );
270             # }
271             }
272             }
273 0 0         if ( exists $FITS_headers->{TRIMSEC} ) {
274 0           my $section = $FITS_headers->{TRIMSEC};
275 0 0         if ( $section !~ /UNKNOWN/i ) {
276 0           $section =~ s/\[//;
277 0           $section =~ s/\]//;
278 0           $section =~ s/,/:/g;
279 0           my @newbounds = split( /:/, $section );
280 0 0         if (@newbounds == grep { $_ == 0 } @newbounds) {
  0            
281 0           print "ERR: TRIMSEC all 0\n";
282             } else {
283 0 0         if ( $FITS_headers->{INSTRUME} !~ /^em0X/i ) {
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             1;