Astro-Montenbruck

 view release on metacpan or  search on metacpan

lib/Astro/Montenbruck/Time/DeltaT.pm  view on Meta::CPAN

    1920 => 21.1,
    1922 => 22.4,
    1924 => 23.5,
    1926 => 23.8,
    1928 => 24.3,
    1930 => 24.0,
    1932 => 23.9,
    1934 => 23.9,
    1936 => 23.7,
    1938 => 24.0,
    1940 => 24.3,
    1942 => 25.3,
    1944 => 26.2,
    1946 => 27.3,
    1948 => 28.2,
    1950 => 29.1,
    1952 => 30.0,
    1954 => 30.7,
    1956 => 31.4,
    1958 => 32.2,
    1960 => 33.1,
    1962 => 34.0,
    1964 => 35.0,
    1966 => 36.5,
    1968 => 38.3,
    1970 => 40.2,
    1972 => 42.2,
    1974 => 44.5,
    1976 => 46.5,
    1978 => 48.5,
    1980 => 50.5,
    1982 => 52.2,
    1984 => 53.8,
    1986 => 54.9,
    1988 => 55.8,
    1990 => 56.9,
    1992 => 58.3,
    1994 => 60.0,
    1996 => 61.6,
    1998 => 63.0,

    # From http://www.staff.science.uu.nl/~gent0113/deltat/deltat_modern.htm
    2000 => 63.8,
    2002 => 63.3,
    2004 => 64.6,
    2006 => 64.9,
    2008 => 65.5,
    2010 => 66.1,
    2012 => 68.0,
    2014 => 69.0,
    2016 => 70.0
);

Readonly our $TAB_SINCE => 1620;
Readonly our $TAB_UNTIL => 2016;

sub _interpolate {
    my ( $jd, $ye ) = @_;

    # For a historical range from 1620 to a recent year, we interpolate from a
    # table of observed values. Outside that range we use formulae.

    # Last value in the table
    if ( $ye == $TAB_UNTIL ) {
        return $HISTORICAL{$TAB_UNTIL};
    }

    # 1620 - 20xx
    my $y0 =
      $ye % 2 == 0 ? $ye : $ye - 1;   # there are only even numbers in the table
    my $y1 = $y0 + 2;
    my $d0 = $HISTORICAL{$y0};
    my $d1 = $HISTORICAL{$y1};
    my $j0 = cal2jd( $y0, 1, 1 );
    my $j1 = cal2jd( $y1, 1, 1 );

    # simple linear interpolation between two values
    ( ( $jd - $j0 ) * ( $d1 - $d0 ) / ( $j1 - $j0 ) ) + $d0;
}

sub delta_t {
    my $jd = shift;

    my ($ye) = jd2cal($jd);

    return _interpolate($jd, $ye) if $ye >= $TAB_SINCE && $ye <= $TAB_UNTIL;
    my $t = ($ye - 2000) / 100.0;
    return polynome( $t, 2177.0, 497.0, 44.1 ) if $ye < 948;

    my $dt = polynome( $t, 102.0, 102.0, 25.3 );
    $dt += 0.37 * ( $ye - 2100 ) if $ye > $TAB_UNTIL && $ye < 2100;
    $dt
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Astro::Montenbruck::Time::DeltaT - difference between I<UT> and I<TDT>.

=head1 VERSION

Version 0.01


=head1 DESCRIPTION

B<Delta-T> indicates the difference between I<UT> and I<TDT>
(I<Terrestrial Dynamic Time>), which used to be called I<Ephemeris time> in the
last century. While I<UT> is not a uniform time scale (it is occasionally
adjusted, due to irregularities in the Earth's rotation), I<TDT> is a uniform
time scale which is needed as an argument for mathematical theories of celestial
movements.

Formulae used by L</delta_t( $jd )> subroutine, are based on NASA Technical
Publication I<"Five Millennium Canon of Solar Eclipses: -1999 to +3000">.
They are valid for any time during the interval 2000 B.C. to 3000 A.D. See
L<NASA Eclipse web site|http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html">.

=head1 EXPORT

=over

=item * L</delta_t( $jd )>

=back

=head1 SUBROUTINES

=head2 delta_t( $jd )

Returns approximate Delta-T in seconds for a given Julian Day.
C<Delta-T = ET - UT>

For a historical range from 1620 to recent years, we interpolate from a
table of observed values. Outside that range we use formulae from
I<Astronomical Algorithms> by I<J.Meeus>, second edition.

=head3 Arguments

=over

=item * B<$jd> — Standard Julian Date.

=back

=head3 Returns

Delta-T in seconds

=cut



( run in 2.449 seconds using v1.01-cache-2.11-cpan-302cb4679cc )