Faster Python using Numeric

pix
Go back to home page

This page provides an introduction to using the Numeric extension to Python.

This page is obsolete.

The latest page is at itmetr.net.

last modified: 05:03 PM MDT, Sun 15 Jun 2008


  1. Charming Python: Numerical Python An explanation of why the array data type speeds up Python.
  2. Numerical Python BasicsA gentle introduction to Numeric. (But note the plotting package DISLIN is not installed on Gentry and is not recommened.)
  3. Numeric vs. numarray Demonstrates that Numeric is faster for small arrays, but numarray is faster for big arrays. Both Numeric and numarray are installed on Gentry. Numeric is preferred in this course, a main reason being that Numeric is used by the module Scientific, and in particular we need to use Scientific.IO.NetCDF to read NetCDF files, which is common data format in meteorology. Nevertheless, numarray is needed to work in the background of the basemap extension of matplotlib. The user can be oblivious to this fact, and use Numeric. BTW, NetCDF and basemap will be used in the NetCDF tutorial.
  4. History of Scipy explains why both Numeric and numarray exist, and why numpy will replace both. This can be really confusing because numpy was once the nickname for Numeric!
  5. Numerical Python Official Numeric documentation in HTML. Note the word NumPy in the documentation. (!)
  6. Numerical Python Official Numeric Documentation as a PDF file. Might be worthwhile to print it out.
  7. Python Numeric Tutorial A rather old, incomplete tutorial. But still quite useful for newbies.

Ready to try Python Numeric? Download numpyplot.tar.gz.

Or (on Gentry) do:

wget http://gentry.metr.ou.edu/numpy/numpyplot.tar.gz
Then
gunzip numpyplot.tar.gz
tar xvf numpyplot.tar
Within numpyplot, view the Readme file. As part of your task, you will be making a sequence of PNG images of the surface pressure fluctuations, as derived from the reanalysis data. You will be showing the animation on the web. A similar animation is shown here, but for 200 mb meridional wind. The gribhelper.py script uses the wgrib utility, which you may want to learn about in the following.

A short tutorial on reanalysis data, GRIB files and the wgrib utility

This short tutorial will show you just about everything I know about GRIB and the reanalysis data. Try this:
wgrib /REANALYSIS/1997/data/at00z12z/vgrd200.prs 

Did you see about 730 lines dumped to your monitor? wgrib followed by the name of the file dumps out the data description embedded in the file, the description of what numbers are stored within the file. I think that is why GRIB is called a self-defining file. Before we go on with the experiments, lets make the path to the file a bit easier to type on the command line by setting a symbolic link:

ln -s /REANALYSIS/1997/data/at00z12z/vgrd200.prs vdat

Now try the command

wgrib vdat

If the symbolic link is working, we move on to:

wgrib vdat -d 300 

That command showed you information about record 300 and binary formatted data was put in a file called dump. You will get more information about what data was dumped if you type:

wgrib vdat -d 300 -V

Here are some more experiments:

wgrib vdat -d 300 -V -text -o xxx.dat

Look inside xxx.dat. See that the first line is a "header". If you don't want the header, use:

wgrib vdat -d 300 -V -text -o xxx.dat -nh

The reanalysis data is stored on horizontal grids of two different sizes. Lets make a symbolic link to some temperature data:

ln -s /REANALYSIS/1997/data/at00z12z/tmp.2m t2m

wgrib t2m -d 300 -V -text -o xxx.dat -nh

Notice the surface data is on a 192x94 "Gaussian grid" which means the latitude is not quite evenly spaced. The information printed to monitor also indicates this is a "6hr fcst", meaning the data is valid for 18Z, rather than the 12Z time indicated for the file.


this is an obsolete site
go to new site
go to obsolete home page

pix
Move to top of page