Astro::Coords::Planet - coordinates relating to planetary motion


Astro-Coords documentation Contained in the Astro-Coords distribution.

Index


Code Index:

NAME

Top

Astro::Coords::Planet - coordinates relating to planetary motion

SYNOPSIS

Top

  $c = new Astro::Coords::Planet( 'uranus' );

DESCRIPTION

Top

This class is used by Astro::Coords for handling coordinates for planets..

METHODS

Top

Constructor

new

Instantiate a new object using the supplied options.

  $c = new Astro::Coords::Planet( 'mars' );

Returns undef on error.

Accessor Methods

planet

Returns the name of the planet.

name

For planets, the name is always just the planet name.

General Methods

Top

array

Return back 11 element array with first element containing the planet name.

This method returns a standardised set of elements across all types of coordinates.

type

Returns the generic type associated with the coordinate system. For this class the answer is always "RADEC".

This is used to aid construction of summary tables when using mixed coordinates.

It could be done using isa relationships.

stringify

Stringify overload. Simple returns the name of the planet in capitals.

summary

Return a one line summary of the coordinates. In the future will accept arguments to control output.

  $summary = $c->summary();

diam

Returns the apparent angular planet diameter from the most recent calculation of the apparent RA/Dec.

 $diam = $c->diam();

Returns the answer as a Astro::Coords::Angle object. Note that this number is not updated automatically. (so don't change the time and expect to get the correct answer without first asking for a ra/dec calculation).

apparent

Return the apparent RA and Dec as two Astro::Coords::Angle objects for the current coordinates and time.

 ($ra_app, $dec_app) = $self->apparent();

rv

Radial velocity of the planet relative to the Earth geocentre.

vdefn

Velocity definition. Always 'RADIO'.

vframe

Velocity reference frame. Always 'GEO'.

NOTES

Top

Usually called via Astro::Coords.

REQUIREMENTS

Top

Astro::SLA is used for all internal astrometric calculations.

AUTHOR

Top

Tim Jenness <t.jenness@cpan.org>

COPYRIGHT

Top


Astro-Coords documentation Contained in the Astro-Coords distribution.
package Astro::Coords::Planet;


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

our $VERSION = '0.03';

use Astro::SLA ();
use Astro::Coords::Angle;
use base qw/ Astro::Coords /;

use overload '""' => "stringify";

our @PLANETS = qw/ sun mercury venus moon mars jupiter saturn
  uranus neptune pluto /;

# invert the planet for lookup
my $i = 0;
our %PLANET = map { $_, $i++  } @PLANETS;

sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;

  my $planet = lc(shift);

  return undef unless defined $planet;

  # Check that we have a valid planet
  return undef unless exists $PLANET{$planet};

  bless { planet => $planet,
	  diameter => undef,
	}, $class;

}



sub planet {
  my $self = shift;
  return $self->{planet};
}

sub name {
  my $self = shift;
  return $self->planet;
}

sub array {
  my $self = shift;
  return ($self->planet, undef, undef,
	  undef, undef, undef, undef, undef, undef, undef, undef);
}

sub type {
  return "PLANET";
}

sub stringify {
  my $self = shift;
  return uc($self->planet());
}

sub summary {
  my $self = shift;
  my $name = $self->name;
  $name = '' unless defined $name;
  return sprintf("%-16s  %-12s  %-13s PLANET",$name,'','');
}

sub diam {
  my $self = shift;
  if (@_) {
    my $d = shift;
    $self->{diam} = new Astro::Coords::Angle( $d, units => 'rad' );
  }
  return $self->{diam};
}

sub apparent {
  my $self = shift;

  my ($ra_app, $dec_app) = $self->_cache_read( "RA_APP", "DEC_APP" );

  # Need to calculate it
  if (!defined $ra_app || !defined $dec_app) {

    my $tel = $self->telescope;
    my $long = (defined $tel ? $tel->long : 0.0 );
    my $lat = (defined $tel ? $tel->lat : 0.0 );

    Astro::SLA::slaRdplan($self->_mjd_tt, $PLANET{$self->planet},
			  $long, $lat, $ra_app, $dec_app, my $diam);

    # Store the diameter
    $self->diam( $diam );

    # Convert to angle objects
    $ra_app = new Astro::Coords::Angle::Hour($ra_app, units => 'rad', range => '2PI');
    $dec_app = new Astro::Coords::Angle($dec_app, units => 'rad');

    # store in cache
    $self->_cache_write( "RA_APP" => $ra_app, "DEC_APP" => $dec_app );
  }

  return ($ra_app, $dec_app);
}

sub rv {
  croak "Not yet implemented planetary radial velocities";
}

sub vdefn {
  return 'RADIO';
}

sub vframe {
  return 'GEO';
}

sub _default_horizon {
  my $self = shift;
  my $name = lc($self->name);

  if ($name eq 'sun') {
    return &Astro::Coords::SUN_RISE_SET;
  } elsif ($name eq 'moon') {
    return (-0.8 * Astro::SLA::DD2R);
    # See http://aa.usno.navy.mil/faq/docs/RST_defs.html
    my $refterm = 0.5666 * Astro::SLA::DD2R; # atmospheric refraction

    # Get the moon radius
    $self->_apparent();
    my $radius = $self->diam() / 2;

    # parallax - assume 57 arcminutes for now
    my $parallax = (57 * 60) * Astro::SLA::DAS2R;

    print "Refraction: $refterm  Radius: $radius  Parallax: $parallax\n";

    return ( -1 * ( $refterm + $radius - $parallax ) );
  } else {
    return 0;
  }
}

1;