NAME

Astro::MoonPhase::Simple - Calculate the phase of the Moon on a given time without too much blah blah

VERSION

Version 0.01

SYNOPSIS

This package provides a single subroutine to calculate the phase of the moon on a given time. The results are returned as a hash.

The heavy lifting is done by Astro::MoonPhase. All this package does is to wrap the functionality of Astro::MoonPhase adding some parameter checking.

use Astro::MoonPhase::Simple;

my $res = calculate_moon_phase({
  'date' => '1974-07-14',
  'timezone' => 'Asia/Nicosia',
});
print "moon is ".$res->{'MoonPhase%'}."% full\n";
print "moon is illuminated by ".$res->{'MoonIllum%'}."%\n";

print $res->{'asString'};

# alternatively provide a location instead of a timezone
# to deduce the timezone
my $res = calculate_moon_phase({
  'date' => '1974-07-14',
  'time' => '04:00',
  'location' => {lat=>49.180000, lon=>-0.370000}
});

...

EXPORT

  • calculate_moon_phase()

SUBROUTINES

calculate_moon_phase

This is the main and only subroutine which is exported by default. It expects a HASH reference as its input parameter containing date, in the form "YYYY-MM-DD", and optionally time, in the form "hh:mm:ss". The timezone the date is pertaining to can be specified using key "timezone", in the form of a TZ identifier, e.g. "Africa/Abidjan". Alternatively, specify the location, as a HASHref of {lon, lat}, the moon is observed from and this will deduce the timezone, albeit not always as accurately as with specifying a "timezone" explicitly.

On failure it returns undef. On success it returns a HASHref with keys:

  • MoonPhase : the moon phase (terminator phase angle) as a number between 0 and 1. New Moon (dark) being 0 and Full Moon (bright) being 1.

  • MoonPhase% : the above as a percentage.

  • MoonIllum : the illuminated fraction of the moon's disc as a number between 0 and 1. New Moon (dark) being 0 and Full Moon (bright) being 1.

  • MoonIllum% : the above as a percentage.

  • MoonAge : the fractional number of days since the Moon's birth (new moon), at specified date.

  • MoonDist : the distance of the Moon from the centre of the Earth (kilometers).

  • MoonAng : the angular diameter subtended by the Moon as seen by an observer at the centre of the Earth

  • SunDist : Moon's distance from the Sun (kilometers).

  • SunAng : the angular size of Sun (degrees).

  • phases : a HASHref containing the date and time for the various Moon phases (at specified date). It contains keys New Moon, First quarter, Full moon, Last quarter, Next New Moon

  • asString : a string representation of the above.

SCRIPT

The script moon-phase-calculator.pl is provided for doing the calculations via the command line.

Example usage: moon-phase-calculator.pl --date 1974-07-14 --timezone 'Asia/Nicosia'

SEE ALSO

This package summarises https://perlmonks.org/?node_id=11137299 over at PerlMonks.org

There are some more goodies in that post e.g. PerlMonk Aldebaran does the same for planets.

I can't iterate enough that this module wraps the functionality of Astro::MoonPhase. Astro::MoonPhase does all the heavy lifting.

AUTHOR

Andreas Hadjiprocopis, <bliako at cpan.org>

DEDICATIONS

Marathon Almaz

BUGS

Please report any bugs or feature requests to bug-astro-moonphase-simple at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Astro-MoonPhase-Simple. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Astro::MoonPhase::Simple

You can also look for information at:

ACKNOWLEDGEMENTS

The authors of Astro::MoonPhase takes all the credit.

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by Andreas Hadjiprocopis.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

1 POD Error

The following errors were encountered while parsing the POD:

Around line 311:

alternative text 'https://perlmonks.org/?node_id=11137299' contains non-escaped | or /