| 1 | package Astro::FITS::HdrTrans::UKIRTNew; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Astro::FITS::HdrTrans::UKIRTNew - Base class for translation of new UKIRT instruments | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | use Astro::FITS::HdrTrans::UKIRTNew; | ||||||||||
| 10 | |||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||
| 12 | |||||||||||
| 13 | This class provides a generic set of translations that are common to | ||||||||||
| 14 | the newer generation of instruments from the United Kingdom Infrared | ||||||||||
| 15 | Telescope. This includes MICHELLE, UIST, UFTI and WFCAM. It should | ||||||||||
| 16 | not be used directly for translation of instrument FITS headers. | ||||||||||
| 17 | |||||||||||
| 18 | =cut | ||||||||||
| 19 | |||||||||||
| 20 | 16 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 16 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 16 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 16 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | # Inherit from UKIRT | ||||||||||
| 26 | 16 | ▶ | use base qw/ Astro::FITS::HdrTrans::UKIRT /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 16 | our $VERSION = "1.66"; | |||||||||
| 29 | |||||||||||
| 30 | # For a constant mapping, there is no FITS header, just a generic | ||||||||||
| 31 | # header that is constant. | ||||||||||
| 32 | 16 | my %CONST_MAP = ( | |||||||||
| 33 | |||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | # Unit mapping implies that the value propogates directly | ||||||||||
| 37 | # to the output with only a keyword name change. | ||||||||||
| 38 | 16 | my %UNIT_MAP = ( | |||||||||
| 39 | DEC_TELESCOPE_OFFSET => "TDECOFF", | ||||||||||
| 40 | DR_RECIPE => "RECIPE", | ||||||||||
| 41 | EXPOSURE_TIME => "EXP_TIME", | ||||||||||
| 42 | GAIN => "GAIN", | ||||||||||
| 43 | RA_TELESCOPE_OFFSET => "TRAOFF", | ||||||||||
| 44 | UTDATE => "UTDATE", | ||||||||||
| 45 | ); | ||||||||||
| 46 | |||||||||||
| 47 | # Create the translation methods. | ||||||||||
| 48 | 16 | __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP ); | |||||||||
| 49 | |||||||||||
| 50 | =head1 COMPLEX CONVERSIONS | ||||||||||
| 51 | |||||||||||
| 52 | These methods are more complicated than a simple mapping. We have to | ||||||||||
| 53 | provide both from- and to-FITS conversions. All these routines are | ||||||||||
| 54 | methods and the to_ routines all take a reference to a hash and return | ||||||||||
| 55 | the translated value (a many-to-one mapping). The from_ methods take | ||||||||||
| 56 | a reference to a generic hash and return a translated hash (sometimes | ||||||||||
| 57 | these are many-to-many). | ||||||||||
| 58 | |||||||||||
| 59 | =over 4 | ||||||||||
| 60 | |||||||||||
| 61 | =item B<to_INST_DHS> | ||||||||||
| 62 | |||||||||||
| 63 | Sets the instrument data-handling-system header. | ||||||||||
| 64 | |||||||||||
| 65 | =cut | ||||||||||
| 66 | |||||||||||
| 67 | 6 | ▶ | sub to_INST_DHS { | ||||||||
|
Subroutine
to_INST_DHS: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 68 | 6 | my $self = shift; | |||||||||
| 69 | 6 | my $FITS_headers = shift; | |||||||||
| 70 | 6 | my $return; | |||||||||
| 71 | |||||||||||
| 72 | 6 | ▶ | if ( exists( $FITS_headers->{DHSVER} ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 6 | $FITS_headers->{DHSVER} =~ /^(\w+)/; | |||||||||
| 74 | 6 | my $dhs = uc( $1 ); | |||||||||
| 75 | 6 | $return = $FITS_headers->{INSTRUME} . "_$dhs"; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 6 | return $return; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | =item B<to_UTSTART> | ||||||||||
| 82 | |||||||||||
| 83 | Converts UT date in C<DATE-OBS> header into C<Time::Piece> object. | ||||||||||
| 84 | |||||||||||
| 85 | =cut | ||||||||||
| 86 | |||||||||||
| 87 | 8 | ▶ | sub to_UTSTART { | ||||||||
|
Subroutine
to_UTSTART: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 88 | 8 | my $self = shift; | |||||||||
| 89 | 8 | my $FITS_headers = shift; | |||||||||
| 90 | my $dateobs = (exists $FITS_headers->{"DATE-OBS"} ? | ||||||||||
| 91 | 8 | ▶ | $FITS_headers->{"DATE-OBS"} : undef ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | my @rutstart = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "UTSTART" ); | |||||||||
| 93 | 8 | my $utstart = $rutstart[0]; | |||||||||
| 94 | 8 | return $self->_parse_date_info( $dateobs, | |||||||||
| 95 | $self->to_UTDATE( $FITS_headers ), | ||||||||||
| 96 | $utstart ); | ||||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | =item B<from_UTSTART> | ||||||||||
| 100 | |||||||||||
| 101 | Returns the starting observation time in ISO8601 format: | ||||||||||
| 102 | YYYY-MM-DDThh:mm:ss. | ||||||||||
| 103 | |||||||||||
| 104 | =cut | ||||||||||
| 105 | |||||||||||
| 106 | 5 | ▶ | sub from_UTSTART { | ||||||||
|
Subroutine
from_UTSTART: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 107 | 5 | my $self = shift; | |||||||||
| 108 | 5 | my $generic_headers = shift; | |||||||||
| 109 | |||||||||||
| 110 | # Use the FITS standard parser. | ||||||||||
| 111 | 5 | my %return_hash = Astro::FITS::HdrTrans::FITS->from_UTSTART( $generic_headers ); | |||||||||
| 112 | |||||||||||
| 113 | 5 | ▶ | if ( exists $return_hash{'DATE-OBS'} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 114 | |||||||||||
| 115 | # Prior to April 2005 the UKIRT FITS headers had a trailing Z. | ||||||||||
| 116 | # This is part of the ISO8601 standard but not part of the FITS | ||||||||||
| 117 | # standard (which always assumes UTC), although it was in the | ||||||||||
| 118 | # draft FITS agreement. | ||||||||||
| 119 | $return_hash{'DATE-OBS'} .= "Z" | ||||||||||
| 120 | 5 | ▶ | if $generic_headers->{UTSTART}->epoch < 1112662116; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 121 | } | ||||||||||
| 122 | 5 | return %return_hash; | |||||||||
| 123 | } | ||||||||||
| 124 | |||||||||||
| 125 | =item B<to_UTEND> | ||||||||||
| 126 | |||||||||||
| 127 | Converts UT date in C<DATE-END> header into C<Time::Piece> object. | ||||||||||
| 128 | |||||||||||
| 129 | =cut | ||||||||||
| 130 | |||||||||||
| 131 | 4 | ▶ | sub to_UTEND { | ||||||||
|
Subroutine
to_UTEND: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 132 | 4 | my $self = shift; | |||||||||
| 133 | 4 | my $FITS_headers = shift; | |||||||||
| 134 | my $dateend = (exists $FITS_headers->{"DATE-END"} ? | ||||||||||
| 135 | 4 | ▶ | $FITS_headers->{"DATE-END"} : undef ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 136 | |||||||||||
| 137 | 0 | my @rutend = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "UTEND" ); | |||||||||
| 138 | 4 | my $utend = $rutend[-1]; | |||||||||
| 139 | 4 | return $self->_parse_date_info( $dateend, | |||||||||
| 140 | $self->to_UTDATE( $FITS_headers ), | ||||||||||
| 141 | $utend ); | ||||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | =item B<from_UTEND> | ||||||||||
| 145 | |||||||||||
| 146 | Returns the starting observation time in ISO8601 format: | ||||||||||
| 147 | YYYY-MM-DDThh:mm:ss. | ||||||||||
| 148 | |||||||||||
| 149 | =cut | ||||||||||
| 150 | |||||||||||
| 151 | 5 | ▶ | sub from_UTEND { | ||||||||
|
Subroutine
from_UTEND: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 152 | 5 | my $self = shift; | |||||||||
| 153 | 5 | my $generic_headers = shift; | |||||||||
| 154 | |||||||||||
| 155 | # Use the FITS standard parser. | ||||||||||
| 156 | 5 | my %return_hash = Astro::FITS::HdrTrans::FITS->from_UTEND( $generic_headers); | |||||||||
| 157 | |||||||||||
| 158 | 5 | ▶ | if ( exists $return_hash{'DATE-END'} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 159 | |||||||||||
| 160 | # Prior to April 2005 the UKIRT FITS headers had a trailing Z. | ||||||||||
| 161 | # This is part of the ISO8601 standard but not part of the FITS | ||||||||||
| 162 | # standard (which always assumes UTC), although it was in the | ||||||||||
| 163 | # draft FITS agreement. | ||||||||||
| 164 | $return_hash{'DATE-END'} .= "Z" | ||||||||||
| 165 | 5 | ▶ | if $generic_headers->{UTEND}->epoch < 1112662116; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 166 | } | ||||||||||
| 167 | 5 | return %return_hash; | |||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | =back | ||||||||||
| 171 | |||||||||||
| 172 | =head1 SEE ALSO | ||||||||||
| 173 | |||||||||||
| 174 | C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT> | ||||||||||
| 175 | |||||||||||
| 176 | =head1 AUTHOR | ||||||||||
| 177 | |||||||||||
| 178 | Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>, | ||||||||||
| 179 | Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>. | ||||||||||
| 180 | Malcolm J. Currie E<lt>mjc@star.rl.ac.ukE<gt> | ||||||||||
| 181 | |||||||||||
| 182 | =head1 COPYRIGHT | ||||||||||
| 183 | |||||||||||
| 184 | Copyright (C) 2007-2008 Science and Technology Facilities Council. | ||||||||||
| 185 | Copyright (C) 2003-2007 Particle Physics and Astronomy Research Council. | ||||||||||
| 186 | All Rights Reserved. | ||||||||||
| 187 | |||||||||||
| 188 | This program is free software; you can redistribute it and/or modify it under | ||||||||||
| 189 | the terms of the GNU General Public License as published by the Free Software | ||||||||||
| 190 | Foundation; either Version 2 of the License, or (at your option) any later | ||||||||||
| 191 | version. | ||||||||||
| 192 | |||||||||||
| 193 | This program is distributed in the hope that it will be useful,but WITHOUT ANY | ||||||||||
| 194 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||||||||||
| 195 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||
| 196 | |||||||||||
| 197 | You should have received a copy of the GNU General Public License along with | ||||||||||
| 198 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||||||||||
| 199 | Place, Suite 330, Boston, MA 02111-1307, USA. | ||||||||||
| 200 | |||||||||||
| 201 | =cut | ||||||||||
| 202 | |||||||||||
| 203 | 16 | 1; | |||||||||