9

I've a query on the results given by the PyEphem module relating to Observer() queries, and the effects of elevation. I understand from a couple of sources (such as http://curious.astro.cornell.edu/question.php?number=388) that the elevation of the observer has a marked effect on sunset time. However in the following code, I see next to no difference:

import ephem

emphemObj = ephem.Observer()
emphemObj.date = '2011/08/09'
emphemObj.lat = '53.4167'
emphemObj.long = '-3'
emphemObj.elevation = 0

ephemResult = ephem.Sun()
ephemResult.compute(emphemObj)
print "Sunset time @ 0m: " + str(emphemObj.previous_rising(ephemResult))

emphemObj.elevation = 10000
ephemResult.compute(emphemObj)
print "Sunset time @ 10000m: " + str(emphemObj.previous_rising(ephemResult))

I get the output:

Sunset time @ 0m: 2011/8/8 04:38:34
Sunset time @ 10000m: 2011/8/8 04:38:34

I'm fairly sure I'm doing something wrong rather than this being a bug, but having tried a number of different ways, I'm afraid I keep winding up with the same results. Does anyone know what I'm doing wrong here?

I posted this on https://launchpad.net/pyephem already, but I've had no response. I'm hoping I've not fundamentally misunderstood the purpose of the elevation function...

Smingos
  • 280
  • 1
  • 3
  • 9
  • If you duplicate the example in the linked article, at the equator at 12,000 meters, do you get the same result? If so, then maybe they haven't implemented elevation concerns yet. – wberry Oct 05 '11 at 14:22
  • I'm not 100% sure I've tried 12,000m but I have certainly tried other (much) higher values. The time reported by previous_rising does change, which leads me to believe the elevation code is doing something. I'm just hoping it isn't solely accounting for atmospheric refraction instead of the 'horizon' effect. – Smingos Oct 05 '11 at 14:36

1 Answers1

6

The elevation of an observer means the elevation above sea level of their location — like the altitude of Flagstaff, Arizona, for example. But it is presumed that not only the observer and their telescope or binoculars is this distance above sea level; it is presumed that the ground — and thus the horizon — are also at this altitude. So an increased elevation gives you no advantage relative to the horizon, because the horizon moves with you when you move to a higher-altitude city.

After a few minutes with a pencil and yellow pad of paper, it looks like the angle down to the horizon hza is related to the earth's radius r and your height above the ground h as follows:

hza = - acos(r / (h + r))

So following on from your example above:

import math
height = 10000
hza = - math.acos(ephem.earth_radius / (height + ephem.earth_radius))
emphemObj.horizon = hza
print "Sunrise time @ 10000m: " + str(emphemObj.previous_rising(ephemResult))

I get the output:

Sunrise time @ 10000m: 2011/8/8 04:08:18

(Note that "sunrise" goes with previous_rising() and "sunset" goes with next_setting()!)

Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147
  • Thanks Brandon! I spent so much time trying to figure out the problem, I hadn't stopped to think if it actually was a problem. Makes sense when I think about it... Still, the calculation above will no doubt be useful for me when there is a significant local prominence. – Smingos Oct 27 '11 at 08:56
  • Oh dear, I only just noticed I'd labelled the previous_rising as Sunset time! :-) Glad that one didn't make it into the actual code! – Smingos Oct 27 '11 at 09:04