WCS Wrapper Installation WindowsOP

From Earth Science Information Partners (ESIP)
Revision as of 14:47, November 13, 2007 by Rhusar (talk | contribs) (New page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Net...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> NetCDF based WCS

NetCDF cubes via Web Coverage Server


This readme applies to Windows setup, Linux readme will be soon ready.

Design goals of Datafed OWS server:

  • Promote WCS as standard interface.
  • Promote NetCDF and CF-1.0 conventions
  • Make it easy to deliver your data via WCS from your own server or workstation.
  • No intrusion: You can have the NetCDF files where you want them to be.
  • A normal PC is enough, no need to have a server.
  • Minimal configuration

Live Demo Servers:

http://niceguy.wustl.edu:81
http://128.252.167.125

Installation on a workstation:

Datafed OWS uses several open source packages. Since we did not check the licences, we're not including them to setup package, you have to get them yourself.

Get Python

Preferably 2.5 since this system has not been tested with earlier versions. You can get it from http://python.org/download/ but Windows users may want to use ActiveState version http://activestate.com/Products/activepython/  since it has for example very nice language sensitive editor pythonwin.

Since the C dll's are 32 bit, get a 32 bit python even if you have 64 bit machine.

Get Web.py framework

Datafed OWS server uses web.py framework, so get it from  http://webpy.org/install. It comes with it's own development server, with is OK for testing and just a few users.

DataFed OWS is tested using version 0.22

Web.py is delivered in unix style .tar.gz file. Under windows, I recommend  http://www.7-zip.org/  to unzip it. You have to first unzip the gnu zip '.tar.gz' to '.tar' and then unzip the .tar file into normal folder.

Go to main directory and type python setup.py install

Get the best Python Xml package, lxml

It's hosted at http://codespeak.net/lxml/, Datafed OWS uses it in XML processing. It's best to download the pre-compiled windows package from http://pypi.python.org/pypi/lxml/ Datafed OWS is tested with 1.3.6. Run the exe to install.

Get NetCDF

If you don't have NetCDF 3.6.1, go to  Main installation page. For windows users, get the prebuild binaries. You will need tools like ncdump anyway, so just get them all. DataFed OWS uses netcdf.dll, which has to be on path.

Get Datafed OWS

from  http://datafed.net/ows/datafed_ows.zip. Unzip it into your installation folder, let's use C:\OWS as an example. You will to have directories C:\OWS\datafed and C:\OWS\web. The folder datafed contains datafed package, which contains tools for ISO 8601 time parsing and NetCDF tools. Web is the WCS framework.

Make sure that C:\OWS is in your PYTHONPATH variable. Create it via Control Panel / System / Advanced / Environment Variables

Run command prompt, start / run, "cmd.exe". Type "SET PYTHONPATH" If you see PYTHONPATH=C:\OWS you're OK

Change Directory to C:\OWS\web folder and type python ows.py, You have now your server running, listening port 8080. You can pass the port as parameter. "python ows.py 80" listens the standard port 80.

Congratulations, you have your server running. Now we need to install some data to serve.

Creating Service from a single NetCDF file.

C:\OWS\web\static\testprovider\ contains files CubeA_ncml.xml, CubeA.py and CubeA.nc

  • CubeA_ncml.xml is a NetCDF Markup Language description of the test coverage.
  • CubeA.py is a script that creates the empty .nc file and fills it with test data. It servers as a good example code how to create your own CF 1.0 compatible files.
  • CubeA.nc is the output of two previous, and serves as our test coverage.

Sections of the WCS url:

http://capita.wustl.edu:8080 is the server url. It returns a static readme page of providers using this server.

/testprovider is the provider name. There must be a folder C:\OWS\web\static\testprovider\.  There can be any number of providers. Providers are unrelated.

&identifier=CubeA is the name of the NetCDF file. So in this example, C:\OWS\web\static\testprovider\ contains file CubeA.nc and it becomes a coverage. There can be any number of NetCDF files. Coverages are all listed in the GetCoverage request.

&RangeSubset=fieldSubset:* selects variables to be returned from the NetCFD, '*' gets all, &RangeSubset=fieldSubset:Spam; fieldSubset:Eggs gets variables Spam and Eggs

Try this test query

The wcs GetCoverage returns an Xml envelope

<?xml version="1.0" encoding="UTF-8"?>
<Coverages xmlns="http://www.opengis.net/wcs/1.1/ows" 
        xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink">
    <Coverage>
        <ows:Title>TBD title</ows:Title>
        <ows:Abstract>TBD abstract</ows:Abstract>
        <Identifier>CubeA</Identifier>
        <Reference xlink:href="http://localhost:8080/static/cache/CubeA_1.nc" xlink:role="urn:ogc:def:role:WCS:1.1:coverage"/>
    </Coverage>
</Coverages>

Of all the standard supported options, &format=image/netcdf&store=true is the only supported one. The reques writes out a netcdf file C:\OWS\web\static\cache\CubeA_1.nc and so it can be retrieved later with url http://localhost:8080/static/cache/CubeA_1.nc and it will be deleted in ten minutes. The number after coverage is a generated sequence number.

In short:

  • Every folder under static becomes a provider. Providers are unrelated.
  • Every NetCDF file in the provider folder becomes a coverage. So WCS Capabilities document is automatically compiled from all the NetCDF files
  • Every variable inside NetCDF becomes a field

Creating Metadata

The metadata queries of WCS, GetCoverage and DescribeCoverage need to be precompiled. Run the following commands:

c:
cd \OWS\web
python owsadmin.py wcs_cap -v 1.1.0 -d localhost testprovider
python owsadmin.py wcs_desc -v 1.1.0 testprovider

They will create files C:\OWS\web\static\testprovider\wcs_1.1.0_capabilities.xml and C:\OWS\web\static\testprovider\wcs_1.1.0_desc_CubeA.xml. Capabilities contains all the coverages that this provider has.

Try now test queries GetCapabilities and DescribeCoverage CubeA

Press ctrl+C to terminate the server. Although this server is intended for development and debugging only, you can use it to server data from your own workstation just fine. For high load sites, look web.py documentation how to set up a high load site.

Notice: Datafed OWS core is written in C++, enabling large amount of data delivery. Python is used only for query parsing, making minimal impact in speed.

Creating a Service from periodical NetCDF files.

We are serving some HTAP data with this method. Our test server is a Windows XP workstation, notice that the OWS server was started with python ows.py 80, using the default http port 80

Live Query Examples:

Linux Server, port 81: GetCapabilities DescribeCoverage GetCoverage

Windows Workstation std.port 80: GetCapabilities DescribeCoverage GetCoverage

How to set this up on your site:

Download our HTAP test package from  http://datafed.net/ows/datafed_ows_HTAP.zip. It only has two days of data to make download small.

Unzip it to the C:\OWS folder, the zip file contains directories C:\OWS\GEMAQ-v1p0, C:\OWS\GEOSChem-v45 and C:\OWS\web\static\HTAP\

The dataset name is HTAP. The coverages are GEMAQ-v1p0 and GEOSChem-v45.

If you used other folder than C:\OWS you need to edit C:\OWS\web\static\HTAP\HTAP_config.py and change the variable netcdf_root_folder to point the correct directory.

Try this  test query. Notice that it starts with http://localhost:8080/.

Server returns a short XML document, which contains a link into the query result, you can retrieve it

Test from another computer using your IP address http://123.456.789.123:8080/

Readme Pages

If no query is present, a default page readme.html should be present.

There is default C:\OWS\web\static\readme.html, which will be displayed from url http://localhost:8080/

Every provider should have a readme like C:\OWS\web\static\testprovider\readme.html which will be displayed from http://localhost:8080/testprovider

If you modify the default readme, make sure not to overwrite it next time you upgrade Datafed OWS package. Keep the main copy elsewhere and copy it back.

Important! web.py development server requires, that text files have Unix-style end of line marker, plain LF. Windows uses CRLF by default. The owsadmin script can be used to fix this:

python C:\OWS\web\owsadmin.py unix_nl "C:\OWS\web\static\testprovider\readme.html"

Use your html editing tool support if possible.