Pyocean
From OCG Test Wiki
Contents |
[edit] pyocean
pyocean is a web interface is written in Python. Previous versions of the web interface use Matlab as the plotting engine. The current web interface uses now only freely available components. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
[edit] Prerequisites
The web interface uses the following software:
- scipy (http://www.scipy.org)
- numpy (http://numpy.scipy.org)
- matplotlib and basemap (http://sourceforge.net/project/showfiles.php?group_id=80706)
- ScientificPython (http://dirac.cnrs-orleans.fr/plone/software/scientificpython/)
- mod_python (http://www.modpython.org)
- Apache web server (http://www.apache.org)
- NetCDF library (http://www.unidata.ucar.edu/software/netcdf)
The web interface is integrated in the Apache web server using the module mod_python.
The web interface is separated into two parts:
- pyocean-web: Python, HTML pages and JavaScript code which should be available under apache's DocumentRoot.
- pyocean: all python scripts which should not be on your Apache's DocumentRoot for security reasons.
[edit] Downloading
Source code is available at http://ocgmod1.marine.usf.edu/src/ or under CVS (for authenticated users). Using CVS, the python scripts can be downloaded by:
export CVSROOT=:pserver:abarth@ocgmod1.marine.usf.edu:/var/cvs cvs checkout pyocean
The files for your web server can be downloaded by:
export CVSROOT=:pserver:abarth@ocgmod1.marine.usf.edu:/var/cvs cvs checkout pyocean-web
[edit] Directory Structure
This the directory structure of pyocean:
- config
- configuration files
- interpolation.py
- general purpose interpolation routines
- plotting.py
- general purpose plotting routines
- util.py
- utility routines (dates conversion)
- web.py
- plotting routine for horizontal sections from web server
- hab.py
- specialized routines for harmful algae bloom (data extraction and plotting)
- bsop.py
- specialized routines for BSOP data (data extraction and plotting)
- inventory.py
- script to create XML inventories of all available forecasts
The directory structure of pyocean-web:
- Css
- Cascading Style Sheets for web pages
- Images
- static images (logos,...)
- Plots
- dynamical images
- Javascript
- JavaScript code
- Python
- Python plotting routine which calls pyocean.
- plot_bsop.html, plot_hab.html, plot_hor.html, plot_vert.html
- static HTML pages
- inventory_bsop.xml, inventory_hab.xml, inventory.xml
- inventory of available forecasts (created by inventory.py)
[edit] pyocean
The pyocean package must be in a place that can be accessed by the web server (but it should not be served as Web content). It can be extracted in a home folder (if your home folder is readable by the web server), for example
/home/abarth/Python/pyocean
In order to use the python package directly (i.e. without the web server), the environment variable PYTHONPATH has to be set:
export PYTHONPATH="$PYTHONPATH:/home/abarth/Python/pyocean"
This setting can be made permanent if this line is added in the user's .bash_profile. The pyocean package is configured by the file pyocean/config/wfs.py and pyocean/config/wfs_ste.py. You should adapt both files to your case.
[edit] pyocean-web
pyocean-web must be copied somewhere under Apache's DocumentRoot. The default DocumentRoot is specific for each Linux distribution:
| Linux Distribution | DocumentRoot |
|---|---|
| Debian/Ubuntu | /var/www |
| Fedora/Red Hat | /var/www/html |
| SuSE | /srv/www/htdocs |
In the following, this directory is called $DOCUMENT_ROOT.
Steps to activate the pyocean-web package:
- enable .htaccess files. Add "AllowOverride All" in Apache's configuration file (Ubuntu: /etc/apache2/sites-available/default, Fedora/RedHat /etc/httpd/conf/httpd.conf). For more security and performance, the .htaccess file can also be added to the Apache's main configuration file.
- enable mod_expires (SUSE: edit APACHE_MODULES in /etc/sysconfig/apache2)
- Adapt the variable web_root and webtemp defined in pyocean/config/wfs_site.py to reflect your $DOCUMENT_ROOT.
- Give the web server write access to $DOCUMENT_ROOT/pyocean-web/Plots:
chmod -R 777 $DOCUMENT_ROOT/pyocean-web/Plots
or use chown
- mount operational archive readable by web server. Add the following to /etc/fstab
ocg0:/DISK5/abarth on /mnt/ocg0/DISK5 type nfs (rw,hard,intr,bg,addr=131.247.138.70)
- change PythonPath in Python/.htaccess to include the directory of pyocean
PythonPath "sys.path+['/home/abarth/Python']"