Category Archives: source code

Kepler22_46_43

Data in an Alien Context: Kepler Visualization Source Code

Last year, I released a video visualization of the 1236 exoplanets identified by the NASA’s Kepler mission. Since then, there have been another 1091 candidates identified, and I thought it’d be a good time to update my visualization – and release the source code.

So, here it it: http://github.com/blprnt/Kepler-Visualization

I’ve tried to comment the code as well as possible – and the sketch overall is fairly simple. You will, of course, need Processing to get it running, as well as Karsten Schmidt’s esssential toxiclibs.

Text Comparison Tool: SOURCE CODE

About this time last year, I built a light-weight tool in Processing to compare two articles that I read about head injuries in the NFL. Later, I extended the tool to compare any two texts, and promised a source release.

Well, it only took 12 months, but I’ve finally cleaned up the code to a point where I think it will be reasonably easy to use and helpful for those who might want to learn a bit more about the code.

I always find myself in a tricky position with source releases. Often, as in the case of this tool, I have ideas about what the project should look like before it gets released. Here, I wanted to build an interface to allow people to select different text sources within the app, so that people could use the app without having to compile it from Processing. This is what delayed the release of the code for a year – I was waiting for the time to get this last piece done.

Two weeks ago, though, I has a chance to speak at an event with Tahir Hemphill. I had sent Tahir a messy version of the project for use with his Hip Hop Word Count initiative a few months back, and he used it to analyze a famous rap battle between Nas and Jay-Z:

Text Correlation Tool: Nas Versus Jay / Ether Versus The Takeover from Staple Crops on Vimeo.

This reminded me of a fairly valuable lesson as far as source code is concerned: If it works, it’s probably good enough to release.

So, without too much further ado, here’s a link to download the Text Comparison Tool:

Text Comparison Tool (1.1MB)

It’s pretty easy to use. First, you’ll need Processing to open and work with the sketch. Also, you’ll need the toxiclibs core library installed. Assuming you have those two things, these are the steps:

1. Drag the unzipped folder into your sketchbook.
2. Place your text files in the sketch’s data folder.
3. Open the sketch.
4. Look for the code block at the top of the main tab where the article information is set. It’s pretty clearly marked, and looks like this:

String title1 = "Tokyo";
String url1 = "asia.txt";
String desc1 = "Suntory Hall";
String date1 = "November 14th, 2009";
color color1 = #140047;

String title2 = "Cairo";
String url2 = "cairo.txt";
String desc2 = "Cairo University";
String date2 = "June 4th, 2009";
color color2 = #680014;

5. Replace the information here with appropriate information for your files.
6. Run the sketch!

That’s it. If you are getting strange results, you can tweak the clean() and cleanBody() methods at the bottom of the main tab to control how your text is filtered.

Hopefully I’ll still find the time to package this thing up in a bit more of a user-friendly form. But, in the meantime, hopefully people will find this useful as an exploratory tool. Note that at any time you can press the ‘s’ key to save out an image – if you find some interesting texts to compare, let me know!

7 Days of Source Day #7: Variance – Better Design Through Genetics?

Project: Variance
Date: January, 2007
Language: ActionScript 2
Key Concepts: Genetic Algorithms

Overview:

I’ll admit – this is some fairly dusty code. But I wanted to end this 7 (or 25) days of source release with this project for a reason: I think it’s a pretty good idea. I took it to a prototype stage but not much further – maybe someone will find the time to move it forward into something more functional.

Variance is a tool that lets you evolve graphics, from pre-built ‘sets’ of elements and typefaces. It combines some simple editing tools (you can manually change colour, position, rotation, etc.) with some evolutionary magic – you can select two different compositions and hybridize them to get a new set of graphics that share some of the properties of their parents. It works fairly well; usually within about 6 generations you can get a graphic that starts to look pretty good (starting from some jumbled random compositions).

When I was building this tool, I imagined how nice it would be if this kind of functionality was built into a ‘traditional’ tool like Illustrator. Working on a logotype, and are feeling a bit stuck? Have the application generate 9 mutations of your current design, then evolve those for a few generations until you get a result you like. Just getting started on a poster design? Pick some assets and have the Variance plug-in generate some possibilities. In both of these cases, the designer is still being a designer – picking the best results, tweaking layouts – but they are letting the genetic algorithms do the grunt work of coming up with possible variations. At the same time, they are allowing for mutations; often modifications that they may not have tried themselves. This is a very direct application of an Evolutionary Creative Process (ECP), which I’ve talked about before on this blog.

Utility aside, it’s fun to play with.

Getting Started:

You can see Variance in action here: http://www.blprnt.com/variance

To read more about the project and to get a walk-through, you can read this post (you may want to do this before you try the application)

You’ll need Flash to get into the source and to get working with it.

Download: VarianceSource(4.12 MB)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

7 Days of Source Day #6: NYTimes GraphMaker

NYTimes Drug Diptych

Project: NYTimes GraphMaker
Date: Fall, 2009
Language: Processing
Key Concepts: Data vizualization, graphing, NYTimes Article Search API

Overview:

The New York Times Article Search API gives us access to a mountain of data: more than 2.6 million indexed articles. There must be countless discoveries waiting to be made in this vast pile of information – we just need more people with shovels! With that in mind, I wanted to release a really simple example of using Processing to access word trend information from the Article Search API. Since I made this project in February, the clever folks at the NYT research lab have released an online tool to explore word trends, but I think it’s useful to have the Processing code released for those of us who want to poke around the data in a slightly deeper way. Indeed, I hope this sketch can act as a starting point for people to take some more involved forays into the dataset – it is ripe to be customized and changed and improved.

This is the simplest project I’m sharing in this now multi-week source release. It should be a nice starting point for those of you who have some programming experience but haven’t done too much in the way of data visualization. As always, if you have questions, feel free to send me an e-mail or post in the comments section below.

You can see a whole pile of radial and standard bar graphs that I made with this sketch earlier in the year in this Flickr set.

Getting Started:

You’ll need the toxiclibs core, which you can download here. Put the unzipped library into the ‘libraries’ folder in your sketchbook (if there isn’t one already, create one).

Put the folder ‘NYT_GraphMaker’ into your Processing sketch folder. Open Processing and open the sketch from the File > Sketchbook menu. You’ll find detailed instructions in the header of the main tab (theNYT_GraphMaker.pde file).

Thanks:

It’s starting to get a bit repetitive, but once again this file depends on Karsten Schmidt’s toxiclibs. These libraries are so good they should ship with Processing.

Download: GraphMaker.zip(88k)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

7 Days of Source Day #5: smart.rockets

Project: smart.rockets
Date: Summer, 2006
Language: ActionScript 2
Key Concepts: Evolutionary computing, genetic algorithms, rocket science

Overview:

For me, 2009 has undoubtedly been the Year of Data Visualization. Three years ago, I was engrossed in the somewhat different world of evolutionary computing. Having come from a background in genetics, I was very interested in exploring how evolutionary techniques could be applied in a programmatic fashion, particularly to the kinds of creative systems that I had been building over the previous years.

In preparation for a talk about my explorations at FlashBelt that year, I built a system in which a set of rockets evolved their way towards a target, navigating through obstacles by evolving their own individual firing patterns over time. It was a good demo to show how the general concept of evolutionary computing worked, and let me talk about mutation rates, hybridization algorithms, and all kinds of other interesting things.

As it turns out, the idea of combining EC and space travel is a very real idea. NASA uses evolutionary computing techniques to solve all kinds of problems, ranging from radio telescope scheduling to satellite antenna design to (you guessed it) construction or rocket firing patterns. In a future of un-manned space probes, the long-term goal will be to have machines that can evolve to adapt to unexpected conditions. Such a machine might use genetic algorithms to evaluate a huge number of possible strategies, and to choose the one that is most likely to be a success.

I’ll admit, that previous paragraph places this little Flash toy in undeservedly grand company. But smart.rockets does provide a simple example to get you thinking about how evolutionary computing works. This project was built in ActionScript 2 (opening the file left me with a strange mix of nostalgia and terror). It would be fairly trivial to convert this project to AS3 or to Processing – if anyone does end up doing this, let me know and I will post a link.

Getting Started:

You can see a working example of this file here: http://www.blprnt.com/smartrockets. You’ll need Flash or some kind of .SWF compiler to get the files working.

Thanks:

In 2006 I was working as a freelance Flash developer and designer. As you might suspect, there wasn’t a whole lot of demand for commercial projects which used evolutionary computation, or Lindenmayer systems, or Particle Swarm Optimization, or any number of other strange things that I was exploring in my spare time. I owe a great deal of thanks to the organizers of conferences like FlashBelt, who gave me a venue to talk about things like evolving rockets and in turn gave me an excuse to keep working in these interesting (and completely non-lucrative) areas.

Download: SmartRockets.zip (48k)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.