skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

Topocentric example on homepage throws error(?) #156

Closed haggletonpie closed 6 years ago

haggletonpie commented 6 years ago

http://rhodesmill.org/skyfield/

When running the 2nd example to compute the apparent position of Mars when viewed from Boston at time t, skyfield gripes about "plussing" the earth body and the Topos for Boston.

TypeError: unsupported operand type(s) for +: 'Body' and 'Topos'

Surely, I'm missing something...?

#====the first example====
#works fine

from skyfield.api import load

planets = load('de421.bsp')
earth, mars = planets['earth'], planets['mars']

ts = load.timescale()
t = ts.now()
astrometric = earth.at(t).observe(mars)
ra, dec, distance = astrometric.radec()

print(ra)
print(dec)
print(distance)

#====appended 2nd example====
#throws type/operand error

from skyfield.api import Topos

boston = earth + Topos('42.3583 N', '71.0636 W')
astrometric = boston.at(t).observe(mars)
alt, az, d = astrometric.apparent().altaz()

print(alt)
print(az)
brandon-rhodes commented 6 years ago

You could be using a very old version of Skyfield — what version do you have installed?

pip freeze| grep skyfield
haggletonpie commented 6 years ago

Thanks.

pip install skyfield --upgrade

Great library. Thanks much.

brandon-rhodes commented 6 years ago

I'm glad it's working for you now! :)