PrePAN

Sign in to PrePAN

Astro::Montenbruck Library of astronomical calculations, based on "Astronomy On The Personal Computer" by O.Montenbruck and T.Phleger

Good

Synopsis

use Astro::Montenbruck::Ephemeris::Planet qw/@PLANETS/;
use Astro::Montenbruck::Ephemeris qw/find_positions/;

my $jd = 2458630.5; # Standard Julian date for May 27, 2019, 00:00 UTC.
my $t  = ($jd - 2451545) / 36525; # Convert Julian date to centuries since epoch 2000.0

# Calculate apparent geocentric ecliptic coordinates  of the Sun, the Moon, and the 8 planets
find_positions($t, \@PLANETS, sub {
    my ($id, %pos) = @_;
    print "$id X: $pos{x}, Y: $pos{y}, Z: $pos{z}\n";
});

# object, longitude, latitude, distance from Earth
# Moon X: 338.817869258643, Y: -3.97888700952293, Z: 0.00270053644038518
# Sun X: 65.4558939369393, Y: -0.000155185099535724, Z: 1.01310398748619
# Mercury X: 72.1106054350995, Y: 1.20735643288534, Z: 1.29184580348904
...

# The coordinates are referred to the true equinox of date and contain corrections
# for precession, nutation, aberration and light-time.

Description

This was formerly posted as "AstroScript". Following the recommendations of djerius@github, I separated the astronomical code into an independent library, named after one of the authors of algorithms, Oliver Montenbruck, and placed it into Astro:: namespace.

The main purpose is to calculate positions of the Sun, the Moon, and the planets with precision that is approximately the same as that found in astronomical yearbooks. Other modules contain time-related routines, coordinates conversions, calculation of the ecliptic obliquity and nutation, etc. Over time, the range of utility functions will grow.

Partially it overlaps some code which already exists in CPAN and elsewhere. For instance, there is a Perl wrapper for Swiss Ephemeris. Swiss Ephemeris is fast and precise C library. Unfortunately, it lacks portability and convenient license.

The present library is an attempt to find a middle-ground between precision on the one hand and compact, well organized code on the other. I tried to follow the best practices of modern Perl programming.

Comments

This is really cool. I'd like to use it!

Please sign up to post a review.