Tuesday, January 29, 2008

using kd-trees for interpolation.

I have been looking for ways to interpolate big model results to other big mode results.. again. This seems to be an unsolved problem in ocean modeling. However, I have stumbled on a new method for finding nearest neighbors that seems quite promising.

As long as you are interpolating from something that has a relatively uniform grid with a relatively smooth field, you don't need to bring out the big guns, like optimal interpolation. In other words, you may often ignore data error in your interpolation - especially going from one model to another to generate initial or boundary conditions.

[Kd-trees](http://en.wikipedia.org/wiki/Kd-tree) (k-dimensional trees) are a method for organizing a set of k-dimensional points. In particular, I would like to find the nearest neighbors in three-dimensions. Many interpolation tools (such as [csa](http://www.marine.csiro.au/~sak007/) or [delaunay](http://scipy.org/scipy/scikits/browser/trunk/delaunay/) only work with 2D data.

The advantage of using kd-trees is twofold: First storing the tree is not very memory intensive, approximately the same size as the original point field itself, and building the tree scales roughly as the number of points (n log(n)). Second, searching for the closest points to a query point is quite fast (log(n)). The [ann library](http://www.cs.umd.edu/~mount/ANN/) can be used to return indicies of and distances to the M closest points to a query point. An example of how to use the ann library for interpolation is below the fold.




ROMS project movie back online

The ROMS project movie (the only thing people seemed to miss during the black months when pong was down) is now back online. See it [here](http://pong.tamu.edu/~rob/movies/roms_project.mov).

Monday, January 14, 2008

Making images and animations of model output in google earth

I have been working on creating images and animations from google earth. I started out [here](http://www.barnabu.co.uk/animations/) for inspiration. Here are some samples of an [image](http://pong.tamu.edu/~rob/files/bsh.kmz) and an [animation](http://pong.tamu.edu/~rob/files/bsh_anim.kmz). The code is actually quite simple:

Sunday, January 13, 2008

Woot! Back up

Finally, after a massive hard drive failure, my web log is back up. To make a long story short, I promise to make better backups and buy Steve a beer.. I feel a pent up pile of posts -- so after waiting for so long, be sure to check often now.