Astro::FITS::HdrTrans::JCMT - class combining common behaviour for mordern JCMT


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

Index


Code Index:

This routine overrides the base class implementation to enable the caches to be cleared for target location.

This means that some conversion methods (in particular those using time in a base class) may not work properly outside the context of a full translation unless they have been subclassed locally.

Date fixups are handled in a super class.

Uses the elevation, azimuth, telescope name, and observation start time headers (ELSTART, AZSTART, TELESCOP, and DATE-OBS headers, respectively) to calculate the base RA.

Returns the RA in degrees.

Uses the elevation, azimuth, telescope name, and observation start time headers (ELSTART, AZSTART, TELESCOP, and DATE-OBS headers, respectively) to calculate the base declination.

Returns the declination in degrees.

Use the average WVM tau measurements.

PRIVATE METHODS

Top

_calc_coords

Function to calculate the coordinates at the start of the observation by using the elevation, azimuth, telescope, and observation start time. Caches the result if it's already been calculated.

Returns an Astro::Coords object.

NAME

Top

Astro::FITS::HdrTrans::JCMT - class combining common behaviour for mordern JCMT instruments

SYNOPSIS

XXX To be supplied.

DESCRIPTION

Top

XXX To be supplied.

METHODS

to_UTDATE

Converts the date in a date-obs header into a number of form YYYYMMDD.

to_UTEND

Converts UT date in a date-end header into Time::Piece object

to_UTSTART

Converts UT date in a date-obs header into Time::Piece object.

SEE ALSO

Top

Astro::FITS::HdrTrans, Astro::FITS::HdrTrans::Base, Astro::FITS::HdrTrans::JAC.

AUTHORS

Top

Anubhav <a.agarwal@jach.hawawii.edu>, 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::JCMT;

use strict;
use warnings;

use Astro::Coords;
use Astro::Telescope;
use DateTime;
use DateTime::TimeZone;

use base qw/ Astro::FITS::HdrTrans::JAC /;

# Unit mapping implies that the value propogates directly
# to the output with only a keyword name change.
my %UNIT_MAP =
  (
    AIRMASS_START        => 'AMSTART',
    AZIMUTH_START        => 'AZSTART',
    ELEVATION_START      => 'ELSTART',
    FILENAME             => 'FILE_ID',
    HUMIDITY             => 'HUMSTART',
    LATITUDE             => 'LAT-OBS',
    LONGITUDE            => 'LONG-OBS',
    OBJECT               => 'OBJECT',
    OBSERVATION_NUMBER   => 'OBSNUM',
    PROJECT              => 'PROJECT',
    STANDARD             => 'STANDARD',
    X_APERTURE           => 'INSTAP_X',
    Y_APERTURE           => 'INSTAP_Y',
  );

my %CONST_MAP = ();

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

our $COORDS;

sub translate_from_FITS {
  my $class = shift;
  my $headers = shift;

  # clear cache
  $COORDS = undef;

  # Go to the base class
  return $class->SUPER::translate_from_FITS( $headers, @_ );
}

sub to_UTDATE {
  my $class = shift;
  my $FITS_headers = shift;

  $class->_fix_dates( $FITS_headers );
  return $class->SUPER::to_UTDATE( $FITS_headers, @_ );
}

sub to_UTEND {
  my $class = shift;
  my $FITS_headers = shift;

  $class->_fix_dates( $FITS_headers );
  return $class->SUPER::to_UTEND( $FITS_headers, @_ );
}

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

  $class->_fix_dates( $FITS_headers );
  return $class->SUPER::to_UTSTART( $FITS_headers, @_ );
}

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

  my $coords = $self->_calc_coords( $FITS_headers );
  return undef unless defined $coords;
  return $coords->ra( format => 'deg' );
}

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

  my $coords = $self->_calc_coords( $FITS_headers );

  return undef unless defined $coords;
  return $coords->dec( format => 'deg' );
}

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

  my $tau = 0.0;
  for my $src (qw/ TAU225 WVMTAU /) {
    my $st = $src . "ST";
    my $en = $src . "EN";

    my @startvals = $self->via_subheader_undef_check( $FITS_headers, $st );
    my @endvals   = $self->via_subheader_undef_check( $FITS_headers, $en );
    my $startval = $startvals[0];
    my $endval = $endvals[-1];

    if (defined $startval && defined $endval) {
      $tau = ($startval + $endval) / 2;
      last;
    } elsif (defined $startval) {
      $tau = $startval;
    } elsif (defined $endval) {
      $tau = $endval;
    }
  }
  return $tau;
}


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

  # Force dates to be standardized
  $self->_fix_dates( $FITS_headers );

  # Here be dragons. Possibility that cache will not be cleared properly
  # if a user comes in outside of the translate_from_FITS() method.
  if ( defined( $COORDS ) &&
       UNIVERSAL::isa( $COORDS, "Astro::Coords" ) ) {
    return $COORDS;
  }

  if ( exists( $FITS_headers->{'TELESCOP'} ) &&
       exists( $FITS_headers->{'DATE-OBS'} ) &&
       exists( $FITS_headers->{'AZSTART'} )  &&
       exists( $FITS_headers->{'ELSTART'} )  &&
       defined $FITS_headers->{AZSTART} &&
       defined $FITS_headers->{ELSTART}
     ) {

    my $dateobs   = $FITS_headers->{'DATE-OBS'};
    my $telescope = $FITS_headers->{'TELESCOP'};
    my $az_start  = $FITS_headers->{'AZSTART'};
    my $el_start  = $FITS_headers->{'ELSTART'};

    my $coords = new Astro::Coords( az => $az_start,
                                    el => $el_start,
                                  );
    $coords->telescope( new Astro::Telescope( $telescope ) );

    # convert ISO date to object
    my $dt = Astro::FITS::HdrTrans::Base->_parse_iso_date( $dateobs );
    return unless defined $dt;

    $coords->datetime( $dt );

    $COORDS = $coords;
    return $COORDS;
  }

  return undef;
}

1;