Difference between revisions of "PyCDF"

From SourceWiki
Jump to navigation Jump to search
Line 35: Line 35:
  
 
=Setting your PYTHONPATH=
 
=Setting your PYTHONPATH=
 +
 +
We will need to make the new module available to your python installation.  A good way to do this is to add the following to your shell start-up file, called '''~/.bashrc''' (the '''~''' indicating that the file is in your home directory):
 +
 +
<pre>
 +
export PYTHONPATH=$PYTHONPATH:$HOME/py/lib/python2.6/site-packages
 +
</pre>
 +
 +
then, in order to re-read that start-up file, you will need to type:
 +
 +
<pre>
 +
source ~/.bashrc
 +
</pre>
 +
 +
The next time you open a new shell, your '''PYTHONPATH''' will be set automatically, and you won't need to bother with all that '''source ..''' malarky.

Revision as of 20:42, 12 August 2009

PyCDF: a handy python module you'll need

Introduction

This is a module that you will need when you come to the exercise when you add a module to GLIMMER-CISM. It's not available through the Ubuntu package manager, so you will install it yourself into your own filespace.

Compiling the Module

OK, first thing's first, let's get the source code. Open a terminal, stay in (move to) your home directory and cut and paste the following:

wget http://sourceforge.net/projects/pysclint/files/pycdf/pycdf-0.6.3b/pycdf-0.6-3b.tar.gz/download

Now, we'll unpack the tarball, and move into the appropriate directory:

tar -xzf pycdf-0.6-3b.tar.gz
cd pycdf-0.6-3b

You will need to edit the file called setup.py to reflect where you installed your NetCDF libraries:

elif USE == NUMPY:
    from numpy.distutils.misc_util import get_numpy_include_dirs
    _pycdf_ext = Extension(extName,
                           sources   = CCode,
                           #library_dirs=["non standard path where libs live"],                       
                           library_dirs=["/home/PSU/pdx05933/installs/netcdf-4.0.1/lib"],
                           include_dirs = get_numpy_include_dirs(),
                           libraries = ["netcdf"])

Setting your PYTHONPATH

We will need to make the new module available to your python installation. A good way to do this is to add the following to your shell start-up file, called ~/.bashrc (the ~ indicating that the file is in your home directory):

export PYTHONPATH=$PYTHONPATH:$HOME/py/lib/python2.6/site-packages

then, in order to re-read that start-up file, you will need to type:

source ~/.bashrc

The next time you open a new shell, your PYTHONPATH will be set automatically, and you won't need to bother with all that source .. malarky.