Results for Observer() seemingly not accounting for elevation effects in PyEphem
Asked Answered
R

1

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...

Reporter answered 5/10, 2011 at 14:3 Comment(2)
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.Septenary
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.Reporter
O
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()!)

Orthodontics answered 27/10, 2011 at 8:15 Comment(2)
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.Reporter
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!Reporter

© 2022 - 2024 — McMap. All rights reserved.