| Astro-Coords documentation | Contained in the Astro-Coords distribution. |
Astro::Coords::Planet - coordinates relating to planetary motion
$c = new Astro::Coords::Planet( 'uranus' );
This class is used by Astro::Coords for handling coordinates
for planets..
Instantiate a new object using the supplied options.
$c = new Astro::Coords::Planet( 'mars' );
Returns undef on error.
Returns the name of the planet.
For planets, the name is always just the planet name.
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.
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 overload. Simple returns the name of the planet in capitals.
Return a one line summary of the coordinates. In the future will accept arguments to control output.
$summary = $c->summary();
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).
Return the apparent RA and Dec as two Astro::Coords::Angle objects for the current
coordinates and time.
($ra_app, $dec_app) = $self->apparent();
Radial velocity of the planet relative to the Earth geocentre.
Velocity definition. Always 'RADIO'.
Velocity reference frame. Always 'GEO'.
Usually called via Astro::Coords.
Astro::SLA is used for all internal astrometric calculations.
Tim Jenness <t.jenness@cpan.org>
Copyright (C) 2001-2005 Particle Physics and Astronomy Research Council. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,Suite 330, Boston, MA 02111-1307, USA
| 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;