Astro::FITS::HdrTrans::UKIRTOld - Base class for translation of old UKIRT instruments


Astro-FITS-HdrTrans documentation Contained in the Astro-FITS-HdrTrans distribution.

Index


Code Index:

NAME

Top

Astro::FITS::HdrTrans::UKIRTOld - Base class for translation of old UKIRT instruments

SYNOPSIS

Top

  use Astro::FITS::HdrTrans::UKIRTOld;

DESCRIPTION

Top

This class provides a generic set of translations that are common to CGS4 and IRCAM from the United Kingdom Infrared Telescope. It should not be used directly for translation of instrument FITS headers.

COMPLEX CONVERSIONS

Top

These methods are more complicated than a simple mapping. We have to provide both from- and to-FITS conversions. All these routines are methods and the to_ routines all take a reference to a hash and return the translated value (a many-to-one mapping). The from_ methods take a reference to a generic hash and return a translated hash (sometimes these are many-to-many).

to_UTDATE

Converts IDATE into UTDATE without any modification. Flattens duplicate headers into a single header.

from_UTDATE

Converts UTDATE into IDATE without any modification.

to_UTSTART

Converts FITS header UT date/time values for the start of the observation into a Time::Piece object.

from_UTSTART

Converts a Time::Piece object into two FITS headers for IRCAM: IDATE (in the format YYYYMMDD) and RUTSTART (decimal hours).

to_UTEND

Converts FITS header UT date/time values for the end of the observation into a Time::Piece object.

from_UTEND

Converts a Time::Piece object into two FITS headers for IRCAM: IDATE (in the format YYYYMMDD) and RUTEND (decimal hours).

to_INST_DHS

Sets the instrument data handling system header. Note that for old instruments there is no DHSVER header so this simply returns the name of the instrument and a UKDHS suffix.

REVISION

Top

 $Id$

SEE ALSO

Top

Astro::FITS::HdrTrans, Astro::FITS::HdrTrans::UKIRT

AUTHOR

Top

Brad Cavanagh <b.cavanagh@jach.hawaii.edu>, Tim Jenness <t.jenness@jach.hawaii.edu>.

COPYRIGHT

Top


Astro-FITS-HdrTrans documentation Contained in the Astro-FITS-HdrTrans distribution.
package Astro::FITS::HdrTrans::UKIRTOld;

use 5.006;
use warnings;
use strict;
use Carp;

# Inherit from UKIRT
use base qw/ Astro::FITS::HdrTrans::UKIRT /;

use vars qw/ $VERSION /;

$VERSION = "1.50";

# For a constant mapping, there is no FITS header, just a generic
# header that is constant.
my %CONST_MAP = (

                );

# Unit mapping implies that the value propogates directly
# to the output with only a keyword name change.
my %UNIT_MAP = (
                DETECTOR_READ_TYPE   => "MODE", # Also UFTI
                DR_RECIPE            => "DRRECIPE",
                EXPOSURE_TIME        => "DEXPTIME",
                GAIN                 => "DEPERDN",
               );

# Create the translation methods.
__PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP );

sub to_UTDATE {
  my $self = shift;
  my $FITS_headers = shift;
  my $return;
  my $utdate = ( exists $FITS_headers->{IDATE} ? $FITS_headers->{IDATE} : undef );
  if ( defined( $utdate ) && ref( $utdate ) eq 'ARRAY' ) {
    $return = $utdate->[0];
  } else {
    $return = $utdate;
  }
  return $return;
}

sub from_UTDATE {
  return ( "IDATE", $_[1]->{'UTDATE'} );
}

sub to_UTSTART {
  my $self = shift;
  my $FITS_headers = shift;

  my $utdate = $self->to_UTDATE( $FITS_headers );
  my @rutstart = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "RUTSTART" );
  my $utdechour = $rutstart[0];

  # We do not have a DATE-OBS.
  return $self->_parse_date_info( undef, $utdate, $utdechour );
}

sub from_UTSTART {
  my $class = shift;
  my $generic_headers = shift;
  my %return_hash;
  if ( exists($generic_headers->{UTSTART} ) ) {
    my $date = $generic_headers->{UTSTART};
    if ( ! UNIVERSAL::isa( $date, "Time::Piece" ) ) {
      return;
    }
    $return_hash{IDATE} = sprintf( "%4d%02d%02d", $date->year, $date->mon, $date->mday );
    $return_hash{RUTSTART} = $date->hour + ( $date->minute / 60 ) + ( $date->second / 3600 );
  }
  return %return_hash;
}

sub to_UTEND {
  my $self = shift;
  my $FITS_headers = shift;
  my $return;
  my $utdate = $self->to_UTDATE( $FITS_headers );
  my @rutend = sort {$a<=>$b} $self->via_subheader( $FITS_headers, "RUTEND" );
  my $utdechour = $rutend[-1];

  # We do not have a DATE-END.
  return $self->_parse_date_info( undef, $utdate, $utdechour );
}

sub from_UTEND {
  my $class = shift;
  my $generic_headers = shift;
  my %return_hash;
  if ( exists($generic_headers->{UTEND} ) ) {
    my $date = $generic_headers->{UTEND};
    if ( ! UNIVERSAL::isa( $date, "Time::Piece" ) ) {
      return;
    }
    $return_hash{IDATE} = sprintf( "%4d%02d%02d", $date->year, $date->mon, $date->mday );
    $return_hash{RUTEND} = $date->hour + ( $date->minute / 60 ) + ( $date->second / 3600 );
  }
  return %return_hash;
}

sub to_INST_DHS {
  my $self = shift;
  my $FITS_headers = shift;
  my $inst = $self->to_INSTRUMENT( $FITS_headers );
  return $inst . '_UKDHS';
}

1;