| 1 | package Astro::FITS::HdrTrans::UKIRTOld; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Astro::FITS::HdrTrans::UKIRTOld - Base class for translation of old UKIRT instruments | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | use Astro::FITS::HdrTrans::UKIRTOld; | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | This class provides a generic set of translations that are common to | ||||||||||||||||||||||||||||
| 14 | CGS4 and IRCAM from the United Kingdom Infrared Telescope. It should | ||||||||||||||||||||||||||||
| 15 | not be used directly for translation of instrument FITS headers. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 12 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # Inherit from UKIRT | ||||||||||||||||||||||||||||
| 25 | 12 | ▶ | use base qw/ Astro::FITS::HdrTrans::UKIRT /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 12 | our $VERSION = "1.66"; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # For a constant mapping, there is no FITS header, just a generic | ||||||||||||||||||||||||||||
| 30 | # header that is constant. | ||||||||||||||||||||||||||||
| 31 | 12 | my %CONST_MAP = ( | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Unit mapping implies that the value propogates directly | ||||||||||||||||||||||||||||
| 36 | # to the output with only a keyword name change. | ||||||||||||||||||||||||||||
| 37 | 12 | my %UNIT_MAP = ( | |||||||||||||||||||||||||||
| 38 | DETECTOR_READ_TYPE => "MODE", # Also UFTI | ||||||||||||||||||||||||||||
| 39 | DR_RECIPE => "DRRECIPE", | ||||||||||||||||||||||||||||
| 40 | EXPOSURE_TIME => "DEXPTIME", | ||||||||||||||||||||||||||||
| 41 | GAIN => "DEPERDN", | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # Create the translation methods. | ||||||||||||||||||||||||||||
| 45 | 12 | __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP ); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head1 COMPLEX CONVERSIONS | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | These methods are more complicated than a simple mapping. We have to | ||||||||||||||||||||||||||||
| 50 | provide both from- and to-FITS conversions. All these routines are | ||||||||||||||||||||||||||||
| 51 | methods and the to_ routines all take a reference to a hash and return | ||||||||||||||||||||||||||||
| 52 | the translated value (a many-to-one mapping). The from_ methods take | ||||||||||||||||||||||||||||
| 53 | a reference to a generic hash and return a translated hash (sometimes | ||||||||||||||||||||||||||||
| 54 | these are many-to-many). | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =over 4 | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =item B<to_UTDATE> | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | Converts IDATE into UTDATE without any modification. Flattens | ||||||||||||||||||||||||||||
| 61 | duplicate headers into a single header. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 36 | ▶ | sub to_UTDATE { | ||||||||||||||||||||||||||
|
Subroutine
to_UTDATE: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 36 | my $self = shift; | |||||||||||||||||||||||||||
| 67 | 36 | my $FITS_headers = shift; | |||||||||||||||||||||||||||
| 68 | 36 | my $return; | |||||||||||||||||||||||||||
| 69 | 36 | ▶ | my $utdate = ( exists $FITS_headers->{IDATE} ? $FITS_headers->{IDATE} : undef ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 36 | ▶ | if ( defined( $utdate ) && ref( $utdate ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $utdate and ref $utdate eq "ARRAY"
MC/DC0%0/2
defined $utdate and ref $utdate eq "ARRAY"
defined $utdate
ref $utdate eq "ARRAY"
Truth table33%1/3
A and B
A= defined $utdateB= ref $utdate eq "ARRAY"
| |||||||||||||||||||||||||||||
| 71 | 0 | $return = $utdate->[0]; | |||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||
| 73 | 36 | $return = $utdate; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 36 | return $return; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =item B<from_UTDATE> | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | Converts UTDATE into IDATE without any modification. | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 6 | ▶ | sub from_UTDATE { | ||||||||||||||||||||||||||
|
Subroutine
from_UTDATE: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 6 | return ( "IDATE", $_[1]->{'UTDATE'} ); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =item B<to_UTSTART> | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | Converts FITS header UT date/time values for the start of the observation | ||||||||||||||||||||||||||||
| 91 | into a C<Time::Piece> object. | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 12 | ▶ | sub to_UTSTART { | ||||||||||||||||||||||||||
|
Subroutine
to_UTSTART: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | 12 | my $FITS_headers = shift; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 12 | my $utdate = $self->to_UTDATE( $FITS_headers ); | |||||||||||||||||||||||||||
| 100 | 0 | my @rutstart = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "RUTSTART" ); | |||||||||||||||||||||||||||
| 101 | 12 | my $utdechour = $rutstart[0]; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # We do not have a DATE-OBS. | ||||||||||||||||||||||||||||
| 104 | 12 | return $self->_parse_date_info( undef, $utdate, $utdechour ); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =item B<from_UTSTART> | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | Converts a C<Time::Piece> object into two FITS headers for IRCAM: IDATE | ||||||||||||||||||||||||||||
| 110 | (in the format YYYYMMDD) and RUTSTART (decimal hours). | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 6 | ▶ | sub from_UTSTART { | ||||||||||||||||||||||||||
|
Subroutine
from_UTSTART: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | 6 | my $class = shift; | |||||||||||||||||||||||||||
| 116 | 6 | my $generic_headers = shift; | |||||||||||||||||||||||||||
| 117 | 6 | my %return_hash; | |||||||||||||||||||||||||||
| 118 | 6 | ▶ | if ( exists($generic_headers->{UTSTART} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 6 | my $date = $generic_headers->{UTSTART}; | |||||||||||||||||||||||||||
| 120 | 6 | ▶ | if ( ! UNIVERSAL::isa( $date, "Time::Piece" ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | return; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | 6 | $return_hash{IDATE} = sprintf( "%4d%02d%02d", $date->year, $date->mon, $date->mday ); | |||||||||||||||||||||||||||
| 124 | 6 | $return_hash{RUTSTART} = $date->hour + ( $date->minute / 60 ) + ( $date->second / 3600 ); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | 6 | return %return_hash; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =item B<to_UTEND> | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | Converts FITS header UT date/time values for the end of the observation into | ||||||||||||||||||||||||||||
| 132 | a C<Time::Piece> object. | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =cut | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 6 | ▶ | sub to_UTEND { | ||||||||||||||||||||||||||
|
Subroutine
to_UTEND: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | 6 | my $FITS_headers = shift; | |||||||||||||||||||||||||||
| 139 | 6 | my $return; | |||||||||||||||||||||||||||
| 140 | 6 | my $utdate = $self->to_UTDATE( $FITS_headers ); | |||||||||||||||||||||||||||
| 141 | 0 | my @rutend = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "RUTEND" ); | |||||||||||||||||||||||||||
| 142 | 6 | my $utdechour = $rutend[-1]; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | # We do not have a DATE-END. | ||||||||||||||||||||||||||||
| 145 | 6 | return $self->_parse_date_info( undef, $utdate, $utdechour ); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =item B<from_UTEND> | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | Converts a C<Time::Piece> object into two FITS headers for IRCAM: IDATE | ||||||||||||||||||||||||||||
| 151 | (in the format YYYYMMDD) and RUTEND (decimal hours). | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =cut | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 6 | ▶ | sub from_UTEND { | ||||||||||||||||||||||||||
|
Subroutine
from_UTEND: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 156 | 6 | my $class = shift; | |||||||||||||||||||||||||||
| 157 | 6 | my $generic_headers = shift; | |||||||||||||||||||||||||||
| 158 | 6 | my %return_hash; | |||||||||||||||||||||||||||
| 159 | 6 | ▶ | if ( exists($generic_headers->{UTEND} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 6 | my $date = $generic_headers->{UTEND}; | |||||||||||||||||||||||||||
| 161 | 6 | ▶ | if ( ! UNIVERSAL::isa( $date, "Time::Piece" ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | return; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 6 | $return_hash{IDATE} = sprintf( "%4d%02d%02d", $date->year, $date->mon, $date->mday ); | |||||||||||||||||||||||||||
| 165 | 6 | $return_hash{RUTEND} = $date->hour + ( $date->minute / 60 ) + ( $date->second / 3600 ); | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | 6 | return %return_hash; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =item B<to_INST_DHS> | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | Sets the instrument data handling system header. Note that for old | ||||||||||||||||||||||||||||
| 173 | instruments there is no DHSVER header so this simply returns | ||||||||||||||||||||||||||||
| 174 | the name of the instrument and a UKDHS suffix. | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =cut | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 6 | ▶ | sub to_INST_DHS { | ||||||||||||||||||||||||||
|
Subroutine
to_INST_DHS: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 179 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 180 | 6 | my $FITS_headers = shift; | |||||||||||||||||||||||||||
| 181 | 6 | my $inst = $self->to_INSTRUMENT( $FITS_headers ); | |||||||||||||||||||||||||||
| 182 | 6 | return $inst . '_UKDHS'; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =back | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | C<Astro::FITS::HdrTrans>, C<Astro::FITS::HdrTrans::UKIRT> | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>, | ||||||||||||||||||||||||||||
| 194 | Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>. | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | Copyright (C) 2007-2008 Science and Technology Facilities Council. | ||||||||||||||||||||||||||||
| 199 | Copyright (C) 2003-2007 Particle Physics and Astronomy Research Council. | ||||||||||||||||||||||||||||
| 200 | All Rights Reserved. | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | This program is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 203 | the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||
| 204 | Foundation; either Version 2 of the License, or (at your option) any later | ||||||||||||||||||||||||||||
| 205 | version. | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | This program is distributed in the hope that it will be useful,but WITHOUT ANY | ||||||||||||||||||||||||||||
| 208 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||||||||||||||||||||||||||||
| 209 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||
| 212 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||||||||||||||||||||||||||||
| 213 | Place, Suite 330, Boston, MA 02111-1307, USA. | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =cut | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 12 | 1; | |||||||||||||||||||||||||||