Devlog :: And Wizardry

Fri, 23 Jun 2006

Animated data visualization application using Geo::ReadGRIB

animated swell image pwizardry.com /An animated GIF of a world wide Wavewatch III GRIB dataset/
*GRIB to GIF* The above image shows the period of the primary wave for seven days starting this last Tuesday, June 20th. The red end of the color spectrum is used for longer period. There's some nice storm activity in the South Indian Ocean. At the beginning we see a pulse passing New Zealand and then, over the week, a bigger one develops and smacks South Australia and NZ. A small amount of that may make it to our shores. *Geo::ReadGRIB for Fun and Profit* I've been working on project for a major surf magazine. I'll develop an application that will draw animated GIF's each day from Wavewatch III forecast data. This is the first application I've done using Geo::ReadGRIB since it went public. I won't say much more about my project or the client for now. In the future I may publish example code or a module that will use Geo::ReadGRIB and draw simple images of Wavewatch III data like the one above. [/items/Perl] permanent link


Performance boost in Geo::ReadGRIB .05

*New method extractLaLo()* I posted [Geo::ReadGRIB http://search.cpan.org/~frankcox/Geo-ReadGRIB-0.5/lib/Geo/ReadGRIB.pm] version .05 which includes a new method with the signature: */extractLaLo(data_type, lat1, long1, lat2, long2, time)/* This will extract all data for a given /data_type/ and /time/ in the rectangular area defined by (lat1, long1) and (lat2, long2) where lat1 >= lat2 and long1 <= long2. That is, lat1 is north or lat2 and long1 is west of long2. This new method takes advantage of the fact that it takes only one call to wgrib to extract all the locations in the GRIB file for a given type and time. The original extract() method was designed for extracting GRIB data for a single location. I'm working on a project now that will create animated surf whether charts for a large area of ocean. Getting the data is much faster using Geo::ReadGRIB .05. *How much faster?* I posted some informal benchmarks [earlier http://pwizardry.com/devlog/index.cgi/2006/06/04#DBM.and.ReadGRIB] . Here are some results using a similar test using a different data set and a larger number of points. extract() no hits: 0.14/s 2.44s/ extractLaLo() no hits: 4.74/s .21s/ This just runs an extract for about 22000 data points using each method. The "no hits" means the objects were fresh and all data had to come from the GRIB file. (Recall, ReadGRIB will cache data in memory and only go to the file if it needs to.) It took the version using extract() about 2.4 seconds per run while extractLaLo() took just .21. That's over 11 times faster. Of course poor extract() was designed for single point at a time extraction but everyone loves a winner. For me, it means the difference between a starch and a coffee break while running tests that need a lot of new GRIB data. [/items/Perl] permanent link