Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

What's the Perl equivalent of pyephem?

Since pyephem is based on a C library(?), I'm guessing someone's created a Perl version too?

share|improve this question
 
And what is pyephem? –  cjm Feb 2 at 5:19
1  
please tell us what you want to do, perhaps there are ways to accomplish them. I doubt there is an exact port as though the module in question is coded in C it is not a wrapper for an external C library. –  Joel Berger Feb 2 at 5:32
 
Ultimately, I'm trying to find the time of the next moon/sun rise/set or twilight at a given location for a given time EVEN IF that event doesn't occur in the next 24 hours. For example, sunset in Barrow AK in mid-June will actually occur many weeks later. –  barrycarter Feb 2 at 5:53
add comment

2 Answers

up vote 4 down vote accepted

Have you checked out libnova? It's quite powerful. There's a Perl wrapper for that: Astro::Nova.

Quoting the documentation below, one of these could do exactly what you want. The Perl docs are relatively sparse because I didn't want to reproduce the entire library documentation for the wrapper. The functions are mostly similar to how the work in C. Exceptions from that should be documented. The main libnova docs have all the details.

(int $status, Astro::Nova::RstTime $rst) =
  get_object_rst(double JD, Astro::Nova::LnLatPosn observer, Astro::Nova::EquPosn object)
(int $status, Astro::Nova::RstTime $rst) =
  get_object_rst_horizon(double JD, Astro::Nova::LnLatPosn observer,
                         Astro::Nova::EquPosn object, double horizon)
(int $status, Astro::Nova::RstTime $rst) =
  get_object_next_rst(double JD, Astro::Nova::LnLatPosn observer, Astro::Nova::EquPosn object)
(int $status, Astro::Nova::RstTime $rst) =
  get_object_next_rst_horizon(double JD, Astro::Nova::LnLatPosn observer,
                              Astro::Nova::EquPosn object, double horizon)
share|improve this answer
 
It turns out Astro::Nova isn't quite as complete as pyephem. Another workaround is Inline::Python which lets you write Python code directly in Perl. –  barrycarter 36 mins ago
add comment

You might want to start here:

Perl Astro Modules

share|improve this answer
1  
I've looked at many Perl Astro modules, including Astro::Sunrise and Astro::Coord::ECI, but none give me minute-to-minute agreement with NOAA's results (Astro::Sunrise comes close, but can be off by a few minutes AND fails when there is either a sunrise OR a sunset, but not both). –  barrycarter Feb 2 at 5:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.