Reputation: 69
Depending on the seasons, it looks like the sun will never go lower than a certain angle with respect to the horizon at some areas.
Is there a way in PyEphem to calculate the lowest possible angle at specific times and locations, so I can avoid an AlwaysUpError?
Upvotes: 3
Views: 425
Reputation: 2270
To get the range of the angles where the sun will reach, use the transit_time, next_antitransit functions. The transit time is when the sun reaches the meridian through your observer location, and that of course corresponds to when the sun reaches its highest altitude. The same idea goes for the anti-transit (when the sun reaches the back side of the meridian)
For example:
... #create observer
sun = ephem.Sun(obs)
obs.date = sun.transit_time
maximum_altitude = sun.alt
And to get the lowest altitude, you can do:
obs.date = obs.next_antitransit(sun)
sun.compute(obs)
minimum_altitude = sun.alt
Upvotes: 2