In [8]:
print("hello world")


hello world

In [9]:
help


Out[9]:
Type help() for interactive help, or help(object) for help about object.

In [10]:
import ephem

In [11]:
m = ephem.Mars('1970')
print(ephem.constellation(m))


('Aqr', 'Aquarius')

In [12]:
m = ephem.Mars()
m.name


Out[12]:
'Mars'

In [13]:
a = ephem.star('Arcturus')
a.name


Out[13]:
'Arcturus'

In [15]:
m = ephem.Mars('2003/8/27')
print('%s %s %.10f' % (m.name, m.elong, m.size))


Mars -173:00:34.2 25.1121063232

In [16]:
j = ephem.Jupiter()
j.compute('1986/2/8')
print('%s %s' % (j.ra, j.dec))


21:57:50.46 -13:17:37.2

In [17]:
j.compute('1986/2/9', epoch='1950')
print('%s %s' % (j.a_ra, j.a_dec))


21:56:50.83 -13:22:54.3

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)


72:19:44.8 134:14:25.3

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


14.8046731949

In [20]:
print(yh.mag)


23.96

In [21]:
print(yh.writedb())
#XEphem format generated


C/2002 Y1 (Juels-Hol,e,103.7816,166.2194,128.8232,242.5695,0,0.9970576,0, 4/13.2508/2003, 1/01/2000,g6.5,4,0

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


('Sgr', 'Sagittarius')

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


-76:24:18.3 13:05:31.1

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 one day the Moon moved 12:33:28.5

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


False
False
0:57:44.7 256:41:01.3

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


42:21:30.4 -71:03:35.2

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


1999/6/27 04:22:45
21:18:33.6 180:00:00.0
1999/6/28 23:28:25
-0:00:05.8 111:10:41.6

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]))


Rise time: 2009/5/1 00:22:15 azimuth: 104:36:16.0

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


5:35:45.28 23:32:54.1 5.6
('Tau', 'Taurus')

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


11:48:20.52 2:41:13.6 -1.96
11:49:15.77 2:37:04.5 7.92
0:14:24.6

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


0:26:11.4
0:38:05.2

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


22:04:47.4
22:04:47.4
0.385365877213
1.38536587721
as a string: 22:04:47.4, as a float: 0.385366

In [0]: