2011 1.08

From XPUB & Lens-Based wiki

Pipeline

Common elements:

  • Showing change over time
  • Live feeds of data (RSS / XML)
  • Data visualisation
  • Browser based displays

In class, sample pipeline:

  • RSS feed [[ ]]
  • Python to convert to word lengths
  • Image Magick to draw circles
  • Bash Loop to produce multiple images
  • Imagemagick to convert frames to animation


Drawing a circle with Image Magick:

convert -size 500x500 xc:skyblue -fill white -stroke black \
	-draw "circle 50,30 40,10"\
	-draw "circle 90,30 40,10"          draw_circle.gif
display draw_circle.gif

Run by typing this in terminal: bash draw.sh


Turning the words of a feed into a number (length of word):

import feedparser, time, random
 
url = "http://search.twitter.com/search.atom?q=flu"

# SET THE LASTTIME BASED ON THE FEED...
feed = feedparser.parse(url)
for x in feed.entries:
	for w in x.title.split():
		print len(w),
	print

Run: python pipeline01.py


Using these numbers to draw circles:

import feedparser, time, random
print """convert -size 500x500 xc:skyblue -fill none -stroke black \\"""


url = "http://search.twitter.com/search.atom?q=flu"

# SET THE LASTTIME BASED ON THE FEED...
feed = feedparser.parse(url)
for x in feed.entries:
	for w in x.title.split():
		print """	-draw "circle %d,%d %d,%d"\\""" % (len(w)*10, 50, 10, 10)
#		print len(w),
#	print
	
print """ draw_circle.gif """
print """ display draw_circle.gif"""

Run: python pipeline02.py | bash


Draw circle.gif