Five Things You Didn't Know You Could Do with Ruby - ' Process Satellite Images ' (
Page 2 of 6 )
When DevSource asked me to write this article, I had to fight two temptations. One was to make it very language-oriented, talking about Ruby's syntax and semantics. Another was to make it very technology-oriented, full of buzzwords such as RSS and XMLRPC.
Though I've used the occasional buzzword here, I took neither of those paths. I've tried instead to present Ruby from a high-level view, almost a management perspective, to show that Ruby is mature, powerful, versatile, and gaining industry acceptance on a daily basis.
ADVERTISEMENT
If you want that "other kind" of information, there are many places online you can find it. I specifically recommend the main Ruby site;
the documentation found at http://ruby-doc.org; and the RubyForge site. There is also an open-sourced online copy of the excellent Programming Ruby (first edition).
Programmers always want to see code; I know, because I am one myself. But there are tens of thousands of lines of good Ruby code that you can find with your search engine and your common sense. In this article, I won't add to that large corpus. Rather than discussing in textbook-like fashion what Ruby can do, let's look at what people are doing with it in the real world today.
So: What can we do with Ruby?
Process Satellite Images and Meteorological Data
Ara Howard is a Ruby programmer working for the National Oceanic and Atmospheric Administration. One of the tasks for which he uses Ruby is processing image data from weather satellites in low Earth orbit. "We're not processing huge amounts of data in this instance," says Howard. "We sometimes have to update small amounts of data in horrible binary formats. I have classes which map the files into memory and provide simple ways to manipulate these files." He adds that the memory-mapping allows the OS to handle all the input/output, so that the overall processing is extremely fast. "The classes I designed help us to work with the data logically and painlessly. This programming used to be very tedious and difficult to experiment with." For more about the data, you can visit http://dmsp.ngdc.noaa.gov (and definitely check out one of the end results, a poster of the nighttime US).
Howard also wrote a 3,000-line tool (Ruby Queue) to handle Linux clustering. Using SQLite and NFS, it handles task distribution in a streamlined, low-footprint decentralized solution.
Rapid prototyping of number crunching applications is another area in which Howard has found Ruby useful. "Many times it's extremely important to see the entire algorithm in one glance — 50 lines of code as opposed to 2,000. Ruby enables us to 'dive for pearls,' so to speak. Often the speed will be good enough, but when the file sizes get around 2 gigabytes, we usually rewrite in C."
He also recalls his first large Ruby project. "It was a Ruby API to manage bi-temporal meteorological metadata and translate it to various formats for near-realtime systems to use. The database was PostgreSQL, and I used Amrita and FastCGI for the Web interface. It's a little outdated now, but was very interesting and very difficult to code. It took me six months to even understand this problem. I never could have coded it in anything less expressive than Ruby."