View Single Post
  #13  
Old 08-07-2021, 12:07 PM
gjr80 (Gary)
Registered User

gjr80 is offline
 
Join Date: Aug 2017
Location: Brisbane
Posts: 34
The problem is the lat/long data you are feeding to your Observer object. Pyephem works internally using radians not degrees. When you pass lat/long as strings pyephem will attempt to parse the strings as degrees (hence the pyephem examples use lat long as decimal degrees in quotes) and store the results as radians. From memory there are a number of different formats that are supported. When you 'print' an Observer object (or otherwise display the lat and long properties of an Observer object) you are by default presented with lat/long in degrees. If you provide lat/long as numerics pyephem interprets the values as radians, so you need to convert the degrees to radians yourself first. So considering your examples, the first would need to be something like:

Code:
import math
 ob.lon, ob.lat, ob.elevation = math.radians(-28.00274), math.radians(153.42999), 0
the second is fine as is:

Code:
ob.lon, ob.lat, ob.elevation = '-27.9985', '153.4227', 0
The third and fourth would need to use math.radians() just like the first.

Try it and 'print' the observer details of each using print(ob) and you you should see the same lat/long for each:

Code:
<ephem.Observer date='2021/7/8 01:40:27' epoch='2000/1/1 12:00:00' lon='-27:59:54.6' lat='153:25:21.7' elevation=0.0m horizon=0:00:00.0 temp=15.0C pressure=1010.0mBar>
Gary
Reply With Quote