2011 1.08: Difference between revisions
(Created page with "Pipeline Common elements: * Showing change over time * Live feeds of data (RSS / XML) * Data visualisation * Browser based displays In class, sample pipeline: * RSS feed [[ ]]...") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 14: | Line 14: | ||
* Bash Loop to produce multiple images | * Bash Loop to produce multiple images | ||
* Imagemagick to convert frames to animation | * Imagemagick to convert frames to animation | ||
Drawing a circle with Image Magick: | |||
<source lang="bash"> | |||
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 | |||
</source> | |||
Run by typing this in terminal: | |||
bash draw.sh | |||
Turning the words of a feed into a number (length of word): | |||
<source lang="python"> | |||
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 | |||
</source> | |||
Run: python pipeline01.py | |||
Using these numbers to draw circles: | |||
<source lang="python"> | |||
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""" | |||
</source> | |||
Run: python pipeline02.py | bash | |||
[[File:Draw_circle.gif]] |
Latest revision as of 16:25, 7 December 2010
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