Tempel 1 NASA Pass-by
This is a brief project involving NASA’s STARDUST-NExT spacecraft. In 2006, the craft collected samples from Comet Wild 2 and turned back around on a follow-up mission to visit the comet Tempel 1. On February 15 of this year (2011), a series of images of a Tempel 1 fly-by were posted on the Jet Propulsion Laboratory website. Blown away by such an amazing event captured in stunning clarity, I immediately had to put together an animated version of these images. Below is a short summary of a quick hack to create such an animation as well as the resulting files.
Python Urllib2 and Urllib are used to grab the pages and download the images, respectively [urllib2,urllib]. Images are then processed with ImageMagick. NOTE: Using a parsing library like Beautiful Soup would be much better, but what would a hack be if it were the optimal method? Now to the code…
grabber.py – get the images download
This will dump all the images into the current directory so probably best to make a new directory and launch from within that desired location.
#!/usr/bin/env python import urllib2,urllib lines = urllib2.urlopen('http://www.jpl.nasa.gov/news/stardust/').readlines() files =  for line in lines: if '<a href="/news/stardust/index.php?fileID=' in line: files.append(line) links =  for line in files: if "<h3>Comet Tempel" in line: links.append(line) pre = "http://www.jpl.nasa.gov" linkslist =  for line in links: this_l = line.split('"') linkslist.append(pre+this_l) x = 0 for link in linkslist: thislink = link thispage = urllib2.urlopen(thislink).readlines() images =  for line in thispage: c =  if "../../images/stardust/stardust2/" in line and "alt='Comet Tempel 1" in line: c.append(line) if c: images.append(c) for image in images: d = image.split("'") g = thislink.rpartition("index.php")+d thisimage = g.rpartition('/') x += 1 try: image = urllib.URLopener() image.retrieve(g,thisimage) print "Grabbed image # ",x," ==> ",thisimage except: print "**** Problem grabbing image # ",x," ==> ",thisimage
Making the animations:
The following will invoke a small ImageMagick GUI instance. Once the images are loaded the animation will play. To tweak/save, right click and the menu will appear where you can manipulate the GIF. Seen here.
Making a scaled version:
Use ImageMagick to scale all the images and animate the scaled products.
for i in *.jpg; do convert -scale 20% "$i" $(basename "$i" ".jpg")"_scaled.jpg"; done animate *_scaled.jpg
… Then felt I like some watcher of the skies
When a new planet swims into his ken;
Or like stout Cortez when with wond’ring eyes
He stared at the Pacific …
- John Keats, ms of sonnet (1816)