Sample Viewer Code

We've hacked together a prototype framework which will let you experiment a bit with viewing data and performing calculations on it with shaders.

What you need

You'll need a Java runtime environment, preferably the latest. installed. You can download that from this page.

Grab the code

The most recent version of the code is always located here. This includes some of sample data files in the data/ directory, a colormap shader, and an RH-calculating shader.

Just extract this file somewhere and run make in that directory (there are some native libraries that need to be compiled for your platform). You'll also find a bin directory, which you may want to add to your path.

If you're trying to compile the java utility files, you'll want to make sure classes/, lib/jython.jar and lib/alchemy.jar are included in your build classpath.

Running the sample

To run the sample code, just run bin/jython View.py in that directory. A window should pop up, showing (clockwise from upper-left) snow depth, dewpoint, and a meaningless calculation involving both (it's actually calculating RH—if you edit the code to load in temperature instead of snow depth, it will even be correct). You can mouse over the screen to read the values beneath the mouse cursor, but note that these are normalized values—snow depth, for example, is not in meters, but in meters * 0.1.

Changing what data is displayed

To load different data, you'll want to put a reference to your data in the loadData method, located in View.py. There, you can see an example of loading either a raw binary data grid, and an example of loading a text grid. Currently, these are the only supported formats, although you can subclass Grid to support your own format (see TextGrid for an example of this).

After loading your data, you'll want to change the draw method to draw it. For example, change this line,

self.T.bind(gl, GL_TEXTURE_2D)

to this,

self.YourData.bind(gl, GL_TEXTURE_2D)

Creating new shaders

If you want to perform different grid operations on the data and display the results, you'll probably want to write some new shaders. Look in the shaders/ directory for a couple of example shaders, and check out the documentation in loadShaders in View.py for information on uploading shaders and connecting them to data.