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