Re: pydap

28 views
Skip to first unread message

Roberto De Almeida

unread,
Mar 2, 2007, 8:02:15 AM3/2/07
to James McCreight, py...@googlegroups.com
Hi, James.

On 3/1/07, James McCreight <mccr...@nsidc.org> wrote:
> Greetings. I'm am brand new to OPeNDAP. I saw your presentation on pyDAP
> and was impressed. I have just spent the last hour trying to install the
> client and server on my office machine. I'm particularly interested in
> transforming my netcdf data to KML so i can visualize it on google earth.
>
> I followed the quick instructions for installing. Everything seemed to
> go smoothly. However, i may be completely naive on this, but i'm not
> certain as to how i'm supposed to actually run the client. I assumed
> that in the dap/ directory i should issue the command
> $ python2.4 client.py
> but that simply returns me to the command line. I assume that all the
> commands you list as examples are to be issued once the client is
> running and that your different prompt >>> signifies this...
>
> so i'm scratching my head wondering if the installation is messed up or
> if i'm simply invoking the client in the wrong way. as i dont have sudo
> or root access on this machine i had to set
> --prefix=/home/mccreigh/pydap
> when installing. i'm suspecting this may be causing problems and i
> should have to reconfigure but i wanted make sure i properly understood
> how to call the client before assuming that.

If all you want to do is visualize netCDF data on Google Earth you
won't be using the DAP client -- in fact, you won't be using OPeNDAP
at all! :) Here's a quick howto, and I'll explain the details as we
go.

First, I recommend you to install the easy_install script, which will
make things much easier. Since you don't have root access, you should
create a file called ``~/.pydistutils.cfg`` with the following
content:

#~/.pydistutils.cfg
[easy_install]
install_dir = /home/mccreigh/.python # you can change this

This will install all Python modules on the ``.python`` directory at
your HOME. This directory has to be in your PYTHONPATH, so I'd
recommed to add the following lines to your ``.bashrc``:

#~/.bashrc
export PYTHONPATH=/home/mccreigh/.python
export PATH=$PYTHONPATH:$PATH

I also added this directory to the PATH, since scripts will be
installed there too. After that, we can proceed to install
EasyInstall. Download this script and run it with Python:

$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ python ez_setup.py

You can run this as a normal user, it will install a module called
setuptools and a script named ``easy_install`` in the the directory we
specified before.

We also need to install the Python Imaging Library, to generate the maps:

$ easy_install -f http://www.pythonware.com/products/pil/ Imaging

And now we can install pydap, the netCDF plugin and the WMS/KML responses:

$ easy_install dap.plugins.netcdf dap.responses.wms

With the WMS response, pydap will behave like a (simple) WMS server,
generating the images that will be requested by Google Earth.

Once we have installed everything we need, we should create a server
"instance", ie, a directory with a configuration file, template and a
place to put our data:

$ paster create -t dap_server myserver project=My-Server

This will create a directory called ``myserver``. Your netCDF files
should go inside ``myserver/data`` (you can put them inside
subdirectories there, as you wish).

Now you should edit the ``myserver/template/index.tmpl`` template.
This is a Cheetah template, but it's pretty easy to understand it;
where going to add a link to the KML file for each file in the server.
Just add the following line:

<td><a href="${file}.kml">[Google Earth]</a></td>

Beneath the DAS and DDS lines. We're all set! To run the server just type:

$ paster serve myserver/server.ini

And browse to http://localhost:8080. A few things:

1. To make the server public, ie, accessible from other machines,
you'll need to edit the ``server.ini`` file and replace the localhost
IP (127.0.0.1) with the IP of the interface you want the server to
listen to, or 0.0.0.0 to listen on all interfaces.

2. To make it faster, install WSGIUtils (easy_install WSGIUtils) and
replace the line ``use = egg:Paste#http`` with ``use =
egg:PasteScript#wsgiutils`` in the server config file. To make it even
faster, use flup and SCGI (http://pydap.org/docs/server.html) with
Apache or Cherokee.

3. For production use you will need a cache, since the images are
generated on the fly. I can think of two different approaches here:
(a) using wsgistate (http://cheeseshop.python.org/pypi/wsgistate) as a
middleware for pydap and (b) integrating TileCache
(http://labs.metacarta.com/wms-c/) with pydap. Both should be
straightforward if you know Python and WSGI, but I haven't tested
them.

Best,
--Rob

Reply all
Reply to author
Forward
0 new messages