NAME

Astro::Montenbruck::RiseSet::RST — rise, set, transit.

SYNOPSIS

use Astro::Montenbruck::MathUtils qw/frac/;
use Astro::Montenbruck::RiseSet::Constants qw/:events :altitudes/;
use Astro::Montenbruck::RiseSet::RST qw/rst_function/;

# create function for calculating Moon events for Munich, Germany, on March 23, 1989.
my $func = rst_function(
    date     => [1989, 3, 23],
    phi    => 48.1,
    lambda => -11.6,
    get_position => sub {
        my $jd = shift;
        # return equatorial coordinates of the celestial body for the Julian Day.
    }
);

# calculate rise. Alternatively, use $EVT_SET for set, $EVT_TRANSIT for
# transit as the first argument
$func->(
    $EVT_RISE,
    on_event  => sub {
        my $jd = shift; # Standard Julian date of the event
        my $ut = frac(jd - 0.5) * 24; # UTC, 18.95 = 18h57m
    },
    on_noevent => sub {
        my $state = shift;
        say "The body is $state"
    }
});

VERSION

Version 0.01

DESCRIPTION

Low-level routines for calculating rise, set and transit times of celestial bodies. The calculations are based on "Astronomical Algorythms" by Jean Meeus. The same subject is discussed in Montenbruck & Phleger's book, but Meeus's method is more general and consistent and generic. Unit tests use examples from the both sources.

The general problem here is to find the instant of time at which a celestial body reaches a predetermined altitude.

FUNCTIONS

rst_function( %args )

Returns function for calculating time of event. See "EVENT FUNCTION" below.

Named Arguments

  • date — array of year (astronomical, zero-based), month [1..12], and day, [1..31].

  • phi — geographical latitude, degrees, positive northward

  • lambda — geographical longitude, degrees, positive westward

  • get_position — function, which given Standard Julian Day, returns equatorial coordinates of the celestial body, in radians.

  • h — the standard altitude, i.e. the geometric altitude of the center of the body at the time of apparent rising or setting, degrees.

EVENT FUNCTION

The event function, returned by "rst_function( %args )", calculates time of a given event (rise, set or trasnsit).

$func->( EVENT_TYPE, on_event => sub{ ... }, on_noevent => sub{ ... } );

Its first argument, event type, is one of $EVT_RISE, $EVT_SET, or $EVT_TRANSIT, see "EVENTS" in Astro::Montenbruck::RiseSet::Constants.

Named arguments are callback functions:

  • on_event is called when the event time is determined. The argument is Standard Julian day of the event.

    on_event => sub { my $jd = shift; ... }
  • on_noevent is called when the event does not happen at the given date, either because the body never rises, or is circumpolar. The argument is respectively $STATE_NEVER_RISES or $STATE_CIRCUMPOLAR, see "STATES" in Astro::Montenbruck::RiseSet::Constants.

    on_noevent => sub { my $state = shift; ... }

AUTHOR

Sergey Krushinsky, <krushi at cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2010-2019 by Sergey Krushinsky

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.