Astro-Montenbruck

 view release on metacpan or  search on metacpan

script/moon_almanac.pl  view on Meta::CPAN

if ( grep( /^[\+\-]?(\d+(\.?\d+)?|(\.\d+))$/, @place ) == 2 ) {
    ( $lat, $lon ) = @place;
}
else {
    ( $lat, $lon ) = parse_geocoords(@place);
}

say "Lunar Calendar";
say sprintf( 'Place: %s', format_geo( $lat, $lon ) );
say '';
my $jd_start = $dt->jd;
my $jd_end = $jd_start + $days * $step;

for (my $jd = $jd_start; $jd < $jd_end; $jd+=$step) {
    my @date = jd2cal($jd);
    say sprintf( 'Date : %s', sprintf('%d-%02d-%02d', @date) );
    say '';

    my %rst = rise_set_transit(@date, $lat, $lon, $tz);
    say sprintf( "Rise: %s\nTransit: %s\nSet: %s",
        map { $rst{$_} } @RS_EVENTS );
    say '';
    my ($mo, $su) = sun_moon_positions($jd);
    say sprintf('Sun longitude: %6.2f', $su);  
    say sprintf('Moon longitude: %6.2f', $mo);  
    say '';

    my ($phase, $deg, $days) = moon_phase(moon => $mo, sun => $su);
    say sprintf("Phase: %s\nAge: %5.2f deg. = %d days", $phase, $deg, $days);  
    say "\n---\n" 
}



__END__

=pod

=encoding UTF-8

=head1 NAME

moon_almanac — Computes rise, set of the Moon, its position and lunar phase circumstances for a range of dates

=head1 SYNOPSIS

  $ moon_almanac [OPTIONS]

=head1 OPTIONS

=over 4

=item B<--help>

Prints a brief help message and exits.

=item B<--start>

Start date, in B<YYYY-DD-MM> format, current date by default.

  --start=2019-06-08 # calendar date

=item B<--days>

Number of days to process, B<1> by default  

=item B<--step>

Step between successive cevents, in days, B<7> by default  

=item B<--timezone>

Time zone name, e.g.: C<EST>, C<UTC>, C<Europe/Berlin> etc. 
or I<offset from Greenwich> in format B<+HHMM> / B<-HHMM>, like C<+0300>.

    --timezone=CET # Central European Time
    --timezone=EST # Eastern Standard Time
    --timezone=UTC # Universal Coordinated Time
    --timezone=GMT # Greenwich Mean Time, same as the UTC
    --timezone=+0300 # UTC + 3h (eastward from Greenwich)
    --timezone="Europe/Moscow"

By default, a local timezone.

Please, note: Windows platform may not recognize some time zone names, like C<MSK>.
In such cases use I<offset from Greenwich> format, as described above.


=item B<--place>

The observer's location. Contains 2 elements, space separated. 

=over

=item * 

latitude in C<DD(N|S)MM> format, B<N> for North, B<S> for South.

=item * 

longitude in C<DDD(W|E)MM> format, B<W> for West, B<E> for East.

=back

E.g.: C<--place=51N28 0W0> for I<Greenwich, UK> (the default).

B<Decimal numbers> are also supported. In that case

=over

=item * 

The latitude always goes first

=item * 

Negative numbers represent I<South> latitude and I<East> longitudes. 

=back

C<--place=55.75 -37.58> for I<Moscow, Russian Federation>.



( run in 2.417 seconds using v1.01-cache-2.11-cpan-0b58ddf2af1 )