Astro-satpass
view release on metacpan or search on metacpan
lib/Astro/Coord/ECI/Sun.pm view on Meta::CPAN
my $station;
$station = $self->get( 'station' )
and ( $station->geodetic() )[0] < 0
and $event = ( $event + @{ $tplt } / 2 ) % @{ $tplt };
return $self->__event_name( $event, $tplt );
}
sub __transit_name_tplt {
my ( $self ) = @_;
return $self->__object_is_self_named() ?
[ 'local midnight', 'local noon' ] :
[ '%s transits nadir', '%s transits meridian' ];
}
sub __twilight_name {
my ( $self, $event, $tplt ) = @_;
$tplt ||= $self->__object_is_self_named() ?
[ 'end twilight', 'begin twilight' ] :
[ 'end %s twilight', 'begin %s twilight' ];
return $self->__event_name( $event, $tplt );
}
=begin comment
=item $time = $self->season( $year, $season );
This method calculates the time of the given season of the given
Gregorian year. The $season is an integer from 0 to 3, with 0 being the
astronomical Spring equinox (first point of Aries), and so on.
The algorithm comes from Jean Meeus' "Astronomical Algorithms", 2nd
Edition, Chapter 27 ("Equinoxes and Solstices), pages 278ff.
THIS METHOD IS UNSUPPORTED. I understand the temptation to call it if
all you want are the seasons, but if possible I would like to be able to
remove it if its use in next_quarter() turns out to be a bad idea. I am
not unwilling to support it; if you want me to, please contact me.
Because it is unsupported, its name may change without warning if
L<Test::Pod::Coverage|Test::Pod::Coverage> becomes smart enough to
realize that the =begin/end comment markers mean that this method is not
documented after all.
=end comment
=cut
sub season {
my ( $self, $year, $season ) = @_;
my ( $Y, $d ) = $year < 1000 ? (
$year / 1000,
[ # Meeus table 27 A
[ -0.00071, 0.00111, 0.06134, 365242.13740, 1721139.29189 ],
[ 0.00025, 0.00907, -0.05323, 365241.72562, 1721233.25401 ],
[ 0.00074, -0.00297, -0.11677, 365242.49558, 1721325.70455 ],
[ -0.00006, -0.00933, -0.00769, 365242.88257, 1721414.39987 ],
]->[ $season ],
) : (
( $year - 2000 ) / 1000,
[ # Meeus table 27 B
[ -0.00057, -0.00411, 0.05169, 365242.37404, 2451623.80984 ],
[ -0.00030, 0.00888, 0.00325, 365241.62603, 2451716.56767 ],
[ 0.00078, 0.00337, -0.11575, 365242.01767, 2451810.21715 ],
[ 0.00032, -0.00823, -0.06223, 365242.74049, 2451900.05952 ],
]->[ $season ],
);
my $JDE0 = ( ( ( $d->[0] * $Y + $d->[1] ) * $Y + $d->[2] ) * $Y +
$d->[3] ) * $Y + $d->[4];
my $T = ( $JDE0 - 2451545.0 ) / 36525;
$self->{debug}
and print "Debug - T = $T\n";
my $W = mod2pi( deg2rad( 35999.373 * $T - 2.47 ) );
my $delta_lambda = 1 + 0.0334 * cos( $W ) + 0.0007 * cos( 2 * $W );
$self->{debug}
and print "Debug - delta lambda = $delta_lambda\n";
my $S = 0;
foreach my $term ( # Meeus table 27 C
[ 485, 324.96, 1934.136 ],
[ 203, 337.23, 32964.467 ],
[ 199, 342.08, 20.186 ],
[ 182, 27.85, 445267.112 ],
[ 156, 73.14, 45036.886 ],
[ 136, 171.52, 22518.443 ],
[ 77, 222.54, 65928.934 ],
[ 74, 296.72, 3034.906 ],
[ 70, 243.58, 9037.513 ],
[ 58, 119.81, 33718.147 ],
[ 52, 297.17, 150.678 ],
[ 50, 21.02, 2281.226 ],
[ 45, 247.54, 29929.562 ],
[ 44, 325.15, 31555.956 ],
[ 29, 60.93, 4443.417 ],
[ 18, 155.12, 67555.328 ],
[ 17, 288.79, 4562.452 ],
[ 16, 198.04, 62894.029 ],
[ 14, 199.76, 31436.921 ],
[ 12, 95.39, 14577.848 ],
[ 12, 287.11, 31931.756 ],
[ 12, 320.81, 34777.259 ],
[ 9, 227.73, 1222.114 ],
[ 8, 15.45, 16859.074 ],
) {
$S += $term->[0] * cos( mod2pi( deg2rad( $term->[1] + $term->[2]
* $T ) ) );
}
$self->{debug}
and print "Debug - S = $S\n";
my $JDE = 0.00001 * $S / $delta_lambda + $JDE0;
$self->{debug}
and print "Debug - JDE = $JDE\n";
my $time = ( $JDE - JD_OF_EPOCH ) * SECSPERDAY;
# Note that gmtime() in the following needs the parens because it
# might have come from Time::y2038, which appears to take more than
# one argument -- even though, as I read it, its prototype is (;$).
$self->{debug}
and print "Debug - dynamical date is ", scalar gmtime( $time ), "\n";
return $time - dynamical_delta( $time ); # Not quite right.
}
=item $sun->set( ... )
This method has been overridden to silently ignore any attempt to set
the C<'sun'> attribute.
( run in 4.727 seconds using v1.01-cache-2.11-cpan-788537b7465 )