Numeric/numarray/numpy
3 array modules in Python? Why so? Well, it's just the times we live in. Here is a quote fromm the Matplotlib User's Guide (May 27, 2007, version 0.91.2svn):
Numeric is the original python module for efficiently processing arrays of numeric data. While highly optimized for performance and very stable, some limitations in the design made it inefficient for very large arrays, and developers decided it was better to start with a new array package to solve some of these design problems and numarray was born. In a sense, the numerical python community split into Numeric and numarray user groups. Travis Oliphant, one of the maintainers of Numeric, began work on a third package, based on the Numeric code base, which incorporated the advances made in numarray, and was called NumPy. NumPy is intended to be the successor to both Numeric and numarray, and to reunite the numerical python community. An array interface was developed in order to allow the three array packages to play well together and to easy migration to NumPy. Numeric is no longer undergoing active development, and the numarray release notes suggest users to switch to Numpy.
The same saga is told in the wikipedia articleNumpy
Getting started:
Charming Python: Numerical Python An explanation of why the array data type speeds up Python. Old, refers to Numeric, but still applicable to numpy.
See array syntax used right here, at JuliaSets.
http://www.scipy.org/Documentation Links to numpy references. Note the official numpy documentation is NOT free.
Numerical Python Basics A gentle introduction to Numeric. (But note the plotting package DISLIN is not installed on Gentry and is not recommened.)
Numeric vs. numarray Demonstrates that Numeric is faster for small arrays, but numarray is faster for big arrays.
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!
Numerical Python Official Numeric documentation in HTML. Note the word NumPy in the documentation, which contributes to the confusion!
Numerical Python Official Numeric Documentation as a PDF file. Unlike the numpy documention, this older Numeric documentation is free.
Python Numeric Tutorial A rather old, incomplete tutorial for Numeric. But still quite useful for newbies.
Your task is within:
numpyplot4.zip (New for Summer 2009)
Within numpyplot4, 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. numpyplot4 comes out of the box, ready to make animations for 200 mb meridional wind. Your task involves several modifications of the scripts. 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.