take_screenshots = True %pylab wx if take_screenshots: %pylab inline from mayavi import mlab from mayavi.sources.builtin_surface import BuiltinSurface from sgp4.earth_gravity import wgs72 from skyfield.constants import AU_KM from skyfield.api import JulianDate, nine_planets, earth pylab.rcParams['figure.figsize'] = (8.0, 8.0) mlab.figure(bgcolor=(0.0, 0.0, 0.0)) planet_color = (0.7, 1.0, 1.0) yellow = (1.0, 1.0, 0.0) # One Earth year day_array = arange(1, 366.3, 0.25) jd = JulianDate(utc=(2014, 6, day_array, 0, 0, 0)) print 'Start:', jd.tt[0] print 'End: ', jd.tt[-1] def reposition_camera(distance, focalpoint=(0.0, 0.0, 0.0)): """Move the camera above the solar system.""" mlab.view(azimuth=90.0, elevation=360.0 - 23.4, distance=distance, focalpoint=focalpoint) if take_screenshots: imshow(mlab.screenshot(antialiased=True)) axis('off') # Get ready to draw! mlab.clf() for planet in nine_planets: x, y, z = planet(jd).position.AU mlab.plot3d(x, y, z, color=planet_color, tube_radius=None, line_width=2.0) print planet.jplname, '- plotted', len(x), 'points' reposition_camera(10.0) reposition_camera(110.0) # Draw a sphere for the Sun sun_r = 695500.0 / AU_KM # km sphere = mlab.points3d(0, 0, 0, name='Sun', scale_mode='none', scale_factor=sun_r * 2.0, color=yellow, resolution=50) reposition_camera(distance=1.3) # Add the Earth x, y, z = earth(JulianDate(tt=jd.tt[-1])).position.AU r = wgs72.radiusearthkm / AU_KM ocean_blue = (0.4, 0.5, 1.0) sphere = mlab.points3d(x, y, z, name='Globe', scale_mode='none', scale_factor=r * 2.0, color=ocean_blue, resolution=50) #sphere.actor.property.specular = 0.20 #sphere.actor.property.specular_power = 10 reposition_camera(distance=0.025, focalpoint=(x, y, z))