In [8]:
print("hello world")
In [9]:
help
Out[9]:
In [10]:
import ephem
In [11]:
m = ephem.Mars('1970')
print(ephem.constellation(m))
In [12]:
m = ephem.Mars()
m.name
Out[12]:
In [13]:
a = ephem.star('Arcturus')
a.name
Out[13]:
In [15]:
m = ephem.Mars('2003/8/27')
print('%s %s %.10f' % (m.name, m.elong, m.size))
In [16]:
j = ephem.Jupiter()
j.compute('1986/2/8')
print('%s %s' % (j.ra, j.dec))
In [17]:
j.compute('1986/2/9', epoch='1950')
print('%s %s' % (j.a_ra, j.a_dec))
In [18]:
gatech = ephem.Observer()
gatech.lon = '-84.39733'
gatech.lat = '33.775867'
gatech.elevation = 320
gatech.date = '1984/5/30 16:22:56'
v = ephem.Venus(gatech)
print('%s %s' % (v.alt, v.az))
#returns the altitude and azimuth angle of venus from the observation point (here I believe it is gorgia tech)
In [19]:
line = "C/2002 Y1 (Juels-Holvorcem),e,103.7816,166.2194,128.8232,242.5695,0.0002609,0.99705756,0.0000,04/13.2508/2003,2000,g 6.5,4.0"
yh = ephem.readdb(line)
yh.compute('2007/10/1')
print('%.10f' % yh.earth_distance)
#reads in XEphem format
In [20]:
print(yh.mag)
In [21]:
print(yh.writedb())
#XEphem format generated
In [23]:
moon = ephem.Moon('1980/6/1')
print(ephem.constellation(moon))
# constellation returns the abrv and full name of constellation that the body (in this case moon) is a part of at the epoch
In [24]:
# read in ISS TLE and return the effective lat and long of position above earth
line1 = "ISS (ZARYA)"
line2 = "1 25544U 98067A 03097.78853147 .00021906 00000-0 28403-3 0 8652"
line3 = "2 25544 51.6361 13.7980 0004256 35.6671 59.2566 15.58778559250029"
iss = ephem.readtle(line1, line2, line3)
iss.compute('2003/3/23')
print('%s %s' % (iss.sublong, iss.sublat))
In [25]:
#returns the angle that separates two positions on a sphere
m1 = ephem.Moon('1970/1/16')
m2 = ephem.Moon('1970/1/17')
s = ephem.separation(m1, m2)
print("In one day the Moon moved %s" % s)
In [28]:
#Tutorial example for setting up an "observer"
lowell = ephem.Observer()
lowell.lon = '-111:32.1'
lowell.lat = '35:05.8'
lowell.elevation = 2198
lowell.date = '1986/3/13'
j = ephem.Jupiter()
j.compute(lowell)
print(j.circumpolar)
print(j.neverup)
print('%s %s' %(j.alt, j.az))
#warning generated said certain attributes are deprecated, convert to Observer functions
In [29]:
#XEphem has small database of cities
#when called, city() generates a new observer
#only includes lat, lon, and elevation
boston = ephem.city('Boston')
print('%s %s' % (boston.lat, boston.lon))
In [32]:
#For celestial bodies (not satellites)
sitka = ephem.Observer()
sitka.date = '1999/6/27'
sitka.lat = '57:10'
sitka.lon = '-135:15'
m = ephem.Mars()
print(sitka.next_transit(m))
print('%s %s' % (m.alt, m.az))
print(sitka.next_rising(m, start='1999/6/28'))
print('%s %s' % (m.alt, m.az))
In [34]:
# read in TLE for IRIDIUM
line1 = "IRIDIUM 80 [+]"
line2 = "1 25469U 98051C 09119.61415140 -.00000218 00000-0 -84793-4 0 4781"
line3 = "2 25469 86.4029 183.4052 0002522 86.7221 273.4294 14.34215064557061"
iridium_80 = ephem.readtle(line1, line2, line3)
boston.date = '2009/5/1'
#next_pass() returns six-element tuple where:
# 0 Rise time
# 1 Rise azimuth
# 2 Max altitude time
# 3 Max altitude
# 4 Set time
# 5 Set azimuth
info = boston.next_pass(iridium_80)
print("Rise time: %s azimuth: %s" % (info[0], info[1]))
In [36]:
#the location and brightness of Uranus on the night it was discovered (march 13, 1781)
u = ephem.Uranus()
u.compute('1781/3/13')
print('%s %s %s' % (u.ra, u.dec, u.mag))
print(ephem.constellation(u))
In [38]:
#when Galileo missed discovering Neptune in 1612...
#Neptune and Jupiter were only 14' apart
j = ephem.Jupiter('1612/12/28')
n = ephem.Neptune('1612/12/28')
print("%s %s %s" % (j.ra, j.dec, j.mag))
print("%s %s %s" % (n.ra, n.dec, n.mag))
print(ephem.separation(j, n))
In [40]:
# showing that mars moves faster when closer to the sun
def hpos(body): return body.hlon, body.hlat
ma0 = ephem.Mars('1976/05/21') # ma: mars near aphelion
ma1 = ephem.Mars('1976/05/22')
print(ephem.separation(hpos(ma0), hpos(ma1)))
mp0 = ephem.Mars('1975/06/13') # mp: mars near perihelion
mp1 = ephem.Mars('1975/06/14')
print(ephem.separation(hpos(mp0), hpos(mp1)))
In [45]:
u = ephem.Uranus('1871/3/13')
print(u.dec) #no specification defaults to string for angles
print(str(u.dec))
print('%.12f' % float(u.dec)) #angles actually computed in radians
print('%.11f' % float(u.dec +1))
print("as a string: %s, as a float: %f" % (u.dec, u.dec))
In [0]: