 zef:tbrowder

# NAME

Astro::Utils - Provides utility functions for astronomical calculations

# SYNOPSIS

```use Astro::Utils :ALL;
my \$x = 1.234;
my \$y = 5.5678;
say Frac \$x;       # OUTPUT: «0.234␤»
say Modulo \$x, \$y; # OUTPUT: «1.234␤»
say Modulo \$y, \$x; # OUTPUT: «0.6318␤»
```

# DESCRIPTION

Raku module Astro::Utils is a collection of utility functions from several popular astronomy-related books by authors such as Montenbruck, Meeus, and Lawrence. Also included are functions from Perl module Astro::Montenbruck.

## Exported functions

### Frac

```sub Frac(\$x --> Real) is export(:Frac) {...}
```

Returns the fractional part of a number (from Ref. 1, p. 8). (Note it is the same as the `frac` function from Raku module `Math::FractionalPart`.)

### Modulo

```sub Modulo(\$x, \$y) is export(:Modulo) {...}
```

Returns \$x mod \$y (from Ref. 1, p. 8). (Note it is the same as the Raku infix operator `%`.)

### delta-T

```sub delta-T(\$year, \$month --> Real) is export(:delta-T) {...}
```

Returns the `delta-T` value for the given year and month.

The orbital positions of the Sun and Moon required by eclipse predictions, are calculated using Terrestrial Dynamical Time (TD) because it is a uniform time scale. However, world time zones and daily life are based on Universal Time (UT). In order to convert eclipse predictions from TD to UT, the difference between these two time scales must be known. The parameter delta-T (ΔT) is the arithmetic difference, in seconds, between the two as:

```ΔT = TD - UT
```

### delta-T2

```sub delta-T2(DateTime \$T --> Real) is export(:delta-T2) {...}
```

Also returns ΔT (see routine `delta-T`), but using code based on the `delta_t` function from Ref. 3, file '../Time/DeltaT.pm'.

### dayfrac2hms

```sub dayfrac2hms(\$dayfraction is copy --> List) is export(:dayfrac2hms) {...}
```

Returns the `\$dayfraction` as a list of `hours` (Int), `minutes` (Int), and `minutes` (Real) (from Ref. 2).

`\$dayfraction` must be a fraction of a day of 24 hours. The input's integral portion, if any, is ignored.

### polynome

```sub polynome(\$t, @terms) is export(:polynome) {...}
```

Calculates the polynomial `a0*t**0 + a1*t**1 + a2*t**2 + a3*t**3...` using code based on the `polynome` function from Ref. 3, file '../Montenbruck/MathUtils.pm'.

Parameters: `\$t` is the coefficient (in astronomical routines it's usually time in centuries) and `@terms` is a list of any number of decimal values.

## References

1. Astronomy on the Personal Computer, 4th Edition, Oliver Montenbruck and Thomas Pfleger, 2000, Springer-Verlag.

2. Celestial Calculations, J. L. Lawrence.

3. Perl module Astro::Montenbruck.

# AUTHOR

Tom Browder (tbrowder@cpan.org)